try apply() :
par(new=F);
apply(s,2,function(x){plot(x[[1]],x[[2]],type="o");par(new=T)})
On 1/8/07, Antje <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've got the following problem. I have a vector containing file names. I
> want to read these files as csv and calculate the density-function for
> each file (has just one column with data). Then, I'd like to plot all
> density functions into one window. I did the following to calculate the
> density data:
>
> s <- sapply(filelist, function(x) {
> if(file.exists(x))
> {
> file <- read.csv(x, sep="\t", header=F)
> return( list(density(file$V1)$x, density(file$V1)$y))
> }
> })
>
> Now I would like to plot these x,y data in a similar way but my result
> "s" is a matrix containing lists...
>
> File1.csv File2.csv File3.csv
> [1,] Numeric,512 Numeric,512 Numeric,512
> [2,] Numeric,512 Numeric,512 Numeric,512
>
> Now I don't know how to handle the x,y values for each plot into an
> sapply (or lapply, I don't know)
>
> Any idea? Maybe, I should somehow change the return type?
>
> Antje
>
> ______________________________________________
> [email protected] 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.
>
______________________________________________
[email protected] 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.