Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- days <- c('Mon', 'Tue', 'Wed', 'Thur', 'Fri')
- temp <- c(20, 30, 20, 24, 25)
- rain <- c(T, F, F, F, T)
- df <- data.frame(days, temp, rain)
- print(df)
- subset(df, subset = temp > 20)
- # new.df <- df[df$temp > 20, ]
- # print(new.df)
- # Ex 10: What is the average mpg for cars that have more than 100 hp AND a wt value of more than 2.5.
- # avg <- mean(mtcars$mpg[mtcars$hp > 100 & mtcars$wt > 2.5])
- # avg <- mean(subset(mtcars, subset = hp > 100 & wt > 2.5)$mpg)
Add Comment
Please, Sign In to add comment