[R] Loading in Large Dataset + variables via loop

cmc0605 colose21 at gmail.com
Sat Jul 14 04:44:43 CEST 2012


Hello, I'm new to R with a (probably elementary) question.

Suppose I have a dataset called /A/ with /n/ locations, and each location
contains within it 3 time series of different variables (all of 100 years
length); each time series is of a weather variable (for each location there
is a temperature, precipitation, and pressure).  For instance, location 1
has a temperature1 time series, a precip1 time series, and a pressure1 time
series; location two has a temperature2, precip2, and pressure2
timeseries...That is, there are 100 rows, and (/n/*3)+1 columns.  The extra
column is the time.

I want to load in this dataset and declare a variable for each time series. 
The columns are in order of location, so it goes temp1, precip1,pressure1,
temp2,... and so forth in increasing column order.  There are always 100
rows.  Manually, Id have to do:

temp1=A[,1]
precip1=A[,2]
pressure1=A[,3]
temp2=A[,4]
precip2=A[,5]
pressure2=A[,6]
temp3=A[,7]
and so forth.....

Problem is, n is large, so I don't want to repeat this pattern forever.  I
figure I need a loop both for the variable name (ie.., the variable at a
particular location) as well as for what column it reads from.

Any help...?



--
View this message in context: http://r.789695.n4.nabble.com/Loading-in-Large-Dataset-variables-via-loop-tp4636501.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list