Or, you may use this approach:
> attach(achtergrond)
> spits <- ifelse(uurenminuut >= 5.30 & uurenminuut < 9.30, "morning",
+ ifelse(uurenminuut >=16.30 & uurenminuut < 19.0, "evening",
+ "between"))
> table(spits)
spits
between evening morning
1636 142 579
>
I personally like the app
You can do this in 2 steps - have cut() make a factor with a different
level for each time period
then use levels<-() to merge some of the levels.
> z <- cut(.5:3.5, breaks=c(0,1,2,3,4), labels=c("0-1", "1-2", "2-3",
"3-4"))
> levels(z)
[1] "0-1" "1-2" "2-3" "3-4"
> levels(z) <- c("betw
> > Hey
> > I have a question about making a new variable in R. I have put my dataset
> > in attachment. I have to make a new variable "spits" where spits=morning
> > when uurenminuut (also a variabel) is between 5.30 and 9.30, when
> > uurenminuut is between 16.30 and 19.0 spits has to be equa
3 matches
Mail list logo