[R] combinatorics again
Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Error in X11(): Font Path?
Hello, I have recently upgraded to the new modular Xorg-7.0 in my gentoo laptop with R-2.2.1. Although everything seems to work fine, now in R I am unable to open the X11 device: -8--- Error in X11() : could not find any X11 fonts Check that the Font Path is correct. -8--- It happens any time that I want to plot anything or simply to open the display. -8--- options('X11fonts') $X11fonts [1] -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-* [2] -adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-* -8--- I have found in some messages to the list that it is usually related to system configuration. But, except for the new Xorg-7.0 installation, anything has changed. Any ideas to follow from now on? Thank you, -8--- version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R -8--- -8--- $ locale LANG=ca_ES.UTF-8 LC_CTYPE=ca_ES.UTF-8 LC_NUMERIC=ca_ES.UTF-8 LC_TIME=ca_ES.UTF-8 LC_COLLATE=ca_ES.UTF-8 LC_MONETARY=ca_ES.UTF-8 LC_MESSAGES=ca_ES.UTF-8 LC_PAPER=ca_ES.UTF-8 LC_NAME=ca_ES.UTF-8 LC_ADDRESS=ca_ES.UTF-8 LC_TELEPHONE=ca_ES.UTF-8 LC_MEASUREMENT=ca_ES.UTF-8 LC_IDENTIFICATION=ca_ES.UTF-8 LC_ALL=ca_ES.UTF-8 -8--- -- Xavier Fernández i Marín __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] combinatorics again
library(gtools) combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] combinatorics again
Thank you Jacques but your solution misses (eg) c(1,1,2) which I need. best wishes Robin On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: library(gtools) combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Semi-log plot in R
On Sun, Mar 05, 2006 at 12:00:19AM +, christophe tournayre wrote: Is it possible to create a semilog plot in R? If you mean a plot with one log-scale axis this is what you want: x = 1:100 y = x^2 plot(x,y, log=y) See ?plot for details cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] combinatorics again
Robin Hankin wrote: Thank you Jacques but your solution misses (eg) c(1,1,2) which I need. See ?combinations which should point you to combinations(5,3, repeats.allowed=TRUE) Best, Uwe best wishes Robin On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: library(gtools) combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] LocFit
I have a question regarding the package LOCFIT of C Loader. After fitting a smooth surface (y modeled by two regressors), I can't seem to find a nice way of making a perspective (or other 3d plot). The contours don't look quite so good. It is meant to be used as illustration of smoothing to my students in regression analysis. Could anybody perhaps assist me in producing a good graph in 3d? It probably works in S-Plus, but I am using R. (I have tried plot (locfit object, type=persp) on the ethanol dataset - but this gives a poor result, with a few warnings.) THANK YOU!. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg APK P O Box 524 Auckland Park 2006 South Africa Tel: +27-11-489-3080 Fax: +27-11-489-2832 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sort problem in merge()
Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] combinatorics again
combinations(5,3,rep=T) Robin Hankin a écrit : Thank you Jacques but your solution misses (eg) c(1,1,2) which I need. best wishes Robin On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: library(gtools) combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] combinatorics again
Patrick, Uwe thanks! [both your solutions were conceptually identical, except for one was ascending and one was descending] very best wishes Robin On 6 Mar 2006, at 09:36, Uwe Ligges wrote: Robin Hankin wrote: Thank you Jacques but your solution misses (eg) c(1,1,2) which I need. See ?combinations which should point you to combinations(5,3, repeats.allowed=TRUE) Best, Uwe best wishes Robin On 6 Mar 2006, at 09:17, Jacques VESLOT wrote: library(gtools) combinations(5,3) [,1] [,2] [,3] [1,]123 [2,]124 [3,]125 [4,]134 [5,]135 [6,]145 [7,]234 [8,]235 [9,]245 [10,]345 Robin Hankin a écrit : Hi I want to enumerate all vectors of length J, whose elements are integers in the range 1 to S, without regard to ordering. With J=S=3, the combinations are as follows: [,1] [,2] [,3] [1,]111 [2,]112 [3,]113 [4,]122 [5,]123 [6,]133 [7,]222 [8,]223 [9,]233 [10,]333 Note that (eg) c(1,2,1) is not on the list because we already have c(1,1,2) which would be equivalent [because the problem is to enumerate the cases without regard to ordering] and I do not want repeats. The best I can do is to create all S^J possibilities and weed out the repeats, using unique() ; code below. Why is this no good? Well, even for the tiny case of J=S=10, this would require a matrix of 10^10 rows, and my little linux machine refuses to cooperate, complaining about allocating a vector of length 1410065408. For these values of J and S, I happen to know that the are 6360 distinct combinations, which is eminently handleable. Anyone got any better ideas? allcomb - function(J,S){ f - function(...) { 1:S } out - as.matrix(do.call(expand.grid, lapply(1:J, FUN = f))) out - t(apply(out,1,sort)) unique(out) } -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Contingency table and zeros
Hello, Let's assume I have a vector of integers : myvector - c(1, 2, 3, 2, 1, 3, 5) My purpose is to obtain the cumulative distribution of these numerical data, i.e. something like : value nb_occur. =12 =24 =36 =46 =57 For this, I create a table with ; mytable - table(myvector) 1 2 3 5 2 2 2 1 However, table() returns an array of integers, mytable[4] returns the occurence number of the 5 item, which makes this table hard to index. I would prefer to have a data structure where mytable[4] could return 0, as there is no 4 in my vector. table() may not be the proper way to do it. For the moment, I use a loop which scans the vector from its lowest value to its highest, and counts the number of times each value appears. Is there a built-in function, or a table() option to do such a task ? Thanks. Regards, Nicolas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove gray grid from levelplot
Hi Jan, The patch requires a recompile of R. As I understand it, this is a fairly painful experience. I haven't done it myself. I find that using the pdf() function to open a pdf device produces better quality output when printing than saving a quartz device from the menu. It appears that the postscript() and pdf() devices use sub-pixel rendering as well, as output shows evidence of gray lines on low resolution devices, however, for me, this isn't evident on a printer at 1200x1200dpi. My guess would be that, in general, levelplot is not a great function to use if the box size approaches the resolution of the underlying device. The first example in help(levelplot) exhibits severe moire patterns on an approx 740x740 quartz or x11() device. When the output from the postscript device is printed out, it looks more or less as expected. If there are more boxes in the levelplot than pixels on the device you are plotting to, then in effect you are asking the display device to do the averaging of the excess boxes for devices that support sub-pixel rendering. I'm still not 100% sure what it is that you are trying to do, but I'm guessing that it boils down to levelplot not being designed to plot analytic functions. Martin P.S. To me, the png() device does not appear to do sub-pixel rendering. The postscript() and pdf() devices do. On 06/03/2006, at 1:43 AM, Jan Marius Hofert wrote: Hi, I am using a Mac (Powerbook G4, Mac Os X 10.4) and this seems to be the problem, but I have absolutely no idea how to use the patch mentioned on https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20060214/ 0b3e99c2/attachment.pl I would also like to create *.ps files so this does not seem to be the appropriate approach. I can also use x11 as trellis.device which fixes the color-problem, but the lines are plotted in bad quality then. Also, I can not save the graph then, when plotted with x11. All other devices (png, pdf) have the same problem with the fine gray lines so the R version for the mac must be the problem, but I have no idea how to fix that. It would not matter if the plots via the quartz device (on the screen) would be bad as long as the postscript file comes out perfect. Thanks again and any more comments/hints are appreciated marius On 05.03.2006, at 13:19, Martin Sandiford wrote: I don't know what kind of computer you are using. If you are on a Mac, then this might be relevant: https://stat.ethz.ch/pipermail/r-sig-mac/2006-February/002679.html (Need to click through to the actual message.) Martin On 05/03/2006, at 2:52 AM, Jan Marius Hofert wrote: Hi, If I use the levelplot function of the lattice library, I always see small squares in the plot. They indicate the region for which the same color is used. If you have a levelplot of a function which is evaluated at 25x25 equally-spaced points you obtain 26 squares in x and 26 squares in y direction. That does not bother too much (but still bothers somehow...), but if you want to plot a function which is evaluated at 1000x1000 equally-spaced points, then the thickness of this gray grid cause the grid lines to hit each other so there is no space for the color in the square anymore (since the squares are actually not visible anymore)... this might change the color of the whole levelplot!. (I tried it with the plot of f(x,y)=max(x+y-1,0) for x,y in the unit interval, i.e. the Lower Frechet copula). So my question is, if it is possible to remove this gray grid form the levelplot graph? Thanks in advance marius __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Contingency table and zeros
myvector - c(1, 2, 3, 2, 1, 3, 5) myf - factor(myvector, levels=1:5) table(myf) myf 1 2 3 4 5 2 2 2 0 1 cumsum(table(myf)) 1 2 3 4 5 2 4 6 6 7 Nicolas Perot a écrit : Hello, Let's assume I have a vector of integers : myvector - c(1, 2, 3, 2, 1, 3, 5) My purpose is to obtain the cumulative distribution of these numerical data, i.e. something like : value nb_occur. =12 =24 =36 =46 =57 For this, I create a table with ; mytable - table(myvector) 1 2 3 5 2 2 2 1 However, table() returns an array of integers, mytable[4] returns the occurence number of the 5 item, which makes this table hard to index. I would prefer to have a data structure where mytable[4] could return 0, as there is no 4 in my vector. table() may not be the proper way to do it. For the moment, I use a loop which scans the vector from its lowest value to its highest, and counts the number of times each value appears. Is there a built-in function, or a table() option to do such a task ? Thanks. Regards, Nicolas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Contingency table and zeros
something like: cumsum(table(factor(myvector,levels=1:5))) will do the job. Nicolas Perot wrote: Hello, Let's assume I have a vector of integers : myvector - c(1, 2, 3, 2, 1, 3, 5) My purpose is to obtain the cumulative distribution of these numerical data, i.e. something like : value nb_occur. =12 =24 =36 =46 =57 For this, I create a table with ; mytable - table(myvector) 1 2 3 5 2 2 2 1 However, table() returns an array of integers, mytable[4] returns the occurence number of the 5 item, which makes this table hard to index. I would prefer to have a data structure where mytable[4] could return 0, as there is no 4 in my vector. table() may not be the proper way to do it. For the moment, I use a loop which scans the vector from its lowest value to its highest, and counts the number of times each value appears. Is there a built-in function, or a table() option to do such a task ? Thanks. Regards, Nicolas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Stéphane DRAY ([EMAIL PROTECTED] ) Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I 43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France Tel: 33 4 72 43 27 57 Fax: 33 4 72 43 13 88 http://www.steph280.freesurf.fr/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Contingency table and zeros
I think ecdf() is more appropriate than table() here, e.g., x - c(1, 2, 3, 2, 1, 3, 5) Fn - ecdf(x) Fn(1:5) * length(x) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Nicolas Perot [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, March 06, 2006 10:56 AM Subject: [R] Contingency table and zeros Hello, Let's assume I have a vector of integers : myvector - c(1, 2, 3, 2, 1, 3, 5) My purpose is to obtain the cumulative distribution of these numerical data, i.e. something like : value nb_occur. =12 =24 =36 =46 =57 For this, I create a table with ; mytable - table(myvector) 1 2 3 5 2 2 2 1 However, table() returns an array of integers, mytable[4] returns the occurence number of the 5 item, which makes this table hard to index. I would prefer to have a data structure where mytable[4] could return 0, as there is no 4 in my vector. table() may not be the proper way to do it. For the moment, I use a loop which scans the vector from its lowest value to its highest, and counts the number of times each value appears. Is there a built-in function, or a table() option to do such a task ? Thanks. Regards, Nicolas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove gray grid from levelplot
On Mon, 6 Mar 2006, Martin Sandiford wrote: [...] P.S. To me, the png() device does not appear to do sub-pixel rendering. The postscript() and pdf() devices do. What could you possibly mean by that? The postscript() and pdf() produce vector graphics and have no concept of a pixel. There are filled polygons as part of the language they output. (Of course the coordinates are output to finite resolution, in fact 0.01dp = 1/7200, so you could think of that as the positioning quantum.) The png device writes on a bitmap. It outputs a rectangular grid of either pre-defined colour indices or RGB values. There is nothing in the PNG standard to allow anything finer. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Averaging over columns
Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable across columns can easily be created by rep(1:12,each=3), but I can't figure out which function to use to get R to calculate the means I want. Thanks in advance Mick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] P-values from survreg (survival package) using a clusterterm
Hi all. Belove is the example from the cluster-help page wtih the output. I simply cannot figure out how to relate the estimate and robust Std. Err to the p-value. I am aware this a marginal model applying the sandwich estimator using (here I guess) an emperical (unstructered/exchangeable?) ICC. Shouldent it be, at least to some extend, comparable to the robust z-test, for rx : 2*pnorm(-0.239/0.0816)=0.0034 ? Any help/hints are appreciated. Steen and R 2.2.1, survival 2.21 on win XP. library(survival) data(rats) marginal.model - survreg(Surv(time, status) ~ rx + cluster(litter), rats ) summary(marginal.model) library(survival) data(rats) marginal.model - survreg(Surv(time, status) ~ rx + cluster(litter), rats ) summary(marginal.model) Call: survreg(formula = Surv(time, status) ~ rx + cluster(litter), data = rats) Value Std. Err (Naive SE) z p (Intercept) 4.983 0.0886 0.0833 56.25 0.934 rx -0.239 0.0816 0.0891 -2.92 0.929 Log(scale) -1.333 0.1688 0.1439 -7.89 0.886 Scale= 0.264 Weibull distribution Loglik(model)= -242.3 Loglik(intercept only)= -246.3 Chisq= 8 on 1 degrees of freedom, p= 0.0047 (Loglikelihood assumes independent observations) Number of Newton-Raphson Iterations: 7 n= 150 Steen Ladelund, statistician +4543233275 stelad01CURLYAglostruphospDOTkbhamt.dk Research Center for Prevention and Health Glostrup University Hospital, Denmark www.fcfs.kbhamt.dk __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Averaging over columns
On 3/6/2006 7:13 AM, michael watson (IAH-C) wrote: Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable across columns can easily be created by rep(1:12,each=3), but I can't figure out which function to use to get R to calculate the means I want. I'd think the easiest thing is to reshape the dataset so you have the variables entirely in their own columns, then just apply mean to the columns. (Add a new column for replicate number so you don't lose that information.) If you want to avoid that, then code like this will do your calculation, but it looks ugly: means - numeric(12) for (i in 0:11) { means[i] - mean(mydata[,3*i + 1:3]) } You could also put something together using tapply and your grouping variable, but I think the two solutions above will be easiest to read. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Averaging over columns
On 3/6/06 7:13 AM, michael watson (IAH-C) [EMAIL PROTECTED] wrote: Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable across columns can easily be created by rep(1:12,each=3), but I can't figure out which function to use to get R to calculate the means I want. Hi, Mick. How about this? a - matrix(rnorm(360),nr=10) b - rep(1:12,each=3) avgmat - aggregate(a,by=list(b)) Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Averaging over columns
t(as.matrix(aggregate(t(as.matrix(DF)), rep(1:12,each=3), mean)[,-1])) michael watson (IAH-C) a écrit : Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable across columns can easily be created by rep(1:12,each=3), but I can't figure out which function to use to get R to calculate the means I want. Thanks in advance Mick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] QCA adn Fuzzy
Does anybody know of aything that will help me do Quantitiative Comparative Analysis (QCA) and/or Fuzzy set analysis?? Or failing that Quine? ta rg Prof R Gott Durham Univesrity UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] LocFit
From: Jacob van Wyk I have a question regarding the package LOCFIT of C Loader. After fitting a smooth surface (y modeled by two regressors), I can't seem to find a nice way of making a perspective (or other 3d plot). The contours don't look quite so good. It is meant to be used as illustration of smoothing to my students in regression analysis. Could anybody perhaps assist me in producing a good graph in 3d? It probably works in S-Plus, but I am using R. (I have tried plot (locfit object, type=persp) on the ethanol dataset - but this gives a poor result, with a few warnings.) Could you elaborate on what `poor result' means? It doesn't look half bad to me (except perhaps it needs to be rotated a bit)... Andy THANK YOU!. Jacob Jacob L van Wyk Department of Statistics University of Johannesburg APK P O Box 524 Auckland Park 2006 South Africa Tel: +27-11-489-3080 Fax: +27-11-489-2832 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] P-values from survreg (survival package) using a clusterterm
Ladelund, Steen [EMAIL PROTECTED] writes: Hi all. Belove is the example from the cluster-help page wtih the output. I simply cannot figure out how to relate the estimate and robust Std. Err to the p-value. I am aware this a marginal model applying the sandwich estimator using (here I guess) an emperical (unstructered/exchangeable?) ICC. Shouldent it be, at least to some extend, comparable to the robust z-test, for rx : 2*pnorm(-0.239/0.0816)=0.0034 ? Any help/hints are appreciated. It's a bug. I predict that the maintainer of survival will turn red as a boiled lobster when he sees it: summary.survreg has else { table - matrix(rep(coef, 5), ncol = 5) dimnames(table) - list(cname, c(Value, Std. Err, (Naive SE), z, p)) stds - sqrt(diag(object$var)) table[, 2] - stds table[, 3] - sqrt(diag(object$naive.var)) table[, 4] - table[, 1]/stds table[, 5] - 2 * pnorm(-abs(table[, 3])) } The last line should work better with table[, 4] since that is the z statistic; table[, 3] is the naive SE ... Steen and R 2.2.1, survival 2.21 on win XP. library(survival) data(rats) marginal.model - survreg(Surv(time, status) ~ rx + cluster(litter), rats ) summary(marginal.model) library(survival) data(rats) marginal.model - survreg(Surv(time, status) ~ rx + cluster(litter), rats ) summary(marginal.model) Call: survreg(formula = Surv(time, status) ~ rx + cluster(litter), data = rats) Value Std. Err (Naive SE) z p (Intercept) 4.983 0.0886 0.0833 56.25 0.934 rx -0.239 0.0816 0.0891 -2.92 0.929 Log(scale) -1.333 0.1688 0.1439 -7.89 0.886 Scale= 0.264 Weibull distribution Loglik(model)= -242.3 Loglik(intercept only)= -246.3 Chisq= 8 on 1 degrees of freedom, p= 0.0047 (Loglikelihood assumes independent observations) Number of Newton-Raphson Iterations: 7 n= 150 Steen Ladelund, statistician +4543233275 stelad01CURLYAglostruphospDOTkbhamt.dk Research Center for Prevention and Health Glostrup University Hospital, Denmark www.fcfs.kbhamt.dk __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] JGR doesn't launch after updating to R 2.2.1
Dear r-helpers, After updating to R version 2.2.1, 2005-12-20, powerpc-apple- darwin7.9.0 (from binary), JGR wouldn't launch. I then deleted everything I could find related to JGR, and reinstalled it from the latest binary. Both R and JGR are installed in /Applications/ \~LocalApps/mathStat/. Advice on how to identify the source of the problem? My machine: Machine Name: PowerBook G4 15 Machine Model: PowerBook5,6 CPU Type: PowerPC G4 (1.2) Number Of CPUs: 1 CPU Speed: 1.67 GHz L2 Cache (per CPU): 512 KB Memory: 2 GB System Version: Mac OS X 10.4.5 (8H14) Kernel Version: Darwin 8.5.0 _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] JGR doesn't launch after updating to R 2.2.1
Where did you get a verion that was supposed to support 2.2.1? On the JGR website it lists the different binaries for the different version of R and the latest one I saw was 2.2.0. http://stats.math.uni-augsburg.de/JGR/ On 3/6/06, Michael Kubovy [EMAIL PROTECTED] wrote: Dear r-helpers, After updating to R version 2.2.1, 2005-12-20, powerpc-apple- darwin7.9.0 (from binary), JGR wouldn't launch. I then deleted everything I could find related to JGR, and reinstalled it from the latest binary. Both R and JGR are installed in /Applications/ \~LocalApps/mathStat/. Advice on how to identify the source of the problem? My machine: Machine Name: PowerBook G4 15 Machine Model: PowerBook5,6 CPU Type: PowerPC G4 (1.2) Number Of CPUs: 1 CPU Speed: 1.67 GHz L2 Cache (per CPU): 512 KB Memory: 2 GB System Version: Mac OS X 10.4.5 (8H14) Kernel Version: Darwin 8.5.0 _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Averaging over columns
sorry, i forgot list(): t(as.matrix(aggregate(t(as.matrix(DF)), list(rep(1:12,each=3)), mean)[,-1])) michael watson (IAH-C) a écrit : Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable across columns can easily be created by rep(1:12,each=3), but I can't figure out which function to use to get R to calculate the means I want. Thanks in advance Mick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Clearing the console?
I hesitate to reply since I don't know if this work in Mac, but on windows Ctrl-L clears the screen, so its worth a try. On 3/5/06, Will Terry [EMAIL PROTECTED] wrote: Hi all, I'm an R novice (and I'm making progress!). I'm getting sick of looking at all my old commands though! Can I clear the console from the command line? I'm running a GUI version of R in Mac OSX. Thanks in advance! Will __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] break a vector into classes
Hi, I'm looking for a function which divides a vector into n classes and returns the breaks as well as the number of values in each class. This is actually what hist(vector, breaks=n) does, but in hist() n is a suggestion only, and is a suggestion only and cannot be enforced (as far as I know...) It is not so difficult to do it yourself, but a ready made function would be nice... cheers wouter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] break a vector into classes
see: ?cut ?findInterval [EMAIL PROTECTED] a écrit : Hi, I'm looking for a function which divides a vector into n classes and returns the breaks as well as the number of values in each class. This is actually what hist(vector, breaks=n) does, but in hist() n is a suggestion only, and is a suggestion only and cannot be enforced (as far as I know...) It is not so difficult to do it yourself, but a ready made function would be nice... cheers wouter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Disconnect all MySQL connections
Hi I've got the error cannot allocate a new connection -- maximum of 16 connections already opened after I tried to create a new connection to a database. However, the reason ist, that i did not disconnect previous connections I don't know the name of this connections. How can I disconnect this unknown connections and drivers? if I delete all objects, the error still occurs. Exists a function which i don't know? Thanks a lot for your help. Regards Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problems with heatmap.2 in the gregmisc package
Hi Sorry to revisit an old problem, I seemed to solve this in 2004, only for it to resurface :-S I am trying to plot a heatmap, and I don't want the columns of my matrix re-ordered. The function doesn't seem to behave as the help would have you believe: a - matrix(rnorm(100),nr=20) a.d - dist(a) a.hc - hclust(a.d) a.de - as.dendrogram(a.hc) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=FALSE) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=1:5) # columns are re-ordered heatmap.2(a, Rowv=a.de, dendrogram=row) # error heatmap.2(a, Rowv=a.de, Colv=FALSE, dendrogram=row) Thanks in advance Mick [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] break a vector into classes
probably you're looking for ?cut(). I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, March 06, 2006 3:06 PM Subject: [R] break a vector into classes Hi, I'm looking for a function which divides a vector into n classes and returns the breaks as well as the number of values in each class. This is actually what hist(vector, breaks=n) does, but in hist() n is a suggestion only, and is a suggestion only and cannot be enforced (as far as I know...) It is not so difficult to do it yourself, but a ready made function would be nice... cheers wouter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems with heatmap.2 in the gregmisc package
On 3/6/06 9:19 AM, michael watson (IAH-C) [EMAIL PROTECTED] wrote: Hi Sorry to revisit an old problem, I seemed to solve this in 2004, only for it to resurface :-S I am trying to plot a heatmap, and I don't want the columns of my matrix re-ordered. The function doesn't seem to behave as the help would have you believe: a - matrix(rnorm(100),nr=20) a.d - dist(a) a.hc - hclust(a.d) a.de - as.dendrogram(a.hc) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=FALSE) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=1:5) # columns are re-ordered heatmap.2(a, Rowv=a.de, dendrogram=row) # error heatmap.2(a, Rowv=a.de, Colv=FALSE, dendrogram=row) How about: heatmap.2(a,Rowv=a.de,Colv=1:5,dendrogram=row) I thought Greg knew about this, but I'm not sure. Have you updated gregmisc recently? Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] break a vector into classes
Would a combination of cut() and range() and possibly seq() do what you need? Sean On 3/6/06 9:06 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I'm looking for a function which divides a vector into n classes and returns the breaks as well as the number of values in each class. This is actually what hist(vector, breaks=n) does, but in hist() n is a suggestion only, and is a suggestion only and cannot be enforced (as far as I know...) It is not so difficult to do it yourself, but a ready made function would be nice... cheers wouter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Book: Multilevel Modeling in R ETA?
On 3/3/06, Spencer Graves [EMAIL PROTECTED] wrote: Hello, Zev: Regarding Doug Bates' Multilevel Modeling in R, I haven't seen any replies to your post, so I assume that the author is not ready to announce a publication date; if you've heard anything, I'd like to know. I'm sorry to say that publication of that book is still a long way off. There are so many things demanding my attention these days that it takes me 6 days to get around to reading through the messages in R-help. Thanks for mentioning the vignettes, Spencer. The mlmRev vignette in particular shows some detailed examples. In the interim, have you seen the vignettes in lme4 and mlmRev? If you have not yet worked with vignettes, I encourage you to check these out, because they provide an R script file as well as an Adobe Acrobat (PDF) file; each complements the other, so the two together are more valuable than either by itself. (For more detail, see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67006.html;). hope this helps, spencer graves Zev Ross wrote: Hi R folks (Dr. Bates in particular), In August 2005, Dr. Bates mentioned that the documentation for lme4 will be in the form of a book with the working title 'Multilevel Modeling in R' and I'm just wondering if there is an estimated date of publication or if it's still a long way off. The Rnews article does a great job of introducing the package, but I'm looking forward to more detail. Thank you, Zev __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Disconnect all MySQL connections
[EMAIL PROTECTED] wrote: Hi I've got the error cannot allocate a new connection -- maximum of 16 connections already opened after I tried to create a new connection to a database. However, the reason ist, that i did not disconnect previous connections I don't know the name of this connections. How can I disconnect this unknown connections and drivers? if I delete all objects, the error still occurs. Exists a function which i don't know? Thanks a lot for your help. Regards Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Which package are we talking about? RODBC has: odbcCloseAll() RMySQL has: dbListConnections() and dbDisconnect() And others have other methods, just read the corresponding manuals. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] barplot names.arg
How can i set a rotation for the names.arg in barplot? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] matrix pakcage
Hi! I get the following message trying to install the matrix pakcage, can anyone help me please? trying URL `http://cran.r-project.org/bin/windows/contrib/2.0/Matrix_0.95-5.zip' Error in download.file(url, destfile, method, mode = wb) : cannot open URL `http://cran.r-project.org/bin/windows/contrib/2.0/Matrix_0.95-5.zip' In addition: Warning message: cannot open: HTTP status was `404 Not Found' Erlend Myre Bremset __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Disconnect all MySQL connections
[EMAIL PROTECTED] wrote: Hi I've got the error cannot allocate a new connection -- maximum of 16 connections already opened after I tried to create a new connection to a database. However, the reason ist, that i did not disconnect previous connections I don't know the name of this connections. How can I disconnect this unknown connections and drivers? if I delete all objects, the error still occurs. Exists a function which i don't know? You can use dbDisconnect() together with dbListConnections() to disconnect those connections RMySQL is managing: all_cons - dbListConnections(MySQL()) for(con in cons) + dbDisconnect(con) ## check all connections have been closed dbListConnections(MySQL()) list() You could also kill any connection you're allowed to (not just those managed by RMySQL): dbGetQuery(con, show processlist) Id User Host db Command Time 1 2366 celnet_do gaia:47944 wireless Connect 19 2 2367 celnet_do gaia:47946 wireless Connect 15 3 2368 celnet_do gaia:47948 wireless Query 0 dbGetQuery(con, kill 2366) dbGetQuery(con, kill 2367) HTH, -- David Thanks a lot for your help. Regards Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
Gabor Grothendieck wrote: If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) Gabor thanks for this, but unfortunatelly the result is the same. I get the following via both ways - note that I use all.x or all.y = TRUE. merge(tmp2, tmp1, all.x = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA But I want this order as it is in tmp 1 col1 1A 2A 3C 4C 50 60 Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must
Re: [R] Disconnect all MySQL connections
Hi I work with RMySQL. Now, it works fine. Thanks a lot for your prompt reply. Have a nice and successful day Best regards Dominik -- Original-Nachricht -- Date: Mon, 06 Mar 2006 15:35:46 +0100 From: Uwe Ligges [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Disconnect all MySQL connections [EMAIL PROTECTED] wrote: Hi I've got the error cannot allocate a new connection -- maximum of 16 connections already opened after I tried to create a new connection to a database. However, the reason ist, that i did not disconnect previous connections I don't know the name of this connections. How can I disconnect this unknown connections and drivers? if I delete all objects, the error still occurs. Exists a function which i don't know? Thanks a lot for your help. Regards Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Which package are we talking about? RODBC has: odbcCloseAll() RMySQL has: dbListConnections() and dbDisconnect() And others have other methods, just read the corresponding manuals. Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Disconnect all MySQL connections
Use the function dbListConnections() to get a list of connections. Then use dbDisconnect() to disconnect them one by one. Using Oracle as an example: dbm - Oracle() dbDisconnect(dbListConnections(dbm)[[1]]) [1] TRUE -Don At 3:18 PM +0100 3/6/06, [EMAIL PROTECTED] wrote: Hi I've got the error cannot allocate a new connection -- maximum of 16 connections already opened after I tried to create a new connection to a database. However, the reason ist, that i did not disconnect previous connections I don't know the name of this connections. How can I disconnect this unknown connections and drivers? if I delete all objects, the error still occurs. Exists a function which i don't know? Thanks a lot for your help. Regards Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove gray grid from levelplot
On 06/03/2006, at 10:40 PM, Prof Brian Ripley wrote: On Mon, 6 Mar 2006, Martin Sandiford wrote: [...] P.S. To me, the png() device does not appear to do sub-pixel rendering. The postscript() and pdf() devices do. What could you possibly mean by that? The postscript() and pdf() produce vector graphics and have no concept of a pixel. There are filled polygons as part of the language they output. (Of course the coordinates are output to finite resolution, in fact 0.01dp = 1/7200, so you could think of that as the positioning quantum.) The png device writes on a bitmap. It outputs a rectangular grid of either pre-defined colour indices or RGB values. There is nothing in the PNG standard to allow anything finer. Sorry, sloppy and inaccurate description. The Mac Preview app antialiases based on the translated fractional device coordinates when viewing PDF/PS files. I don't believe the png device does antialiasing directly. Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] JGR doesn't launch after updating to R 2.2.1
Hi Roger, Thanks for the reply. Indeed the JGR site says that it runs with 2.2.0. I assumed that a minor update to R wouldn't break the link to JGR, and inferred that I had done something wrong. On Mar 6, 2006, at 8:51 AM, roger bos wrote: Where did you get a verion that was supposed to support 2.2.1? On the JGR website it lists the different binaries for the different version of R and the latest one I saw was 2.2.0. http://stats.math.uni-augsburg.de/JGR/ On 3/6/06, Michael Kubovy [EMAIL PROTECTED] wrote: Dear r-helpers, After updating to R version 2.2.1, 2005-12-20, powerpc-apple- darwin7.9.0 (from binary), JGR wouldn't launch. I then deleted everything I could find related to JGR, and reinstalled it from the latest binary. Both R and JGR are installed in /Applications/ \~LocalApps/mathStat/. Advice on how to identify the source of the problem? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] error function
[Kjetil Brinchmann Halvorsen] erf [in] package (CRAN) NORMT3, as help.search(error function) could have told [you] It does not for me. I would presume one needs NORMT3 installed first, and NORMT3 is seemingly not part of standard base R installation. -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix pakcage
Erlend Myre Bremset wrote: Hi! I get the following message trying to install the matrix pakcage, can anyone help me please? trying URL `http://cran.r-project.org/bin/windows/contrib/2.0/Matrix_0.95-5.zip' Error in download.file(url, destfile, method, mode = wb) : cannot open URL `http://cran.r-project.org/bin/windows/contrib/2.0/Matrix_0.95-5.zip' In addition: Warning message: cannot open: HTTP status was `404 Not Found' The Windows binary package repository for R-2.0.x is no longer supported (since 1 year!). Please upgrade your version of R! Anyway, I have fixed the error in the archive (fix will appear on CRAN master within 24 hours). Uwe Ligges Erlend Myre Bremset __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] barplot names.arg
On Mon, 2006-03-06 at 15:40 +0100, Roland Kaiser wrote: How can i set a rotation for the names.arg in barplot? See R FAQ 7.27 How can I create rotated axis labels?: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f That provides the basic concept, which is easy to use with barplot() along with knowing that barplot() returns the bar midpoints. See the Value section of ?barplot. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems with heatmap.2 in the gregmisc package
We're just about to relase a version of gregmisc that improves the code and documentation so that Rowv=FALSE and/or Colv=FALSE leaves the rows/columns in the original order. -G -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Sean Davis Sent: Monday, March 06, 2006 9:25 AM To: michael watson (IAH-C); r-help Cc: Warnes, Gregory R Subject: Re: [R] Problems with heatmap.2 in the gregmisc package On 3/6/06 9:19 AM, michael watson (IAH-C) [EMAIL PROTECTED] wrote: Hi Sorry to revisit an old problem, I seemed to solve this in 2004, only for it to resurface :-S I am trying to plot a heatmap, and I don't want the columns of my matrix re-ordered. The function doesn't seem to behave as the help would have you believe: a - matrix(rnorm(100),nr=20) a.d - dist(a) a.hc - hclust(a.d) a.de - as.dendrogram(a.hc) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=FALSE) # columns are re-ordered heatmap.2(a, Rowv=a.de, Colv=1:5) # columns are re-ordered heatmap.2(a, Rowv=a.de, dendrogram=row) # error heatmap.2(a, Rowv=a.de, Colv=FALSE, dendrogram=row) How about: heatmap.2(a,Rowv=a.de,Colv=1:5,dendrogram=row) I thought Greg knew about this, but I'm not sure. Have you updated gregmisc recently? Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
If believe that merge is trying to put first whatever cells that are nonempty. For example if you instead did tmp2 - data.frame(col1 = factor(c(C, D, E, F,A), levs), col2 = 1:5) tmp2 col1 col2 1C1 2D2 3E3 4F4 5A5 merge(tmp2, tmp1, all.y = TRUE, sort = FALSE) col1 col2 1A5 2A5 3C1 4C1 50 NA 60 NA tmp1 col1 1A 2A 3C 4C 50 60 and if you do this tmp1 - data.frame(col1 = factor(c(0, 0, C, C, A, A), levs)) merge(tmp2, tmp1, all.y = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A5 4A5 50 NA 60 NA So I think it is doing what you want it to do. Jean Gregor Gorjanc wrote: Gabor Grothendieck wrote: If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) Gabor thanks for this, but unfortunatelly the result is the same. I get the following via both ways - note that I use all.x or all.y = TRUE. merge(tmp2, tmp1, all.x = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA But I want this order as it is in tmp 1 col1 1A 2A 3C 4C 50 60 Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386
Re: [R] error function
On Mon, 6 Mar 2006, François Pinard wrote: [Kjetil Brinchmann Halvorsen] erf [in] package (CRAN) NORMT3, as help.search(error function) could have told [you] It does not for me. I would presume one needs NORMT3 installed first, and NORMT3 is seemingly not part of standard base R installation. True. And that function is really for complex arguments, and does not work correctly on 64-bit machines, e.g. erf(1) Error in erfc(z) : Error code from TOMS 680 was 1 Perhaps more helpful is to point out that erf and erfc are simple transformations of pnorm. RSiteSearch(erf) gave several results such as http://finzi.psych.upenn.edu/R/Rhelp02a/archive/36416.html which all point you to example(pnorm) for the details. I'll add appropriate \concept fields. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
I think you will need to reorder it: out - merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE, sort = FALSE) out[out$seq, -2] On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) Gabor thanks for this, but unfortunatelly the result is the same. I get the following via both ways - note that I use all.x or all.y = TRUE. merge(tmp2, tmp1, all.x = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA But I want this order as it is in tmp 1 col1 1A 2A 3C 4C 50 60 Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Lep pozdrav / With regards, Gregor Gorjanc --
Re: [R] memory once again
On Fri, 3 Mar 2006, Dimitri Joe wrote: Dear all, A few weeks ago, I asked this list why small Stata files became huge R files. Thomas Lumley said it was because Stata uses single-precision floating point by default and can use 1-byte and 2-byte integers. R uses double precision floating point and four-byte integers. And it seemed I couldn't do anythig about it. Is it true? I mean, isn't there a (more or less simple) way to change how R stores data (maybe by changing the source code and compiling it)? It's not impossible, but it really isn't as easy as you might think. It would be relatively easy to change the definition of REALSXPs and INTSXPs so that they stored 4-byte and 2-byte data respectively. It would be a lot harder to go through all the C and Fortran numerical, input/output, and other processing code to either translate from short to long data types or to make the code work for short data types. For example, the math functions would want to do computations in double (as Stata does) but the input/output functions would presumably want to use float. Adding two more SEXP types to give eg single and shortint might be easier (if there are enough bits left in the SEXPTYPE header), but would still require adding code to nearly every C function in R. Single-precision floating point has been discussed for R in the past, and the extra effort and resulting larger code were always considered too high a price. Since the size of data set R can handle doubles every 18 months or so without any effort on our part it is hard to motivate diverting effort away from problems that will not solve themselves. This doesn't help you, of course, but it may help explain why we can't. Another thing that might be worth pointing out: Stata also keeps all its data in memory and so can handle only small data sets. One reason that Stata is so fast and that Stata's small data sets can be larger than R's is the more restrictive language. This is more important than the compression from smaller data types -- you can use a dataset in Stata that is nearly as large as available memory (or address space), which is a factor of 3-10 better than R manages. On the other hand, for operations that do not fit well with the Stata language structure, it is quite slow. For example, the new Stata graphics in version 8 required some fairly significant extensions to the language and are still notably slower than the lattice graphics in R (a reasonably fair comparison since both are interpreted code). The terabyte-scale physics and astronomy data that other posters alluded to require a much more restrictive form of programming than R to get reasonable performance. R does not make you worry about how your data are stored and which data access patterns are fast or slow, but if your data are larger than memory you have to worry about these things. The difference between one-pass and multi-pass algorithms, between O(n) and O(n^2) time, even between sequential-access and random-access algorithms all matter, and the language can't hide them. Fortunately, most statistical problems are small enough to solve by throwing computing power at them, perhaps after an initial subsampling or aggegrating phase. The initial question was about read.dta. Now, read.dta() could almost certainly be improved a lot, especially for wide data sets. It uses very inefficient data frame operations to handle factors, for example. It used to be a lot faster than read.table, but that was before Brian Ripley improved read.table. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] duration analysis
Hi, It seems the list faced some problems during the weekend, so I am re-sending this message. I am trying to estimate the effects of covariates on the hazard function, rather than on the survival. I know this is actually the same thing. For example, using the survival package, and doing: myfit - survreg( Surv(time, event) ~ mymodel ) all I have to do to get the quantities of my interest is -myfit$coefficients/myfit$scale The standard erros are easily worked out, as the absolute z-statistics are the same. Ok, so I can get easily what I want from survreg(). But I'd like to get it even more directly. Does anyone know some function to do it? Thank you, Dimitri Szerman __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] collocation methods
Hi All, I have found the function poly(), that computes orthogonal polynomials. I was wondering if there are users of this function on the list. What kind of an orthognal polynomial is this fititng ? Is it, for example, least square, galerkin, or collocation ? It references Chambers and Hastie, and Kennedy and Gentle, but I dont have access to either. thanks Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] barplot names.arg
Marc Schwartz (via MN) wrote: On Mon, 2006-03-06 at 15:40 +0100, Roland Kaiser wrote: How can i set a rotation for the names.arg in barplot? See R FAQ 7.27 How can I create rotated axis labels?: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f Interesting That provides the basic concept, which is easy to use with barplot() along with knowing that barplot() returns the bar midpoints. See the Value section of ?barplot. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
Actually we don't need sort = FALSE if we are reordering it anyways: out - merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE) out[out$seq, -2] On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: I think you will need to reorder it: out - merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE, sort = FALSE) out[out$seq, -2] On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) Gabor thanks for this, but unfortunatelly the result is the same. I get the following via both ways - note that I use all.x or all.y = TRUE. merge(tmp2, tmp1, all.x = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA But I want this order as it is in tmp 1 col1 1A 2A 3C 4C 50 60 Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer versions? ## Is there any other way to get the same order as in 'y' i.e. tmp1? R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R Thank you very much! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it,
Re: [R] R-help list: temporary problem in local archives
Dimitri == Dimitri Szerman [EMAIL PROTECTED] on Mon, 6 Mar 2006 14:17:33 -0300 writes: Dimitri Hi, Dimitri It seems the list faced some problems during the Dimitri weekend, so I am re-sending this message. To be specific: The only problems it saw was that the local *archiving* had stopped working from ~ Friday 17:30 MET. The archiver now works again (and I have spent about an hour to ensure that everything shows up in the archives as it should). Dimitri's message actually *did* appear well on the list (yesterday). Martin Maechler, ETH Zurich your mailing list manager __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R-help list: temporary problem in local archives
Martin == Martin Maechler [EMAIL PROTECTED] on Mon, 6 Mar 2006 18:37:06 +0100 writes: Dimitri == Dimitri Szerman [EMAIL PROTECTED] on Mon, 6 Mar 2006 14:17:33 -0300 writes: Dimitri Hi, Dimitri It seems the list faced some problems during the Dimitri weekend, so I am re-sending this message. Martin To be specific: The only problems it saw was that the local *archiving* Martin had stopped working from ~ Friday 17:30 MET. Martin The archiver now works again (and I have spent about an hour to Martin ensure that everything shows up in the archives as it should). well, unfortunately, I have managed to wipeout the index.html file of the full archive there. AARgh! [the archives, its HTML pages, everything is still there, but all the older parts are currently not *linked* to] Recreating everything from scratch (1997) would need so many hours --- where mailman delivery to r-help was completely blocked --- that I'm considering other plans to get that file back (and only recreate the March 2006 part). All this mess just because of a spam that I wanted to have removed, something which needs careful manual intervention; I have failed in my care at one place. Martin Martin Dimitri's message actually *did* appear well on the list Martin (yesterday). Martin Martin Maechler, ETH Zurich Martin your mailing list manager __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] t.test question
Hi, I have a data matrix of gene expression data from two groups that I would like to compare using the t-test. The data has been processed using RMA and transformed using log2. I would like to compare the two groups for each gene (N=10,000 genes) and have a result that lists the p-value for each test. Can anyone help me with the t.test setup for this analysis? Thanks, Rich Rich Roth, PhD Senior Scientist Molecular Medicine Neurocrine Biosciences 858-617-7204 MMS neurocrine.com made the following annotations on 03/06/2006 10:04:49 AM -- This email may contain confidential and privileged material ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] text labels in 3d scatter
Hello, I am trying to draw a 3d scatter plot of the variables used in a multiple regresion (including the regression plane). I have had some luck with scatterplot3d; it fullfills those basic requirements. My problem though is that I also need to add the participant codes as a text-label to each point; after days of searching and reading, I cannot figure out how this is done. I would appreciate any advice that the community can offer. Thank you, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] text labels in 3d scatter
JOHN VOIKLIS wrote: Hello, I am trying to draw a 3d scatter plot of the variables used in a multiple regresion (including the regression plane). I have had some luck with scatterplot3d; it fullfills those basic requirements. My problem though is that I also need to add the participant codes as a text-label to each point; after days of searching and reading, I cannot figure out how this is done. I would appreciate any advice that the community can offer. Thank you, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html See this example: dat - data.frame(x=1:10, y=1:10, z=1:10, label=letters[1:10]) library(scatterplot3d) s3d - scatterplot3d(dat$x, dat$y, dat$z) text(s3d$xyz.convert(dat$x, dat$y, dat$z), labels=dat$label, pos=1) Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] t.test question
Roth, Richard wrote: Hi, I have a data matrix of gene expression data from two groups that I would like to compare using the t-test. The data has been processed using RMA and transformed using log2. I would like to compare the two groups for each gene (N=10,000 genes) and have a result that lists the p-value for each test. Can anyone help me with the t.test setup for this analysis? Take a look at the limma package in BioConductor. You will be able to do what you want much faster than using e.g., t.test(). There is an extensive user's guide that should help you figure out what to do. HTH, Jim Thanks, Rich Rich Roth, PhD Senior Scientist Molecular Medicine Neurocrine Biosciences 858-617-7204 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sweave and long strings
Roger Bivand a écrit : On Sun, 5 Mar 2006, Laurent Rhelp wrote: Dear R-List, I use Sweave (which is wonderful) and I have a problem with the strings when they are too long according to the width of the page. For example when I do in my .Rnw document : UsingRODBC,echo=TRUE= channel - odbcConnect(dsn=database,uid=root,pwd=password) df1 - sqlFetch(channel,table1,rownames=TRUE) df2 - sqlFetch(channel,table2,rownames=TRUE) cmd - SELECT t1.isoisotope, t1.periode,t1.nbZ, t2.filnomchaineradio, t2.filcodepere, t2.filcodefils, t2.filproba, t2.filtransition from table1 t1, table2 t2 WHERE t1.isoisotope = t2.filcodepere dfQuery - sqlQuery(channel, cmd ) odbcCloseAll() @ etc... in the pdf document the command cmd - SELECT t1.isoisotope, t1.periode,t1.nbZ, t2.filnomchaineradio, t2.filcodepere, t2.filcodefils, is written truncated only on one line not as it is written in the chunk above. I read in the R-archives we have to use the options command but even using options(width=30) in the chunk it doesn't work. This is because it is a single string. Could you also say: cmd - paste(SELECT t1.isoisotope,, t1.periode,t1.nbZ,, t2.filnomchaineradio,, t2.filcodepere,, t2.filcodefils,, t2.filproba,, t2.filtransition from table1 t1,, table2 t2, WHERE t1.isoisotope = t2.filcodepere) or an equivalent with the included white space and line breaks? It will be parsed anyway inside Sweave, so at least using paste() should prevent it overrunning the right margin. May you help me ? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html It is less readable but it is a very good idea ! thank you very much __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [Q] BIC as a goodness-of-fit stat
Dear R-List I have a question about how to interpret BIC as a goodness-of-fit statistic. I was trying to use EMclust and other mclust library and found that BIC was used as a goodness-of-fit statistic. Although I know that smaller BIC indicates a better fit, it is not clear to me how good a fit is by reading a BIC number. Is there a standard way of interpreting a BIC value? Thanks in advance. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] LME Correlation Component using spectrum()?
Dear List-mates, Is there a corStruct constructor already written to calculate the shape of the spectral density for linear models using Fourier estimates (e.g. terms for a linear model derived from the frequency domain)? I have data with a long memory process but do not want to destroy it by taking n-differences for a suitable corAR, or corARIMA object. Thank you, KeithC. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
Gabor and Jean thank you for your time and answers. Gabors approach does not do what I want (with or without sort). Gabor note that when we merge data.frame, this new data.frame gets new row.names and we can not be consistent with sort. out - merge(cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE) col1 seq col2 10 5 NA 20 6 NA 3A 1 NA 4A 2 NA 5C 31 6C 41 out[out$seq, -2] col1 col2 5C1 6C1 10 NA 20 NA 3A NA 4A NA out - merge(cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE, sort = TRUE) col1 seq col2 10 5 NA 20 6 NA 3A 1 NA 4A 2 NA 5C 31 6C 41 out[out$seq, -2] col1 col2 5C1 6C1 10 NA 20 NA 3A NA 4A NA But I want to get out A NA A NA C 1 C 1 0 NA 0 NA i.e. with the same order as in tmp1. I really need the same order, since I will cbind this data frame to another one and I need to keep the order intact. I am quite confident that this points to a bug in merge code or at least in merge documentation. NA's seem to introduce problems as showed by Jean. Can someone (R core) also confirm this? Gabor Grothendieck wrote: Actually we don't need sort = FALSE if we are reordering it anyways: out - merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE) out[out$seq, -2] On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: I think you will need to reorder it: out - merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE, sort = FALSE) out[out$seq, -2] On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: If you make the levels the same does that give what you want: levs - c(LETTERS[1:6], 0) tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2 - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) merge(tmp2, tmp1, all = TRUE, sort = FALSE) merge(tmp1, tmp2, all = TRUE, sort = FALSE) Gabor thanks for this, but unfortunatelly the result is the same. I get the following via both ways - note that I use all.x or all.y = TRUE. merge(tmp2, tmp1, all.x = TRUE, sort = FALSE) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA But I want this order as it is in tmp 1 col1 1A 2A 3C 4C 50 60 Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer tmp1 - data.frame(col1 = factor(c(A, A, C, C, 0, 0))) tmp2 - data.frame(col1 = factor(c(C, D, E, F)), col2 = 1:4) tmp1 col1 1A 2A 3C 4C 50 60 tmp2 col1 col2 1C1 2D2 3E3 4F4 ## Now merge them (tmp12 - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## As you can see, sort was applied, since row order is not the same as ## in tmp1. Reading help page for ?merge did not reveal much about ## sorting. However I did try to see the result of non-default - ## help page says that order should be the same as in 'y'. So above ## makes sense ## Now merge - but change x an y (tmp21 - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The result is the same. I am stumped here. But looking a bit at these ## object I found something peculiar str(tmp1) `data.frame': 6 obs. of 1 variable: $ col1: Factor w/ 3 levels 0,A,C: 2 2 3 3 1 1 str(tmp2) `data.frame': 4 obs. of 2 variables: $ col1: Factor w/ 4 levels C,D,E,F: 1 2 3 4 $ col2: int 1 2 3 4 str(tmp12) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 3 levels 0,A,C: 3 3 2 2 1 1 $ col2: int 1 1 NA NA NA NA str(tmp21) `data.frame': 6 obs. of 2 variables: $ col1: Factor w/ 6 levels C,D,E,F,..: 1 1 6 6 5 5 $ col2: int 1 1 NA NA NA NA ## Is it OK, that internal presentation of factors vary between ## different merges. Levels are also different, once only levels ## from original data.frame are used, while in second example all ## levels are propagated. ## I have tried the same with characters tmp1$col1 - as.character(tmp1$col1) tmp2$col1 - as.character(tmp2$col1) (tmp12c - merge(tmp1, tmp2, by.x = col1, by.y = col1, all.x = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA (tmp21c - merge(tmp2, tmp1, by.x = col1, by.y = col1, all.y = TRUE, sort = FALSE)) col1 col2 1C1 2C1 3A NA 4A NA 50 NA 60 NA ## The same with characters. Is this a bug. It definitely does not agree ## with help page, since order is not the same as in 'y'. Can someone ## please check on newer
Re: [R] [Q] BIC as a goodness-of-fit stat
Young-Jin, Similar to AIC, BIC is nothing but a penalized version of loglikelihood. There is no way to tell 'how small is small' for BIC unless you compare BIC from one model with BIC from another model. On 3/6/06, Young-Jin Lee [EMAIL PROTECTED] wrote: Dear R-List I have a question about how to interpret BIC as a goodness-of-fit statistic. I was trying to use EMclust and other mclust library and found that BIC was used as a goodness-of-fit statistic. Although I know that smaller BIC indicates a better fit, it is not clear to me how good a fit is by reading a BIC number. Is there a standard way of interpreting a BIC value? Thanks in advance. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- WenSui Liu (http://statcompute.blogspot.com) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Length of a vector of POSIX objects reported incorrectly?
I have a vector of POSIX times/dates (called times) that I want to plot. But I'm having trouble because R reports the length of the vector incorrectly. Can someone help me figure out what's going on here? This code print(times) print(class(times)) print(length(times)) Produces this... . . . [355] 2006-03-06 18:34:00 2006-03-06 18:32:00 2006-03-06 18:31:00 [358] 2006-03-06 18:30:00 2006-03-06 18:29:00 2006-03-06 18:27:00 [361] 2006-03-06 18:26:00 2006-03-06 18:25:00 2006-03-06 18:24:00 [364] 2006-03-06 18:23:00 2006-03-06 18:21:00 2006-03-06 18:20:00 [1] POSIXt POSIXlt [1] 9 Huh? As you can see there are 365 entries in the times vector. Why does R think there are only 9? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: But I want to get out A NA A NA C 1 C 1 0 NA 0 NA That's what I get except for the rownames. Be sure to make the factor levels consistent. I have renamed the data frames tmp1a and tmp2a to distinguish them from the ones in your post and have also reset the rownames to be the original ones, as requested, so that the following is self contained and should be reproducible: levs - c(LETTERS[1:6], 0) tmp1a - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2a - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) outa - merge( cbind(tmp1a, seq = 1:nrow(tmp1a)), tmp2a, all.x = TRUE) outa - outa[out$seq, -2] rownames(outa) - rownames(tmp1a) outa col1 col2 10 NA 20 NA 3A NA 4A NA 5C1 6C1 R.version.string # Windows XP [1] R version 2.2.1, 2005-12-20 By the way, the main limitation with this approach is that the elements of tmp2$col1 be unique so that the result has rows which correspond to those of tmp1; however, that seems to be the case here. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Length of a vector of POSIX objects reported incorrectly?
POSIXlt stores its data in a 9 component structure so its length is always 9. See R News 4/1 help desk article for more info. To get what you are looking for try using POSIXct, not POSIXlt: length(as.POSIXct(times)) On 3/6/06, Jason Horn [EMAIL PROTECTED] wrote: I have a vector of POSIX times/dates (called times) that I want to plot. But I'm having trouble because R reports the length of the vector incorrectly. Can someone help me figure out what's going on here? This code print(times) print(class(times)) print(length(times)) Produces this... . . . [355] 2006-03-06 18:34:00 2006-03-06 18:32:00 2006-03-06 18:31:00 [358] 2006-03-06 18:30:00 2006-03-06 18:29:00 2006-03-06 18:27:00 [361] 2006-03-06 18:26:00 2006-03-06 18:25:00 2006-03-06 18:24:00 [364] 2006-03-06 18:23:00 2006-03-06 18:21:00 2006-03-06 18:20:00 [1] POSIXt POSIXlt [1] 9 Huh? As you can see there are 365 entries in the times vector. Why does R think there are only 9? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
Sorry, I mixed up out and outa in the last post. Here it is correctly. levs - c(LETTERS[1:6], 0) tmp1a - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2a - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) out - merge( cbind(tmp1a, seq = 1:nrow(tmp1a)), tmp2a, all.x = TRUE) out - out[out$seq, -2] rownames(out) - rownames(tmp1a) out col1 col2 1A NA 2A NA 3C1 4C1 50 NA 60 NA On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: But I want to get out A NA A NA C 1 C 1 0 NA 0 NA That's what I get except for the rownames. Be sure to make the factor levels consistent. I have renamed the data frames tmp1a and tmp2a to distinguish them from the ones in your post and have also reset the rownames to be the original ones, as requested, so that the following is self contained and should be reproducible: levs - c(LETTERS[1:6], 0) tmp1a - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2a - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) outa - merge( cbind(tmp1a, seq = 1:nrow(tmp1a)), tmp2a, all.x = TRUE) outa - outa[out$seq, -2] rownames(outa) - rownames(tmp1a) outa col1 col2 10 NA 20 NA 3A NA 4A NA 5C1 6C1 R.version.string # Windows XP [1] R version 2.2.1, 2005-12-20 By the way, the main limitation with this approach is that the elements of tmp2$col1 be unique so that the result has rows which correspond to those of tmp1; however, that seems to be the case here. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort problem in merge()
One other idea; one could use match instead of merge: # tmp1a and tmp2a from below cbind(tmp1a, tmp2a[match(tmp1a$col1, tmp2a$col1), -1, drop = FALSE]) col1 col2 1A NA 2A NA 3C1 4C1 50 NA 60 NA This avoids having to muck with reordering of rows and reseting of rownames. Like the prior solution, it assumes that the elements of tmp2a$col1 are unique. On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Sorry, I mixed up out and outa in the last post. Here it is correctly. levs - c(LETTERS[1:6], 0) tmp1a - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2a - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) out - merge( cbind(tmp1a, seq = 1:nrow(tmp1a)), tmp2a, all.x = TRUE) out - out[out$seq, -2] rownames(out) - rownames(tmp1a) out col1 col2 1A NA 2A NA 3C1 4C1 50 NA 60 NA On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 3/6/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: But I want to get out A NA A NA C 1 C 1 0 NA 0 NA That's what I get except for the rownames. Be sure to make the factor levels consistent. I have renamed the data frames tmp1a and tmp2a to distinguish them from the ones in your post and have also reset the rownames to be the original ones, as requested, so that the following is self contained and should be reproducible: levs - c(LETTERS[1:6], 0) tmp1a - data.frame(col1 = factor(c(A, A, C, C, 0, 0), levs)) tmp2a - data.frame(col1 = factor(c(C, D, E, F), levs), col2 = 1:4) outa - merge( cbind(tmp1a, seq = 1:nrow(tmp1a)), tmp2a, all.x = TRUE) outa - outa[out$seq, -2] rownames(outa) - rownames(tmp1a) outa col1 col2 10 NA 20 NA 3A NA 4A NA 5C1 6C1 R.version.string # Windows XP [1] R version 2.2.1, 2005-12-20 By the way, the main limitation with this approach is that the elements of tmp2$col1 be unique so that the result has rows which correspond to those of tmp1; however, that seems to be the case here. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] is there a way to let R do smart matrix-vector operation?
Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
On Mon, 2006-03-06 at 15:10 -0800, Michael wrote: Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays apply(A, 2, -, B) [,1] [,2] [,3] [1,]135 [2,]135 You can use apply() on column-wise operations such as this. See ?apply for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
It's rarely necessary to have a vector in matrix form. In this case, it actually make things harder. If B had been a vector, you would have gotten: A=matrix(c(2:7), 2, 3) B=matrix(c(1, 2), 2, 1) A - as.vector(B) [,1] [,2] [,3] [1,]135 [2,]135 Andy From: Michael Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
Well, I'm not sure what's smart and what's dumb. As Mark said, a standard prescription for this sort of thing is to use apply() type calls -- but that actually is still using a loop, though generally very efficiently. If you want to avoid even that sort of hidden looping then try: matrix(as.vector(A)-as.vector(B),nr=nrow(A)) If B is a vector, not a matrix, the as.vector(B) cast isn't necessary. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Sent: Monday, March 06, 2006 3:11 PM To: R-help@stat.math.ethz.ch Subject: [R] is there a way to let R do smart matrix-vector operation? Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
Hi Michael, Try: A-as.vector(B) Cheers, Anders. On Monday 06 March 2006 01:10 pm, Michael wrote: Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Optimization problem: selecting independent rows to maximizethe mean
Does R have packages for such multi-objectives optimization problems ? The rgenoud (R-GENetic Optimization Using Derivatives) package allows for multiple object optimization problems. See the lexical option which searches for the Pareto front. The package is written for NP-hard problems (but they are...well...difficult). See CRAN or: http://sekhon.berkeley.edu/rgenoud/ Cheers, Jas. === Jasjeet S. Sekhon Associate Professor Survey Research Center UC Berkeley http://sekhon.berkeley.edu/ V: 510-642-9974 F: 617-507-5524 === nojhan wrote: Le Wed, 01 Mar 2006 13:07:07 -0800, Berton Gunter a ?crit : 2) That the mean and sd can be simultaneously optimized as you describe-- what if the subset with maximum mean also has bigger than minimal sd? Then you have two choices : 1) balance the two objectives with weights, according to the importance you give to each one 2) get a list of non-dominated solutions (a Pareto front) Does R have packages for such multi-objectives optimization problems ? Moreover, does it have a package for difficult (i.e. NP-hard) problems ? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove gray grid from levelplot
[Brian Ripley] On Mon, 6 Mar 2006, Martin Sandiford wrote: [...] P.S. To me, the png() device does not appear to do sub-pixel rendering. The postscript() and pdf() devices do. What could you possibly mean by that? I would think the original poster refers to aliasing issues. The png device writes on a bitmap. It outputs a rectangular grid of either pre-defined colour indices or RGB values. There is nothing in the PNG standard to allow anything finer. Granted. Yet, there are nuances. Anti-aliasing techniques may be applied to bit-mapped images like PNGs, and a carefully computed alpha channel could be included in the PNG as a way to acknowledge sub-pixel rendering matters. If the background of the generated image is opaque instead of transparent, the graphics and the background might be combined at PNG generation, swallowing what would have been an alpha channel and so, sparing the need of including any in the generated PNG. However, on this Linux system, if I understood correctly, R goes through X11 for generating PNGs, and so, does no better than X11 itself (at least as currently driven by R) in the area of anti-aliasing. Anti-aliasing libraries exist (which I never really studied or used myself) that could likely provide better PNG quality. Did some decision has been reached among developers on this topic? I would guess, without really knowing, that developers favor vector-to-raster rendering to be done outside R, whenever quality is required. Using an anti-aliasing library for higher output quality within R would mean, besides the obvious trouble of selecting one of those libraries and programming the interface, adding yet another dependency at R build-time (likely autoconfigured, of course), and an observable slowdown for graphics which are more heavily loaded, especially in interactive mode. For one, I do not need more than draft quality so far when using R interactively for plots. Maybe some draft, quality or aa flag is added to control anti-aliasing behaviour? (I know that quality is already used to mean something else for JPEG images). Just a few thoughts. Keep happy, all! -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove gray grid from levelplot
On 3/6/06, Martin Sandiford [EMAIL PROTECTED] wrote: Hi Jan, The patch requires a recompile of R. As I understand it, this is a fairly painful experience. I haven't done it myself. I find that using the pdf() function to open a pdf device produces better quality output when printing than saving a quartz device from the menu. It appears that the postscript() and pdf() devices use sub-pixel rendering as well, as output shows evidence of gray lines on low resolution devices, however, for me, this isn't evident on a printer at 1200x1200dpi. My guess would be that, in general, levelplot is not a great function to use if the box size approaches the resolution of the underlying device. The first example in help(levelplot) exhibits severe moire patterns on an approx 740x740 quartz or x11() device. When the output from the postscript device is printed out, it looks more or less as expected. 740x740 what? I don't see any obvious problems on x11 on Linux. If there are more boxes in the levelplot than pixels on the device you are plotting to, then in effect you are asking the display device to do the averaging of the excess boxes for devices that support sub-pixel rendering. That was my first instinct too, but based on (offlist) screenshots Jan sent me, that isn't the issue here. I haven't been able reproduce his results (since I don't have a mac) but the artifacts there are very similar to what I often see in postscript output. The viewer matters here, and with gv on Linux, these artifacts are present when anti-aliasing is turned on, but they go away when AA is turned off. I.e., anti-aliasing is doing more harm than good. If indeed the quartz device performs anti-aliasing by default (as your other post suggests), that would explain the behaviour. If it is possible to turn of AA, that should help. In any case, there doesn't seem to be much of an (R) issue here. Printed output should be fine (since there's no AA involved). Anti-aliasing distorts the true image in a manner that usually helps but messes up in this case. That's the trade-off you have to accept if you decide to use AA. -Deepayan I'm still not 100% sure what it is that you are trying to do, but I'm guessing that it boils down to levelplot not being designed to plot analytic functions. Martin P.S. To me, the png() device does not appear to do sub-pixel rendering. The postscript() and pdf() devices do. On 06/03/2006, at 1:43 AM, Jan Marius Hofert wrote: Hi, I am using a Mac (Powerbook G4, Mac Os X 10.4) and this seems to be the problem, but I have absolutely no idea how to use the patch mentioned on https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20060214/ 0b3e99c2/attachment.pl I would also like to create *.ps files so this does not seem to be the appropriate approach. I can also use x11 as trellis.device which fixes the color-problem, but the lines are plotted in bad quality then. Also, I can not save the graph then, when plotted with x11. All other devices (png, pdf) have the same problem with the fine gray lines so the R version for the mac must be the problem, but I have no idea how to fix that. It would not matter if the plots via the quartz device (on the screen) would be bad as long as the postscript file comes out perfect. Thanks again and any more comments/hints are appreciated marius On 05.03.2006, at 13:19, Martin Sandiford wrote: I don't know what kind of computer you are using. If you are on a Mac, then this might be relevant: https://stat.ethz.ch/pipermail/r-sig-mac/2006-February/002679.html (Need to click through to the actual message.) Martin On 05/03/2006, at 2:52 AM, Jan Marius Hofert wrote: Hi, If I use the levelplot function of the lattice library, I always see small squares in the plot. They indicate the region for which the same color is used. If you have a levelplot of a function which is evaluated at 25x25 equally-spaced points you obtain 26 squares in x and 26 squares in y direction. That does not bother too much (but still bothers somehow...), but if you want to plot a function which is evaluated at 1000x1000 equally-spaced points, then the thickness of this gray grid cause the grid lines to hit each other so there is no space for the color in the square anymore (since the squares are actually not visible anymore)... this might change the color of the whole levelplot!. (I tried it with the plot of f(x,y)=max(x+y-1,0) for x,y in the unit interval, i.e. the Lower Frechet copula). So my question is, if it is possible to remove this gray grid form the levelplot graph? Thanks in advance marius __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Contingency table and zeros
Let's assume I have a vector of integers : myvector - c(1, 2, 3, 2, 1, 3, 5) For this, I create a table with ; mytable - table(myvector) 1 2 3 5 2 2 2 1 However, table() returns an array of integers, mytable[4] returns the occurence number of the 5 item, which makes this table hard to index. I would prefer to have a data structure where mytable[4] could return 0, as there is no 4 in my vector. ?tabulate so cumsum(tabulate(myvector)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
The following are nearly identical to what others have already written but just in case: A - c(B) or A - B[,1] or if B were already a vector, b, in the first place, rather than a matrix: b - 1:2 A - b On 3/6/06, Michael [EMAIL PROTECTED] wrote: Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [Fwd: maximum likelihood estimate]
Original Message Subject: [R] maximum likelihood estimate From:[EMAIL PROTECTED] Date:Mon, March 6, 2006 1:14 pm To: r-help@stat.math.ethz.ch -- Hi! Recently I try to find the method maximum likelihood for gamma,weibull,Pearson type III,Kappa Distribution, mixed exponential distribution, skew distribution. I have tried function ms() for gamma two parameters and weibull two parameters.It works but not for Pearson type III. I have problem to find the likelihood function for mixed exponential distribution and kappa distribution. So can anyone tell me the programming for those functions? especially in finding their maximum likelihood,because I have trouble to write down the likelihood function for mixed exponential distribution and the other two.If possible ,how to get the hessian matrix? Currently I am using SPlus 6.2. Thanks. suhaila __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
Does R have a similarly smart division? I've tried hard on: A/as.vector(as.matrix(ddLen)) Error in A/as.vector(as.matrix(ddLen)) : non-numeric argument to binary operator but failed... Here my A is 10x10 matrix, and ddLen is a length-10 list of single numbers. On 3/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: The following are nearly identical to what others have already written but just in case: A - c(B) or A - B[,1] or if B were already a vector, b, in the first place, rather than a matrix: b - 1:2 A - b On 3/6/06, Michael [EMAIL PROTECTED] wrote: Hi all, I want to substract vector B from A's each column... how can R do that smartly without a loop? A=matrix(c(2:7), 2, 3) A [,1] [,2] [,3] [1,]246 [2,]357 B=matrix(c(1, 2), 2, 1) B [,1] [1,]1 [2,]2 A-B Error in A - B : non-conformable arrays [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] is there a way to let R do smart matrix-vector operation?
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Sent: Monday, March 06, 2006 5:56 PM To: Gabor Grothendieck Cc: R-help@stat.math.ethz.ch Subject: Re: [R] is there a way to let R do smart matrix-vector operation? Does R have a similarly smart division? I've tried hard on: A/as.vector(as.matrix(ddLen)) Error in A/as.vector(as.matrix(ddLen)) : non-numeric argument to binary operator If ddLen is truly a list, then you might try A/unlist(ddLen) Hope this helps, Dan Daniel Nordlund Bothell, WA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R for Windows GUI front-end has encountered a problem
Hi, Thank you very much for your reply. The modeil is about estimating nonparametric regression parameters which incorporates large dimensionality compared to the number of observations. This may cause the problem that R can run the same model just sometime, not always. Is there any solution to solve this kind of problem? Sincerely yours, Nantachai From: Uwe Ligges [EMAIL PROTECTED] To: Nantachai Kantanantha [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch, [EMAIL PROTECTED] Subject: Re: [R] R for Windows GUI front-end has encountered a problem Date: Fri, 03 Mar 2006 08:21:21 +0100 Nantachai Kantanantha wrote: Hi, I try to run my model using Quantile Regression (quantreg) package. However, when I run the script, it has an error message in a pop-up window: R for Windows GUI front-end has encountered a problem and needs to close. We are sorry for the inconvenience. The error has error information as follows: Error signature AppName: rgui.exe AppVer: 2.21.51220.0ModName: r.dll ModVer: 2.21.51220.0 Offset: 00065e50 I am not sure what causes this problem since sometime the model is run through and give the result. Sometime it has an error during the way. If the model itself is wrong, it should not give any result but in my case, it gives the result but just sometime. If you know what causes this problem and know how to solve it, please let me know. Thank you very much for your help. Sincerely yours, Nantachai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Please report your problem together with a small but reproducible example to the package maintainer (hence CC: Roger Koenker). Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] replicated time series - lme?
What are your primary research objectives? Are you primarily interested in a simple model of how the system evolves over time? Or do your 17 different series include variations in simulation conditions? If I were largely interested in understanding better how the system evolves over time, I might approach the analysis as follows: 1. Make separate normal probability plots of all series. If they aren't normal, can I transform to normality (e.g., taking logarithms -- or using the famous Box-Cox transformation, making lambda plots as described in VR = Venables and Ripley (2004) Modern Applied Statistics with S, 4th ed. (Springer) and the companion MASS package for R). 2. If I could get each of the 17 normal plots to look relatively normal (possibly after a transformation), I'd then try to fit a separate ARIMA model to each of the 17 series using acf, pacf, arima, etc., as described in VR (see step # 1). NOTE: You do NOT want to ask lme to estimate an autoregression of order 100. That's nonsense. The genius of the Box-Jenkins / ARIMA system is that it provides a very flexible system for modeling series with potentially very long lags with parsimoneous models expressed as rational functions (i.e., ratios of polynomials) in the back-shift operator. To understand this, see any good reference on ARIMA modeling, e.g., the original Box and Jenkins, Time Series Analysis, Forecasting and Control. 3. After you have fit parsimoneous models to the several of the 17 series, you should begin to see a pattern in what kinds of models should fit reasonably well. Then you can return to lme to look for further patterns in how the parameters of the parsimoneous time series models are related. Does this help? spencer graves Katrin Meyer wrote: Dear R-helpers, I have a time series analysis problem in R: I want to analyse the output of my simulation model which is proportional cover of shrubs in a savanna plot for each of 500 successive years. I have run the model (which includes stochasticity, especially in the initial conditions) 17 times generating 17 time series of shrub cover. I am interested in a possible periodicity of shrub cover (the time lag(s) of significant autocorrelation) and would like to include the information from the 17 replicate simulations. From the acf and pacf plots, I can assume that time lags of up to 150 years are relevant. I tried a mixed effects model as following: #short example version of input file with 2 runs and 5 time steps (instead of 17 runs and 500 time steps) run t cover 1 1 0.234306 1 2 0.188896 1 3 0.198193 1 4 0.213959 1 5 0.184952 2 1 0.189316 2 2 0.185631 2 3 0.20211 2 4 0.216064 2 5 0.216064 #calculate the correlation of lag 1 over 17 replicates a-0 for (i in 1:17) { c-ts( cover[run==i] ) d-acf( c, lag=1, plot=F) a-a+d$acf[2] } a-a/17 a #[1] 0.9021463 #mixed effects model model1-lme(cover~t,random=~t|run, method=ML) model2-update(model1,correlation=corCAR1(0.902,form=~t|run)) anova(model1,model2) But this just gives significance for a lag of 1, so I tried to find out the correlation at greater lags with arima to be able to use corARMA() as correlation structure: arima(cover[run==1],order=c(100,0,0)) #does not work: “error in polyroot(z): polynomial degree too high” Any ideas to solve this? Maybe, I don’t even need a mixed effects model? I would be very grateful for any help Katrin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] NA in eigen()
I didn't see a reply to your latest question: Are you familiar with sessionInfo()? This is designed to provide a brief summary of your installation, attached packages, etc. Beyond this, from Prof. Ripley's reply (below), you might consider writing a wrapper function with a name like eigen. or eigenSym that might call eigen with the default LAPACK option and try EISPACK only if you have NAs as eigenvalues -- or call both, do some comparison, and act accordingly. hope this helps. spencer graves Elizabeth Purdom wrote: Sorry, I forgot to give my system details. I am using R 2.2.1 on a Windows XP. I just did the standard download from the CRAN page for Windows. I did not use any special options. I don't know what compilation the download is, the details of BLAS or LAPACK for my computer, etc. -- how can I find this information for my computer? Thanks, Elizabeth At 03:46 AM 3/4/2006, Prof Brian Ripley wrote: The default is to use LAPACK rather than EISPACK. In general, LAPACK is a lot faster and a lot stabler than EISPACK, so you will get `odd behavior' much more often with EISPACK=TRUE (sic). You have not told us your machine or R details. Most of the problem reports we see in this area are not due to R itself but to a problem in the BLAS or LAPACK in use on the system running R. So exactly what system is this, how was R compiled and with what options? On Fri, 3 Mar 2006, Elizabeth Purdom wrote: Hi, I am using eigen to get an eigen decomposition of a square, symmetric matrix. For some reason, I am getting a column in my eigen vectors (the 52nd column out of 601) that is a column of all NAs. I am using the option, NAs and not NaNs? I don't think the internal code of eigen knows how to generate NAs, and is.na is not a test for NAs. symmetric=T for eigen. I just discovered that I do not get this behavior when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is (up to rounding error) a vector of all zeros except for -0.6714 and +0.6714 in two locations. The eigenvalues (which are the same with either one) has the 52nd eigenvalue being exactly 19. I also do not have the NA problem if I choose symmetric=F. My main question is whether there is any reason I should not use the EISPACK option (I do not know that what the EISPACK option really means, except that its not preferred)? Or stated another way, should I trust that the results for EISPACK=T, and just ignore the very odd behavior of EISPACK=F? Or is there something inherently problematic or unstable about my eigen decomposition of this matrix -- and if so, is it my matrix or the program? I have no idea what's causing it, and I can't get a reproducible example, other than with my large matrix. My original matrix has no NAs in it. Here is code, but of course it requires my original, 601x601 symmetric matrix called mat any(is.na(mat)) [1] FALSE any(is.na(d)) [1] FALSE dim(mat) [1] 601 601 length(which(d==0)) [1] 5 d-rowSums(mat) temp1-eigen(diag(d)-mat,symmetric=T) temp2-eigen(diag(d)-mat,symmetric=T,EISPACK=T) any(is.na(temp1$vec)) [1] TRUE any(is.na(temp1$vec[,-52])) [1] FALSE any(is.na(temp2$vec)) [1] FALSE all.equal(abs(temp1$vec[,-52]),abs(temp2$vec[,-52])) [1] Mean relative difference: 0.3278133 all.equal(temp1$val,temp2$val) [1] TRUE temp2$val[52] [1] 19 Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Statistical Learning and Datamining Course
Short course: Statistical Learning and Data Mining II: tools for tall and wide data Trevor Hastie and Robert Tibshirani, Stanford University Sheraton Hotel, Palo Alto, California, April 3-4, 2006. This two-day course gives a detailed overview of statistical models for data mining, inference and prediction. With the rapid developments in internet technology, genomics, financial risk modeling, and other high-tech industries, we rely increasingly more on data analysis and statistical models to exploit the vast amounts of data at our fingertips. This course is the third in a series, and follows our popular past offerings Modern Regression and Classification, and Statistical Learning and Data Mining. The two earlier courses are not a prerequisite for this new course. In this course we emphasize the tools useful for tackling modern-day data analysis problems. We focus on both tall data ( Np where N=#cases, p=#features) and wide data (pN). The tools include gradient boosting, SVMs and kernel methods, random forests, lasso and LARS, ridge regression and GAMs, supervised principal components, and cross-validation. We also present some interesting case studies in a variety of application areas. All our examples are developed using the S language, and most of the procedures we discuss are implemented in publicly available R packages. Please visit the site http://www-stat.stanford.edu/~hastie/sldm.html for more information and registration details. --- Trevor Hastie [EMAIL PROTECTED] Professor, Department of Statistics, Stanford University Phone: (650) 725-2231 (Statistics) Fax: (650) 725-8977 (650) 498-5233 (Biostatistics) Fax: (650) 725-6951 URL: http://www-stat.stanford.edu/~hastie address: room 104, Department of Statistics, Sequoia Hall 390 Serra Mall, Stanford University, CA 94305-4065 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] returning the largest element in an array/matrix?
Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only works for vector... Is there any convinient way to solve this problem? Thanks a lot! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Installing Damn Small Linux and R
Installing Damn Small Linux and R Following my experiences with Knoppix (described in another mail) I did similar test on Damn Small Linux (dsl -http://www.damnsmalllinux.org/ ). DSL was interesting, because it is the smallest yet fully functional version of Linux, hence more suited to older and smaller computers than Knoppix. Importantly, it uses lightweight windowing system (no KDE or GNOME) so its memory requirements are much smaller. Also, it seems to have a lively user community, which saved me a lot of work. DSL can be used as 'live CD' but can also be installed on a hard disk - I followed the instructions on http://www.damnsmalllinux.org/dsl-hd-install.html , using the latest DSL 2.2b version . (I installed it to an empty machine, so no dual-boot considerations were important). Upon startup the memory usage reported was 20mb (not 30 as I mentioned in my Knoppix article). Trying to follow the same way of installing R as with Knoppix I discovered that many more libraries are missing or are older in DSL than in Knoppix. There is a list of packages already prepared for installation on DSL at http://distro.ibiblio.org/pub/linux/distributions/damnsmall/mydsl/ and to my joy one of them (under 'applications') was R.tar.gz (version 2.0.1) Using identical procedure as described in the Knoppix article I transferred that through an USB drive to /opt directory, then executed tar -xvzf R.tar.gz It created /opt/R directory. In bin directory I executed R shell script and it simply worked. After that I decided to get adventerous and, from the same place (under 'system'), I downloaded tcltk8.3.dsl . That is a special packaging for DSL extensions and http://www.damnsmalllinux.org/wiki/index.php/Installing_MyDSL_Extensions describes how to install them. Actually it is as simple as opening the file manager EmelFM , higlighting the tcltk8.3 file and pressing the button 'MyDSL'. After that I could run Rtcltk script, which started the R GUI. Memory usage was 40mb at that stage. The whole process took less than one hour and at the end of it I had fully functional R installation, including GUI. And enough memory spare (80mb) for a lot of calculations. P.S. I tested also OpenOffice.uci - a mountable version of OpenOffice 2.0 and it started and worked without problems. The memory usage after starting Writer was around 60mb (R was not running at that time - just the Writer). I expected more, following dire warnings on the DSL site. P.P.S. Judging by these numbers there is a possiblity that with DSL, any old computer with 64mb memory and 1gb hard drive can comfortably run R and OpenOffice. The interface is not so cute as in Knoppix, but for a working computer it quite comfortable and rather fast. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Applying strptime() to a data set or array
I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] returning the largest element in an array/matrix?
indcol - rep(1:ncol(mat), each=nrow(mat))[which.max(mat)] indrow - rep(1:nrow(mat), ncol(mat))[which.max(mat)] indrow - which(apply(mat==max(mat),1,sum)!=0) indcol - which(apply(mat==max(mat),2,sum)!=0) Michael a écrit : Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only works for vector... Is there any convinient way to solve this problem? Thanks a lot! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Applying strptime() to a data set or array
maybe you need to transform A$date to character: A$date - strptime(as.character(A$date), ...) see also: ?ISOdatetime Andrew Athan a écrit : I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Applying strptime() to a data set or array
A$date is already a string, as read from the file. I tried it anyway, for you... A$date-strptime(as.character(A$date),%Y-%m-%d %H:%M:%s) Error in $-.data.frame(`*tmp*`, date, value = list(sec = c(0, 0, : replacement has 9 rows, data has 3198 A. Jacques VESLOT wrote: maybe you need to transform A$date to character: A$date - strptime(as.character(A$date), ...) see also: ?ISOdatetime Andrew Athan a écrit : I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Applying strptime() to a data set or array
POSIXct, not POSIXlt, are used in data frame columns. See ?POSIXct where this is mentioned and try: A$date - as.POSIXct(A$date) Also be sure to read R News 4/1 for more about dates and times. On 3/6/06, Andrew Athan [EMAIL PROTECTED] wrote: I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Applying strptime() to a data set or array
Try prepending as.POSIXct A[,1] - as.POSIXct(strptime(A$date,%Y-%m-%d %H:%M:%s)) A. On Mon, Mar 06, 2006 at 11:58:01PM -0500, Andrew Athan wrote: I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Applying strptime() to a data set or array
it's probably a factor, not a string vector... so i would do as.vector or as.character - but it may be not necessary ! as.POSIXct(strptime(as.vector(A$date),...)) or: seq( from = ISOdate(2006,02,28, 12, 0, 0, tz=), to = ISOdate(...), by=30 min) Andrew Athan a écrit : A$date is already a string, as read from the file. I tried it anyway, for you... A$date-strptime(as.character(A$date),%Y-%m-%d %H:%M:%s) Error in $-.data.frame(`*tmp*`, date, value = list(sec = c(0, 0, : replacement has 9 rows, data has 3198 A. Jacques VESLOT wrote: maybe you need to transform A$date to character: A$date - strptime(as.character(A$date), ...) see also: ?ISOdatetime Andrew Athan a écrit : I'm sure this is just the result of a basic misunderstanding of the syntax of R, but I am stumped. A - read.table(file=sumByThirtyMinute.csv,sep=,,col.names=c(date,pandl)) A now consists of thousands of rows, but A$date is a string... ... 3183 2006-02-28 12:00:00548.470 3184 2006-02-28 12:30:00515.240 3185 2006-02-28 13:00:00140.120 3186 2006-02-28 13:30:00450.940 3187 2006-02-28 14:00:00318.570 ... So, I try to convert A$date to a POSIXlt ... A[,1]-strptime(A$date,%Y-%m-%d %H:%M:%s) A$date-strptime(A$date,%Y-%m-%d %H:%M:%s) which gives me a warning that the length of the array I am trying to replace A$date with is 9 ... but if I print strptime(A$date,%Y-%m-%d %H:%M:%s), it clearly has thousands of rows. Yet, if I ask for length(strptime(A$date,%Y-%m-%d %H:%M:%s)), I get 9. What am I doing wrong? Do I need to convert the return value of strptime(A$date,%Y-%m-%d %H:%M:%s) to some array/vector/matrix datatype before attempting to assign it? Thanks, Andrew __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html