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
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
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"
>
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
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
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
6 matches
Mail list logo