[R] sapply and its return value

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


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))
		}
		else
		{
			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 
guess...)
Could anybody give me a hint?

Thank you!
Antje



More information about the R-help mailing list