Get Subset from Data Frame
- salary$id
- is one way to access a variable inside the data frame
- salary$id[1]
- access first element of the vector
- alary$id[2:3]
- access a subset of elements
- salary$id[c(5,7)]
- salary$id[ salary$[salary$startyr == 95]
- salary[1,]
- salary[,2]
- salary[3:7, 2:4]
- salary[, c("id","temp")]
- yes = antibiotics[antibiotics$antib == 1, ]
- put this subset into a new data frame
Data1 <-ID_ICD9_Date1st_count_v2018_1M_random[,c(2,5,7,10:18,21)]
survdata_run <- dplyr::select(Data_Analysis, 1,3:9,17)
Data1 <- Data1[sample(nrow(Data1), 50000), ]
Reference: