[R] sapply and its return value

Antje niederlein-rstat at yahoo.de
Thu Feb 15 14:06:07 CET 2007


I have some problems with sapply. I wanted to do the following:

s <- sapply(filelist, function(x) {
			return( list(density(file$V1)$x, density(file$V1)$y))
			print(paste("plotDensity ERROR - File does not exist: ",x,sep=""))
			return( NULL)

	if(is.null( - ??? - ))
		print("no plot")

That means, I try to read every file and to get some data from it. It 
may happen, that the file does not exist and then I don't want to plot 
anything. As return, I get a list and I have quite a lot of problems to 
access its content... (I did not really understand how this works, I 
Could anybody give me a hint?

Thank you!

More information about the R-help mailing list