[Rd] Multiple Intersections
Hi all, I don't know if this is the correct venue for this question, but I am sure that someone will correct me if I am in the wrong list. I have been searching throughout R for a function that can find the intersection of multiple sets of "things". Say for instance, I have a list of $n$ character vectors and would like to find the intersection of all $k$ subsets. I don't believe that there is such a function to do this (or am I wrong?). It is a pretty easy to encode such a function...there was an e-mail about how a recursive function to intersect an arbitrary number of sets which is elegant and useful (sorry I forgot the person's name who wrote the 2 line function). My question is two-fold: 1. If such a function already exists, what is it called? 2. If such a function does not exists, it is worthwhile to encode it (i.e. can I send my code to someone?). Cheers, --tony [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] table(factor(x), exclude=NULL) (PR#11494)
[EMAIL PROTECTED] wrote: Hi. I don't know if this a bug or just annoying to me: x <- c(1,2,3,NA) table(x, exclude=NULL) x 123 1111 table(factor(x), exclude=NULL) 1 2 3 1 1 1 I don't think many people use factor(x, exclude=NULL): it is not the default handling of character data by read.table(). Cheers, David Duffy. I've moved this to "wishlist" in the bug repository. It's a documented annoyance, but we might be able to do better. The underlying issue is the following: > f <- factor(c(1:3,NA),labels=letters[3:1]) > f [1] cba Levels: c b a > factor(f) [1] cba Levels: c b a > factor(f,exclude=NULL) [1] cba Levels: c b a > factor(f,levels=levels(f),exclude=NULL) [1] cba Levels: c b a > factor(f,levels=c(levels(f),NA),exclude=NULL) [1] cba Levels: c b a and this code in table() suggests that the latter is what was intended (since we actually try to pass exclude=NULL): cat <- if (is.factor(a)) { if (!missing(exclude)) { ll <- levels(a) factor(a, levels = ll[!(ll %in% exclude)], exclude = if (is.null(exclude)) NULL else NA) } else a (levels = if(is.null(exclude)) c(ll,NA) else ll[!(ll %in% exclude)] should do. This will change behaviour of the case where you have mixed factors and non-factors, so I'm not just implementing it right away. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple Intersections
Hi Tony -- off-list, as I think you're looking for something else... "Tony Chiang" <[EMAIL PROTECTED]> writes: > Hi all, > > I don't know if this is the correct venue for this question, but I am sure > that someone will correct me if I am in the wrong list. > > I have been searching throughout R for a function that can find the > intersection of multiple sets of "things". Say for instance, I have a list > of $n$ character vectors and would like to find the intersection of all $k$ > subsets. I don't believe that there is such a function to do this (or am I > wrong?). It is a pretty easy to encode such a function...there was an e-mail > about how a recursive function to intersect an arbitrary number of sets > which is elegant and useful (sorry I forgot the person's name who wrote the > 2 line function). Maybe this is what you were thinking of? Intersect=function(x, ...) { if (length(list(...))>1) Intersect(x, Intersect(...)) else intersect(x, ...) } > Intersect(letters[1:5], letters[3:6], letters[4:7]) [1] "d" "e" > l=list(letters[1:5], letters[3:6], letters[4:7]) > do.call("Intersect", l) [1] "d" "e" Also > Reduce(intersect, l, letters) [1] "d" "e" This won't be efficient for a large set of 'things', and I'm not getting how n and k fit in -- 'all k subsets' implies all elements of n? Martin > My question is two-fold: > > 1. If such a function already exists, what is it called? > 2. If such a function does not exists, it is worthwhile to encode it (i.e. > can I send my code to someone?). > > Cheers, > --tony > > [[alternative HTML version deleted]] > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple Intersections
Hi Martin, I think I was extremely unclear about my question. If I have a list of $n$ character vectors, I would like to look at the intersection of $k$ of these vectors (of which there are n choose k). Martin, you methods (at least the first one) is one that I use, but I also use the combn(n,k) and take the columns of the output to subset the original list for which to take the multiple intersections. Robert has pointed out (to me) that this might be a (hyper)graph function. While I agree that the list could be represented as hyper-edges, I also tend to think that it is a more general set theoretic issue. Personally, I am looking at some statistics on posets, and this comes up for me. But without any other suggestions, I will find out if I can incorporate a function into graph or hypergraph. Cheers, --tony On Wed, May 28, 2008 at 3:58 PM, Martin Morgan <[EMAIL PROTECTED]> wrote: > Hi Tony -- off-list, as I think you're looking for something else... > > "Tony Chiang" <[EMAIL PROTECTED]> writes: > > > Hi all, > > > > I don't know if this is the correct venue for this question, but I am > sure > > that someone will correct me if I am in the wrong list. > > > > I have been searching throughout R for a function that can find the > > intersection of multiple sets of "things". Say for instance, I have a > list > > of $n$ character vectors and would like to find the intersection of all > $k$ > > subsets. I don't believe that there is such a function to do this (or am > I > > wrong?). It is a pretty easy to encode such a function...there was an > e-mail > > about how a recursive function to intersect an arbitrary number of sets > > which is elegant and useful (sorry I forgot the person's name who wrote > the > > 2 line function). > > Maybe this is what you were thinking of? > > Intersect=function(x, ...) { >if (length(list(...))>1) >Intersect(x, Intersect(...)) >else >intersect(x, ...) > } > > > Intersect(letters[1:5], letters[3:6], letters[4:7]) > [1] "d" "e" > > l=list(letters[1:5], letters[3:6], letters[4:7]) > > do.call("Intersect", l) > [1] "d" "e" > > Also > > > Reduce(intersect, l, letters) > [1] "d" "e" > > This won't be efficient for a large set of 'things', and I'm not > getting how n and k fit in -- 'all k subsets' implies all elements of > n? > > Martin > > > My question is two-fold: > > > > 1. If such a function already exists, what is it called? > > 2. If such a function does not exists, it is worthwhile to encode it > (i.e. > > can I send my code to someone?). > > > > Cheers, > > --tony > > > > [[alternative HTML version deleted]] > > > > __ > > R-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > -- > Martin Morgan > Computational Biology / Fred Hutchinson Cancer Research Center > 1100 Fairview Ave. N. > PO Box 19024 Seattle, WA 98109 > > Location: Arnold Building M2 B169 > Phone: (206) 667-2793 > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] error: C stack usage is too close to the limit.
rapache version 1.0.4 and earlier attempted to turn off stack-checking *before* initializing R. After reading the source, it seems that it should turn it off *after* initializing R. I've fixed this in the latest release of 1.0.5. Sorry for the confusion; it's hard to understand just from reading the 'Writing R Extensions' manual exactly what can/should be accomplished before R initializes compared to what can/should be accomplished afterwards to influence R's embedded environment. For instance, turning off R's signal handling is accomplished by setting R_SignalHandlers = 0 *before* initializing R; at least that's what the source code is telling me. Best, Jeff Prof Brian Ripley wrote on 05/28/2008 01:53 AM: Please look it up in 'Writing R Extensions'. Especially in the discussion around 'There is a potential issue with the stack-checking mechanism where threads are involved.' This is an issue for the author of RApache, who it seems has not turned off C stack checking in the version you are using, and in any case the advice is to set appropriate limits, not turn it off. On Tue, 27 May 2008, jeroenooms wrote: I am trying to set up a RApache server on my Ubuntu 8.04. I have installed apache2, R-2.7.0, and the RApache plugin. Both Apache and R seem to work fine, but whenever i try to use the plugin i get this error: C stack usage is too close to the limit. I have tried to recompile apache2, R, and RApache, but i keep getting the error. The weird thing is, i had exactly the same problem when i installed RApache on my Debian box, but somehow that suddenly dissapeared and now it is working fine. However, i cant resolve the error on my Ubuntu machine. I have mailed the author of RApache, and he told me he thought that he actually had "turned off" c stack checking in RApache. He couldnt find the cause of any problems in my logs. I realise probably not a lot of people are using RApache, but the error seems more familiar in R when you google it. Unfortunatly i have no idea what it means. Any suggestions in which direction i should look for a solution? http://www.nabble.com/file/p17498015/2hdw8eo.png -- View this message in context: http://www.nabble.com/error%3A-C-stack-usage-is-too-close-to-the-limit.-tp17498015p17498015.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Unnecssary warnings in plot function (PR#11530)
Full_Name: Joseph Amuah Version: 2.7.0 (2008-04-22) OS: Windows Submission from: (NULL) (205.207.78.4) I used the plot function to create some graphs but wanted to add soem restrictions. A set of warning were produced even though the plot worked fine. Can these warnings be cleaned up? Here is an example: *** > plot(xx$month, xx$log10RR, xlab="", ylab="", type='n', xlim=c(0,60), ylim=c(-0.2,0.3),tick=F, labels=F) Warning messages: 1: In plot.window(...) : "tick" is not a graphical parameter 2: In plot.window(...) : "labels" is not a graphical parameter 3: In plot.xy(xy, type, ...) : "tick" is not a graphical parameter 4: In plot.xy(xy, type, ...) : "labels" is not a graphical parameter 5: In box(...) : "tick" is not a graphical parameter 6: In box(...) : "labels" is not a graphical parameter 7: In title(...) : "tick" is not a graphical parameter 8: In title(...) : "labels" is not a graphical parameter > # expect warning that tick and labels are non-graphical parameters but it works > points(xx$month, xx$log10RR, col='red') > lines(xx$month, xx$log10RR, col='red') __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] thought for posting guide
I know that lots of first-time posters don't read the posting guide, but for those that do ... I often find myself pointing out to posters that they should include relevant details about their subject area -- that R-helpers are not necessarily experts on options trading, population genetics, or whatever they happen to be doing ... Ben Bolker signature.asc Description: OpenPGP digital signature __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple Intersections
Please, Gentlemen, this whole thread has *nothing* to do with "R-devel", and pretty much with "R-help". So please revert to there (or do reply off-list if you really want that) Regards, Martin > "TC" == Tony Chiang <[EMAIL PROTECTED]> > on Wed, 28 May 2008 16:57:04 +0100 writes: TC> Hi Martin, I think I was extremely unclear about my TC> question. If I have a list of $n$ character vectors, I TC> would like to look at the intersection of $k$ of these TC> vectors (of which there are n choose k). Martin, you TC> methods (at least the first one) is one that I use, but TC> I also use the combn(n,k) and take the columns of the TC> output to subset the original list for which to take the TC> multiple intersections. TC> Robert has pointed out (to me) that this might be a TC> (hyper)graph function. While I agree that the list TC> could be represented as hyper-edges, I also tend to TC> think that it is a more general set theoretic TC> issue. Personally, I am looking at some statistics on TC> posets, and this comes up for me. But without any other TC> suggestions, I will find out if I can incorporate a TC> function into graph or hypergraph. TC> Cheers, --tony TC> On Wed, May 28, 2008 at 3:58 PM, Martin Morgan TC> <[EMAIL PROTECTED]> wrote: >> Hi Tony -- off-list, as I think you're looking for >> something else... >> >> "Tony Chiang" <[EMAIL PROTECTED]> writes: >> >> > Hi all, >> > >> > I don't know if this is the correct venue for this >> question, but I am sure > that someone will correct me if >> I am in the wrong list. >> > >> > I have been searching throughout R for a function that >> can find the > intersection of multiple sets of >> "things". Say for instance, I have a list > of $n$ >> character vectors and would like to find the intersection >> of all $k$ > subsets. I don't believe that there is such >> a function to do this (or am I > wrong?). It is a pretty >> easy to encode such a function...there was an e-mail > >> about how a recursive function to intersect an arbitrary >> number of sets > which is elegant and useful (sorry I >> forgot the person's name who wrote the > 2 line >> function). >> >> Maybe this is what you were thinking of? >> >> Intersect=function(x, ...) { if (length(list(...))>1) >> Intersect(x, Intersect(...)) else intersect(x, ...) } >> >> > Intersect(letters[1:5], letters[3:6], letters[4:7]) [1] >> "d" "e" > l=list(letters[1:5], letters[3:6], >> letters[4:7]) > do.call("Intersect", l) [1] "d" "e" >> >> Also >> >> > Reduce(intersect, l, letters) [1] "d" "e" >> >> This won't be efficient for a large set of 'things', and >> I'm not getting how n and k fit in -- 'all k subsets' >> implies all elements of n? >> >> Martin >> >> > My question is two-fold: >> > >> > 1. If such a function already exists, what is it >> called? > 2. If such a function does not exists, it is >> worthwhile to encode it (i.e. > can I send my code to >> someone?). >> > >> > Cheers, > --tony >> > >> > [[alternative HTML version deleted]] >> > >> > __ > >> R-devel@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> -- >> Martin Morgan Computational Biology / Fred Hutchinson >> Cancer Research Center 1100 Fairview Ave. N. PO Box >> 19024 Seattle, WA 98109 >> >> Location: Arnold Building M2 B169 Phone: (206) 667-2793 >> [[alternative HTML version deleted]] TC> __ TC> R-devel@r-project.org mailing list TC> https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] A small modification of plot.acf (patch)
2008/5/27 Prof Brian Ripley <[EMAIL PROTECTED]>: > That is the part that needs justification. I've never seen an example where > that was the case (and you don't give one), and I use acf() a lot. The > examples fit and their series names are not particularly short. > > Also, the user has the option to supply 'main' to plot.acf via '...', so why > is that not sufficient? And you can even suppress the title by main="" and > use title() for even more control. > Here is an example with real-life series names and plot dimensions: data <- cbind('Число пожаров' = arima.sim(n = 100, list(ar = 0.5)), 'Инд. Нестерова' = arima.sim(n = 100, list(ar = 0.1))) x11(width = 4.8, height = 4.2) acf(data, mar = c(3, 3, 3, 1) + 0.1, cex.main = 1) I have tried to supply main argument to the acf function: acf(data, mar = c(3, 3, 3, 1) + 0.1, cex.main = 1, main = matrix(c('Число пожаров', 'Число пожаров &\nИнд. Нестерова', 'Число пожаров &\nИнд. Нестерова', 'Инд. Нестерова'), 2, 2)) but it doesn't work the desired way. Please see the implementation of plot.acf. title function doesn't seem to play well with par(mfrow = ), so it doesn't help, too. In principle, it's not *that* hard to implement a custom version of multivariate acf plot, but the current version of plot.acf provides some sweet features like y-axes alignment etc. Writing another plot.acf will inevitably lead to massive code duplication, which is bad. I have several ideas of how to tweak current plot.acf so it would suffice my needs: 1) Add new main.sep argument (see the patch). 2) Let plot.acf recognize if main is a matrix and use its elements for different plots, not just coerce it to vector and pass to every title. 3) Let plot.acf recognize if main is a function and call it with 2 arguments (i-series name and j-series name) to compose captions. 1) seems to be the easiest for a user, 2) and 3) provide more freedom. Andrey Paramonov __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] A small modification of plot.acf (patch)
The changes seem reasonable to me but here is a workaround just in case (using builtin BOD and letters as examples): i <- 0 setHook("plot.new", function() title(letters[i <<- i+1])) acf(BOD, main = "") setHook("plot.new", NULL, "replace") On Wed, May 28, 2008 at 12:08 PM, Андрей Парамонов <[EMAIL PROTECTED]> wrote: > 2008/5/27 Prof Brian Ripley <[EMAIL PROTECTED]>: >> That is the part that needs justification. I've never seen an example where >> that was the case (and you don't give one), and I use acf() a lot. The >> examples fit and their series names are not particularly short. >> >> Also, the user has the option to supply 'main' to plot.acf via '...', so why >> is that not sufficient? And you can even suppress the title by main="" and >> use title() for even more control. >> > > Here is an example with real-life series names and plot dimensions: > > data <- cbind('Число пожаров' = arima.sim(n = 100, list(ar = 0.5)), > 'Инд. Нестерова' = arima.sim(n = 100, list(ar = 0.1))) > > x11(width = 4.8, height = 4.2) > acf(data, mar = c(3, 3, 3, 1) + 0.1, cex.main = 1) > > I have tried to supply main argument to the acf function: > > acf(data, mar = c(3, 3, 3, 1) + 0.1, cex.main = 1, > main = matrix(c('Число пожаров', > 'Число пожаров &\nИнд. Нестерова', > 'Число пожаров &\nИнд. Нестерова', > 'Инд. Нестерова'), 2, 2)) > > but it doesn't work the desired way. Please see the implementation of > plot.acf. title function doesn't seem to play well with par(mfrow = ), > so it doesn't help, too. > > In principle, it's not *that* hard to implement a custom version of > multivariate acf plot, but the current version of plot.acf provides > some sweet features like y-axes alignment etc. Writing another > plot.acf will inevitably lead to massive code duplication, which is > bad. > > I have several ideas of how to tweak current plot.acf so it would > suffice my needs: > > 1) Add new main.sep argument (see the patch). > > 2) Let plot.acf recognize if main is a matrix and use its elements for > different plots, not just coerce it to vector and pass to every title. > > 3) Let plot.acf recognize if main is a function and call it with 2 > arguments (i-series name and j-series name) to compose captions. > > 1) seems to be the easiest for a user, 2) and 3) provide more freedom. > > Andrey Paramonov > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Cross-compilers for 2.7.0
Hello, Am I right in thinking the cross-compilations tools, kindly maintained by Prof Ripley, are still waiting to be updated for 2.7.0? Thanks, Iago -- Iago Mosqueira Cefas Systems Modelling Pakefield Rd. Lowestoft NR33 0HT U.K. +44 (0)1502 558003 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] quartz identify bug (PR#11491)
Olivier, On May 20, 2008, at 9:30 AM, olivier wrote: > Full_Name: olivier > Version: 2.7.0 > OS: mac os 10.5.2 > Submission from: (NULL) (62.39.72.218) Hi, I did not see you wrote how to terminate identify. + works very well so there is no more problem of crash. There is always the same problem with theses examples : #1 x=rnorm(10) qqnorm(x) identify(x) #2 x=rnorm(10) par(mfrow=c(2,1)) plot(x) qqnorm(x) identify(x) identify does not find any points. Thank you for your help. Olivier. -- View this message in context: http://www.nabble.com/quartz-identify-bug-%28PR-11491%29-tp17340518p17522757.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] mingw cross compiler binaries available
snpMatrix (http://bioconductor.org/packages/2.2/bioc/html/snpMatrix.html) is now part of Bioconductor. I use the mingw cross compiler to make the window releases so I made the effort to build the cross-compiler as an rpm for x86_64 fedora 8/9. It might be also useful to other R-developers, or some might find the rpm spec file interesting anyway: https://sourceforge.net/project/showfiles.php?group_id=217165 The cross-compiler is relocatable, I believe, so feel free to do "rpm2cpio | cpio --extract -d" or use alien to convert it to *.deb. This is provided as is, but will probably get updated from time to time. (The Bioconductor people have different ideas about release numbers, but trust me - I am one of the authors - that snpMatrix on the outmodedbonsai download page is a bit newer than what is available through bioc). __ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Unnecssary warnings in plot function (PR#11530)
Shaibu Pompo wrote: > > Full_Name: Joseph Amuah > Version: 2.7.0 (2008-04-22) > OS: Windows > Submission from: (NULL) (205.207.78.4) > > > I used the plot function to create some graphs but wanted to add soem > restrictions. A set of warning were produced even though the plot worked > fine. > Can these warnings be cleaned up? Here is an example: > *** >> plot(xx$month, xx$log10RR, xlab="", ylab="", type='n', xlim=c(0,60), > ylim=c(-0.2,0.3),tick=F, labels=F) > Warning messages: > 1: In plot.window(...) : "tick" is not a graphical parameter > 2: In plot.window(...) : "labels" is not a graphical parameter > 3: In plot.xy(xy, type, ...) : "tick" is not a graphical parameter > 4: In plot.xy(xy, type, ...) : "labels" is not a graphical parameter > 5: In box(...) : "tick" is not a graphical parameter > 6: In box(...) : "labels" is not a graphical parameter > 7: In title(...) : "tick" is not a graphical parameter > 8: In title(...) : "labels" is not a graphical parameter >> # expect warning that tick and labels are non-graphical parameters but it > works >> points(xx$month, xx$log10RR, col='red') >> lines(xx$month, xx$log10RR, col='red') > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > Try: plot(xx$month, xx$log10RR, xlab="", ylab="", type='n', xlim=c(0,60),ylim=c(-0.2,0.3)) - Blay S KATH Kumasi, Ghana. -- View this message in context: http://www.nabble.com/Unnecssary-warnings-in-plot-function-%28PR-11530%29-tp17516160p17527998.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel