Re: [R] lists and rownames

2016-04-18 Thread jim holtman
You can always add those names to the list: is this what you are after? > example.names <- c("con1-1-masked-bottom-green.tsv", "con1-1-masked-bottom-red.tsv" + , "con1-1-masked-top-green.tsv","con1-1-masked-top-red.tsv") > example.list <- strsplit(example.names, "-") > names(example.l

Re: [R] lists and rownames

2016-04-18 Thread Sarah Goslee
They aren't being stored, they are being generated on the fly. You can create the same names using make.names() example.names <- c("con1-1-masked-bottom-green.tsv", "con1-1-masked-bottom-red.tsv", "con1-1-masked-top-green.tsv", "con1-1-masked-top-red.tsv") example.list <- strsplit(example.names,

Re: [R] Lists heading in an array of lists in R

2016-01-22 Thread Duncan Murdoch
On 22/01/2016 2:29 AM, TJUN KIAT TEO wrote: I am trying to populate an array of lists in R . Here is my code TunePar<-matrix(list(Null),2,2) TunePar[1,1]=list(G=2) But when I type TunePar[1,1,], all I get is 2. The G has disappeared. why? If I do this Test=list(G=2) Test $G [1] 2 Matric

Re: [R] Lists heading in an array of lists in R

2016-01-22 Thread Dénes Tóth
Hi, Provide a list of a list in the second assignment: -- TunePar <- matrix(list(NULL), 2, 2) TunePar[2,1] <- list(list(G = 2)) TunePar[2,1] TunePar[2,1][[1]]$G TunePar[[2]]$G --- The point is that "[" returns the list element of the same level as the original object (TunePar in the present ex

Re: [R] Lists with numbers lists and strings

2013-10-18 Thread arun
Hi, Not sure this is what you wanted. lstNew <- list(Spans, lapply(lapply(Spans,`[`,1),as.character) ) str(lstNew) #List of 2  $ :List of 3   ..$ : num [1:2] 8.37e+08 8.42e+08   ..$ : num [1:2] 8.32e+08 8.37e+08   ..$ : num [1:2] 9.30e+08 9.35e+08  $ :List of 3   ..$ : chr "8.37e+08"   ..$ : chr "8

Re: [R] lists as matrix cells ?

2012-11-21 Thread Sarah Goslee
A matrix may only contain one data type. By not specifying when you created m, it was filled with logical values of NA. A logical value can't hold a list. You can see that with str(m) which returns: > str(m) logi [1:3, 1:2] NA NA NA NA NA NA - attr(*, "dimnames")=List of 2 ..$ : chr [1:3] "Ro

Re: [R] lists everywhere

2011-12-05 Thread William Dunlap
First, some general suggestions: To see the structure of an object I would recommend the str() function or, for a more concise output, the class() function. I don't think most ordinary users should be using is.list() and, especially, is.vector(). Now for the particulars. dbGetQuery pr

Re: [R] Lists of tables and conditional statements

2011-03-31 Thread Herbert, Alan G
-help@r-project.org Help Subject: Re: [R] Lists of tables and conditional statements On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote: > Try this: > > lapply(l, function(x)x[x[,'Sum'] == 3,]) If this is the right answer, you should send a "solved" message. The

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote: Try this: lapply(l, function(x)x[x[,'Sum'] == 3,]) If this is the right answer, you should send a "solved" message. The dput extract was incomplete. -- David. On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G wrote: Hi R-users

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread Henrique Dallazuanna
Try this: lapply(l, function(x)x[x[,'Sum'] == 3,]) On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G wrote: > Hi R-users, > > I have a list containing numeric tables of differing row length. I want to > make a new list that contains only rows from tables with a "Sum" greater than > 3, plus the

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 5:38 PM, Herbert, Alan G wrote: Hi R-users, I have a list containing numeric tables of differing row length. I want to make a new list that contains only rows from tables with a "Sum" greater than 3, plus the names of each table. I was wondering whether there is an el

Re: [R] Lists and functions in data.frame?

2010-12-08 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/08/2010 11:22 AM, jim holtman wrote: > It sounds like you want to use a "list" instead of a dataframe, No - I would like to have a data,frame. I am aware of the differences, but as far as I understand, each column in a data.frame can have a diff

Re: [R] Lists and functions in data.frame?

2010-12-08 Thread jim holtman
It sounds like you want to use a "list" instead of a dataframe, especially if the elements are a different length. > d <- list() # initialize > d[[length(d) + 1]] <- list() # extend > d[[length(d)]]$fun <- sin # add a function > d[[length(d) + 1]] <- list() # extend again > d[[length(d)]]$fun

Re: [R] Lists with NULL entries

2010-09-21 Thread Greg Snow
alf Of Peter Langfelder > Sent: Monday, September 20, 2010 9:52 PM > To: r-help > Subject: Re: [R] Lists with NULL entries > > Hi Joshua, > > thanks, I came up with that solution myself after a bit of thinking. > Normally I wouldn't worry about NULL components of lists

Re: [R] Lists with NULL entries

2010-09-20 Thread Peter Langfelder
Hi Joshua, thanks, I came up with that solution myself after a bit of thinking. Normally I wouldn't worry about NULL components of lists, but dimnames is a list and often some components are null and is therefore a bit tricky to manipulate... Peter On Mon, Sep 20, 2010 at 7:39 PM, Joshua Wiley

Re: [R] Lists with NULL entries

2010-09-20 Thread Joshua Wiley
Sorry, that was a really half-hearted reply. This will create a new list that is the old list shifted down (and should be much faster than the for loop too). lst <- list(NULL,2) lst2 <- vector("list", length(lst) + 1) lst2[2:length(lst2)] <- lst lst lst2 If you really need to use a for loop, may

Re: [R] Lists with NULL entries

2010-09-20 Thread Joshua Wiley
Hello Peter, This is because assigning a value of NULL removes that element of the list. I am not quite sure what the reference for that is. I remember reading it in the documentation once though. I looked through ?list to no avail. At any rate, to avoid it, you would have to assign something

Re: [R] Lists into matrices within lists...again

2010-02-22 Thread Peter Alspach
Tena koe Edward It is difficult to know the best approach from the information supplied, but using unlist() at the appropriate place in your code, maybe unlist(stats[[i]]$means), will probably get you where you want to be. HTH . Peter Alspach > -Original Message- > From: r-help-bou

Re: [R] Lists into matrices within lists...again

2010-02-22 Thread David Winsemius
On Feb 22, 2010, at 8:27 PM, ewaters wrote: Related questions to this have been asked before, but I have tried all options they gave me unsuccessfully (do.call and unlist). I start with three lists of summary statistics, 100 elements each, which I bind together: None of this represents

Re: [R] Lists

2009-07-25 Thread Linlin Yan
How about like this: for (i in seq_along(a)) { result <- as.list(a[1:i]) cat("iterator", i, ":\n") print(result) } On Sat, Jul 25, 2009 at 6:48 AM, Alberto Lora M wrote: > Hi Everybody > > I have the following problem > > suppose that we > > a<-c("uno","dos","tres") > > I am working with a

Re: [R] Lists

2009-07-25 Thread jim holtman
Here is one way: > a<-c("uno","dos","tres") > x <- list() > a<-c("uno","dos","tres") > x <- list() > for (i in seq_along(a)){ + # add to the list + x[[i]] <- a[i] + str(x) + } List of 1 $ : chr "uno" List of 2 $ : chr "uno" $ : chr "dos" List of 3 $ : chr "uno" $ : chr "dos" $ : chr "t

Re: [R] Lists of data.frame

2008-04-26 Thread jim holtman
I think this is what you want. You need to look at the help file for ?'[' and ?'[['. Also understand the differences between a data.frame and a list. in the case of defining qn you need to use a list and not a data.frame because here is what happens with a data.frame: > q1 <- data.frame(q=d1, n