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,

[R] lists and rownames

2016-04-18 Thread Ed Siefker
I'm doing some string manipulation on a vector of file names, and noticed something curious. When I strsplit the vector, I get a list of character vectors. The list is numbered, as lists are. When I cast that list as a data frame with 'as.data.frame()', the resulting columns have names derived fr

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

[R] Lists with numbers lists and strings

2013-10-18 Thread Alaios
Dear all, I have a list that is created like that Spans<-list( c(837e6,842e6),       c(832e6,837e6),       c(930.1e6,935.1e6)       ) I would like to include a second list that will contain the string that would correspond to the numbers at the left side. I would like thus insi

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

[R] lists as matrix cells ?

2012-11-21 Thread Asis Hallab
Dear R experts, since more or less half a year I am using R. In many of my computations I construct huge matrices. Often I do so using 'cbind' on named lists: do.call( 'cbind', list( "Column_A"=list("Row_one"=1.0, "Row_two"=2.0, "Row_three"=3.0), "Column_B"=list("Row_one"=4.0, "Row_two

Re: [R] lists everywhere

2011-12-05 Thread William Dunlap
linear algebra (or aviation or physics or almost anywhere else). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Kehl Dániel > Sent: Monday, December 05,

[R] lists everywhere

2011-12-05 Thread Kehl Dániel
Dear list members, I have a really simple problem. I connected to a DB and have the following query adat <- dbGetQuery(con, paste("select * from kmdata where SzeAZ='", szeazok[i], "' order by datum", sep="")) now I have the data in the adat variable which is a list. In fact the elements of t

[R] lists within lists

2011-04-04 Thread Darcy Webber
Hello R users, I am dealing with some resonably big data sets that I have split up into lists based on various factors. In the code below, I have got my code producing 100 values between point1x and point1y for the first matrix in my list. for (k in 1:length(point1x[[1]][, 1])) { linex[[k]] = seq

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

[R] Lists of tables and conditional statements

2011-03-30 Thread Herbert, Alan G
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 elegant way to do this using apply of related functions as th

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

[R] Lists and functions in data.frame?

2010-12-08 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I would like to have a data.frame, where one column contains functions, and another one lists. i.e.: FUN <- function(l) {return(l$a+l$b+l$c} LIST <- list(a=1, b=2, c=3) d <- data.frame(fun=FUN, no=LIST, value=2, b=TRUE) FUN <- function(l) {retur

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

[R] Lists with NULL entries

2010-09-20 Thread Peter Langfelder
Hello, I encountered a weird problem. Consider the following code that takes a list "lst" and shifts all elements one index up (for example, to make space for a new first element): lst = list(1,2) ll = length(lst); for (i in ll:1) lst[[i+1]] = lst[[i]]; lst If you run it, you get the expected

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

2010-02-22 Thread Peter Alspach
r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of ewaters > Sent: Tuesday, 23 February 2010 3:27 p.m. > To: r-help@r-project.org > Subject: [R] Lists into matrices within lists...again > > > Related questions to this have been asked before, but

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

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

2010-02-22 Thread ewaters
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: statslist <- as.data.frame(cbind (means, vars, mcrs)) I then take 100 sampl

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

[R] Lists

2009-07-24 Thread Alberto Lora M
Hi Everybody I have the following problem suppose that we a<-c("uno","dos","tres") I am working with a while cycle and the idea is in each iteration adding an item to a list In the first iteration the resultshould be: [[1]] [1] "uno" In the second [[1]] [1] "uno" [[2]] [1] "dos" And the fina

Re: [R] Filtering R lists

2009-03-04 Thread Nikol Simecek
Many thanks for all your suggestions - much appreciated! Nikol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,

Re: [R] Odp: Filtering R lists

2009-03-04 Thread Wacek Kusnierczyk
Petr PIKAL wrote: > Hi > > > r-help-boun...@r-project.org napsal dne 04.03.2009 13:18:30: > > >> Hello >> I am am new to R and any help with the following would be appreciated: >> I have a list (example attached) and I would like to create a new list >> which is a filtered version of this list.

Re: [R] Filtering R lists

2009-03-04 Thread Wacek Kusnierczyk
Nikol Simecek wrote: > Hello > I am am new to R and any help with the following would be appreciated: > I have a list (example attached) and I would like to create a new list > which is a filtered version of this list. I.e I would like a list that > only contains elements with this value: > > Chr 1

Re: [R] Filtering R lists

2009-03-04 Thread Jorge Ivan Velez
Dear Nikol, Try this: do.call(c,lapply(yourlist,function(x) x[2] )) HTH, Jorge On Wed, Mar 4, 2009 at 7:18 AM, Nikol Simecek wrote: > Hello > I am am new to R and any help with the following would be appreciated: > I have a list (example attached) and I would like to create a new list > whic

[R] Odp: Filtering R lists

2009-03-04 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 04.03.2009 13:18:30: > Hello > I am am new to R and any help with the following would be appreciated: > I have a list (example attached) and I would like to create a new list > which is a filtered version of this list. I.e I would like a list that > o

[R] Filtering R lists

2009-03-04 Thread Nikol Simecek
Hello I am am new to R and any help with the following would be appreciated: I have a list (example attached) and I would like to create a new list which is a filtered version of this list. I.e I would like a list that only contains elements with this value: Chr 10 : 21853562 - 21855482 Any p

[R] lists on a script

2009-02-13 Thread diego Diego
Dear R experts, I have a problem with a function I wrote. The fuction looks like this: series<-function(x,s){ foo<-list(); ind3<-integer(); for (j in diff){ for (i in 1:(n-12)){ if (!(x[i,j]==0)&!(x[i+1,j]==0)&!(x[i+2,j]==0)&!(x[i+3,j]==0)&!(x[i+4,j]==0)&!(x[i+5,j]==0)&!(x[i+6,j]==0) &!(x[i+

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

[R] Lists of data.frame

2008-04-26 Thread Worik R
I cannot find out how to build data structures as lists of data structures. I want to do... r-help@r-project.org d1 <- data.frame(x=1, y=2) d2 <- data.frame(x=1, y=3) d3 <- data.frame(x=21, y=3) q1 <- data.frame(q=d1, n="a") q2 <- data.frame(q=d2, n="a") q3 <- data.frame(q=d3, n="a") v <-