[R] Plotting a list of lists
arun
smartpink111 at yahoo.com
Sun Nov 17 09:04:50 CET 2013
Hi,
It is not very clear.
May be this gets you started:
set.seed(42)
lst1 <- lapply(1:5, function(i) lapply(1:50,function(i) rnorm(sample(50,1))))
lst2 <- lapply(lst1,function(x) data.frame(X= rep(seq_along(x),sapply(x,length)),Y=unlist(x)))
pdf("test2.pdf")
lapply(lst2,function(x) with(x,plot(Y~X)))
dev.off()
A.K.
I have a list if lists in R (part of which is shown below). I wish to
plot these lists on the same graph where each list corresponds to a
single x coordinate. For example for the 45th list all the values would
be plotted on the line x=45. Anyone able to help?
[[45]]
[1] -0.110067765 -0.040016980 -0.024073054 -0.221518631 0.158046458
[6] -0.110134750 0.004824416 0.067080351 -0.052912475 0.034445239
[11] 0.017093804 0.014526023 0.123733756 -0.076593627 -0.049173945
[16] -0.044804543 0.089349788 -0.061330124 -0.108191264 0.210778889
[21] 0.057898773 -0.000392106 -0.020911704 0.084198206 -0.064250534
[26] -0.041634491 -0.142851316 -0.116919985 0.115766019 0.082258703
[31] 0.048376129 -0.036986678 -0.002247251 0.202808035 0.178324911
[36] 0.027862391 -0.092909969 -0.158287227 0.048137063 0.142961443
[41] 0.024102742 -0.034740816 0.095980313 0.234679333 0.062757475
[46] -0.083656499 -0.026666635 -0.049571943 -0.003269980 0.012924383
[[46]]
[1] 0.112291702 0.455557078 -0.188595792 0.023815125 0.047757787
[6] -0.108520094 0.119083003 0.065705185 0.224999137 0.076742666
[11] 0.247330698 0.096306189 -0.222250082 -0.004899562 -0.026481377
[16] -0.171317015 0.183442656 -0.026224042 0.017024487 0.180420266
[21] 0.108220342 -0.002034567 -0.059184763 0.024854329 -0.267982999
[26] -0.181058542 0.271709202 0.078113700 0.145173899 -0.259035363
[31] -0.033086712 -0.136858819 -0.232087471 -0.014715389 0.105185758
[36] -0.119881528 0.098842549 0.060748033 -0.306107128 0.022539607
[41] -0.093208642 0.140678025 0.095285130 0.140788810 -0.274918531
[46] 0.080010582 -0.070639892 0.100321500 0.047547311 0.107104289
[[47]]
[1] 0.137215639 -0.074820424 -0.082442176 0.250054175 0.185168148
[6] -0.146350321 -0.135327713 -0.184682332 0.143446849 0.047635866
[11] -0.073068031 -0.002690403 -0.162714729 -0.151941475 -0.122147610
[16] -0.041184742 0.098393496 -0.000948722 -0.164136918 0.086485859
[21] -0.101381633 0.017928356 0.086042233 0.167799050 -0.066286935
[26] 0.153897947 0.046226772 -0.042488379 0.157126544 -0.026546025
[31] -0.098447831 0.248466421 -0.240674997 -0.067275509 0.219154426
[36] 0.261614097 -0.085938742 0.169890170 0.038687110 0.273939911
[41] -0.207415094 -0.242613302 -0.070860536 -0.108869865 0.002090580
More information about the R-help
mailing list