[R] make a list with names with s/lapply
Rui Barradas
ruipbarradas at sapo.pt
Tue Feb 19 22:39:59 CET 2013
Hello,
I'm not sure I understabd, but if the names are in 'namen' then the
following might do what you want.
names(open.list) <- namen
Hope this helps,
Rui Barradas
Em 19-02-2013 18:09, Hermann Norpois escreveu:
> Hello,
>
> I open some files in a directory and get a list.
>
>
> open.list <- sapply (namen, function (x) {file <- list.files (ddir,
> pattern=x, full.names=TRUE) # namen is vector and each element detects a
> special file to open
> file <- read.table (file)
> }
> )
>
>
>
> This list has no names. I would like to get a list with key/value pairs and
> namen is the vector delivering the names. So how does sapply or lapply get
> the information to generate key/value pairs?
>
> Thanks
> Hermann
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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, self-contained, reproducible code.
>
More information about the R-help
mailing list