Re: [R] Calling a list element

2010-05-12 Thread Erik Iverson
The key is that "[" is a function. So, you have a list, you want to apply a function to a list, and return a vector, think sapply. sapply(strsplit(as.character(Elecciones$Municipios),"\\."), "[", 1) Luis Felipe Parra wrote: Hello, i have the following list strsplit(as.character(Elecciones

Re: [R] Calling a list element

2010-05-12 Thread David Winsemius
On May 12, 2010, at 5:18 PM, Luis Felipe Parra wrote: Hello, i have the following list strsplit(as.character(Elecciones$Municipios),"\\.") [[1]] [1] "ANTIOQUIA" "ABEJORRAL" [[2]] [1] "META""ACACIAS" [[3]] [1] "CASANARE" "AGUAZUL" [[4]] and I would like to make a vector of the first element

Re: [R] Calling a list element

2010-05-12 Thread Henrique Dallazuanna
Try this: sapply(strsplit(as.character(Elecciones$Municipios),"\\."), '[[', 1) On Wed, May 12, 2010 at 6:18 PM, Luis Felipe Parra < felipe.pa...@quantil.com.co> wrote: > Hello, i have the following list > strsplit(as.character(Elecciones$Municipios),"\\.") > [[1]] > [1] "ANTIOQUIA" "ABEJORRAL" >

[R] Calling a list element

2010-05-12 Thread Luis Felipe Parra
Hello, i have the following list strsplit(as.character(Elecciones$Municipios),"\\.") [[1]] [1] "ANTIOQUIA" "ABEJORRAL" [[2]] [1] "META""ACACIAS" [[3]] [1] "CASANARE" "AGUAZUL" [[4]] and I would like to make a vector of the first element of each of the list items, in this case ANTIOQUIA, META, C

Re: [R] calling a list element from a list name passed to a function

2008-01-27 Thread Gabor Grothendieck
Its a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f On Jan 27, 2008 8:42 AM, Gonçalo Ferraz <[EMAIL PROTECTED]> wrote: > Hi, > > 'true_name' is a list of numerical, matrix, and text items > > I do > > pass_name <- "true_name" > > and pass the name

[R] calling a list element from a list name passed to a function

2008-01-27 Thread Gonçalo Ferraz
Hi, 'true_name' is a list of numerical, matrix, and text items I do pass_name <- "true_name" and pass the name of the list to a function so that the character class variable 'passed_name' contains the name of the list called 'true_name' Inside the function, how can I get a specified elemen