Re: [R] urgent: question concerning data manipulation

2013-03-04 Thread Eik Vettorazzi
There’s more than one way to skin a cat, here is another mm<-model.matrix(~personId+law+0,testdata) merge(testdata,aggregate(mm[,-1],list(personId=mm[,"personId"]),max)) cheers Am 04.03.2013 16:44, schrieb David Studer: > Hello everyone! > > Does anyone of you know how I could solve the followi

Re: [R] urgent: question concerning data manipulation

2013-03-04 Thread ONKELINX, Thierry
_ Van: r-help-boun...@r-project.org [r-help-boun...@r-project.org] namens David Studer [stude...@gmail.com] Verzonden: maandag 4 maart 2013 16:44 Aan: r-help@r-project.org Onderwerp: [R] urgent: question concerning data manipulation Hello everyone! Does anyone of you know how I could solve t

Re: [R] urgent: question concerning data manipulation

2013-03-04 Thread MacQueen, Don
Here is one way. There will be many ways to do it; I offer this one because it is very general. -Don tmp <- split(testdata, testdata$personId) myfun <- function(df) { dfo <- df if (any(df$law=='SVG')) dfo$svg <- 1 else dfo$svg <- 0 dfo } tmpo <- lapply(tmp,myfun) testout <- do.call('rbi

[R] urgent: question concerning data manipulation

2013-03-04 Thread David Studer
Hello everyone! Does anyone of you know how I could solve the following problem. I guess, it is not a very difficult question, but I simply lack of the right idea: I have a dataset containing data of convictions. This dataset contains 4 columns: - personId: individual number that identifies the o