Hello,
I am trying to cycle through a csv and make some summary statistics.
I need to select rows based on the number in the row name that comes
after the letter 'y'. For example, BA1y1 would equal 1, C3A2r3y1
would equal 1 and MA3r3y1r3 would equal 1.
I currently have my code cycling through by the 5th character but my
rows have variable length and the y can occur in several different
locations in the row name.
Here is my current code
sdat <- read.csv (paste(data.dir,"/summary.data.csv", sep=""))
year <-c("1", "2", "3")
for (y in year) {
sdat2 <- sdat[sapply(strsplit(as.character(sdat$GCM), ""),
function(zzz)zzz[5] == y),]
Thanks
Daisy Englert Duursma
Bioclimatic Modeller
Macquarie University
Sydney, NSW, Australia
______________________________________________
[email protected] 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.