Re: [R] [EXTERNAL] Re: unexpected behavior in apply

2021-10-08 Thread Grzegorz Smoliński
This will work as well: d<-data.frame(d1 = letters[1:3], d2 = c(1,2,3), d3 = c(NA_character_,NA_character_,6)) apply(d, 2, FUN=function(x)all(x[!is.na(x)] <= 3)) d1 d2 d3 FALSE TRUE FALSE i.e. when NA changed do NA_character_ pt., 8 paź 2021 o 20:44 D

Re: [R] [EXTERNAL] Re: unexpected behavior in apply

2021-10-08 Thread Derickson, Ryan, VHA NCOD via R-help
This is interesting and does seem suboptimal. Especially because if I start with a matrix from the beginning, it behaves as expected. > d<-data.frame(d1 = letters[1:3], + d2 = c("1","2","3"), + d3 = c(NA,NA,"6")) > > str(d) 'data.frame': 3 obs. of 3 variables: $ d