Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread Bert Gunter
Whoa! 1. First and most important, there is very likely no reason you need to do this. R can handle multiple groupings automatically in fitting and plotting without creating artificial labels of the sort you appear to want to create. Please read an "Intro to R" and/or get help to see how. 2. The

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread David L Carlson
How about this? > indx <- unique(cbind(Dates, Groups)) > indx DatesGroups [1,] "12/10/2010" "A" [2,] "12/10/2010" "B" [3,] "13/10/2010" "A" [4,] "13/10/2010" "B" [5,] "13/10/2010" "C" > indx <- data.frame(indx, id=1:nrow(indx)) > indx Dates Groups id 1 12/10/2010

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread ONKELINX, Thierry
Dear Chandra, You're on the wrong track. You don't need for loops as you can do this vectorised. as.numeric(interaction(data$Groups, data$Dates, drop = TRUE)) Best regards, Thierry > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > N