How to subset a list of dataframes in R? -


i have multiple datasets of physical variables, , want work on r. however, use list. here code 1 of dataframe :

# table definition df.jannuary <- read.table("c:\\...file1.csv", sep=";")  # subset of table containing variables of interest df.jannuary_sub <- subset(df.jannuary, select=c(2:8, 11:12))  # column names colnames(df.jannuary_sub)<-c("year","day","hour","minute","temp_air","temp_eau","humidity_rel","wind_intensity","wind_direction")  # aggregation of 4 year-day-hour-minute columns single column , conversion posixct objet through temporary column "timestamp" df.jannuary_sub$timestamp <- as.posixct(paste(df.jannuary_sub$year, df.jannuary_sub$day, df.jannuary_sub$hour, df.jannuary_sub$minute), format="%y %j %h %m", tz="gmt")  # getting date new format julian day normal day column called "date" df.jannuary_sub$date <- format(df.jannuary_sub$timestamp,"%d/%m/%y %h:%m",tz = "gmt")  # suppression of 4 year-day-hour-minute initial columns , of temporary column "timestamp", , placement of date column column 1 df.jannuary_sub <- subset(df.jannuary_sub, select=c(11, 5:9)) 

this code works. thing got months of year, several years.

so started use list, here example year 2011 :

df.jannuary <- read.table("c:\\...\file1.dat", sep=",") #... df.december <- read.table("c:\\...\file12.dat", sep=",")  # creation of list containing month datasets, subset of tables containing variables of interest list.dataset_2011<-list( df.jannuary_sub <- subset(df.jannuary, select=c(2:8, 11:12)), #... df.december_sub <- subset(df.december, select=c(2:8, 11:12)) )  # column names variables of list (j in 1:12) { colnames(list.dataset_2011[[j]])<-c("year","day","hour","minute","temp_air","temp_eau","humidity_rel","wind_intensity","wind_direction") }  # conversion of list data.frame called "list.dataset_2011" (i in 1:9) { list.dataset_2011[[i]]<-as.data.frame(list.dataset_2011[[i]]) }  # aggregation of 4 year-day-hour-minute columns single column , conversion posixct objet through temporary column "timestamp" list.dataset_2011$timestamp <- as.posixct(paste(list.dataset_2011$year, list.dataset_2011$day, list.dataset_2011$hour, list.dataset_2011$minute), format="%y %j %h %m", tz="gmt")  # getting date new format julian day normal day column called "date" list.dataset_2011$date <- format(list.dataset_2011$timestamp,"%d/%m/%y %h:%m",tz = "gmt")  # suppression of 4 year-day-hour-minute initial columns , of temporary column "timestamp", , placement of date column column 1 list.dataset_2011 <- subset(list.dataset_2011, select=c(11, 5:9)) 

i encounter problem @ end of code (hoping rest working !) subset command, doesn't appear work attribute "list".


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -