[R] Parsing array data

Altaweel, Mark R. maltaweel at anl.gov
Tue Aug 12 19:35:07 CEST 2008


Hi,

I read in csv files with the following code:

res <- vector(mode="list",length=3)
 for(i in 1: length(res))
res[[i]]<-read.csv(file=paste("/Users/markaltaweel/Desktop/Output/HydroDataOutput",i,".csv",sep=""),header=T,sep=",")

This allows me to load the data into an array of length 3, with the res array containing my data from the csv files.

I would like to parse the data in the res array so that I can access my specific data columns. For instance, I have field names called 'Discharge,' 'Volume,' and 'Id'. I would like to aggregate these fields for all the loaded files in the array so that I can perform some basic comparisons of distributions, etc.
Does anyone have any example code that would allow me to parse the array so that I can extract the column names and perform some data aggregation and basic stats.  Currently, even if I do the following code I get a Null response:

a=res[1]
a[['Discharge']] # this returns [[1]] NULL

Please let me know if there is a solution to this or what am I doing wrong.

Thank you in advance.

Mark



More information about the R-help mailing list