Advertisement
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)
- sorted.temp <- order(df['temp'])
- print(sorted.temp)
- new.df <- df[sorted.temp, ]
- print(new.df)
- desc.sorted.temp <- order(-df['temp'])
- new.df.desc <- df[desc.sorted.temp, ]
- print(new.df.desc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement