Re: [R] function to create multiple matrices

2010-03-10 Thread jim holtman
Is this what you want: > yrData <- data.frame(year=sample(1990:2000, 100, TRUE), + species=sample(1:3,100,TRUE), loc=sample(1:2,100,TRUE)) > byYear <- split(yrData, yrData$year) > > byYear[1:3] $`1990` year species loc 39 1990 3 2 57 1990 3 1 62 1990 1 1 68 1990

[R] function to create multiple matrices

2010-03-10 Thread Lanna Jin
Hi All, If given a dataframe (long form) with Year, Species, and Location, How would I write a function that would create a unique matrix of Species & Location for each Year? What I've tried doing is the following: data #dataframe dataT<-table(data$Species,data$Location,data$Year) #creates table