Your 'x' has length 2, so x[[3]] cannot be calculated ('subscript out of
bounds' is what I get). You can check for this with length(x)<3.
In general, you want to be more precise: 'does not have a value', 'is
NULL', and 'is empty' are not synonymous. I'm not sure what 'does not have
a value' mean
Thanks. This is what I was referring to:
x <- rep(NA, 3)
is.na(x)
[1] TRUE TRUE TRUE
if (is.na(x)) {print("True")}
[1] "True"
Warning message:
In if (is.na(x)) { :
the condition has length > 1 and only the first element will be used
You are of course right - the warning is generated by if(), n
This may be out of context, but on the face of it, this claim is wrong:
On 20/12/2014, 1:57 PM, Boris Steipe wrote:
"Moreover is.na() behaves differently when evaluated on its own, or as
the condition of an if() statement."
The conditions in an if() statement are not evaluated in special
conditio
Boris et. al:
Indeed, corner cases are a bear, which is why it is incumbent on any
OP to precisely define what they mean by, say, "missing",
"null","empty", etc.
Here is an evil example to illustrate the sorts of nastiness that can occur:
> z <- list(a=NULL, b=list(), c=NA)
> with(z,{
+ c(ident
This can be tricky, because depending on what the missing object is, you can
get either NULL, NA, or an error. Moreover is.na() behaves differently when
evaluated on its own, or as the condition of an if() statement. Here is a
function that may make life easier. The goal is NOT to have to pass e
Hello,
Your list seems to have only 2 elements. You can check this with
length(x)
Or you can try
lapply(x, is.null)
Hope this helps,
Rui Barradas
Em 20-12-2014 15:58, Ragia Ibrahim escreveu:
Hello,
Kindly I have a list of lists as follow
x
[[1]]
[1] 7
[[2]]
[1] 3 4 5
as showen x[[3]] doe
Hi,
On Dec 20, 2014, at 10:58 AM, Ragia Ibrahim wrote:
> Hello,
> Kindly I have a list of lists as follow
> x
> [[1]]
> [1] 7
>
> [[2]]
> [1] 3 4 5
>
> as showen x[[3]] does not have a value and it has NULL, how can I check on
> this
> how to test if x[[3]] is empty.
>
In general you can
Hello,
Kindly I have a list of lists as follow
x
[[1]]
[1] 7
[[2]]
[1] 3 4 5
as showen x[[3]] does not have a value and it has NULL, how can I check on this
how to test if x[[3]] is empty.
thanks in advance
Ragia
[[alternative HTML version dele
Munjal,
Something like this should work:
Digits = c(20, 30, 40, 50, 60)
result = vector(length(Digits), mode="list")
names(result) = Digits
for(j in seq(Digits)) {
a = vector(Digits[j], mode="list")
b = vector(Digits[j], mode="list")
for(i in 1:Digits[j]) {
#Do Calculation
a[[i]] = data.frame(#
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Munjal Patel
> Sent: Monday, July 14, 2014 8:45 PM
> To: r-help@r-project.org
> Subject: [R] List of Lists by for Loop
>
> Dear Experts,
> I
Dear Experts,
I have a one more doubt about making list of lists.
Here is the simple code i have made.
I am doing the following for only one digit=20
a=vector(20,mode="list")
b=vector(20,mode="list")
for (i in 1:20){
#Do Calculation
a[[i]]=data.frame()
b[[i]]=data.frame()
}
Now i have
Dear Experts,
I have a one more doubt about making list of lists.
Here is the simple code i have made.
I am doing the following for only one digit=20
a=vector(20,mode="list")
b=vector(20,mode="list")
for (i in 1:20){
#Do Calculation
a[[i]]=data.frame()
b[[i]]=data.frame()
}
Now i hav
uot;a" )
}
listoffiles <- list(cpufile=cpufile,
cpufiledescriptors=cpufiledescriptors)
return (listoffiles)
}
Thanks,
Mohan
Re: [R] List of lists
applied to an object of class "c
('integer', 'numeric')"
Thanks,
Mohan
On 07/30/2013 10:05 PM, mohan.radhakrish...@polarisft.com wrote:
Hi,
I am creating a list of 2 lists, one containing filenames
and the other file descriptors. When I retrieve them I am unable to close
the file descriptor.
I am getting this error when I try to call close(filede
Hi,
I am creating a list of 2 lists, one containing filenames
and the other file descriptors. When I retrieve them I am unable to close
the file descriptor.
I am getting this error when I try to call close(filedescriptors
[[2]][[1]]).
Error in UseMethod("close") :
no applicabl
or example data is much better.
John Kane
Kingston ON Canada
> -Original Message-
> From: eliza_bo...@hotmail.com
> Sent: Mon, 7 Jan 2013 16:13:03 +0000
> To: r-help@r-project.org
> Subject: [R] list of lists to matrix
>
>
> dear R family,
> [a text file has been a
Thanks arun and weylandt,it perfectly worked out..
elisa
> From: michael.weyla...@gmail.com
> Date: Mon, 7 Jan 2013 16:37:53 +
> Subject: Re: [R] list of lists to matrix
> To: eliza_bo...@hotmail.com
> CC: r-help@r-project.org
>
> Something like
>
> do.call(c
Something like
do.call(cbind, lists)
?
MW
On Mon, Jan 7, 2013 at 4:13 PM, eliza botto wrote:
>
> dear R family,
> [a text file has been attached for better understanding]
> i have a list of 16 and each of of that is further subdivided into variable
> number of lists. So, i have a kind of list
dear R family,
[a text file has been attached for better understanding]
i have a list of 16 and each of of that is further subdivided into variable
number of lists. So, i have a kind of list into lists phenomenon.
[[1]]$'1'
1 2 3 4 5 6
7 8 9
[[1]]$'2'
1 2
: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
> Sent: Wednesday, November 16, 2011 5:26 PM
> To: rkevinbur...@charter.net
> Cc: r-help@r-project.org
> Subject: Re: [R] List of lists to data frame?
>
> unlist(..., recursive = F)
>
> Michael
>
> On Wed, Nov 16, 2011
On the face of it this looks like a job for ldply() in the plyr package
which specialises in taking things apart and putting them back together.
ldply() applies a function for each element of a list and then combine
results into a data frame
On 17 November 2011 04:53, Sarah Goslee wrote:
> O
l help.
> Kevin
>
> -Original Message-
> From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
> Sent: Wednesday, November 16, 2011 5:26 PM
> To: rkevinbur...@charter.net
> Cc: r-help@r-project.org
> Subject: Re: [R] List of lists to data frame?
>
&g
d be recycled for each row. My brute
force code attempts to build the data frame by appending to the master data
frame but like I said it is *very* slow.
Kevin
-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
Sent: Wednesday, November 16, 2011 5:26 PM
To:
unlist(..., recursive = F)
Michael
On Wed, Nov 16, 2011 at 6:20 PM, wrote:
>
> I would like to make the following faster:
>
> df <- NULL
> for(i in 1:length(s))
> {
> df <- rbind(df, cbind(names(s[i]), time(s[[i]]$series),
> as.vector(s[[i]]$series), s[[i]]$c
I would like to make the following faster:
df <- NULL
for(i in 1:length(s))
{
df <- rbind(df, cbind(names(s[i]), time(s[[i]]$series),
as.vector(s[[i]]$series), s[[i]]$category))
}
names(df) <- c("name", "time", "value", "category")
Is this what you want:
> x <- list()
> x[[1]] <- list(1:3)
> x[[2]] <- list(3:1)
> x
[[1]]
[[1]][[1]]
[1] 1 2 3
[[2]]
[[2]][[1]]
[1] 3 2 1
On Mon, Aug 9, 2010 at 12:57 PM, Carlos Petti wrote:
> Dear list,
>
> I have to use a list of lists containing vectors.
>
> For instance :
>
> [[1]]
> [[
On Aug 9, 2010, at 12:57 PM, Carlos Petti wrote:
Dear list,
I have to use a list of lists containing vectors.
For instance :
[[1]]
[[1]][[1]]
[1] 1 2 3
[[1]][[2]]
[1] 3 2 1
I want to attribute vectors to the main list
without use of an intermediate list,
but it does not work :
More spec
Dear list,
I have to use a list of lists containing vectors.
For instance :
[[1]]
[[1]][[1]]
[1] 1 2 3
[[1]][[2]]
[1] 3 2 1
I want to attribute vectors to the main list
without use of an intermediate list,
but it does not work :
x <- list()
x[[1]][[1]] <- c(1, 2, 3)
x[[1]][[2]] <- c(3, 2, 1
On Wed, Jan 14, 2009 at 1:53 PM, glenn wrote:
> Dear All;
>
> Is it possible to create a list of lists (I am sure it is) along these
> lines;
>
> I have a dataframe data02 that holds a lot of information, and the first
> column is ³date²
>
> I have a list of dates in;
>
> data03<-c(date1,.,dat
See if one of %in% or match gets your further.
> 1:10 %in% c(1,3,5,9)
[1] TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE FALSE
> match(c(1,3,5,9), 1:10)
[1] 1 3 5 9
> match(c(1,3,5,9), 10:1)
[1] 10 8 6 2
date03 as offered was not a list, but a vector.
date04 <- date02[which(date02$da
Dear All;
Is it possible to create a list of lists (I am sure it is) along these
lines;
I have a dataframe data02 that holds a lot of information, and the first
column is ³date²
I have a list of dates in;
data03<-c(date1,.,daten)
And would like to create a list;
data04 <- subset(data02, d
32 matches
Mail list logo