Re: [R] list of lists, is this element empty

2014-12-21 Thread William Dunlap
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'

[R] list of lists, is this element empty

2014-12-20 Thread Ragia Ibrahim
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

Re: [R] list of lists, is this element empty

2014-12-20 Thread Ben Tupper
Hi, On Dec 20, 2014, at 10:58 AM, Ragia Ibrahim ragi...@hotmail.com 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

Re: [R] list of lists, is this element empty

2014-12-20 Thread Rui Barradas
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]]

Re: [R] list of lists, is this element empty

2014-12-20 Thread Boris Steipe
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

Re: [R] list of lists, is this element empty

2014-12-20 Thread Bert Gunter
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,{ +

Re: [R] list of lists, is this element empty

2014-12-20 Thread Duncan Murdoch
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

Re: [R] list of lists, is this element empty

2014-12-20 Thread Boris Steipe
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(), not by

Re: [R] List of Lists by for Loop

2014-07-15 Thread PIKAL Petr
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 have a one more doubt about making list

Re: [R] List of Lists in For Loop

2014-07-15 Thread Adams, Jean
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()

[R] List of Lists by for Loop

2014-07-14 Thread Munjal Patel
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

[R] List of Lists in For Loop

2014-07-14 Thread Munjal Patel
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 to

Re: [R] List of lists

2013-08-01 Thread mohan . radhakrishnan
Re: [R] List of lists Jim Lemon

Re: [R] List of lists

2013-07-31 Thread mohan . radhakrishnan
of class c ('integer', 'numeric') Thanks, Mohan Re: [R] List

[R] List of lists

2013-07-30 Thread mohan . radhakrishnan
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 applicable

Re: [R] List of lists

2013-07-30 Thread Jim Lemon
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

Re: [R] list of lists to matrix

2013-01-08 Thread John Kane
ON Canada -Original Message- From: eliza_bo...@hotmail.com Sent: Mon, 7 Jan 2013 16:13:03 + To: r-help@r-project.org Subject: [R] list of lists to matrix 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

[R] list of lists to matrix

2013-01-07 Thread eliza botto
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

Re: [R] list of lists to matrix

2013-01-07 Thread R. Michael Weylandt
Something like do.call(cbind, lists) ? MW On Mon, Jan 7, 2013 at 4:13 PM, eliza botto eliza_bo...@hotmail.com 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

Re: [R] list of lists to matrix

2013-01-07 Thread eliza botto
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(cbind, lists) ? MW On Mon, Jan 7

Re: [R] List of lists to data frame?

2011-11-17 Thread Bert Gunter
: Re: [R] List of lists to data frame? unlist(..., recursive = F) Michael On Wed, Nov 16, 2011 at 6:20 PM,  rkevinbur...@charter.net wrote: I would like to make the following faster:        df - NULL        for(i in 1:length(s))        {                df - rbind(df, cbind(names(s[i

[R] List of lists to data frame?

2011-11-16 Thread rkevinburton
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) return(df)

Re: [R] List of lists to data frame?

2011-11-16 Thread R. Michael Weylandt
unlist(..., recursive = F) Michael On Wed, Nov 16, 2011 at 6:20 PM, rkevinbur...@charter.net 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),

Re: [R] List of lists to data frame?

2011-11-16 Thread Kevin Burton
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: rkevinbur...@charter.net Cc: r-help@r-project.org Subject: Re: [R] List of lists to data frame? unlist

Re: [R] List of lists to data frame?

2011-11-16 Thread Sarah Goslee
, 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 at 6:20 PM,  rkevinbur...@charter.net wrote: I would like to make the following faster:        df - NULL

Re: [R] List of lists to data frame?

2011-11-16 Thread christiaan pauw
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

[R] List of lists ?

2010-08-09 Thread Carlos Petti
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)

Re: [R] List of lists ?

2010-08-09 Thread David Winsemius
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

Re: [R] List of lists ?

2010-08-09 Thread jim holtman
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 carlos.pe...@gmail.com wrote: Dear list, I have to use a list of lists containing vectors. For instance :

Re: [R] List of Lists

2009-01-14 Thread David Winsemius
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$date

Re: [R] List of Lists

2009-01-14 Thread hadley wickham
On Wed, Jan 14, 2009 at 1:53 PM, glenn g1enn.robe...@btinternet.com 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;