Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Jim Lemon
Hi Allaisone, If you want a data frame as the output you will have to put up with a few NA values unless each Customer has the same number of diet types: a1df<-read.table(text="CustomerIDDietType 1 a 1c 1b 2

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread peter dalgaard
It depends quite strongly on what you want to do with the result, but I wonder if what is really needed might be a list of diettypes per person, i.e. continuing from Eric's code > On 25 Feb 2018, at 18:56 , Eric Berger wrote: > > Hi Allaisone, > I took a slightly different approach but you mig

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Eric Berger
Hi Allaisone, I took a slightly different approach but you might find this either as or more useful than your approach, or at least a start on the path to a solution you need. df1 <- data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"), strin

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Bert Gunter
I believe you need to spend time with an R tutorial or two: a data frame (presumably the "table" data structure you describe) can *not* contain "blanks" -- all columns must be the same length, which means NA's are filled in as needed. Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fi