Re: [R] List of data frame

2019-10-20 Thread ani jaya
Hai Rui, It seems doesnt work for me, the "" still there. So I used this one (Bert suggestion), test<-lapply(test,function(x){x$RR[x$RR==] <- NA; x}) Best, Ani On Sat, Oct 19, 2019 at 6:55 PM Rui Barradas wrote: > Hello, > > Why not use read.xlsx argument 'na.strings', an argumen

Re: [R] List of data frame

2019-10-19 Thread Rui Barradas
Hello, Why not use read.xlsx argument 'na.strings', an argument that exists in many file reading functions? (read.table, and derivatives.) test <- lapply(sheets,function(i) { read.xlsx("rainfall.xlsx", sheet = i, startRow = 8, cols = 1:2, na.strings = "") }) Ho

Re: [R] List of data frame

2019-10-17 Thread Jim Lemon
Hi ani, Sorry, a typo in the function - should be: makeNA(x)<-function(x,varname,value) { x[,varname][x[,varname]==value]<-NA return(x) } Jim On Fri, Oct 18, 2019 at 2:01 PM Jim Lemon wrote: > > Hi ani, > You say you want to replace with NA, so: > > # it will be easier if you don't use n

Re: [R] List of data frame

2019-10-17 Thread Jim Lemon
Hi ani, You say you want to replace with NA, so: # it will be easier if you don't use numbers for the names of the data frames names(test) <- paste0("Y",1986:2015) makeNA(x)<-function(x,varname,value) { x[,varname][x[,varname]<-value]<-NA return(x) } lapply(test,makeNA,list("RR",)) War

Re: [R] List of data frame

2019-10-17 Thread ani jaya
Thank you Mr. Bert, but my data frame is in the list, here 'test' list of data frame have 30 data frames (elements), names '1986' ~ '2015', and each data frame contain two variables, date and R. >a2<-rbind(test$`1987`) >is.na(a2$RR)<- a2$RR== Above is good enough but only for '1987'. Is it po

Re: [R] List of data frame

2019-10-17 Thread Bert Gunter
I'm a little unclear, but maybe ?is.na . As in: > x <- c(1:3,) > x [1]123 > is.na(x) <- x== ## rhs is an "index vector" of logicals > x [1] 1 2 3 NA Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- O