Hi Do not post in HTML, please. Try to show your real data - use str(test), or preferably dput(test). If test is big, use only fraction of it The problem must be probably in your data.
x <- sample(1:20, 100, replace=T) fake <- paste("T", x, sep="") ifelse(fake=="T14", 1,0) [1] 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 head(fake) [1] "T7" "T9" "T3" "T9" "T12" "T9" > str(fake) chr [1:100] "T7" "T9" "T3" "T9" "T12" "T9" "T19" "T19" "T12" "T2" "T17" ... > Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of javed khan > Sent: Wednesday, January 26, 2022 2:47 PM > To: R-help <r-help@r-project.org> > Subject: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE > needed > > I get this error: > > Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed > > I used this: > > var <- ifelse(test$operator == 'T14', 1, 0) > > operator has several values like T1, T3, T7, T15, T31, T37 > > For some values like T3, T7 it works fine but for majority of values it gives error. > > When I use: is.na(ts$operator), it shows all false values so no NAs. > > Where could be the problem? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.