[R] name returned by lapply

Antje niederlein-rstat at yahoo.de
Fri Jul 18 13:45:18 CEST 2008


Hi there,

I have a very simple question. If I execute the following code:


test <- function(x) {
	name <- paste(x,"info_within_function")
	c(1,2,3,4,5)
}

ret <- lapply(1:10, test)


, I end up with a list and each entry is just numbered [[1]], [[2]], ... [[10]]

How can I force the result entries gettings names which are determined within 
the function. For this example, I'd like the entries named like:

"1 info_within_function" instead of [[1]]
"2 info_within_function" instead of [[2]]
and so on.
(that's why I put this strange "name <- ..." line inside)

Can anybody help me what I have to do to get the returned list entries like this?

Thanks a lot!

Antje



More information about the R-help mailing list