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 tables of
Species vs Location for each Year

But I'm encountering issues individually indexing the tables and converting
them into matrices in one fell swoop.

r1997<-as.matrix(tableT[,,"1997"]) #How I would do it individually; but I
can I make matrices for each year as a function?

Thanks in advance for your suggestions!

-- 
Lanna Jin

lanna...@gmail.com
510-898-8525

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to