Hello, I think this is easy, but I can't seem to find a good way to do this in the R help. I have a list of sites, with multiple years of data for each site id. I want to create a new column that gives a number describing whether it is the 1st year ("1" ) the data was collected for the site, the second year ("2"), etc. I have different years for each siteid, but I don't care which year it was collected, just the order that it is in for that siteid. This is what I have so far, but it doesn't do the analysis separately for each SiteID.
indexi<-indexg[order(indexg$SiteID,indexg$Yr),] obs=0 indexi=na.omit(indexi) for(i in 1:length(indexi$SiteID)){ obs=obs+1 indexi$obs[i]=obs } Thanks for any help you can give. Christy Meredith USDA Forest Service Rocky Mountain Research Station PIBO Monitoring Data Analyst Voice: 435-755-3573 Fax: 435-755-3563 This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[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.