Show answer
name <- c("Mercury", "Venus", "Earth", "Mars")
nameFor each of the following parts indicate the type of variable according to the taxonomy of data.
The number of classes a student is taking
A student’s year in college (Freshman, Sophomore, etc.)
Student’s favorite color
The area code of a student’s phone number
The amount of time it takes to finish a STAT 20 quiz
The temperature of a room in Fahrenheit degrees
The type of car you drive
The speed of a vehicle in miles per hour
A car’s model year
The number of text messages you send per day
The brand of coffee you drink
Your student ID number
The number of siblings a person has
A person’s home zip code
The rating of a movie (1 to 5 stars)
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 planetgravity: gravity (\(m/s^2\))temp: mean temperature in Celsiusmoons_num: number of moons (numeric)moons_fac: number of moons (factor)haswater: whether it has known bodies of liquid water on its surfaceGo 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.
name and display it (i.e. type its name)name <- c("Mercury", "Venus", "Earth", "Mars")
namegravitygravity <- c(3.7, 8.9, 9.8, 3.7)
gravitytemptemp <- c(167, 464, 15, -65)
tempmoons_nummoons_num <- c(0, 0, 1, 2)
moons_nummoons_facmoons_fac <- factor(c("none", "none", "one", "two"))
moons_fachaswaterhaswater <- factor(c("no", "no", "yes", "no"))
haswaterAnswer each of the following parts in their own code chunks.
length() function to find the number of elements in vector name.length(name)sqrt() function to calculate the square root of gravity values.sqrt(gravity)mean() function to compute the mean number of moons.mean(moons_num)> to see which temperature values in temp are greater than 100temp > 100x\[ \texttt{x} = \frac{\texttt{temp}^2 + \log(\texttt{gravity})}{\texttt{moons\_num} + 10} \]
x = (temp^2 + log(gravity)) / (moons_num + 10)
x
planetsIn 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.
planets = data.frame(name, gravity, temp, moons_num, moons_fac, haswater)
planets