Re: [R] list concatenation
Bert Gunter gunter.ber...@gene.com writes: Lists are (isomorphic to) trees with (possibly) labelled nodes. A completely general solution in which two trees have possibly different topologies and different labels would therefore involve identifying the paths to leaves on each tree, e.g. via depth first search using recursion, and unioning leaves with the same paths (which could be quickly found in R via match() on the paths). This is a standard exercise in a data structures course. Considerable simplification could be effected if tree topologies and/or labels are identical or have other restrictions on them. However, you have not made it clear in your post whether this is the case (it is in your example). Thanks so much to all of you for your very helpful suggestions, that helped me solve my problem. The tree topologies are indeed identical, so the suggested solutions did work, but just for me to learn: Can somebody point me to how a general solution mentioned by Bert would look like? Cheers, Georg __ R-help@r-project.org 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.
[R] list concatenation
Dear R gurus, first let me apologize for a question that might hve been answered before. I was not able to find the solution yet. I want to concatenate two lists of lists at their lowest level. Suppose I have two lists of lists: list.1 - list(I=list(A=c(a, b, c), B=c(d, e, f)), II=list(A=c(g, h, i), B=c(j, k, l))) list.2 - list(I=list(A=c(A, B, C), B=c(D, E, F)), II=list(A=c(G, H, I), B=c(J, K, L))) list.1 $I $I$A [1] a b c $I$B [1] d e f $II $II$A [1] g h i $II$B [1] j k l list.2 $I $I$A [1] A B C $I$B [1] D E F $II $II$A [1] G H I $II$B [1] J K L Now I want to concatenate list elements of the lowest levels, so the result looks like this: $I $I$A [1] a b c A B C $I$B [1] d e f D E F $II $II$A [1] g h i G H I $II$B [1] j k l J K L Has anybody a good solution for that? Best, Georg __ R-help@r-project.org 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.
Re: [R] Find in R and R books
Alaios ala...@yahoo.com writes: Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. What are your tricks when you want to find some function that provides some functionality? To search R-specific sites the best place to go is this one: http://www.rseek.org/ Cheers, Georg __ R-help@r-project.org 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.
Re: [R] Latex and r
moleps mole...@gmail.com writes: Apparently you don't have xdvi installed on your system. HTH Georg Dear R´ers I´m trying to get a summary table using latex and summary in the rms package to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I have the mactex 2009 distribution installed. Any obvious things I´m missing? //M options(digits=3) set.seed(173) sex - factor(sample(c(m,f), 500, rep=TRUE)) age - rnorm(500, 50, 5) treatment - factor(sample(c(Drug,Placebo), 500, rep=TRUE)) f - summary(treatment ~ age + sex + Symptoms, method=reverse, test=TRUE) latex(f) results in the following: This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) entering extended mode (/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex LaTeX2e 2009/09/24 Babel v3.8l and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded. (/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls Document Class: report 2007/10/19 v1.4h Standard LaTeX document class (/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty (/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty) (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty) (/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg)) No file file587f83cb.aux. *geometry auto-detecting driver* *geometry detected driver: dvips* Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23 [] [1] (./file587f83cb.aux) LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right. ) (see the transcript file for additional information) Output written on file587f83cb.dvi (1 page, 1620 bytes). Transcript written on file587f83cb.log. sh: xdvi: command not found __ R-help@r-project.org 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.
[R] Sweave figure
Hi, I have a problem using figures in Sweave: To save my figures, I use \SweaveOpts{prefix.string=figures/figure} I adjust the figure size for my pdf document using graphicsFun, fig=TRUE, echo=FALSE, height=10, width=5, eval=TRUE= this works fine. The file figures/figure-graphicsFun.pdf has the right size, and so has the figure in the final pdf document. The problem is, that during Sweave'ing, the plot is printed also to the active x11 device, which has default size settings. In some cases, this results in an error, because some parameters (e.g. margins) might not be compatible with the default size. I think the best solution would be to supress printing to the x11 device by that code chunk, since I do not really need this side effect, but I have not found how to do this and do not know if this is possible. Any hints? Best, Georg __ R-help@r-project.org 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.
Re: [R] applying a function recursively
Hi, thanks a lot for your help. Somehow rapply had escaped my notice. I also have a follow-up question on that. I would like to flatten my output list to a list with only one level. Option unlist in rapply returns a character vector, in my example: rapply(test.list, rev, how=unlist) I.A1I.A2I.A3I.B1I.B2I.B3I.C1I.C2I.C3 II.A.a1 c b a f e d i h g c II.A.a2 II.A.a3 II.A.b1 II.A.b2 II.A.b3 II.A.c1 II.A.c2 II.A.c3 II.B1 II.B2 b a f e d i h g f e II.B3 II.C1 II.C2 II.C3 d i h g What I rather would like to achieve is a list like this: $I.A [1] c b a $I.B [1] f e d $I.C [1] i h g $II.A.a [1] c b a $II.A.b [1] f e d $II.A.c [1] i h g $II.B [1] f e d $II.C [1] i h g Any hint will be appreciated. Best, Georg Prof Brian Ripley [EMAIL PROTECTED] writes: See ?rapply On Wed, 11 Jun 2008, Georg Otto wrote: Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), C=c(g, h, i)), + II=list(A=list(a=c(a, b, c), b=c(d, e, f), + c=c(g, h, i)), + B=c(d, e, f), C=c(g, h, i))) test.list $I $I$A [1] a b c $I$B [1] d e f $I$C [1] g h i $II $II$A $II$A$a [1] a b c $II$A$b [1] d e f $II$A$c [1] g h i $II$B [1] d e f $II$C [1] g h i I would like to apply a function recursively to that list, in a way that the function does someting with each vector (eg. rev()) and returns a list of modified vectors that has the same structure as the input list, in my example: $I $I$A [1] c b a $I$B [1] f e d $I$C [1] i h g $II $II$A $II$A$a [1] c b a $II$A$b [1] f e d $II$A$c [1] i h g $II$B [1] f e d $II$C [1] i h g I understand that with a fixed number of recursion levels one can use lapply() in a nested way, but what if the numbers of recursion levels is not fixed or is different between the list elements as it is in my example? Any hint will be appreciated. Best, Georg __ R-help@r-project.org 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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org 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. __ R-help@r-project.org 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.
[R] applying a function recursively
Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: test.list-list(I=list(A=c(a, b, c), B=c(d, e, f), C=c(g, h, i)), + II=list(A=list(a=c(a, b, c), b=c(d, e, f), + c=c(g, h, i)), + B=c(d, e, f), C=c(g, h, i))) test.list $I $I$A [1] a b c $I$B [1] d e f $I$C [1] g h i $II $II$A $II$A$a [1] a b c $II$A$b [1] d e f $II$A$c [1] g h i $II$B [1] d e f $II$C [1] g h i I would like to apply a function recursively to that list, in a way that the function does someting with each vector (eg. rev()) and returns a list of modified vectors that has the same structure as the input list, in my example: $I $I$A [1] c b a $I$B [1] f e d $I$C [1] i h g $II $II$A $II$A$a [1] c b a $II$A$b [1] f e d $II$A$c [1] i h g $II$B [1] f e d $II$C [1] i h g I understand that with a fixed number of recursion levels one can use lapply() in a nested way, but what if the numbers of recursion levels is not fixed or is different between the list elements as it is in my example? Any hint will be appreciated. Best, Georg __ R-help@r-project.org 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.
Re: [R] legend for several graphics
Thanks a lot, John, Gavin; Hadley and Greg, for your helpful comments and suggestions. I finally achieved what I wanted using the suggested method from Gavin with corrections from Greg. Out of curiosity (and interest to learn): Hadley, how would you simplify that code using lattice or ggplot and how would you automatically draw the legend? Best, Georg Greg Snow [EMAIL PROTECTED] writes: My modification of your example is: library(TeachingDemos) op - par(mfrow = c(3,3), ## split region oma = c(5,0,4,0) + 0.1, ## create outer margin mar = c(5,4,2,2) + 0.1) ## shrink some margins plot(1:10, main = a, pch = 1:2, col= 1:2) plot(1:10, main = b, pch = 1:2, col= 1:2) tmp1 - cnvrt.coords( 0.5, 0, input='plt' )$tdev # save location for mtext plot(1:10, main = c, pch = 1:2, col= 1:2) plot(1:10, main = d, pch = 1:2, col= 1:2) plot(1:10, main = e, pch = 1:2, col= 1:2) plot(1:10, main = f, pch = 1:2, col= 1:2) plot(1:10, main = g, pch = 1:2, col= 1:2) plot(1:10, main = h, pch = 1:2, col= 1:2) plot(1:10, main = i, pch = 1:2, col= 1:2) ## title mtext(My Plots, side = 3, outer = TRUE, font = 2, line = 1, cex = 1.2, at=tmp1$x) ## draw legend par(xpd=NA) tmp2 - cnvrt.coords( tmp1$x, 0.05, input='tdev' )$usr # get location for legend legend(tmp2$x, tmp2$y, legend = c(Type 1, Type 2), pch = 1:2, col = 1:2, ncol = 2, xjust=0.5, yjust=0.5) par(op) __ R-help@r-project.org 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.
[R] legend for several graphics
Hi, I am trying to generate a figure of 9 plots that are contained in one device by using par(mfrow = c(3,3,)) I would like to have 1 common legend for all 9 plots somewhere outside of the plotting area (as opposed to one legend inside each of the 9 plots, which the function legend() seems to generate by default). Any hint how to do this? Best, Georg __ R-help@r-project.org 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.
Re: [R] Interpretation of log odds
Dear Corinna, please do post questions related to bioconductor packages directly to the bioconductor mailing list. You will have a much higher chance to get a helpful answer. The B-statistic is explained best explained in the limma user guide (chapter 10), which comes with the limma package or from http://www.bioconductor.org/packages/release/bioc/html/limma.html Hope that helps, Georg Schmitt, Corinna [EMAIL PROTECTED] writes: Hallo, fit12-lmFit(qrg[,1:2]) t12-toptable(fit12,adjust=fdr,number=15000,genelist=qrg$genes[,1]) t12 ID logFC t P.Value adj.P.ValB 1560 orf6.2714 -5,95911144 -7,5045373620,0616459272630 0,00430961073320568 20,85141454 8689 SW232,709344216 3,41198098 0,000644926129763921000 0,03967585550307640 -0,62704052 The data example comes from one experiment, where I want to know if genes are differentially expressed. As I saw in the onlinehelp for toptable the value B is the log odds that the gene is differentially expressed. When I now look at the B value 20,85141454 it says that the gene orf6.2714 is in 20,85% differentially expressed. Is it right? But how should I interpret the second example SW23 with a negative B value? __ R-help@r-project.org 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.