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,
>
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
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
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:
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
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
6 matches
Mail list logo