[R] sapply and its return value

2007-02-15 Thread Antje
Hello, I have some problems with sapply. I wanted to do the following: s <- sapply(filelist, function(x) { if(file.exists(x)) { ... return( list(density(file$V1)$x, density(file$V1)$y)) }

Re: [R] sapply and its return value

2007-02-15 Thread jim holtman
What is being returned from the 'sapply' is a 'list' and to process the information in the list, you should use 'lapply'. I assume that you want to keep 's' around for further processing. Here is a simple example that makes every other entry in the list a NULL and then uses 'lapply' to iterate th