Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Dagmar
Hello Rui and Gerrit and Sarah, Thank you very much for your help. I finally got it to work! Have a great day! Dagmar Am 29.10.2015 um 08:38 schrieb ruipbarra...@sapo.pt: > > Hello, > > Try the following. > > > newframe <- myframe > newframe$Hungertype <- with(myframe, ifelse(Hunger <= 1, NA, >

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Gerrit Eichner
Hello, Sarah, take a look at the online help page of the function cut() (and apply the function to the Hunger-column). Hth -- Gerrit On Thu, 29 Oct 2015, Dagmar wrote: Dear Sarah, (dear All), Thank you for trying to help! You are right, that I want to add a column to my dataframe with a

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread ruipbarradas
Hello, Try the following. newframe <- myframe newframe$Hungertype <- with(myframe, ifelse(Hunger <= 1, NA,                             ifelse(1 < Hunger & Hunger <= 2, "Hunger",                             ifelse(Hunger < 3, "bigHUnger", "verybigHunger") ))) Note that the new column is of type c

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-29 Thread Dagmar
Dear Sarah, (dear All), Thank you for trying to help! You are right, that I want to add a column to my dataframe with a corresponding value to the Hunger column. Your solution is basically correct in the result but my data are a little more complicated. Maybe that example describes it better:

Re: [R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Sarah Goslee
If I'm reading this correctly, you want to add a column to your dataframe with a name corresponding to the value in the Hunger column. myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) ) myframe$Hungertype <- c("none", "bighunger", "ver

[R] rbind - names in dataframe. Beginner Question

2015-10-28 Thread Dagmar Cimiotti
Hello, It must be very easy. I have data like this: myframe <- data.frame (ID=c("Ernie", "Ernie", "Ernie", "Bert", "Bert","Bert", "Duck"), Hunger=c(1,1,1,2,2,1,3) ) myframe bighunger <- subset (myframe, myframe$Hunger>=2 &myframe$Hunger <3 ) bighunger verybighunger <- subset(myframe,myframe$Hun