Practice: Taxonomy of Data

1) Types of Variables

For each of the following parts indicate the type of variable according to the taxonomy of data.

  1. The number of classes a student is taking

  2. A student’s year in college (Freshman, Sophomore, etc.)

  3. Student’s favorite color

  4. The area code of a student’s phone number

  5. The amount of time it takes to finish a STAT 20 quiz

  6. The temperature of a room in Fahrenheit degrees

  7. The type of car you drive

  8. The speed of a vehicle in miles per hour

  9. A car’s model year

  10. The number of text messages you send per day

  11. The brand of coffee you drink

  12. Your student ID number

  13. The number of siblings a person has

  14. A person’s home zip code

  15. The rating of a movie (1 to 5 stars)

  1. discrete numerical
  2. ordinal categorical
  3. nominal categorical
  4. nominal categorical
  5. continuous numerical
  6. continuous numerical
  7. nominal categorical
  8. continuous numerical
  9. ordinal categorical
  10. discrete numerical
  11. nominal categorical
  12. nominal categorical
  13. discrete numerical
  14. nominal categorical
  15. usually discrete numerical, but one can also argue that it can be ordinal categorical (depending on the context, and application)

2) Terrestrial Planets

Consider the following table containing data from so-called Terrestrial planets.

name gravity temp moons_num moons_fac haswater
Mercury 3.7 167 0 none no
Venus 8.9 464 0 none no
Earth 9.8 15 1 one yes
Mars 3.7 -65 2 two no
  • name: name of planet
  • gravity: gravity (\(m/s^2\))
  • temp: mean temperature in Celsius
  • moons_num: number of moons (numeric)
  • moons_fac: number of moons (factor)
  • haswater: whether it has known bodies of liquid water on its surface

2.1) Creating Vectors and Factors

Go to stat20.datahub and open a new Quarto document (.qmd file).

Refer to the data table of terrestrial planets. Insert new code chunks to create the following vectors.

  1. Create a vector name and display it (i.e. type its name)
Show answer
name <- c("Mercury", "Venus", "Earth", "Mars")
name
  1. Create a vector gravity
Show answer
gravity <- c(3.7, 8.9, 9.8, 3.7)
gravity
  1. Create a vector temp
Show answer
temp <- c(167, 464, 15, -65)
temp
  1. Create a vector moons_num
Show answer
moons_num <- c(0, 0, 1, 2)
moons_num
  1. Create a factor moons_fac
Show answer
moons_fac <- factor(c("none", "none", "one", "two"))
moons_fac
  1. Create a factor haswater
Show answer
haswater <- factor(c("no", "no", "yes", "no"))
haswater

2.2) Some basic computations

Answer each of the following parts in their own code chunks.

  1. Use the length() function to find the number of elements in vector name.
Show answer
length(name)
  1. Use the sqrt() function to calculate the square root of gravity values.
Show answer
sqrt(gravity)
  1. Use the mean() function to compute the mean number of moons.
Show answer
mean(moons_num)
  1. Use the comparison operator > to see which temperature values in temp are greater than 100
Show answer
temp > 100
  1. Use the following formula to compute x

\[ \texttt{x} = \frac{\texttt{temp}^2 + \log(\texttt{gravity})}{\texttt{moons\_num} + 10} \]

Show answer
x = (temp^2 + log(gravity)) / (moons_num + 10)
x


2.3) Data Frame planets

In a new code chunk, use the data.frame() function to create a planets data frame containing all the vectors and factors created in part 2.1. And then type (print) planets in order to see its contents.

Show answer
planets = data.frame(name, gravity, temp, moons_num, moons_fac, haswater)
planets