Thank you all for your help, it worked!
Op 23 mei 2018 om 19:27 heeft marta azores
mailto:martazo...@gmail.com>> het volgende geschreven:
Try that code
NewDF<-DF[!DF$Anxiolytics==1,]
2018-05-23 10:14 GMT+00:00 Lisa van der Burgh
mailto:lisavdbu...@hotmail.com>>:
Hi all,
I have a very genera
Hello,
See if this inspires you.
set.seed(1962)
DF <- data.frame(Anxiolytics = factor(sample(c(0, 2, NA), 1000, TRUE),
levels = 0:2))
summary(DF$Anxiolytics)
DF$Anxiolytics <- droplevels(DF$Anxiolytics)
summary(DF$Anxiolytics)
DF$Anxiolytics <- factor(DF$Anxiolytics, labels = 0:1)
summary(D
It looks like your data has class "factor". If you call factor() on a
factor variable, without supplying an explicit 'levels' argument it
produces a new factor variable without any levels not present in the input
factor. E.g.,
> fOrig <- factor(c(NA,"A","B","D",NA,"D"), levels=c("D","C","B","A")
Dear Abraham,
If I follow correctly what you want to do, the following should do it:
> f <- factor(c(1, 1, 5, 5, 8, 8, 9, 9, 0, 0))
> f
[1] 1 1 5 5 8 8 9 9 0 0
Levels: 0 1 5 8 9
> recode(f, " '1'=3; '5'=1; '0'=2; else=NA ")
[1] 331122
Levels: 1 2 3
I think that your
4 matches
Mail list logo