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
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 = "")
})
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
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",))
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
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."
--
Dear R-Help,
I have a list of data frame that I import from excel file using read.xlsx
command.
sheets <- openxlsx::getSheetNames("rainfall.xlsx")
test <- lapply(sheets,function(i) read.xlsx("rainfall.xlsx", sheet=i,
startRow=8, cols=1:2))
names(test) <- sprintf("%i", 1986:2015)
And I got a
Hi,
set.seed(249)
dat1- as.data.frame(matrix(sample(1:20,40*20,replace=TRUE),ncol=20))
#Based on your code:
vecNew-sort(t(as.data.frame(lapply(dat1,sum))),decreasing=TRUE)[1:10]
#or
vec1-sort(unlist(lapply(dat1,sum),use.names=FALSE),decreasing=TRUE)[1:10]
identical(vec1,vecNew)
#[1] TRUE
I need to make a data frame out of the data that I currently have in a list.
This works, but is ugly:
ineffData-rbind(ineffFilesList[[1]], ineffFilesList[[2]], ineffFilesList[[3]],
ineffFilesList[[4]], ineffFilesList[[5]], ineffFilesList[[6]],
ineffFilesList[[7]], ineffFilesList[[8]],
Hi Franklin,
Try
do.call(rbind, ineffFilesList)
See ?do.call for more details.
HTH,
Jorge
On Sun, Apr 10, 2011 at 2:01 PM, Franklin Tamborello II wrote:
I need to make a data frame out of the data that I currently have in a
list. This works, but is ugly:
On Sun, Apr 10, 2011 at 06:01:39PM +, Franklin Tamborello II wrote:
I need to make a data frame out of the data that I currently have in
a list. This works, but is ugly:
ineffData-rbind(ineffFilesList[[1]], ineffFilesList[[2]],
ineffFilesList[[3]], ineffFilesList[[4]], ineffFilesList[[5]],
Hi,
Any ideas on how to efficiently convert
list(c(1,2,3),c(4,5,6))
to
data.frame(OriginalListIndex=c(1,1,1,2,2,2),Item=c(1,2,3,4,5,6))
Thanks for any hints,
Joh
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
Try this:
stack(data.frame(list('A' = c(1,2,3), 'B' = c(4,5,6
On Mon, Jul 26, 2010 at 11:46 AM, Johannes Graumann
johannes_graum...@web.de wrote:
Hi,
Any ideas on how to efficiently convert
list(c(1,2,3),c(4,5,6))
to
Hi,
Here is another option if you already have a list you want to convert.
This will handle different elements of the list being different
lengths.
#Using your example data
mydata - list(c(1,2,3),c(4,5,6))
data.frame(
OriginalListIndex = rep(x = seq_along(mydata),
times =
Thanks a lot!
This solves my problem!
Joh
On Monday 26 July 2010 17:06:37 Joshua Wiley wrote:
Hi,
Here is another option if you already have a list you want to convert.
This will handle different elements of the list being different
lengths.
#Using your example data
mydata -
This is programming style, best practices type of question.
When converting a list to a data frame (eg to use in ggplot), what is best
way to store descriptive elements?
For example, a survfit object mostly maps to a data frame, but I would also
like to carry along the type, call, etc.
I'm
16 matches
Mail list logo