Hello, I used R a year ago. With the data I am working with now, I realized that I need to go back to R. Unfortunately, my memory is not my friend if it comes down to coding :-)
What I want to do is extract the length of a variable of a file with certain conditions and then print this number in a new variable.. My file (yukon), contains information about fires in the Yukon Territory, and it looks basically like this: Fire_Year Area_Hecta InitialFir ... and other headers but they are not important The Fire_Year ranges from 1980-2010, the Area_Hecta contains numbers and the InitialFir contains a date written like this: 24/05/1980 My end goal is to plot 2 plots, one with the summed area burned per year and the other plot should show the number of fires happening per year. I managed the first plot with the command aggregate. annualAB.sum<-aggregate(yukon$Area_Hecta~yukon$Fire_Year, sum, data=yukon) Now I am having troubles with the second plot. I created subsets for each year and then used the length command..then I could take all those numbers and put them in a new variable... y1980 <- subset(yukon,Fire_Year=="1980") length(y1980$Area_Hecta) but I somehow feel that there must be a better solution...maybe a loop? Any help is greatly appreciated Thanks so much Sandra -- View this message in context: http://r.789695.n4.nabble.com/Count-objects-and-print-it-into-a-new-variable-tp3595174p3595174.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.