How to perform selection and indexing of data frame elements in R?
To perform such operations, we have to build a dataframe first
# Some made up weather data
days <- c('mon','tue','wed','thu','fri')
temp <- c(22.2,21,23,24.3,25)
rain <- c(TRUE, TRUE, FALSE, FALSE, TRUE)
# Pass in the vectors:
df <- data.frame(days,temp,rain)
df
We can select everything from first row
# Everything from first row
df[1,]
We can select everything from first column
df[,1]
mon tue wed thu fri