Re: [R] persp()
Am Donnerstag, den 04.08.2011, 02:58 +0200 schrieb Rosario Garcia Gil: I am trying to draw a basic black and white map of two European countries. Are you planning just to draw the boundaries? Or what do you mean by basic black and white. After searching some key words in google and reading many pages I arrived to the conclusion that persp() could be used to draw that map. If you want to create a 3D map where z are, say, the altitudes, yes. Have you read http://cran.r-project.org/view=spatial ? There is no mentioning of persp(). I have prepared three small example files, which are supposed to be the files required for running that function. I haven't seen these files as attachments of your mail. I am certain they would help us a lot to see what your problem is. xvector is a vector with the longitudes yvector is a vector with the latitudes zmatrix is supposed to the height, but since I only need a flat map I just gave the value 1 to each of the entries of the matrix (I am not sure this is correct though). Then persp() will draw you a mesh of a flat plane, which is not informative, which gives me the impression that persp() is not hat you need. Have you run example(persp) at all? The result does not even look basic black and white. The first question for me when using persp() is that x and y values should be in increasing values (following the instructions), but I understand that the coordinates x and y are actually pairs of values (longitude/latitude pairs of values) and if I order them in ascending order both then the pairing is gone. I guess I am totally lost! Still even if I try to run persp() by ordering in ascending value x and y values (even if it does not make sense for me) I still get this message: - persp(xvector,yvector,zmatrix,theta=-40,phi=30) Error in persp.default(xvector, yvector, zmatrix, theta = -40, phi = 30) : increasing 'x' and 'y' values expected Any help is wellcome. Is there any other better function to draw a flat map (2D), also example of the imput files is wellcome. Thanks in advance. Rosario __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] OT Really: Odds Are, It's Wrong...
Dieter Menne schrieb: Marc Schwartz-3 wrote: I thought that readers of R-Help might find the following article at ScienceNews of interest: Odds Are, It's Wrong Science fails to face the shortcomings of statistics By Tom Siegfried March 27th, 2010; Vol.177 #7 (p. 26) http://www.sciencenews.org/view/feature/id/57091/title/Odds_are,_its_wrong Too bad the article is so long that all my p-value-greedy colleagues from the medical faculty won't read it. Journals should apply a post-hoc Bonferroni-correction by the number of p-values cited in an article. The main problem is the multitude of p-value not cited. I have little problems with scientists publishing all their findings with p-values (or confidence intervals) but big problems with people who use them as a filter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Solving graph theory problems with R ? (minimum vertex cover)
Tal Galili schrieb: I just realized (after many discussion with friends), that I might need to solve a (classical) graph theory problem with R. My specific problem is called: Minimum vertex cover http://en.wikipedia.org/wiki/Vertex_cover#Definition for a hypergraph http://en.wikipedia.org/wiki/Hypergraph (Please see the links for a formal explanation, also with some pictures) I know nothing about the problem at hand, but on the Wikipedia page it says that the problem can be formulated as an integer linear program. There is an R packages that interfaces to a linear programming package (Rglpk), which may or may not help you. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unusual result with any
Erin Hodgess schrieb: xy [1] 0.7305081 2.4224211 str(xy) num [1:2] 0.73 2.42 any(xy) 1 [1] FALSE Warning message: In any(xy) : coercing argument of type 'double' to logical What am I doing wrong please? xy 1 should return TRUE FALSE, and you want to apply any() to that. Thus: any(xy 1) any(xy) returns TRUE, as the nonzero numbers are coerced to TRUE When TRUE is compared with 1, it is coerced to a number (no warning is issued here), namely 1. 1 1 returns FALSE. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accumulating results from for loop in a list/array
Steven Kang schrieb: Dear R users, I would like to accumulate objects generated from 'for' loop to a list or array. To illustrate the problem, arbitrary data set and script is shown below, x - data.frame(a = c(rep(n,3),rep(y,2),rep(n,3),rep(y,2)), b = c(rep(y,2),rep(n,4),rep(y,3),n), c = c(rep(n,7),rep(y,3)), d = c(y, rep(n,4), rep(y,2), rep(n,3))) for (i in 1:(dim(x)[2])) { assign(paste(ind, i, sep = ), which(x[ , i] == y)) accum - c(ind1, ind2, ind3, ind4) } Using for loops is not idiomatic; I tend to use them only if I really need intermediate results. res - apply(x, 2, function(answer) which(answer == y)) names(res) - paste(ind, 1:ncol(x), sep=) ind1 [1] 4 5 9 10 ind2 [1] 1 2 7 8 9 ind3 [1] 8 9 10 ind4 [1] 1 6 7 accum [1] 4 5 9 10 1 2 7 8 9 8 9 10 1 6 7 Are there any alternative method where the highlighted statement above can be represented without typing individual objects manually? (as it can be very tedious with large number of objects; i.e ind1, ind2, ., ind100) /I think you are looking for unlist()./ Also, is there any way to extract individual objects ('ind1' etc) from 'accum'? Well, I think they are not objects by themselves anymore. You may want to give the vector elements individual names based on their origin and then extract appropriate elements by string matching. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re gression using age and Duration of disease as a continous factors
Mehdi Khan schrieb: http://www.amazon.com/gp/product/007310874X/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=304485901pf_rd_s=lpo-top-stripe-1pf_rd_t=201pf_rd_i=0256117365pf_rd_m=ATVPDKIKX0DERpf_rd_r=155Y7AP1SHTSJESHM15M This is our textbook for regression analysis. Go through the first 8 or 9 chapters and you're good. I think he'd be ill-advised to do so. Modelling the course of a disease is a very tricky problem whic definitely asks for a statistician with a couple of years experience under his belt, and more than just a few hours of his time. Perusing a book on regression may be a good thing to do in order to be able to communicate to the statistician, or solve some (considerably) simpler problem oneself, but it's like perusing a book of anatomy before your first surgical intervention. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Finding data association in R
Am 19.05.2009 um 05:39 schrieb phen_ys: surgery - data.frame(outcome = c(0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, + 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0), age = c(50, 50, 51, + 51, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 57, 57, 58, + 59, 60, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 64, 64, 65, + 67, 67, 68, 68, 69, 70, 71)) How to use R to find association of the death rate and age with the above data? with(surgery, boxplot(age ~ outcome)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Debbie Zhang schrieb: Dear R users, I incurred some problems with importing data into R. i.e. If I want to import a text file or word file which contains lots of numerical numbers, what function should I use? It does help if you read the posting guide first. In general, the file has to be a bit more structured than a numeric file containing lots of wordy words. Getting an idea of the structure of the data is important to anyone who wants to try to answer your question. Please help. Thanks a lot. Debbie _ View photos of singles in your area Click Here au%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1_t=773166090_r=Hotmail_Endtext_m=EXT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looking for a quick way to combine rows in a matrix
jim holtman schrieb: Try this: key - rownames(a) key[key == AT] - TA do.call(rbind, by(a, key, colSums)) something like paste(sort(strsplit(key, split=)[[1]]), ) might be more general. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Graphics help
Liz Webb schrieb: Hi, I would like to draw a graph as follows: A simplified example is that on the X axis are different countries, I have several temperature measurements taken from each country and would like to plot these linearly above each country. So one would imagine that cold countries would have lots of points at lower temperatures and the opposite for higher countries with a few outliers. I am not entirely certain if I have understood your concept of linearly. Is this what you need: temp - replicate(5, rnorm(12)*10+rnorm(1)*10+10) colnames(temp) - c(Syldavia, Borduria, Arcadia, Grand Fenwick, Molvania) stripchart(temp ~ col(temp), vertical=TRUE, group.names=colnames(temp)) I am not sure how to do this and would be grateful for any direction. Many thanks in advance, Liz _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re : Have a function like the _n_ in R ? (Automatic count function )
If you are in the context of a data frame (which is closest to the concept of a data set in SAS), the 1:nrow(df) is closest to what you may look for. For instance: data(iris) .n. - 1:nrow(iris) You may notice that this number is not very idiomatic in R. If you have something like: if(_N_ 50) then output; in R you can simply put iris[-(1:50),] without using an explicit counter variable. In the context of a matrix, the row() and col() functions may do what you want. Am 25.02.2009 um 15:34 schrieb justin bem: R is more flexible that SAS. You have many functions for loop e.g. for, while, repeat. You also have dim and length functions to get objects dimensions. i-0 dat-matrix(c(1, runif(1), .Random.seed[1]),nr=1) repeat{ i=i+1 dat-rbind(dat, matrix(c(1+i, runif(1), .Random.seed[1]),nr=1)) if (i==4) break } colnames(dat)-c(counter, x,seed) dat Justin BEM BP 1917 Yaoundé Tél (237) 99597295 (237) 22040246 De : Nash morri...@ibms.sinica.edu.tw À : r-help r-help@r-project.org Envoyé le : Mercredi, 25 Février 2009, 13h25mn 18s Objet : [R] Have a function like the _n_ in R ? (Automatic count function ) Have the counter function in R ? if we use the software SAS /*** SAS Code **/ data tmp(drop= i); retain seed x 0; do i = 1 to 5; call ranuni(seed,x); output; end; run; data new; counter=_n_; * this keyword _n_ ; set tmp; run; /* _n_ (Automatic variables) are created automatically by the DATA step or by DATA step statements. */ /*** Output counter seed x 1 584043288 0.27197 2 935902963 0.43581 3 301879523 0.14057 4 753212598 0.35074 5 1607264573 0.74844 / Have a function like the _n_ in R ? -- Nash - morri...@ibms.sinica.edu.tw __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternative way to replicate()
Am 03.12.2008 um 09:06 schrieb Liviu Andronic: Dear all, I'm looking for an alternative way to replicate the 2, string for an x number of times, and end up with one string containing 2, x times. I can partly achieve this using replicate(). y - rep(2,, times=3) y JFTR: replicate() is a different function from rep(). See ?rep and ?replicate. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Formula for Xi
Am 30.10.2008 um 16:53 schrieb [EMAIL PROTECTED]: Hallo! ?xml:namespace prefix = o ns = urn:schemas-microsoft-com:office:office /o:p/o:p [...] [[alternative HTML version deleted]] This is a rare case where I would have liked to see the HTML version in order to see how these o:p tags are interpreted (paragraphs? tab advances?). But then I doubt if MS-Office generated HTML will be any more conclusive. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Select only cases with negative values
Am 18.10.2008 um 23:03 schrieb Michael Just: Hello, I was wondering if there was a way to only select cases my from data frame that contained a negative value? c-c(1,2,3,4,5,6,7,8,9,10) d- c(-1,2,-3,-4,5,6,-7,8,-9,10) f - cbind(c,d) dat -data.frame(f) dat.lm -lm(c~d) If I wanted to only use the rows that had a negative value in column d for my regression, how could I make that selection? untested: dat[dat$d 0, ] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave-LaTEX question
Am 12.10.2008 um 01:39 schrieb Felipe Carrillo: Does LATEX have to be installed on your computer? Not necessarily, but you'd have to have a graphic imagination to get an idea of how your document will look printed on paper. The general idea is that you don't have to (separation of content and markup), but most people I've met are eager enough to see what the document they wrote will look like. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] apply
Am 27.09.2008 um 05:46 schrieb John Sorkin: Windows XP R 2.7.1 I am trying to use apply (or lapply, sapply) to get the sample function to select 1000 samples of size 10 from c(1,2,3) with probability c(0.1,0.2,0.7), i.e. for (i in 1:1000) { j-sample(c(1,2,3),10,replace=TRUE,prob=c(0.1,0.2,0.7)) print(j) } matrix(sample(c(1, 2, 3), 1, replace=TRUE, prob=c(.1, .2, .7)), nrow=10) or replicate(sample(c(1, 2, 3), 10, replace=TRUE, prob=c(.1, .2, .7)), 1000) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Proper power computation for one-sided binomial tests.
Am 23.09.2008 um 23:57 schrieb Peter Dalgaard: For this kind of problem I'd go directly for the binomial distribution. If the actual probability is 0, this is essentially deterministic and you can look at binom.test(0,99,p=.03, alt=less) This means that you don't sample from the p=.03 population? Note that there is a 5 per cent chance to have 0 failures in 99 trials with p=.03. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bootstrap confidence bands
This is an attempt to an answer to Geertja van der Heijden's question, which seems not to have been answered yet. Your attempt was: drought - read.table(D:/drought080525.txt, header=T) regres - function(x, indices) { x - x[indices,] coef(lm(x$AGB ~ x$days, weights=x$weights)) } and what you need are the confidence bands for the regression line. How about generating fitted values out of bootstrap samples the following way (untested!): days - seq(from=min(x$days), to=max(x$days), length=200) days.df - as.data.frame(days) regres - function(x, indices) { x - x[indices,] predict(lm(x$AGB ~ x$days), newdata=days.df) } predvals - boot(drought, regres, R=1, stype=i) You can then plot the results of boot.ci as lines. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] continuous coloring of a polygon
Am 15.08.2008 um 14:00 schrieb Roger Leenders: I can draw the polygon as above, but I don't know how to do the coloring. It is easy to give the polygon only one color (e.g. through polygon(c(x1,x2),c(y1,y2), col=red)), but I need a way in which to color the polygon such that the color moves through the color spectrum from red (left) to green (right). Can anyone help me to achieve this? I don't know of another way than to segment the polygon and give the segments distinctive colours. The function rainbow(n, start=0, end=1/3) might help specifying the colours, where n is chosen sufficiently high. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Categorizing Fonts using Statistical Methods
Leonard Mada [EMAIL PROTECTED] [Sun, May 04, 2008 at 07:26:04PM CEST]: Dear list members, Every modern OS comes with dozens of useless fonts, so that the current font drop-down list in most programs is overcrowded with fonts one never will use. Selecting a useful font becomes a nightmare. In an attempt to ease the selection of useful fonts, I began looking into sorting fonts using some statistical techniques. I summed my ideas on the OpenOffice.org wiki: http://wiki.services.openoffice.org/wiki/User_Experience/ToDo/Product/Font_Categories Of course, there is NO guarantee that something useful will emerge, but at least someone has tried it. Why is there nothing mentioned with respect to the classical font categorization, Venetian, Aldine, Transitional, Modern, Slab Serif, ... ? [...] - maybe some other measures If you can obtain the *.afm information of the font, you have some useful parameters such as cap height, ascender height, descender height, oblique angle ... -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using the sink() function in a for-look
Rolf Turner [EMAIL PROTECTED] [Thu, May 01, 2008 at 06:59:29AM CEST]: On 1/05/2008, at 4:40 PM, Johannes Hüsing wrote: [...] When you do the following: for (i in 1:100) { summary(rnorm(80))} what output do you get? He'd get nothing at all. That's the point. Did you ***try*** your code? And all this output ``All this output''! Consisting of the empty set !!! Hm, I thought this group would be mathematically inclined enough not to single out the empty set as a special case. is redirected to your file by sink(), so it works as expected. That all depends on what you expect, I guess. I upgraded my expectations after keying ?sink and reading. Most people would expect to get some output. As Tony expected. I readily concede that your answer was taking it easier on the beginner than mine. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matlab user: Octave, scilab or R-project?
schoappied [EMAIL PROTECTED] [Thu, May 01, 2008 at 06:00:51PM CEST]: what is a good alternative for matlab? Octave is generally said to be the alternative. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using the sink() function in a for-look
Tony Dell [EMAIL PROTECTED] [Thu, May 01, 2008 at 04:32:23AM CEST]: hi all, i wanted to use the sink function to sequentially output regression summaries within a for-loop. i must have something wrong somewhere (or be using the sink function incorrectly), but can anyone help? the code I am using is: Please use code and data which is reproducible for us. As we don't have access to your data, we'd have to construct some of our own. This code, however, has the same effect: for (i in 1:100) { sink(./sometext.txt, append=TRUE) summary(rnorm(80)) sink()} When you do the following: for (i in 1:100) { summary(rnorm(80))} what output do you get? And all this output is redirected to your file by sink(), so it works as expected. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If(cond) statement
Beck, Kenneth (STP) [EMAIL PROTECTED] [Tue, Apr 29, 2008 at 07:21:40PM CEST]: mxx=max(cpx_list$nMV); mxy=max(trend_list$nMV); if (mxxmxy) mxy=mxx else mxx=mxy Can't this be replaced by mxx - max(c(cpx_list$nMV, trend_list$nMV)) mxy - mxx ? -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Thinking about using two y-scales on your plot?
Am 07.04.2008 um 12:24 schrieb Richard Cotton: thegeologician wrote: Of course, these plots could be plotted separately with a common x-axis, it's just a matter of saving space and of being used to that kind of graph. I can't imagine anyone being falsely lead to a thought like oh gosh, the temperature is much higher/bigger/more than the precipitation! - that makes no sense. I think in the temperature/ precipitation case, whether to draw multiple y-axes or not is a fairly minor decision. The reader would have to be pretty dumb to assume that temperatures and precipitations can be compared. Au contraire, the diagrams are set up to allow this comparison. Google for Walter Lieth for details. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multiset Permutations
You can use the function permutation from the e1071 package, then library(e1071) multisetperm - function(multiset) { unique(apply(matrix(multiset[permutations(length(multiset))], ncol=length(multiset)), 1, paste, sep=, collapse=)) } multisetperm(c(0, 0, 1, 2, 2)) The output would look something like this: 00122 01220 01210 20201 10202 12200 etc... The Java algorithm you cited does not look any more clever or less wasteful than this. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] APPLY as alternate to FOR loop?
[EMAIL PROTECTED] [EMAIL PROTECTED] [Mon, Mar 31, 2008 at 07:02:25AM CEST]: As far as I know there is no function called 'APPLY' There is one called 'apply', but why are you determined to use it here? It is essentially concealed looping. I always use apply instead of for when the steps can be performed independently and are parallelizable. By the same token as I use map instead of recursion in Lisp. R is essentially concealed Lisp, or so I'm told. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Thinking about using two y-scales on your plot?
I wonder how long it will take until metereologists will see the light. http://www.zoolex.org/walter.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] normal (as in Guassian)
Am 02.03.2008 um 17:44 schrieb Gabor Csardi: I'm not a statistician, but do i remember well that among all distributions with a given mean and variance, the normal distribution has the highest entropy? This is good enough for me to call it normal There's more. Among all rotation-symmetric distributions, the standard bivariate normal is the only one where x and y are independent. Also, the formula for the standard normal distribution is the only one that is its own Fourier transform. So, if we assume the same distribution for a momentum and a location of a physical object, according to Heisenberg's Law it has to be the normal. Whereas we ought to be wary about assumption of normality for the distribution of phenomena in nature, the normal and its henchmen play a defendable role when describing summaries of phenomena, like arithmetic means. I'd even go as far as buy into Youden's hype described in that Kruskal and Stigler essay. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing a function
mohamed nur anisah [EMAIL PROTECTED] [Fri, Feb 08, 2008 at 04:42:41PM CET]: Dear lists, I'm in my process of learning of writing a function. I tried to write a simple functions of a matrix and a vector. Here are the codes: mm-function(m,n){ #matrix function w-matrix(nrow=m, ncol=n) for(i in 1:m){ for(j in 1:n){ w[i,j]=i+j } } return(w[i,j]) } In addition to the other comments, allow me to remark that R provides a lot of convenience functions on vectors that make explicit looping unnecessary. An error such as yours wouldn't have occurred to a more experienced expRt because indices wouldn't turn up in the code at all: mm - function(m, n) { a - array(nrow=m, ncol=n) row(a)+col(a) } Greetings Johannes -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to create following chart for visualizing multivariate time series
Megh Dal [EMAIL PROTECTED] [Sun, Feb 03, 2008 at 12:17:00PM CET]: Can anyone here please tell me whether is it possible to produce a chart displayed in http://www.datawolf.blogspot.com/ in R for visualizing multivariate time series? If possible how? Assuming you mean http://bp0.blogger.com/_k3l6qPzizGs/RvDVglPknRI/AKo/itlWOvuuOtI/s1600-h/pairwise_kl_window60.png type ?heatmap at the R prompt and proceed from there. Greetings Johannes -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Randomization tests, grouped data
Tom Backer Johnsen [EMAIL PROTECTED] [Fri, Jan 11, 2008 at 06:57:41PM CET]: [...] Are there something that can handle this in R? Have you considered the coin package? After a few hours thinking on and off about the problem, I suspect that the question may be stupid or silly (or both). If that is the case, I would very much like to know why. I am not quite clear in my thinking anymore, but there are 2^2n permutations, of which (2n choose n) happen to yield the same effect. These cases are part of life and should be counted in the permutation test just as well. You might save a little bit of computation time by singling these group-preserving permutations out, but this is not worth the while at all. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function for AUC?
Armin Goralczyk [EMAIL PROTECTED] [Mon, Dec 17, 2007 at 11:07:25AM CET]: [AUC] I tried it: y-c(1,2,3,4,5);x-c(10,15,10,5,0) Are you sure you don't have x and y wrong? Normally the x values should be monotonically increasing. -- Johannes H�sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rating R Helpers
Mark Kimpel [EMAIL PROTECTED] [Sat, Dec 01, 2007 at 05:28:28PM CET]: What I would find useful would be some sort of tagging system for messages. Hrm. I find tags immensely useful for entities which do not contain primarily text, such as photos. I am at doubt how keywords are important when they are not found in the text. There are situations where the first keyword that comes to mind is tiptoed around in the message, but I don't know if this is often the case. I can't count the times I've remembered seeing a message that addresses a question I have down the road but, when Googled, I can't find it. Is it a problem of way too many false positives or a problem of false negatives? Tags may help out in the second case, but in my experiencd it is rare. [...] Of course, this would be work to set up, but how many of our experts who so kindly give of their time, get exasperated when similar questions keep popping up on the list? Do you think that people who keep asking similar questions do so because they didn't do their homework first, or that they Googled and failed? -- Johannes H�sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Packages - a great resource, but hard to find the right one
Antony Unwin [EMAIL PROTECTED] [Thu, Nov 22, 2007 at 12:43:07PM CET]: There have been several constructive responses to John Sorkin's comment, but none of them are fully satisfactory. Of course, if you know the name of the function you are looking for, there are lots of ways to search ? provided that everyone calls the function by a name that matches your search. I follow the suggestion to Google (mostly restricted by site:cran.r-project.org) which gets me quite far. If you think there might be a function, but you don't know the name, then you have to be lucky in how you search. R is a language and the suggestions so far seem to me like dictionary suggestions, whereas maybe what John is looking for is something more like a thesarus. This is hard to do in a collaborative effort. One analogue is the HOWTOs vs the man pages which I see in Linux. Some of the HOWTOs are outstanding, the only problem they are facing is that they tend to be out of date. R packages are a strange collection, as befits a growing language. There are large packages, small packages, good packages (and not so good packages), personal mixtures of tools in packages, packages to accompany books, superceded packages, unusual packages, everything. Above all there are lots of packages. As the software editor of the Journal of Statistical Software I suggested we should review R packages. You mean: prior to submission? No one has shown any enthusiasm for this suggestion, but I think it would help. Any volunteers? I am still putting some hope into the R Wiki. To my dismay it is also package oriented, not method-oriented. I tend to think that there is a chance of controlled documentation if somebody set out an infrastructure going beyond the current one. Anything like a classification of methods. Thing is, I may like to volunteer, but not in the here's a package for you to review by week 32 way. Rather in the way that I search a package which fits my problem. One package lets me down and I'd like to know other users and the maintainer about it. The other one works black magic and I'd like to drop a raving review about it. This needs an infrastructure with a low barrier to entry. A wiki is not the worst idea if the initial infrastructure is geared at addressing problems rather than packages. -- Johannes H�sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Couldn't find function par
I have just installed version 2.6.0 of R using the Ubuntu Dapper Drake packages from CRAN. I picked the installation option of overwriting the existing config files. Since then, R starts with an error message which I don't quite get because the function it claims not to have found can be called nicely. It wouldn't bug me at all, but R CMD Sweave is a bit more picky than me and dies after issuing this message. The diagnostic message does not appear if I call R --vanilla instead of R, but it does when I call R --vanilla CMD Sweave tobewoven.Rnw. /usr/lib/R R R version 2.6.0 (2007-10-03) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R ist freie Software und kommt OHNE JEGLICHE GARANTIE. Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten. Tippen Sie 'license()' or 'licence()' f�r Details dazu. R ist ein Gemeinschaftsprojekt mit vielen Beitragenden. Tippen Sie 'contributors()' f�r mehr Information und 'citation()', um zu erfahren, wie R oder R packages in Publikationen zitiert werden k�nnen. Tippen Sie 'demo()' f�r einige Demos, 'help()' f�r on-line Hilfe, oder 'help.start()' f�r eine HTML Browserschnittstelle zur Hilfe. Tippen Sie 'q()', um R zu verlassen. Fehler: konnte Funktion par nicht finden par function (..., no.readonly = FALSE) { single - FALSE args - list(...) if (!length(args)) args - as.list(if (no.readonly) .Pars[-match(.Internal(readonly.pars()), .Pars)] else .Pars) else { if (all(unlist(lapply(args, is.character args - as.list(unlist(args)) if (length(args) == 1) { if (is.list(args[[1]]) | is.null(args[[1]])) args - args[[1]] else if (is.null(names(args))) single - TRUE } } value - if (single) .Internal(par(args))[[1]] else .Internal(par(args)) if (!is.null(names(args))) invisible(value) else value } environment: namespace:graphics -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] protecting ...
Dear expRts, I just realized that the ... argument in a function cannot be used without taking precautions sometimes. The following behaviour is what I stumbled upon: myrepl - function(length, fun, ...) { + replicate(length, fun(...))} myrepl(20, sample, 1:5) [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 myotherrepl - function(length, fun, ...) { + args - list(...) + replicate(length, do.call(fun, args))} myotherrepl(20, sample, 1:5) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,]123431541 3 1 1 5 2 [2,]541112435 4 2 3 4 3 [3,]332225252 2 5 2 3 5 [4,]455354113 5 4 4 1 4 [5,]214543324 1 3 5 2 1 [,15] [,16] [,17] [,18] [,19] [,20] [1,] 4 5 1 2 5 5 [2,] 2 1 4 1 1 4 [3,] 3 3 2 3 3 3 [4,] 1 4 3 5 4 2 [5,] 5 2 5 4 2 1 Is the necessity to protect ... unique to replicate(), or have I been (or am I still) missing something basic here? Best wishes Johannes -- Johannes H�sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a repetition of simulation
Excuse me, but I think your code deserves some comments. Unfortunately, the history of postings is in reverse order, so I'll address your first question first: The simulation looks like this: z - 0 x - 0 y - 0 aps - 0 tiss - 0 for (i in 1:500){ z[i] - rbinom(1, 1, .6) x[i] - rbinom(1, 1, .95) y[i] - z[i]*x[i] If I'm getting this correctly, you don't need z and x later on? Then y - rbinom(500, 1, .6*.95) should do the trick. if (y[i]==1) aps[i] - rnorm(1,mean=13.4, sd=7.09) else aps[i] - rnorm(1,mean=12.67, sd=6.82) if (y[i]==1) tiss[i] - rnorm(1,mean=20.731,sd=9.751) else tiss[i] - rnorm(1,mean=18.531,sd=9.499) tiss - ifelse(y, rnorm(500, mean=20.731, sd=9.751), rnorm(500, mean=18.531, sd=9.499)) Likewise for aps. } v - data.frame(y, aps, tiss) log_v - glm(y~., family=binomial, data=v) summary(log_v) Makes me wonder what you need aps and tiss for. Let's assume for a moment that they are the coefficients. I do not see the necessity to put everything into a data frame, so log_v - glm(y ~ aps+tiss, family=binomial) should be sufficient and summary(log_v)$coefficients[,Pr(|z|)] extracts the p value. how can I see all the P.Values (Pr(|z|)) of the covariates from the 1000 iterations? I tried names(log_v) and couldn'n find it. Try str(summary(log_v)) and you see the whole structure. -- Johannes H�sing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:[EMAIL PROTECTED] from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] random walk w/ reflecting boundary: avoid control construct?
This is beautiful, thank you! Greetings Johannes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.