On Fri, Feb 24, 2012 at 09:48:16AM -0800, uday wrote: > > I want to create r object from my data set. > I have several data files and I would like to read individual parameter > from file and save all 10 files parameter in a single array > e.g > setwd("/temp/") > file_s <- list.files(path = ".", pattern = "0b.was", all.files = FALSE, > full.names = FALSE, recursive = FALSE, ignore.case = > FALSE) > lat <- NULL > lon <- NULL > ch4 <- NULL > for ( i in 1:10) { > data <- read.table(file_s[i],header=TRUE,skip=55 ) > lat[i] = data[,7] # latitude > temp.lon = data[,8] # longitude > # the longitude data is in 360 degree format need to convert to -180 to 180 > lon[i] = ((temp.lon+180) %% 360 ) - 180 > ch4[i] = data[,45] # ch4 > } > > save (lat,lon,ch4, file="myData.RData"") > > but some how it does not work .
Hi. If you get an error message, please, send it. If you get a result, but it differs from what you expect, explain, what is wrong. At the first glance, i do not see anything suspicious. However, i do not know, what is the contents of the files file_s[i] and whether the number of file names in file_s is at least 10. Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.