Re: [R] Format integer
This is one of those problems where the fine details matter. 1) The version of R. I optimized sprintf() for long inputs and a single format in R 2.7.0 -- the differences are mainly for multiple inputs and where coercion is needed. See also below. 2) The system. My home system with an Intel Core 2 Duo is usually about the same speed as my office desktop with dual Opterons. But not here: Home: system.time(a-formatC(x,digits=10,flag='0')) user system elapsed 9.705 0.088 9.810 system.time(b-sprintf(%011d,x)) user system elapsed 0.283 0.000 0.283 Office: system.time(a-formatC(x,digits=10,flag='0')) user system elapsed 15.851 0.125 16.007 system.time(b-sprintf(%011d,x)) user system elapsed 0.816 0.001 0.818 and my Windows laptop is similar to the second here. So a speed-up of 95x seems atypical. On Mon, 12 May 2008, Phil Spector wrote: I guess little means different things to different people: x = sample(1:100,65,replace=TRUE) system.time(a-formatC(x,digits=10,flag='0')) user system elapsed 32.854 0.444 34.813 system.time(b-sprintf(%011d,x)) user system elapsed 0.352 0.012 0.363 If you look at the definitions of the functions, you'll see that formatC is written in R, and sprintf uses a single call to an .Internal function. I Not really: the meat of formatC() is a .C call. In this case it is calling format.default(), also a .Internal. But profiling shows that most of the time here is spent in paste(), another function which was optimized in 2.7.0. (I see 2.7.0 as 1.7x faster than 2.6.2 on formatC here.) But although sprintf is more flexible, on most problems it will be substantially faster. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley [EMAIL PROTECTED] On Mon, 12 May 2008, Anh Tran wrote: Yea, thanks all. I checked back and I got a few things mistyped. The array is 650,000 and it took 25 seconds :p. It's acceptable. Just that I had too many variable at the time I ran it. Also, seems like sprintf is a little faster. Thanks all. Anh Tran On Mon, May 12, 2008 at 2:55 PM, Uwe Ligges [EMAIL PROTECTED] wrote: Anh Tran wrote: Thanks. formatC(flag) works. But it's awefully slow. I try to do that for 65000 numbers (generating ID for each item) and it seems like forever. On my not that recent laptop: system.time(formatC(1:65000, width=10, flag=0)) user system elapsed 1.920.001.94 I think 2 seconds is less than forever. Uwe Ligges Is there any faster way? Thank all. Anh Tran On Mon, May 12, 2008 at 2:36 PM, Uwe Ligges [EMAIL PROTECTED] wrote: Anh Tran wrote: Hi, What's one way to convert an integer to a string with preceding 0's? such that '13' becomes '013' to be put into a string I've tried formatC, but they removes all the zeros and replace it with blanks Not so for me: formatC(13, digits=10, flag=0) Uwe LIgges Thanks -- Regards, Anh Tran [[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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] is.category
Applejus ielkhoury at gmail.com writes: Hello, Could someone tell me what the SPLUS is.category function do and what is its equivalent in R? Thank you, I couldn't find any help elsewhere... If you Web search for splus help or similar, you will find, among others, http://www.uni-muenster.de/ZIV/Mitarbeiter/BennoSueselbeck/s-html/shelp.html and there under is.category Creates or tests for categorical objects (vectors with a levels attribute). This function is deprecated; factor or ordered are now preferred. Hans Werner __ 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] Compare columns
Dear R-users, I have the following 2 files; A V1V2 A 1 A 2 A 3 A 4 B 1 B 4 C 1 C 3 D 4 B V1V2 process1 1 process2 2 process3 3 process4 4 I want to get this output C V1V2 V3 A 1 process1 A 2 process2 A 3 process3 A 4 process4 B 1 process1 B 4 process4 C 1 process1 C 3 process3 D 4 process4 I want to compare A$V2 with B$V2, if it is the same, then append B$V1 to A. Any tips are highly appreciated. TQVM! -- Suhaila Zainudin PhD Candidate Universiti Teknologi Malaysia [[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.
Re: [R] ggplot2: font size mismatch for pdf output
What you can do is change the parameter pointsize when creating the device. See ?pdf. It will change the size of all texts (labels, legend, title...) at the same time. I tried it with png, it works quite well (provided you use the latest versions of everything, including cairo, I think). Xavier hadley wickham a écrit : More generally, how do I control the size of fonts used in legends and axis labels? There is no general way (yet) - it is on my customisation to do list, which I hope to make progress on over summer. Hadley -- Xavier Chardon Thésard Institut de l'élevage / INRA Projet ACTA modélisation environnementale des systèmes bovins et porcins [EMAIL PROTECTED] [EMAIL PROTECTED] 02 23 48 50 91 __ 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] array dimension changes with assignment
Why does the assignment of a 3178x93 object to another 3178x93 object remove the dimension attribute? GT - array(dim = c(6,nrow(InData),ncol(InSNPs))) dim(GT) [1]6 3178 93 SNP1 - InSNPs[InData[,C1],] dim(SNP1) [1] 3178 93 SNP2 - InSNPs[InData[,C2],] dim(SNP2) [1] 3178 93 dim(pmin(SNP1,SNP2)) [1] 3178 93 GT[1,,] - pmin(SNP1,SNP2) dim(GT) NULL# why?? GT[2,,] - pmax(SNP1,SNP2) Error in GT[2, , ] - pmax(SNP1, SNP2) : incorrect number of subscripts Knut M. Wittkowski, PhD,DSc Sr Research Associate,The Rockefeller University Biometrician,The Rockefeller University Hospital Director, Biostatistics/Epidemiology/Research Design Center for Clinical and Translational Science (CCTS) apl. Professor, Eberhard-Karls-University, Tübingen 1230 York Ave #121B, Box 322, New York, NY 10021, US Tel: +1 (212) 327-7175, Fax: +1 (212) 327-8450 [EMAIL PROTECTED], www.rockefeller.edu/ccts/rdbs [[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] How to get predicted marginal (aka predicted mean) after multinomial logistic?
I tried to use the effect() to get predicted marginals for multinomial logistic as I did for general logistic regression, but failed. Is there anyway to do that? Thx! -- View this message in context: http://www.nabble.com/How-to-get-predicted-marginal-%28aka-predicted-mean%29-after-multinomial-logistic--tp17200114p17200114.html Sent from the R help mailing list archive at Nabble.com. __ 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] how to do trend test?
say I have a categorical variable X with 3 levels coded as 1,2,3 and then I have a table of age, sex and etc, by X, which looks like the following: x-level1 x-level2 x-level3p-trend age 5654 57 ? female% 67% 65% 66%? my question is how to test if there is a statistically significant trend across x-levels for age and for sex? any suggestion will be greatly appreciated! -- View this message in context: http://www.nabble.com/how-to-do-trend-test--tp17200200p17200200.html Sent from the R help mailing list archive at Nabble.com. __ 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] R help: problems with step function
Dear List Members, I have encountered two problems when using the step function to select models. To better illustrate the problems, attached is an R image which includes the objects needed to run the code attached. lm.data.frame have factor variables with 3 levels. The following run shows the first problem. AICs (* and **) are different. I noticed that the Df for rs13482096:rs13483699 is 4, while I think Df should be 6, 2 from rs13483699 and 4 from interactions. When I ran add1 directly, I got Df=6 and AIC 848.75. step2.bic.out - step(step.bic.out, scope=list(lower=scope.lower2, upper=scope.upper2), + direction=both, k=log(length(step.bic.out$y)), trace=1) Start: AIC=841.18 pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 Df DevianceAIC + rs13482096:rs13483699 4 216.63 840.63 (*) none 233.82 841.18 - rs8254221 2 244.08 842.90 - rs13482096 2 245.20 844.31 .. Step: AIC=848.75 (**) pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 + rs13482096:rs13483699 add1(step.bic.out, scope=rs13482096:rs13483699, k=log(length(step.bic.out$y))) Single term additions Model: pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 Df DevianceAIC none 233.82 841.18 rs13482096:rs13483699 6 214.28 848.75 (**) When I used add1 to handle terms to be added together and separately, I got different results. The example is shown below. This might explain the discrepancy shown above. add1(step.bic.out, scope=int.terms[11:12], k=log(length(step.bic.out$y))) Single term additions Model: pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 Df DevianceAIC none 233.82 841.18 rs13479085:rs13475933 6 224.95 863.66 rs13480057:rs13475933 4 226.72 854.62 (***) add1(step.bic.out, scope=int.terms[11], k=log(length(step.bic.out$y))) Single term additions Model: pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 Df DevianceAIC none 233.82 841.18 rs13479085:rs13475933 6 224.95 863.66 add1(step.bic.out, scope=int.terms[12], k=log(length(step.bic.out$y))) Single term additions Model: pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 Df DevianceAIC none 233.82 841.18 rs13480057:rs13475933 6 215.95 851.12 (***) Another problem is that the final model seems to be the first model that satisfies (bAIC = AIC + 1e-07) if steps haven't used up, rather than the one before that. Please see below. formula(step2.bic.out) pheno.dat ~ rs13479085 + rs13480057 + rs13482096 + rs8254221 + rs13482096:rs13483699 step2.bic.out$anova Step Df Deviance Resid. Df Resid. Dev AIC 1 NA NA 298 233.8226 841.1784 Any insights would be greatly appreciated. Thanks much ! Ping Wang __ 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] Left censored responses in mixed effects models
Dear Bert, a solution is the 'package' censre3 by Hughes JP Reference: Hughes JP: Mixed effects models with censored data with application to HIV RNA levels. Biometrics, 55:625-629, 1999. Giovanni Don MacQueen ha scritto: I assume you've looked at the NADA package(?) While I don't believe it goes as far as dealing the mixed effects models, it might give you a starting point, and possibly some additional references. -Don At 9:08 AM -0700 5/12/08, Bert Gunter wrote: Dear R Fellow-Travellers: What is your recommended way of dealing with a left-censored response (non-detects) in (linear Gaussian) mixed effects models? Specifics: Response is a numeric positive measurement (of volume, actually); but when it falls below some unknown and slightly random value (depending on how the sample is prepared and measured), it cannot be measured and is recorded as 0. There is some statistical literature on this, but I was unable to find anything that appeared to me to implement a strategy in any R package. If it matters, I am less interested in inference than in removing possible bias in estimation. Feel free to respond off-list if you feel that this would not be of general interest. Cheers, Bert Gunter Genentech __ 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. -- dr. Giovanni Parrinello Department of Biotecnologies Medical Statistics Unit University of Brescia Viale Europa, 11 25123 Brescia email: [EMAIL PROTECTED] Phone: +390303717528 Fax: +390303717488 __ 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] Left censored responses in mixed effects models(II)
Dear Bert, you can also translate in nlme, as I'm trying to do, the approach of Thiébaut and *Gadda( *Mixed models for longitudinal left-censored repeated measures. Computer Methods and Programs in Biomedicine 74 http://www.informatik.uni-trier.de/%7Eley/db/journals/cmpb/cmpb74.html#ThiebautJ04(3): javascript:void(0)(2004)) written in nlmixed(SAS) Giovanni Bert Gunter ha scritto: Dear R Fellow-Travellers: What is your recommended way of dealing with a left-censored response (non-detects) in (linear Gaussian) mixed effects models? Specifics: Response is a numeric positive measurement (of volume, actually); but when it falls below some unknown and slightly random value (depending on how the sample is prepared and measured), it cannot be measured and is recorded as 0. There is some statistical literature on this, but I was unable to find anything that appeared to me to implement a strategy in any R package. If it matters, I am less interested in inference than in removing possible bias in estimation. Feel free to respond off-list if you feel that this would not be of general interest. Cheers, Bert Gunter Genentech __ 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. -- dr. Giovanni Parrinello Department of Biotecnologies Medical Statistics Unit University of Brescia Viale Europa, 11 25123 Brescia email: [EMAIL PROTECTED] Phone: +390303717528 Fax: +390303717488 __ 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] Permutations
Dear R-users, Is there an easy way to determine all possible vectors of length 21 with each entry having permutations from 0 to 4, instead of doing it like this? It really takes up too much time, and I am convinced that there exists something easier. Can you help me? Thank you in advance! Kind regards, Elke for (a in 0:4){ for (b in 0:4){ for (c in 0:4){ for (d in 0:4){ for (e in 0:4){ for (f in 0:4){ for (g in 0:4){ for (h in 0:4){ for (i in 0:4){ for (j in 0:4){ for (k in 0:4){ for (l in 0:4){ for (m in 0:4){ for (n in 0:4){ for (o in 0:4){ for (p in 0:4){ for (q in 0:4){ for (r in 0:4){ for (s in 0:4){ for (u in 0:4){ for (v in 0:4){ vec-list(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v) write.table(vec,file=C:/Documents and Settings/My Documents/permutations.txt,sep=;,col.names=FALSE, row.names=FALSE, append=TRUE) } } } } } } } } } } } } } } } } } } } } } Elke Moons, PhD Transportation Research Institute/ Instituut voor Mobiliteit (IMOB) Wetenschapspark 1, bus 15 3590 Diepenbeek BELGIUM Tel. +32-11-26.91.26 Fax. +32-11-26.91.99 E-mail: [EMAIL PROTECTED] [[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.
Re: [R] Permutations
Dear Elke, I think you need something like this. It's only for 3 variables, but I think you know how to expand it for more variables. mat - expand.grid(a = 0:4, b = 0:4, c = 0:4) write.table(mat, file=C:/Documents and Settings/My Documents/permutations.txt,sep=;,col.names=FALSE, row.names=FALSE) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Elke Moons Verzonden: dinsdag 13 mei 2008 9:49 Aan: r-help@r-project.org Onderwerp: [R] Permutations Dear R-users, Is there an easy way to determine all possible vectors of length 21 with each entry having permutations from 0 to 4, instead of doing it like this? It really takes up too much time, and I am convinced that there exists something easier. Can you help me? Thank you in advance! Kind regards, Elke for (a in 0:4){ for (b in 0:4){ for (c in 0:4){ for (d in 0:4){ for (e in 0:4){ for (f in 0:4){ for (g in 0:4){ for (h in 0:4){ for (i in 0:4){ for (j in 0:4){ for (k in 0:4){ for (l in 0:4){ for (m in 0:4){ for (n in 0:4){ for (o in 0:4){ for (p in 0:4){ for (q in 0:4){ for (r in 0:4){ for (s in 0:4){ for (u in 0:4){ for (v in 0:4){ vec-list(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v) write.table(vec,file=C:/Documents and Settings/My Documents/permutations.txt,sep=;,col.names=FALSE, row.names=FALSE, append=TRUE) } } } } } } } } } } } } } } } } } } } } } Elke Moons, PhD Transportation Research Institute/ Instituut voor Mobiliteit (IMOB) Wetenschapspark 1, bus 15 3590 Diepenbeek BELGIUM Tel. +32-11-26.91.26 Fax. +32-11-26.91.99 E-mail: [EMAIL PROTECTED] [[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.
[R] xirr...
Hello. A few weeks ago, I need to calculate the Internal Rate of Return for irregular intervals. There is the package 'financial', with the function 'cashflow', calculating irr for regular intervals. So I developed xirr, managing irregular intervals, that's accepting a vector of dates as xirr Excel function. You can find the code at http://albertosantini.blogspot.com/2008/01/xirr.html #~ Title: XIRR Excel function simulation #~ #~ Reference 1: How to manage irregular intervals - http://www.geocities.com/accessreddy/excel/xirr.htm #~ Reference 2: How to calculate IRR manually - http://www.s-anand.net/Calculating_IRR_manually.html #~ #~ Step 1: enter zeroes (0) against dates that do not have any cash outflow or inflows. #~ Step 1bis: calculate IRR for these cash flow values using normal IRR function. #~ Step 1tris: or using an iteractive approach as bisection method to find the NPV zeroes. #~ Step 2: multiply this value of IRR by 365 to get annual IRR (since, these are daily cash flows). #~ Step 3: refine using the formula =( 1+ R / 365) ^ 365 - 1), where R is the the value obtained in Step2. #~ Regards, Alberto Santini -- View this message in context: http://www.nabble.com/xirr...-tp17203475p17203475.html Sent from the R help mailing list archive at Nabble.com. __ 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] ggplot2: font size mismatch for pdf output
If I do windows(width=6, height=5) then the pdf plot is very good copy of what I see on screen. So the main issue seems to be that you changed the device size when you asked for the save. If you do that, you need to change 'pointsize' too -- but as you changed the aspect ratio, you cannot make that work exactly. There is a bug in ggsave() for bitmap devices: it computes the width and height from 'dpi', but it fails to pass that information on to the devices, which assume 72dpi. So what it actually asked for was a 8 x 6.67 inch plot at 72dpi. 72dpi would be a better default, as not all of the many bitmap devices work correctly at other resolutions (and none did prior to R 2.7.0). If you want an accurate png copy of what you see on screen, use savePlot() or the device menus. That copies the backing bitmap. On Mon, 12 May 2008, Michael Friendly wrote: Sorry for not providing this in my initial posting. I'm using R version 2.7.0 (2008-04-22), on Win XP Pro. As I said, the .png output matched what I saw on screen. It was the .pdf output for which the font size was noticeably larger, enough to make the legend run off the screen. -Michael Prof Brian Ripley wrote: What version of R and OS is this? Prior to R 2.7.0 there was little attempt to match output dimensions from various devices, and one of the png devices in 2.7.0 has an error in doing so, fixed in R-patched (see NEWS). On Mon, 12 May 2008, Michael Friendly wrote: Hi In the following, the graph I see on the screen and the .png output coincide. However, in the .pdf file, the fonts seem to be scaled fairly larger, resulting in the label for the top legend disappearing. Is this an infelicity or bug, or is there something I've missed? More generally, how do I control the size of fonts used in legends and axis labels? library(car) library(ggplot2) qp -qplot (education , income , shape=type , size=women , colour=prestige , xlab=Education , ylab=Income, data=Prestige) + scale_y_continuous(limits=c(NA, 2)) Hmm, you can't break the line before '+'. qp + scale_size(to=c(1,8)) ggsave(file=prestige-ggplot.png, width=6, height=5) # OK ggsave(file=prestige-ggplot.pdf, width=6, height=5) # fonts too large I would not expect you to be able to specify a smaller size without also reducing 'pointsize'. E.g. dev.print() does so, but ggsave seems not to. -Michael -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Permutations
Hi Elke, the matrix you are trying to create has 5^21 = 476837158203125 rows and 21 columns. I'm afraid Thierry's proposal with n=21 will not fit into memory. And the file you are writing is 5^21*5*8 bytes big, about 80108643 GB. Perhaps you want to think a little more about what you are trying to achieve and, e.g., consider random sampling from the matrix? In addition, look at your code: you append every single line to the output file, i.e., you open and close your file 5^21 = 476837158203125 times. File I/O always takes a lot of time. File I/O in a loop usually leads to slow execution. HTH, Stephan ONKELINX, Thierry schrieb: Dear Elke, I think you need something like this. It's only for 3 variables, but I think you know how to expand it for more variables. mat - expand.grid(a = 0:4, b = 0:4, c = 0:4) write.table(mat, file=C:/Documents and Settings/My Documents/permutations.txt,sep=;,col.names=FALSE, row.names=FALSE) HTH, Thierry Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Elke Moons Verzonden: dinsdag 13 mei 2008 9:49 Aan: r-help@r-project.org Onderwerp: [R] Permutations Dear R-users, Is there an easy way to determine all possible vectors of length 21 with each entry having permutations from 0 to 4, instead of doing it like this? It really takes up too much time, and I am convinced that there exists something easier. Can you help me? Thank you in advance! Kind regards, Elke for (a in 0:4){ for (b in 0:4){ for (c in 0:4){ for (d in 0:4){ for (e in 0:4){ for (f in 0:4){ for (g in 0:4){ for (h in 0:4){ for (i in 0:4){ for (j in 0:4){ for (k in 0:4){ for (l in 0:4){ for (m in 0:4){ for (n in 0:4){ for (o in 0:4){ for (p in 0:4){ for (q in 0:4){ for (r in 0:4){ for (s in 0:4){ for (u in 0:4){ for (v in 0:4){ vec-list(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v) write.table(vec,file=C:/Documents and Settings/My Documents/permutations.txt,sep=;,col.names=FALSE, row.names=FALSE, append=TRUE) } } } } } } } } } } } } } } } } } } } } } -- __ 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] fft: characteristic function to distribution
Matthias Kohl was so kind and provided me the following lines in this issue: library(distrEx) chf - function(t, D){ E(D, function(x){exp(1i*t*x)}, useApply = FALSE) } ## Normalverteilung D - Norm() t - seq(-3, 3, by = 0.05) chf.norm - sapply(t, chf, D = D) chf.exakt - exp(-t^2/2) chf.diff - chf.norm - chf.exakt plot(chf.diff) abs(chf.diff) This is nice BUT: * Only built-in distributions can be used * I want to understand the fft() function, instead here you used E() of the distrEx package. Apart from this it was exactly what i was looking for: I know the characteristic function and want to get the distribution. (My porposal was to use fft(,inverse=T).) Any help appreciated, Thomas __ 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] Regular Expressions
Hi R, Again struck with regular expressions... Suppose, S=c(World_is_beautiful, one_two_three_four,My_book) I need to extract the last but one element of the strings. So, my output should look like: Ans=c(is,three,My) gsub() can do this...but wondering how do I give the regular expression Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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] Regular Expressions
try this: S - c(World_is_beautiful, one_two_three_four,My_book) sapply(strsplit(S, _), tail, n = 2)[1, ] # or sapply(strsplit(S, _), function(x) x[length(x) - 1]) I hope it helps. Best, Dimitris Dimitris Rizopoulos 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://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Shubha Vishwanath Karanth [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 13, 2008 11:02 AM Subject: [R] Regular Expressions Hi R, Again struck with regular expressions... Suppose, S=c(World_is_beautiful, one_two_three_four,My_book) I need to extract the last but one element of the strings. So, my output should look like: Ans=c(is,three,My) gsub() can do this...but wondering how do I give the regular expression Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] Format integer
Anh Tran wrote: Hi, What's one way to convert an integer to a string with preceding 0's? such that '13' becomes '013' to be put into a string I've tried formatC, but they removes all the zeros and replace it with blanks Hi, try sprintf: i=13 cat(sprintf(%05d\n, i)) 00013 HTH, Esmail __ 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] array dimension changes with assignment
Why does the assignment of a 3178x93 object to another 3178x93 object remove the dimension attribute? GT - array(dim = c(6,nrow(InData),ncol(InSNPs))) dim(GT)[1] 6 3178 93 SNP1 - InSNPs[InData[,C1],] dim(SNP1)[1] 3178 93 SNP2 - InSNPs[InData[,C2],] dim(SNP2)[1] 3178 93 dim(pmin(SNP1,SNP2))[1] 3178 93 GT[1,,] - pmin(SNP1,SNP2) dim(GT)NULL # why?? GT[2,,] - pmax(SNP1,SNP2)Error in GT[2, , ] - pmax(SNP1, SNP2) : incorrect number of .subscripts --- My understanding is that an array is just a list with a dimension attribute, so first note that loosing the dim attribute is not a great loss. It does not represent an inefficiency. But consider this code: GT - array(dim = c(6,3178, 93) ) dim(GT)[1]6 3178 93 SNP1 -as.array(matrix(0,nrow=3178,ncol=93)) dim(SNP1)[1] 3178 93 GT[1,,] - SNP1 dim(GT)[1]6 3178 93 Here what you wanted to happen happened just fine. So the question you might ask yourself is: what is different? And that leads to asking what class is the SNP1 object? If you can coerce into an array you probably can avoid the issue. Jeremiah Rounds Graduate Student Utah State University _ Get Free (PRODUCT) RED Emoticons, Winks and Display Pics. [[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.
Re: [R] Random number generation
On Behalf Of Esmail Bonakdarian wrote: ... What I read doesn't seem to be incorrect however (it may even have been an archived message here), the *language* itself does not seem to support block *comments*. Using conditional constructs, or an IDE/editor to achieve similar results is a work around - but not the same. I don't mean to nitpick, but as a computer scientist I see this as different :-) For those using NEdit, the R block comment macro: replace_in_selection(^,#,regex) and the corresponding R block uncomment macro: replace_in_selection(^#,,regex) are both trivial. Just highlight the block and detonate the macro. Jim __ 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] test
Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? In any case, regardless if we see them, they are getting posted, which is what matters :) Cheers, Esmail __ 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] add horizontal line (ABLINE(V=)) to xyplot lattice
Hi, In a lattice plot like this: win.graph() xyplot(tmx~frequ|as.factor(as.numeric(spf)),groups=as.factor(blm),data=tmx,type=l,pch=16,xlab=frequency (N),ylab=Area held (ha), auto.key=list(blm,points=F,lines=T,title=Blm factor,cex.title=0.7,cex=0.7,corner=c(1,1)),main=Mangroves target=1573ha,layout=c(2,3)) I would like to add a horizontal line to each one of the 5 graphs with a single value, v=1573 Any idea will be welcome Paulo De: [EMAIL PROTECTED] em nome de Jim Lemon Enviada: ter 13-05-2008 10:56 Para: [EMAIL PROTECTED] Assunto: Re: [R] Random number generation On Behalf Of Esmail Bonakdarian wrote: ... What I read doesn't seem to be incorrect however (it may even have been an archived message here), the *language* itself does not seem to support block *comments*. Using conditional constructs, or an IDE/editor to achieve similar results is a work around - but not the same. I don't mean to nitpick, but as a computer scientist I see this as different :-) For those using NEdit, the R block comment macro: replace_in_selection(^,#,regex) and the corresponding R block uncomment macro: replace_in_selection(^#,,regex) are both trivial. Just highlight the block and detonate the macro. Jim __ 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.
Re: [R] Regular Expressions
S=c(World_is_beautiful, one_two_three_four,My_book) I need to extract the last but one element of the strings. So, my output should look like: Ans=c(is,three,My) gsub() can do this...but wondering how do I give the regular expression sapply(strsplit(S, _), function(x) x[length(x)-1]) You could use regular expressions, but I think it would only be complicating things. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ 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 needed please
HI I have a data to test its normality and simulate after how with R. thanks in advance __ [[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.
Re: [R] test
On May 13, 2008, at 5:52 AM, Esmail Bonakdarian wrote: Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? Bingo! Well, I don't know if this happens with the web interface to gmail, but if you use POP to access your gmail account, then any emails you send to any kind of list will not get back to you (Problem being, sort of, that gmail groups things in Conversations, and in this case will remember the email you sent out and use that copy in the conversation, instead of the one sent through the list. Not a very good excuse in my opinion, and a particularly irritating feature.). I wouldn't really expect them to fix it any time soon. In the rare occasions where my waiting powers get exhausted before someone on this very helpful list replies to my email, I just use the online archives to check whether my email was sent or not. In any case, regardless if we see them, they are getting posted, which is what matters :) Cheers, Esmail Haris Skiadas Department of Mathematics and Computer Science Hanover College __ 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] Left censored responses in mixed effects models
Bert Gunter wrote: What is your recommended way of dealing with a left-censored response (non-detects) in (linear Gaussian) mixed effects models? Specifics: Response is a numeric positive measurement (of volume, actually); but when it falls below some unknown and slightly random value (depending on how the sample is prepared and measured), it cannot be measured and is recorded as 0. There is some statistical literature on this, but I was unable to find anything that appeared to me to implement a strategy in any R package. If it matters, I am less interested in inference than in removing possible bias in estimation. The simplest way is to substitute some number for the nondetects, typically half the limit of detection. This method is usually fine if you have less than about 10% nondetects, but can lead to big biases with larger numbers of nondetects. Denis Helsel has written fairly extensively on this topic, and is the author of the book Nondetects and data analysis, which the NADA R package is based upon. He discusses it here: http://www.practicalstats.com/nada/nadafiles/files/NADAforR_Examples.pdf http://www.practicalstats.com/nada/nadafiles/files/NADAforR_Examples.pdf Possibly the best option is to use OpenBUGS to run an MCMC model. It has a nice interface with R using the R2WinBUGS package. Be warned though, this option does require some understanding of Bayesian stats. - Regards, Richie. Mathematical Sciences Unit HSL -- View this message in context: http://www.nabble.com/Left-censored-responses-in-mixed-effects-models-tp17190869p17205469.html Sent from the R help mailing list archive at Nabble.com. __ 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] test
Charilaos Skiadas wrote: On May 13, 2008, at 5:52 AM, Esmail Bonakdarian wrote: Tony Plate wrote: You probably should check this section in your R-help subscription options (via https://stat.ethz.ch/mailman/options/r-help/, I think): Receive your own posts to the list? Tony, Like jt I too have it set to receive my own messages, but I too don't see them. I wonder if it has to do with the fact that both of us use gmail to post to the list? Bingo! Well, I don't know if this happens with the web interface to gmail, but if you use POP to access your gmail account, then any emails you send to any kind of list will not get back to you Yup, I use Thunderbird to read/process my gmail :-) (Problem being, sort of, that gmail groups things in Conversations, and in this case will remember the email you sent out and use that copy in the conversation, instead of the one sent through the list. Except that part of the conversation sits in my sent folder rather than being nicely threaded into the conversation. Not a very good excuse in my opinion, and a particularly irritating feature.). agreed! In the rare occasions where my waiting powers get exhausted before someone on this very helpful list replies to my email, I just use the online archives to check whether my email was sent or not. Yes, I did that initially when I wasn't sure if my message was getting out. Often thought I don't have to do this because the helpful folks on this list have already replied to my posting. Best, Esmail __ 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 get predicted marginal (aka predicted mean) after multinomial logistic?
Dear monogift, effect() doesn't currently handle mulinom objects. You'll find a paper, some functions, and some example code at http://socserv.mcmaster.ca/jfox/Misc/polytomous-effect-displays/index.html for effect displays for multinomial and proportional odds logit models, with standard errors computed by the delta method. A plan to incorporate this code in the effects package is nearly complete, but for the time being, you'll have to set up the displays yourself, as in the examples. I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of monogift Sent: May-12-08 10:54 PM To: r-help@r-project.org Subject: [R] How to get predicted marginal (aka predicted mean) after multinomial logistic? I tried to use the effect() to get predicted marginals for multinomial logistic as I did for general logistic regression, but failed. Is there anyway to do that? Thx! -- View this message in context: http://www.nabble.com/How-to-get-predicted- marginal-%28aka-predicted-mean%29-after-multinomial-logistic-- tp17200114p17200114.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pch=. plots much faster
Dear list, I realised by chance when analysing a 1521862 × 8 matrix that plotting was much faster when using . as the argument of `pch'. I was just wondering if there were other ways to get this speed improvement: it is otherwise quite difficult to explore such big matrices, especially given that X11 redraws the plot whenever its window is covered/uncovered by another window, or when I switch virtual desktops. Best regards, -- Charles Plessy, Wakō, Saitama, Japan __ 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] Remove an object by the reference
Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x. something like rm(somefunction(x))...Is this possible? Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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] Remove an object by the reference
How about rm(list=x)? Richard. Shubha Vishwanath Karanth wrote: Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x. something like rm(somefunction(x))...Is this possible? Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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. -- Richard D. Pearson [EMAIL PROTECTED] School of Computer Science,http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK.Fax: +44 161 275 6204 __ 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] add horizontal line (ABLINE(V=)) to xyplot lattice
In a lattice plot like this: win.graph() xyplot(tmx~frequ|as.factor(as.numeric(spf)),groups=as.factor(blm), data=tmx,type=l,pch=16,xlab=frequency (N),ylab=Area held (ha), auto.key=list(blm,points=F,lines=T,title=Blm factor,cex.title=0.7, cex=0.7,corner=c(1,1)),main=Mangroves target=1573ha,layout=c(2,3)) I would like to add a horizontal line to each one of the 5 graphs with a single value, v=1573 Try using a custom panel function, something like: mypanelfn - function(x,y,...) { panel.xyplot(x=x, y=y, ...) grid.lines(c(0,1), unit(rep(1573, 2), native) } xyplot(your params, panel=mypanelfn) You can also try using llines instead of grid.lines. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ 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] Remove an object by the reference
a - 1 x - a rm(list=x) a Error: object a not found See ?rm for details. Gabor On Tue, May 13, 2008 at 05:13:41PM +0530, Shubha Vishwanath Karanth wrote: Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x. something like rm(somefunction(x))...Is this possible? Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San Jos? * Singapore * www.ambaresearch.com This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ 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] pch=. plots much faster
On Tue, 13 May 2008, Charles Plessy wrote: Dear list, I realised by chance when analysing a 1521862 × 8 matrix that plotting was much faster when using . as the argument of `pch'. Why is that surprising? Drawing a small square is rather easy compared to a circle, say. I was just wondering if there were other ways to get this speed improvement: it is otherwise quite difficult to explore such big matrices, especially given that X11 redraws the plot whenever its window is covered/uncovered by another window, or when I switch virtual desktops. That is a function of your X setup. R does ask for backing store to be used, and so it seeems your setup is not doing so. Also, the type=cairo in X11() will repaint from a backing pixmap. You might want to contemplate better ways to visualize 1.5m points. It is not clear what plot you are actually doing, but a density plot is likely to be more informative (especially a 2D pairs plot of densities), or a hexbin plot (from the BioC package or that name) or Best regards, -- Charles Plessy, Wakō, Saitama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] upperbound of C index Conf.int. greater than 1
R-users, I am bootstrapping the C Index of a model created using lrm{Design} and boot{boot}, and I get that the upperbound of the confidence interval is greater than 1. Here is my code: library(HSAUR) data(plasma) ##fit model fit.design - lrm (ESR ~ fibrinogen + globulin,data=plasma) fit.design$stats[6] C 0.8044872 ##bootstrap C Index cindex - function(formula,data,indices){ + d=data[indices,] + fit-lrm(formula,data = d) + return(fit$stats[[6]]) + } results - boot(data=w,statistic=cindex,R=500,formula = ESR ~ fibrinogen + globulin) results ORDINARY NONPARAMETRIC BOOTSTRAP Call: boot(data = plasma, statistic = cindex, R = 500, formula = ESR ~ fibrinogen + globulin) Bootstrap Statistics : original biasstd. error t1* 0.8044872 0.008834767 0.1574710 boot.ci(results,type=basic) BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS Based on 500 bootstrap replicates CALL : boot.ci(boot.out = results, type = basic) Intervals : Level Basic 95% ( 0.6090, 1.1443 ) Calculations and Intervals on Original Scale I see that the std.error is rather large and this might be the problem, but how can I explain this for publication purposes? Is such an interval acceptable? Any help would be greatly appreciated David __ 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] ggplot2: font size mismatch for pdf output
There is a bug in ggsave() for bitmap devices: it computes the width and height from 'dpi', but it fails to pass that information on to the devices, which assume 72dpi. So what it actually asked for was a 8 x 6.67 inch plot at 72dpi. 72dpi would be a better default, as not all of the many bitmap devices work correctly at other resolutions (and none did prior to R 2.7.0). Thanks for the bug report. I've fixed it by changing the default dpi to 72, and passing res = dpi to the raster devices. However, in light of the fact that most devices don't support dpi, I wonder if using units (like the raster devices) would be more appropriate. Is there any likelihood that the vector devices support will support the units argument in the future? (I also added support for the tiff device, and fixed a severe bug with postscript output) Hadley -- http://had.co.nz/ __ 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] Regular Expressions
On Tue, May 13, 2008 at 5:02 AM, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: Suppose, S=c(World_is_beautiful, one_two_three_four,My_book) I need to extract the last but one element of the strings. So, my output should look like: Ans=c(is,three,My) gsub() can do this...but wondering how do I give the regular expression As others have mentioned strsplit is probably easier in this case but it can be done with a regular expression as shown below where [^_]+ matches a any string of characters not containing _ : re - ^([^_]+_)*([^_]+)_([^_]+)$ gsub(re, \\2, S) [1] isthree My The strapply function in the gsubfn package can also be used. out below has the same value as strsplit(S, _): library(gsubfn) out - strapply(S, [^_]+) sapply(out, function(x) tail(x, 2)[1]) __ 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] R benchmarking program
Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : geMatrix is not a defined class Calls: new - getClass Execution halted __ 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] Calling C code from R...wrapping C structures
Hi everyone, I am currently trying to call some C code from R, specifically calling a function which populates a C struct. typedef struct{ // contents } Model; void test(Model *m){ // fill the struct with crap } I compile the C code into a shared library, which loads into R properly. My simple test functions work (i.e adding numbers etc) setModel - function(){ model-vector(list, 6) name(model) - c( SET THE NAMES OF THE MODEL HERE ) model } t - setModel() testcode - function(setModel){ dyn.load(Simulation.so) foo - .C(test, Model=setModel) foo } testcode(t) However I get segfaults whenever I try to access any of the variables contained in Model. So my question is: am I doing something wrong here? Is list the right data type to wrap a structure in? I cant see any documentation about wrapping structs in R. Also when I pass strings to C from R they dont seem to be passed at all? Is this a problem with R or a problem with me and if so how do I fix it? Many Thanks in advance, Nathan [[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] Bubble plot pie chart map
Hello, I am currently trying to show the abundance of two species of zooplankton within the North Sea as pie chart bubble plots. I followed Werner Wernersen's advice in R help (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48644.html) and used Paul Murrell's paper Integrating Grid Graphics Output with Base Graphics Output (in R News) to try and do this (using the gridBase package). It generally works well, except for when I try and put in the map of the coastline and the points with no zooplankton present (0 values of both plankton species). The following error comes up: Error in gridPLT() : Figure region too small and/or viewport too large and other errors along those lines. Can anyone suggest either what I'm doing wrong, or some other way to plot this? Many thanks Deborah Deborah Davidson PhD student School of Biological Sciences University of Aberdeen Aberdeen, AB24 2TZ Scotland Tel: +44 (0)1224 274106 Email: [EMAIL PROTECTED] The University of Aberdeen is a charity registered in Scotland, No SC013683. __ 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] Likelihood between observed and predicted response
Hi, I've two fitted models, one binomial model with presence-absence data that predicts probability of presence and one gaussian model (normal or log-normal abundances). I would like to evaluate these models not on their capability of adjustment but on their capability of prediction by calculating the (log)likelihood between predicted and observed values for each type of model. I found the following formula for Bernouilli model : -2 log lik = -2 sum (y*log phat + (1-y)*log(1-phat) ), with phat is the probaility (between 0 and 1) and y is the observed values (0 or 1). 1) Is anybody can tell me if this formula is statistically true? 2) Can someone tell me what is the formula of the likelihood between observed and predicted values for a gaussian model ? Thanks -- Christophe LOOTS PhD student - Hydrobiological modelling of fish habitats Sea Fisheries Laboratory - IFREMER Boulogne sur Mer 150, Quai Gambetta. BP 699 62321 Boulogne sur Mer- FRANCE Tél : +33(0)3 21 99 56 86 Fax : +33(0)3 21 99 56 01 E-mail : [EMAIL PROTECTED] http://www.ifremer.fr/drvboulogne/labo/equipe.htm __ 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] pch=. plots much faster
Prof Brian Ripley: matrices, especially given that X11 redraws the plot whenever its window is covered/uncovered by another window, or when I switch virtual desktops. That is a function of your X setup. R does ask for backing store to be used, and so it seeems your setup is not doing so. I believe this is a common problem. I have observed it on all systems and R versions I've used. On my Fedora 8 system with R 2.7.0 Patched, the following causes complete repainting every time you I slightly move a window in front of the graphics window: X11(type=Xlib); n=10^5; plot(rnorm(n),rnorm(n)) Using cairo, the backing pixmap is used (but cairo is extremely slow in plotting 10^5 points, so that doesn't help much :-/ ). -- Karl Ove Hufthammer __ 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] Compare columns
Hi Suhaila, Is this what you want? A= V1V2 A 1 A 2 A 3 A 4 B 1 B 4 C 1 C 3 D 4 B=V1V2 process1 1 process2 2 process3 3 process4 4 A=read.table(textConnection(A),header=TRUE) B=read.table(textConnection(B),header=TRUE) A$V3-ifelse(A$V2%in%B$V2,paste('process',A$V2,sep=)) A V1V2 V3 A 1 process1 A 2 process2 A 3 process3 A 4 process4 B 1 process1 B 4 process4 C 1 process1 C 3 process3 D 4 process4 HTH, Jorge On Tue, May 13, 2008 at 3:08 AM, Suhaila Zainudin [EMAIL PROTECTED] wrote: Dear R-users, I have the following 2 files; A V1V2 A 1 A 2 A 3 A 4 B 1 B 4 C 1 C 3 D 4 B V1V2 process1 1 process2 2 process3 3 process4 4 I want to get this output C V1V2 V3 A 1 process1 A 2 process2 A 3 process3 A 4 process4 B 1 process1 B 4 process4 C 1 process1 C 3 process3 D 4 process4 I want to compare A$V2 with B$V2, if it is the same, then append B$V1 to A. Any tips are highly appreciated. TQVM! -- Suhaila Zainudin PhD Candidate Universiti Teknologi Malaysia [[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. [[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.
Re: [R] Simple regex problem
Thanks to Gabor Grothendieck Ted Harding. both solutions work very nicely. --- Gabor Grothendieck [EMAIL PROTECTED] wrote: Try this (no gsub required): as.chron(as.Date(xx, %b %d, %Y)) On Sat, May 10, 2008 at 12:49 PM, John Kane [EMAIL PROTECTED] wrote: I am cleaning up some character data to convert to dates using chron. The regex that I am using work fine but there should be a better way to do this. Can anyone suggest a cleaner bit of code than the gsub, sub approach? Thanks #Test Run on dates. xx - c(May 1, 2007, May 2, 2007, May 3, 2007, May 4, 2007, May 5, 2007, May 6, 2007, May 7, 2007, May 8, 2007, May 9, 2007, May 10, 2007, May 11, 2007, May 12, 2007) yy - gsub( +, /, xx) ; yy zz - sub(,, , yy) ; zz library(chron) ttdates - chron(zz, format = c(dates = mon/d/y)) __ 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. __ [[elided Yahoo spam]] __ 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 can one make stepAIC and lme
Hi again, I've tried using with() inside my function in the following manner: library(nlme) library(MASS) PredRes-function(D1) { with(D1, {lmemod-lme(distance~age*Sex, random=~1|Subject, data=subset(D1,age!=14), method=ML) themod-stepAIC(lmemod,dir=both) summary(themod) prs=predict(themod,newdata=subset(D1,age==14)) obs-subset(D1,age==14)$distance print(mean(obs-prs)) } ) } but the error message still reads: PredRes(Orthodont) Start: AIC=345.12 distance ~ age * Sex Error in subset(D1, age != 14) : object D1 not found Does this mean that the only option for making a function of this type work is to use the - operator? -- Regards Jorunn 2008/5/9 Prof Brian Ripley [EMAIL PROTECTED]: It's a known scoping issue in lme -- you are doing this from a function. Make sure your dataset is visible -- e.g. use with(). On Fri, 9 May 2008, Jorunn Slagstad wrote: Dear R-help I'm working on a large dataset which I have divided into 20 subsets based on similar features. Each subset consists of observations from different locations and I wish to use the location as a random effect. For each group I want to select regressors by a stepwise procedure and include a random effect on the intercept. I use stepAIC() and lme(). (The lmer()-function doesn't work with the stepAIC()-function.) Since I have many groups, and I wish to do the same thing for each group, I have constructed a function which takes the dataset as input variable and gives a prediction result (here mean absolute error) as output. This is an example using the Orthodont dataset: library(MASS) library(nlme) PredRes-function(D1) { lmemod=lme(distance~age*Sex, random=~1|Subject, data=subset(D1,age!=14),method=ML) themod=stepAIC(lmemod,dir=both) prs=predict(themod,newdata=subset(D1,age==14)) obs-subset(D1,age==14)$distance print(mean(obs-prs)) } Using this function with D1=Orthodont gives: PredRes(Orthodont) Start: AIC=345.12 distance ~ age * Sex Error in subset(D1, age != 14) : object D1 not found The code works when I take Orthodont in directly: lmemod=lme(distance~age*Sex, random=~1|Subject, data=subset(Orthodont,age!=14),method=ML) themod=stepAIC(lmemod,dir=both) Start: AIC=345.12 distance ~ age * Sex DfAIC - age:Sex 1 344.49 none 345.12 Step: AIC=344.49 distance ~ age + Sex DfAIC none 344.49 + age:Sex 1 345.12 - Sex 1 348.70 - age 1 371.77 prs=predict(themod,newdata=subset(Orthodont,age==14)) obs-subset(Orthodont,age==14)$distance print(mean(obs-prs)) [1] 0.2962963 How can I make this code work with dataset av input variable in a function? I'm using R version: Version: platform = x86_64-unknown-linux-gnu arch = x86_64 os = linux-gnu system = x86_64, linux-gnu status = major = 2 minor = 6.0 year = 2007 month = 10 day = 03 svn rev = 43063 language = R version.string = R version 2.6.0 (2007-10-03) Locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C Search Path: .GlobalEnv, package:MASS, package:nlme, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base By the way the R version 2.7.0 Patched (2008-05-08 r45647) gives the same error message. -- Regards Jorunn Slagstad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with odfWeave: Unescaped '' not allowed in attributes values
Dear R users, I am having a problem with odfWeave: when I run odfWeave('notes.odt', 'notes_out.odt') I get a bunch of errors that start with Unescaped '' not allowed in attributes values in post-processing: snip ... 'content_1.xml' has been Sweaved Removing content.xml Post-processing the contents Unescaped '' not allowed in attributes values attributes construct error error parsing attribute name attributes construct error xmlParseStartTag: problem parsing attributes Couldn't find end of Start Tag text:list-level-style-bullet line 2 error parsing attribute name attributes construct error xmlParseStartTag: problem parsing attributes Couldn't find end of Start Tag U line 2 Opening and ending tag mismatch: text:list-style line 2 and text:list-level-style-bullet Unescaped '' not allowed in attributes values ... /snip I cannot determine the cause of this. The error seems to come and go erratically, as I experiment with deleting chunks of R code one by one and pasting them back, i.e. no single chunk seems to be responsible. I am using the current version of odfWeave (0.7.5). The thing is, the file processed just fine in a previous version (0.7.3). Does anyone have any suggestion how to deal with this? I am now kind of locked since I cannot reproduce a report I was working on... I also tried to downgrade to the previous working odfWeave version, however I could not the windows binary for anything other than the latest version 0.7.5. I attempted to install from source by installing Rtools (Rtools28.exe), however when I try to install odfWeave 0.7.3 (re-zipped from tar.gz) I get: install.packages(pkgs=c('C:/Archive/R/packages/odfWeave.zip', 'C:/Archive/R/packages/XML.zip'), repos=NULL) updating HTML package descriptions library(odfWeave) Error in library(odfWeave) : 'odfWeave' is not a valid package -- installed 2.0.0? What am I doing wrong? Is it possible to downgrade in this way? Any other suggestions how to overcome this problem would be very much appreciated. Thank you, Aleksey [[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.
Re: [R] R benchmarking program
Hello, I did this bechmark test. Perhaps is it a good oppotunity to rewrite it and make it compatible with R 2.7.0, David? Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Baker D.J. wrote: Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : geMatrix is not a defined class Calls: new - getClass Execution halted __ 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] Random number generation
Greg Snow wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Esmail Bonakdarian Sent: Sunday, May 11, 2008 7:25 AM To: Prof Brian Ripley Cc: [EMAIL PROTECTED] Subject: Re: [R] Random number generation [snip] What I read doesn't seem to be incorrect however (it may even have been an archived message here), the *language* itself does not seem to support block *comments*. Using conditional constructs, or an IDE/editor to achieve similar results is a work around - but not the same. I don't mean to nitpick, but as a computer scientist I see this as different :-) I am not a computer scientist, so correct me if I am wrong, but from what I remember (and a quick glance at my copy of Kernighan Ritchie), the C *language* itself does not support block *comments*, rather the preproccessor Hi there, Yes, while that may be true, many other languages that don't use an explicit pre-processor mechanism (though internally will go through a similar process) do support block comments. It's a moot point anyway, since when you compile a C program the preprocessor also runs (just like the linker etc) unless you specifically ask for something differently via command line switches. As far as the programmer is concerned the semantics are those of a language that provides block comments with the simple use of /* */ , and not dependent on if-statements or editor/IDE tricks. Since R is optimized for interactive use rather than compilation, running everything through a preproccessor is not really an option. However as an additional work around My use then may be not typical since I am trying to write scripts in R and only use R directly to try out functions/language constructs. you could always run your R scripts through the C preproccessor and have it strip the block comments for you. Too much work, call me old school, but I like the computer do work for me, rather than the other way around :-) Given the complexity of implementing block commenting (even deciding on the syntax) and the ease of current work arounds, the cost benefit ratio probably puts this very near the bottom of the priority list. I couldn't possibly offer an opinion on that .. I'll happily defer to you and the other experts here for this. Cheers, Esmail __ 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] R benchmarking program
Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : geMatrix is not a defined class Calls: new - getClass Execution halted __ 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] Converting qqplot2 qplot() to grammar?
On Mon, May 12, 2008 at 3:31 PM, B. Bogart [EMAIL PROTECTED] wrote: Hello all, I've been using the following qplot command: qplot(pixX,pixY, data=som, geom=tile, fill=rgb) + scale_fill_identity() + opts(aspect.ratio = .75) + facet_grid(unitX ~ unitY) Now I would like to convert it into the explicit ggplot grammar, so I can remove the extras: axes, labels, background, borders, facet labels, and extra white-space around the plot. (If anyone has suggestions on removing these please let me know) You're missing one thing. You want: layer(data = somdf, geom = tile, aes(fill=rgb)) (i.e. there's an aes function wrapped around the fill). I'd probably use a few more of the built in defaults to get: geom_tile(aes(fill = rgb)) The other issue I'm having is that the above seems to create multiple plots, another, apparently identical, plot gets drawn after I call dev.off(). I have no idea why this would be so. Could you provide a fuller description of what you're trying to do? Setting name and breaks to seems like a hack to get rid of the axis stuff, is there a better way? Not at the moment. Oh, and I can't find documentation for opts() on the ggplot2 website, where is it available? Just in R at the moment - see ?opts. Hadley -- http://had.co.nz/ __ 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 number generation
Esmail Bonakdarian: you could always run your R scripts through the C preproccessor and have it strip the block comments for you. Too much work, call me old school, but I like the computer do work for me, rather than the other way around Most editors (and every editor worth using) supports block-commenting via a keyboard shortcut. For instance, in KDE-based editors, such as Kwrite, Kate and RKward (the latter is a KDE-based GUI for R), you can just select the lines you want to comment and press 'Ctrl + D' to comment them, or 'Shift + Ctrl + D' to uncomment them. -- Karl Ove Hufthammer __ 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] A Very Simple Question
Hi Rusers! I am ashed of asking such a simple question. X-matrix(rnorm(24), 4) X0-apply(X,2,mean) What I want is a matrix which consists of colums such as X[,1]--X0[1]. X-X0 doesn't work. Perhaps apply function? Thanks in advance. Yukihiro Ishii 2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan +81463691922 __ 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] Calling C code from R...wrapping C structures
On 5/13/2008 7:51 AM, Nathan Harmston wrote: Hi everyone, I am currently trying to call some C code from R, specifically calling a function which populates a C struct. typedef struct{ // contents } Model; void test(Model *m){ // fill the struct with crap } I compile the C code into a shared library, which loads into R properly. My simple test functions work (i.e adding numbers etc) setModel - function(){ model-vector(list, 6) name(model) - c( SET THE NAMES OF THE MODEL HERE ) model } t - setModel() testcode - function(setModel){ dyn.load(Simulation.so) foo - .C(test, Model=setModel) foo } testcode(t) However I get segfaults whenever I try to access any of the variables contained in Model. So my question is: am I doing something wrong here? Is list the right data type to wrap a structure in? I cant see any documentation about wrapping structs in R. Also when I pass strings to C from R they dont seem to be passed at all? Is this a problem with R or a problem with me and if so how do I fix it? It is a problem in your C code. The .C interface doesn't know about the C declaration of the Model structure; it can only pass things it knows about. So your C function test() should have its header set to accept what gets passed to it. In your case, that's a list, so your C function receives an array of pointers to SEXP structures; not the easiest things to work with. Most people using .C() pass in simple vectors (numeric, integer, etc.), and use the .Call() interface if they really need R internals. Duncan Murdoch Many Thanks in advance, Nathan [[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] what kind of residuals are the ones calculated in coxph?
Hi Karen, those are martingale residuals. You don't have to be a Guru to find it out. Did you check ?coxph Under values it tells you an object of class coxph. See coxph.object for details. So you can ask for help for coxph.object ?coxph.object and then you will see among the components: residuals the martingale residuals. I hope this helps, Roland Chang Liu wrote: Hi Gurus: In the coxph() objects in Survival package, there is an attribute called residuals. Usually, there are several kinds for censored survival data. I can't seem to find in the documentation as to which one this is calculating. Anyone knows? Karen _ [[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] poisson regression with robust error variance ('eyestudy
At 00:56 09/05/2008, Ted Harding wrote: I'd like to thank Paul Johnson and Achim Zeileis heartily for their thorough and accurate responses to my query. I think that the details og how to use the procedure, and of its variants, which they have sent to the list should be definitive -- and very helpfully usable -- for folks like myself who may in future grope in the archives concerning this question. And, just to confirm, it all worked perfectly for me in the end. There is an article available online (by a frequent contributor to this list) which addresses the topic of estimating relative risk in multivariable models. I found it very helpful. http://www.bepress.com/uwbiostat/paper293/ Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 09-May-08 Time: 00:56:14 -- XFMail -- Michael Dewey http://www.aghmed.fsnet.co.uk __ 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] Plotting Frequency Distribution in R
Hi, How can plot a frequency distribution curve for the following data. V1 V2 1 1 160.54% 2 1 201.59% 3 1 18.45% 4 1 179.03% 5 1 274.37% 6 1 0.00% 7 1 24.52% 8 1 39.17% 9 3 43.72% 10 1 53.06% 11 1 64.97% 12 1 79.84% 13 1 98.08% 14 1 115.32% 15 1 127.96% 16 1 155.38% 17 1 157.25% 18 1 193.17% 19 1 51.53% 20 15 99.32% 21 1 106.86% 22 1 219.44% Where V1 is count for each V2 value. for example there are 3 entries for 43.72% value. Thanks in advance for the help. Regards, Sachin [[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.
Re: [R] array dimension changes with assignment
On 5/13/2008 12:47 AM, Knut M. Wittkowski wrote: Why does the assignment of a 3178x93 object to another 3178x93 object remove the dimension attribute? Your example is not reproducible. When I make one that is reproducible, I don't see the error: GT - array(dim = c(6,3178,93)) dim(GT) [1]6 3178 93 GT[1,,] - array(dim=c(3178,93)) dim(GT) [1]6 3178 93 (This was done in R 2.7.0.) So I'd suggest that you try to make the example reproducible, and you'll likely discover that something else you did caused the loss of dimension. Duncan Murdoch GT - array(dim = c(6,nrow(InData),ncol(InSNPs))) dim(GT) [1]6 3178 93 SNP1 - InSNPs[InData[,C1],] dim(SNP1) [1] 3178 93 SNP2 - InSNPs[InData[,C2],] dim(SNP2) [1] 3178 93 dim(pmin(SNP1,SNP2)) [1] 3178 93 GT[1,,] - pmin(SNP1,SNP2) dim(GT) NULL# why?? GT[2,,] - pmax(SNP1,SNP2) Error in GT[2, , ] - pmax(SNP1, SNP2) : incorrect number of subscripts Knut M. Wittkowski, PhD,DSc Sr Research Associate,The Rockefeller University Biometrician,The Rockefeller University Hospital Director, Biostatistics/Epidemiology/Research Design Center for Clinical and Translational Science (CCTS) apl. Professor, Eberhard-Karls-University, Tübingen 1230 York Ave #121B, Box 322, New York, NY 10021, US Tel: +1 (212) 327-7175, Fax: +1 (212) 327-8450 [EMAIL PROTECTED], www.rockefeller.edu/ccts/rdbs [[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] R benchmarking program
Hello Philippe, Thank for your reply. I agree that this is an interesting project. As I say we have just started to buy Intel quad core machines after years of offered a service on AMD machines. I recompiled R with the GoTo BLAS, and did some basic tests..things like matrix cross products, solve, svd, etc, etc. The speed up on the Intels was stunning vs our AMD machines. Previously we have always worked with R + ACML BLAS on the AMDs (perhaps we have missing out on GoTo performance). It would be great to bring the benchmarking programme up to date, and run it. My knowledge of R is basic -- I am a Unix administrator. Would you be able to spend some time working on the program please or do you know any colleagues who would be keen to put some effort in to this? Regards -- David. -Original Message- From: Philippe Grosjean [mailto:[EMAIL PROTECTED] Sent: 13 May 2008 15:10 To: Baker D.J. Cc: r-help@r-project.org Subject: Re: [R] R benchmarking program Hello, I did this bechmark test. Perhaps is it a good oppotunity to rewrite it and make it compatible with R 2.7.0, David? Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Baker D.J. wrote: Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : geMatrix is not a defined class Calls: new - getClass Execution halted __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] details for help needed please
thank you very much Mr john Kane ,Mr Jorge Ivan Velez i first do an cpa method for my LogNeperien (data hydrology ) (30years of inflows) for 12 months to be sure that my residuals normality will be true in order to reconstitute the 30years of the data with pca in an other way choice of number of PC and simulate residuals for each month and also i must generate 30years in future i need this for an optimization model __ [[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.
Re: [R] A Very Simple Question
On 5/13/2008 10:27 AM, Yukihiro Ishii wrote: Hi Rusers! I am ashed of asking such a simple question. X-matrix(rnorm(24), 4) X0-apply(X,2,mean) What I want is a matrix which consists of colums such as X[,1]--X0[1]. X-X0 doesn't work. Perhaps apply function? scale(X, scale=FALSE) ?scale Thanks in advance. Yukihiro Ishii 2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan +81463691922 __ 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. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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 Very Simple Question
?sweep -Original Message- From: Yukihiro Ishii [EMAIL PROTECTED] To: r-help@r-project.org r-help@r-project.org Sent: 5/13/08 8:30 AM Subject: [R] A Very Simple Question Hi Rusers! I am ashed of asking such a simple question. X-matrix(rnorm(24), 4) X0-apply(X,2,mean) What I want is a matrix which consists of colums such as X[,1]--X0[1]. X-X0 doesn't work. Perhaps apply function? Thanks in advance. Yukihiro Ishii 2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan +81463691922 __ 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] How can one make stepAIC and lme
You are using subset() as a function -- lme has a subset argument, and subset() has non-standard semantics. The dataset you are using is subset(D1,age!=14): it is that which you need to make sure is visible. You didn't make D1 visible, just its columns. On Tue, 13 May 2008, Jorunn Slagstad wrote: Hi again, I've tried using with() inside my function in the following manner: library(nlme) library(MASS) PredRes-function(D1) { with(D1, {lmemod-lme(distance~age*Sex, random=~1|Subject, data=subset(D1,age!=14), method=ML) themod-stepAIC(lmemod,dir=both) summary(themod) prs=predict(themod,newdata=subset(D1,age==14)) obs-subset(D1,age==14)$distance print(mean(obs-prs)) } ) } but the error message still reads: PredRes(Orthodont) Start: AIC=345.12 distance ~ age * Sex Error in subset(D1, age != 14) : object D1 not found Does this mean that the only option for making a function of this type work is to use the - operator? -- Regards Jorunn 2008/5/9 Prof Brian Ripley [EMAIL PROTECTED]: It's a known scoping issue in lme -- you are doing this from a function. Make sure your dataset is visible -- e.g. use with(). On Fri, 9 May 2008, Jorunn Slagstad wrote: Dear R-help I'm working on a large dataset which I have divided into 20 subsets based on similar features. Each subset consists of observations from different locations and I wish to use the location as a random effect. For each group I want to select regressors by a stepwise procedure and include a random effect on the intercept. I use stepAIC() and lme(). (The lmer()-function doesn't work with the stepAIC()-function.) Since I have many groups, and I wish to do the same thing for each group, I have constructed a function which takes the dataset as input variable and gives a prediction result (here mean absolute error) as output. This is an example using the Orthodont dataset: library(MASS) library(nlme) PredRes-function(D1) { lmemod=lme(distance~age*Sex, random=~1|Subject, data=subset(D1,age!=14),method=ML) themod=stepAIC(lmemod,dir=both) prs=predict(themod,newdata=subset(D1,age==14)) obs-subset(D1,age==14)$distance print(mean(obs-prs)) } Using this function with D1=Orthodont gives: PredRes(Orthodont) Start: AIC=345.12 distance ~ age * Sex Error in subset(D1, age != 14) : object D1 not found The code works when I take Orthodont in directly: lmemod=lme(distance~age*Sex, random=~1|Subject, data=subset(Orthodont,age!=14),method=ML) themod=stepAIC(lmemod,dir=both) Start: AIC=345.12 distance ~ age * Sex DfAIC - age:Sex 1 344.49 none 345.12 Step: AIC=344.49 distance ~ age + Sex DfAIC none 344.49 + age:Sex 1 345.12 - Sex 1 348.70 - age 1 371.77 prs=predict(themod,newdata=subset(Orthodont,age==14)) obs-subset(Orthodont,age==14)$distance print(mean(obs-prs)) [1] 0.2962963 How can I make this code work with dataset av input variable in a function? I'm using R version: Version: platform = x86_64-unknown-linux-gnu arch = x86_64 os = linux-gnu system = x86_64, linux-gnu status = major = 2 minor = 6.0 year = 2007 month = 10 day = 03 svn rev = 43063 language = R version.string = R version 2.6.0 (2007-10-03) Locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C Search Path: .GlobalEnv, package:MASS, package:nlme, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base By the way the R version 2.7.0 Patched (2008-05-08 r45647) gives the same error message. -- Regards Jorunn Slagstad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org
Re: [R] pch=. plots much faster
On Tue, 13 May 2008, Karl Ove Hufthammer wrote: Prof Brian Ripley: matrices, especially given that X11 redraws the plot whenever its window is covered/uncovered by another window, or when I switch virtual desktops. That is a function of your X setup. R does ask for backing store to be used, and so it seeems your setup is not doing so. I believe this is a common problem. I have observed it on all systems and R versions I've used. Well, I've observed it with some window mangers in F8, but I've also seen other systems where a backing store was used. On my Fedora 8 system with R 2.7.0 Patched, the following causes complete repainting every time you I slightly move a window in front of the graphics window: X11(type=Xlib); n=10^5; plot(rnorm(n),rnorm(n)) Using cairo, the backing pixmap is used (but cairo is extremely slow in plotting 10^5 points, so that doesn't help much :-/ ). It does if you use a more suitable plot of 10^5 points. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R benchmarking program
The best benchmark is a calculation you really want to do. For most people matrix algebra is an insignificant proportion of what they do in R. A few need complex matrix arithmetic (where compilers and BLAS differ a lot in speed). So there is no universal benchmark. Also, the reference BLAS supplied with R is usually more accurate than the optimized BLAS, and many users will prefer accuracy to speed. There are packages that will not complete their tests with an optimized BLAS. On Tue, 13 May 2008, Baker D.J. wrote: Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I do wonder why -- as the manual says, the easiest and most efficient way to do this is to link the Goto BLAS to R_HOME/lib/libRblas.so (assuming this is Linux). No rebuilding is needed. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : geMatrix is not a defined class Calls: new - getClass Execution halted __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] calculating confidence intervals for the turnbull estimate
Does anyone know of software to calculate confidence intervals for the non-parametric estimate of the survival distribution when data are interval censored, ie, for the Turnbull estimate? Thanks, Soyeon __ 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 Very Simple Question
See ?scale HTH, Giovanni Date: Tue, 13 May 2008 23:27:59 +0900 From: Yukihiro Ishii [EMAIL PROTECTED] Sender: [EMAIL PROTECTED] Precedence: list DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=ybb20050223; d=ybb.ne.jp; Hi Rusers! I am ashed of asking such a simple question. X-matrix(rnorm(24), 4) X0-apply(X,2,mean) What I want is a matrix which consists of colums such as X[,1]--X0[1]. X-X0 doesn't work. Perhaps apply function? Thanks in advance. Yukihiro Ishii 2-3-28 Tsurumakiminami, Hadano, 250-0002 Japan +81463691922 __ 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. -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] hessian in constrained optimization (constrOptim)
See nlme::fdHess HTH, Giovanni Date: Mon, 12 May 2008 18:18:57 +0100 From: Carlo Fezzi [EMAIL PROTECTED] Sender: [EMAIL PROTECTED] Precedence: list Thread-index: Aci0VENEgf84jUE7T0mEusn0OTj4AA== Dear helpers, I am using the function constrOptim to estimate a model with ML with an inequality constraint using the option method='Nelder-Mead'. When I specify the option: hessian = TRUE I obtain the response: Error in f(theta, ...) : unused argument(s) (hessian = TRUE) I guess the function constrOptim does not allow this argument which, on the other hand, is allowed in optim. I would be extremely grateful if anybody could suggest a way I could use to I obtain the values of the hessian matrix... Many thanks, Carlo ** Carlo Fezzi Senior Research Associate Centre for Social Research on the Global Environment (CSERGE) Department of Environmental Sciences University of East Anglia Norwich (UK) NR2 7TJ Telephone: +44(0)1603 591408 Fax: +44(0)1603 593739 __ 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. -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ 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] Missing coefficient on a glm object
On Tue, 13 May 2008, Diego Cesar wrote: Hello guys, i looked over the archive files and found nothing about this kind of error. It's a feature. I have a database of 33 elements described in 8 variables, i'm using the Leave-One-Out iterative process to take one of the elements to be the test element and make a regression with the other 32 and then I try to predict the clas of the element out. I'm using this call as a part of a Leave-One-Out experiment: glmresult - glm(Y ~ x1+x2+x3+x4+x5+x6+x7+x8, family=binomial, control=glm.control(epsilon = 1e-8, maxit = 100, trace = FALSE)) but when i look at the coefficients with: coef(glmresult) Everything goes well (i get all the coefficients) until the 27th element which gets a NA as a coefficient to variable x8 The vectors Y, x1,x2,x3,x4,x5,x6,x7,x8 have the same length and there isn't any missing data. don't know what to do right now as i already reviewed the code a lot and i'm starting to think the problem is in the data. Correct, collinearity aka extrinsic aliasing. x8 is not linearly independent of (1, x1 ... x7) on your dataset and so is dropped from the model. Diego Cesar [[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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] poisson regression with robust error variance ('eyestud
On 13-May-08 14:25:37, Michael Dewey wrote: At 00:56 09/05/2008, Ted Harding wrote: I'd like to thank Paul Johnson and Achim Zeileis heartily for their thorough and accurate responses to my query. I think that the details og how to use the procedure, and of its variants, which they have sent to the list should be definitive -- and very helpfully usable -- for folks like myself who may in future grope in the archives concerning this question. And, just to confirm, it all worked perfectly for me in the end. There is an article available online (by a frequent contributor to this list) which addresses the topic of estimating relative risk in multivariable models. I found it very helpful. http://www.bepress.com/uwbiostat/paper293/ Thanks, Michael. That is indeed an excellent survey and reference! Ted. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 09-May-08 Time: 00:56:14 -- XFMail -- Michael Dewey http://www.aghmed.fsnet.co.uk __ 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. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 13-May-08 Time: 17:43:10 -- XFMail -- __ 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] RE : Re: details for help needed please
yes and this with other software like hydrolab(hydrology) will take big time and it is a very urgent work . many thanks Jorge Ivan Velez [EMAIL PROTECTED] a écrit : Hi Tebbi, Does it mean that you want to simulate your PCA analysis? Thanks, Jorge On Tue, May 13, 2008 at 11:20 AM, TEBBI FATIMA [EMAIL PROTECTED] wrote: thank you very much Mr john Kane ,Mr Jorge Ivan Velez i first do an cpa method for my LogNeperien (data hydrology ) (30years of inflows) for 12 months to be sure that my residuals normality will be true in order to reconstitute the 30years of the data with pca in an other way choice of number of PC and simulate residuals for each month and also i must generate 30years in future i need this for an optimization model __ [[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. __ [[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] Missing coefficient on a glm object
Hello guys, i looked over the archive files and found nothing about this kind of error. I have a database of 33 elements described in 8 variables, i'm using the Leave-One-Out iterative process to take one of the elements to be the test element and make a regression with the other 32 and then I try to predict the clas of the element out. I'm using this call as a part of a Leave-One-Out experiment: glmresult - glm(Y ~ x1+x2+x3+x4+x5+x6+x7+x8, family=binomial, control=glm.control(epsilon = 1e-8, maxit = 100, trace = FALSE)) but when i look at the coefficients with: coef(glmresult) Everything goes well (i get all the coefficients) until the 27th element which gets a NA as a coefficient to variable x8 The vectors Y, x1,x2,x3,x4,x5,x6,x7,x8 have the same length and there isn't any missing data. don't know what to do right now as i already reviewed the code a lot and i'm starting to think the problem is in the data. Diego Cesar [[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] 3dscatterplot -different colors for different factors of the same variable
Dear R users, I was trying to do a 3d scatterplot for the following set of datas: obj time X Y 1 yellow 333 388.7 492.3 2 yellow 567 388.7 492.3 3 green 621 135.5 371.7 4 green 1039 135.5 371.7 5 red 1373 744.1 205.0 6 red 1763 744.1 205.0 The points should be drew in the plot taking information of time, X and Y. The colors of these points should be assigned according to the information contained in variable obj. What I did but it didn't work out is: 1) Plotting only one set of points (the green one) s3d-scatterplot3d(greenpts[,3],greenpts[,2],greenpts[,4],type=p,scale.y=4, angle=10, color=green) and try to overlay the others (as you normally would do with plot): s3d$points3d(redpts[,3],redpts[,2],redpts[,4],col=red,type=o) s3d$points3d(yellowpts[,3],yellowpts[,2],yellowpts[,4], col=yellow,type=o) s3d$points3d(bluepts[,3],bluepts[,2],bluepts[,4],col=blue,type=o) s3d$points3d(pinkpts[,3],pinkpts[,2],pinkpts[,4],col=pink,type=o) R has plotted only the first set and wasn't able to overlay other points. 2) I have generated a for loop that should have taken points information ,arranged into a list object, plotting them one by one. - listpoints = list(X,Y,time) -color-rep(black,26) ##solution found in one of the discussion around scatterplot color[mat1$obj==green]-green color[mat1$obj==yellow]-yellow color[mat1$obj==red]-red color[mat1$obj==pink]-pink color[mat1$obj==blue]-blue for (i in 1:26) points3d(listpoints[i],type=1, col=color[i]) Also this way didn't work out. Do you have any solution? Many thanks Moreno P.S. I have tried also points3d(rgl) trying to follow an explanation given in the forum but i haven't understood how to set the function. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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] Problem with odfWeave: Unescaped '' not allowed in attributes values
Aleksey, I am using the current version of odfWeave (0.7.5). The thing is, the file processed just fine in a previous version (0.7.3). Does anyone have any suggestion how to deal with this? I am now kind of locked since I cannot reproduce a report I was working on... What version of the XML package are you using? What version of R etc? There have been some changes to the XML package lately where encodings are handled differently. This affects you since OO (and other word processors) sometimes substitute smart quotes for regular quotes. For example: topepo instead of topepo (some dashes also get converted to long dashes) These characters will cause the R parser to choke. I had previously coded around this, but interactions between odfWeave and XML are subverting those error traps (but I it still works on Linux and OS X, depending on your default encoding). I'm working on a fix that will accomplish the same thing so you won't have to deal with these characters (as before) Try searching through your to code chunks and Sexpr in your document for these characters and convert them to their usual analogs. Most applications with smart quotes allow you to turn them off. Also, it is generally better to contact the package maintainer in situations like these. If you still have issues after changing the characters, please let me know. Max __ 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] ARCH model
I have an ARCH model like this: Delta y = y_{t+1} - t_t = k (theta - y_t) Delta t + v_t N(0,1) sqrt(Delta t) where v_t^2 = a_0 + a_1 (y_{t-1} - E[y_{t-1}])^2 Is there any R function that, given a series y_i, determines k, theta, a_0 and a_1 by maximum likelihood? I tried to use garch from tseries, but didn't understant how the output from its summary relate to the above quantities. Alberto Monteiro __ 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 number generation
-Original Message- From: Esmail Bonakdarian [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 13, 2008 8:13 AM To: Greg Snow Cc: Prof Brian Ripley; [EMAIL PROTECTED] Subject: Re: [R] Random number generation Greg Snow wrote: -Original Message- [snip] you could always run your R scripts through the C preproccessor and have it strip the block comments for you. Too much work, call me old school, but I like the computer do work for me, rather than the other way around :-) So, have the computer do the work. Here is a simple function that tells the computer to do the work: cppsource - function(file) { tmp - paste(tempfile(), '.R', sep='') system(paste('cpp',file,tmp)) source(tmp) unlink(tmp) } Now, instead of doing source('myfile.R') do cppsource('myfile.R') and it will automatically do the preproccing to remove the c-style comments (assuming that cpp is on your path, etc.). If typing the extra 3 characters is too much work, then just name it something else. Or if you just want to strip the comments in R and don't want to use the c preprocessor then the function: cssource - function(file) { tmp - readLines(file) tmp2 - paste(tmp, collapse='\n') tmp3 - gsub('(?s)/\\*.*?\\*/','',tmp2,perl=TRUE) source(textConnection(tmp3)) } Will do that (it will not deal with nested comments or some other special cases, but both the above functions worked for my quick test case). Given the complexity of implementing block commenting (even deciding on the syntax) and the ease of current work arounds, the cost benefit ratio probably puts this very near the bottom of the priority list. I couldn't possibly offer an opinion on that .. I'll happily defer to you and the other experts here for this. I am not really an expert on this. I just remember being bitten when writing C and trying to comment out a section of code that already had a comment in it. I would rather have the R core team spending their time on their current priorities than even get involved in a discussion of whether block comments should be able to be nested or not. You now have at least 4 possible work arounds, hopefully one of them is satifactory, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 __ 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 number generation
On 5/13/2008 1:38 PM, Greg Snow wrote: -Original Message- From: Esmail Bonakdarian [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 13, 2008 8:13 AM To: Greg Snow Cc: Prof Brian Ripley; [EMAIL PROTECTED] Subject: Re: [R] Random number generation Greg Snow wrote: -Original Message- [snip] you could always run your R scripts through the C preproccessor and have it strip the block comments for you. Too much work, call me old school, but I like the computer do work for me, rather than the other way around :-) So, have the computer do the work. Here is a simple function that tells the computer to do the work: cppsource - function(file) { tmp - paste(tempfile(), '.R', sep='') system(paste('cpp',file,tmp)) source(tmp) unlink(tmp) } Now, instead of doing source('myfile.R') do cppsource('myfile.R') and it will automatically do the preproccing to remove the c-style comments (assuming that cpp is on your path, etc.). If typing the extra 3 characters is too much work, then just name it something else. Or if you just want to strip the comments in R and don't want to use the c preprocessor then the function: cssource - function(file) { tmp - readLines(file) tmp2 - paste(tmp, collapse='\n') tmp3 - gsub('(?s)/\\*.*?\\*/','',tmp2,perl=TRUE) source(textConnection(tmp3)) } Will do that (it will not deal with nested comments or some other special cases, but both the above functions worked for my quick test case). One problem with this idea is that it makes the very helpful syntax error messages from source() less useful: cppsource('test.R') Error in source(tmp) : c:\temp\Rtmpmyoc5a\file678418be.R: unexpected symbol at 8: 9: if (y 1:2 cat Duncan Murdoch Given the complexity of implementing block commenting (even deciding on the syntax) and the ease of current work arounds, the cost benefit ratio probably puts this very near the bottom of the priority list. I couldn't possibly offer an opinion on that .. I'll happily defer to you and the other experts here for this. I am not really an expert on this. I just remember being bitten when writing C and trying to comment out a section of code that already had a comment in it. I would rather have the R core team spending their time on their current priorities than even get involved in a discussion of whether block comments should be able to be nested or not. You now have at least 4 possible work arounds, hopefully one of them is satifactory, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 __ 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] Bubble plot pie chart map
Using just base graphics you can use the floating.pie function from the plotrix package, or the my.symbols function from the TeachingDemos package with your own symbol/plotting function. Pie charts are usually not very useful, there may be another type of symbol (see the symbols function) or plot (to use with my.symbols or subplot from the TeachingDemos package) that would convey the information better. One of the examples in ?subplot shows adding small barcharts to a map. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Davidson, D. Sent: Tuesday, May 13, 2008 6:09 AM To: [EMAIL PROTECTED] Subject: [R] Bubble plot pie chart map Hello, I am currently trying to show the abundance of two species of zooplankton within the North Sea as pie chart bubble plots. I followed Werner Wernersen's advice in R help (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48644.html) and used Paul Murrell's paper Integrating Grid Graphics Output with Base Graphics Output (in R News) to try and do this (using the gridBase package). It generally works well, except for when I try and put in the map of the coastline and the points with no zooplankton present (0 values of both plankton species). The following error comes up: Error in gridPLT() : Figure region too small and/or viewport too large and other errors along those lines. Can anyone suggest either what I'm doing wrong, or some other way to plot this? Many thanks Deborah Deborah Davidson PhD student School of Biological Sciences University of Aberdeen Aberdeen, AB24 2TZ Scotland Tel: +44 (0)1224 274106 Email: [EMAIL PROTECTED] The University of Aberdeen is a charity registered in Scotland, No SC013683. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Repeated measures on a split-plot experiment
Please advise the proper format for coding the random effects of a split-plot experiment WITH repeated measures. I have been unable to figure out how to use either lme or lmer's grouping to properly assign the error terms. I am measuring univariate responses. Here is the set-up: WP - whole plot factor SP - split-plot factor SSP - split-split-plot factor, also the repeated measure (time) Plot - replicates of each SSP treatment How do I combine the split-plot effects with the repeated measures [ Time|Plot(WP*SP) ] effect into a random statement? James Hudson UBC Geography Vancouver, Canada __ 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] 3dscatterplot -different colors for different facto rs of the same variable
Moreno Ignazio Coco M.I.Coco at sms.ed.ac.uk writes: I was trying to do a 3d scatterplot for the following set of datas: obj time X Y 1 yellow 333 388.7 492.3 2 yellow 567 388.7 492.3 3 green 621 135.5 371.7 4 green 1039 135.5 371.7 5 red 1373 744.1 205.0 6 red 1763 744.1 205.0 The points should be drew in the plot taking information of time, X and Y. The colors of these points should be assigned according to the information contained in variable obj. What I did but it didn't work out is: 1) Plotting only one set of points (the green one) s3d-scatterplot3d(greenpts[,3],greenpts[,2],greenpts[,4],type=p,scale.y=4, angle=10, color=green) This does not plot the green points (you did not tell us how to get the data, please show the way you read these in). With a bit of guessing, I assume that you plotted all 6 points in green. and try to overlay the others (as you normally would do with plot): s3d$points3d(redpts[,3],redpts[,2],redpts[,4],col=red,type=o) I don't understand this one. Try the following # See also http://finzi.psych.upenn.edu/R/Rhelp02a/archive/62479.html library(scatterplot3d) pts = read.table(d3data.txt) pts # gives for me: # obj time X Y #1 yellow 333 388.7 492.3 #2 yellow 567 388.7 492.3 #3 green 621 135.5 371.7 #4 green 1039 135.5 371.7 #5red 1373 744.1 205.0 #6red 1763 744.1 205.0 # must use larger points and pch=16 here, otherwise yellow is almost invisible scatterplot3d(pts$X,pts$time,pts$Y,type=p,scale.y=4, angle=10, color=pts$obj,pch=16) # Here come the two rgl-base alternatives. Note that rgls for historical reasons has two interfaces which you should not mix; only use one of the two methods. You can rotate the rgl plot with the mouse, and also add axis. rgl is an amazing package; thanks, Duncan. Dieter library(rgl) # 3d interface open3d() points3d(x=pts$X,y=pts$time,z=pts$Y,pch=16,color=pts$obj,size=5) # rgl.* interface rgl.open() rgl.points(x=pts$X,y=pts$time,z=pts$Y,pch=16,color=pts$obj,size=5) __ 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] pch=. plots much faster
FYI, there is also smoothScatter() in the 'geneplotter' package (part of the Bioconductor.org project). /Henrik On Tue, May 13, 2008 at 5:08 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue, 13 May 2008, Charles Plessy wrote: Dear list, I realised by chance when analysing a 1521862 × 8 matrix that plotting was much faster when using . as the argument of `pch'. Why is that surprising? Drawing a small square is rather easy compared to a circle, say. I was just wondering if there were other ways to get this speed improvement: it is otherwise quite difficult to explore such big matrices, especially given that X11 redraws the plot whenever its window is covered/uncovered by another window, or when I switch virtual desktops. That is a function of your X setup. R does ask for backing store to be used, and so it seeems your setup is not doing so. Also, the type=cairo in X11() will repaint from a backing pixmap. You might want to contemplate better ways to visualize 1.5m points. It is not clear what plot you are actually doing, but a density plot is likely to be more informative (especially a 2D pairs plot of densities), or a hexbin plot (from the BioC package or that name) or Best regards, -- Charles Plessy, Wakō, Saitama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is there a package assuming a DIRICHLET model for Marketing Consumer Panel
Hi List, I was wondering if there is a package in R that uses the DIRICHLET model for panel data like in Goodhart, Ehrenberg, Chatfield 1984. The model uses a combination of distributions and is specifically designed for marketing panel data, using input data such as penetration, brand share, buying frequency and so on. It is used mainly for assessing the fit of this model to the data and for testing if differences in penetration or market share for two periods on a continuous sample, are different or not. Any suggestion is highly appreciated. I searched nabble, and i have seen VGAM package (for ?dirichlet) but could not find anything resembling the above model. Thank you and have a great day ahead! [[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.
Re: [R] Repeated measures on a split-plot experiment
On Tue, May 13, 2008 at 1:40 PM, James Hudson [EMAIL PROTECTED] wrote: Please advise the proper format for coding the random effects of a split-plot experiment WITH repeated measures. I have been unable to figure out how to use either lme or lmer's grouping to properly assign the error terms. I am measuring univariate responses. Here is the set-up: WP - whole plot factor SP - split-plot factor SSP - split-split-plot factor, also the repeated measure (time) Plot - replicates of each SSP treatment How do I combine the split-plot effects with the repeated measures [ Time|Plot(WP*SP) ] effect into a random statement? There has been a long exchange on the [EMAIL PROTECTED] mailing list over the last few days about a similar coding issue. You can check the archives at https://stat.ethz.ch/pipermail/r-sig-mixed-models/ To be able to answer your question I think we would need more information about exactly which variances and covariances of random effects you wish to estimate. I realize that many software packages allow you to fit the repeated measures model, whether or not it is appropriate for your data. In R you have more flexibility but that means that you must be more specific. __ 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] upperbound of C index Conf.int. greater than 1
DAVID ARTETA GARCIA wrote: R-users, I am bootstrapping the C Index of a model created using lrm{Design} and boot{boot}, and I get that the upperbound of the confidence interval is greater than 1. Here is my code: library(HSAUR) data(plasma) ##fit model fit.design - lrm (ESR ~ fibrinogen + globulin,data=plasma) fit.design$stats[6] C 0.8044872 ##bootstrap C Index cindex - function(formula,data,indices){ + d=data[indices,] + fit-lrm(formula,data = d) + return(fit$stats[[6]]) + } results - boot(data=w,statistic=cindex,R=500,formula = ESR ~ fibrinogen + globulin) results ORDINARY NONPARAMETRIC BOOTSTRAP Call: boot(data = plasma, statistic = cindex, R = 500, formula = ESR ~ fibrinogen + globulin) Bootstrap Statistics : original biasstd. error t1* 0.8044872 0.008834767 0.1574710 boot.ci(results,type=basic) BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS Based on 500 bootstrap replicates CALL : boot.ci(boot.out = results, type = basic) Intervals : Level Basic 95% ( 0.6090, 1.1443 ) Calculations and Intervals on Original Scale I see that the std.error is rather large and this might be the problem, but how can I explain this for publication purposes? Is such an interval acceptable? Any help would be greatly appreciated David A few observations. 1. With minimal overfitting, rcorr.cens(predict(fit), Y) gives a good standard error for Dxy = 2*(C-.5) and bootstrapping isn't very necessary 2. If you bootstrap use the nonparametric bootstrap percentile method or other methods that constrain the confidence interval to be in [0,1]. 3. I don't know why the model would be linear on the two predictors you are using. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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] [R-sig-ME] lme nesting/interaction advice
Thanks very much for your long, detailed, patient, and lucid response to my cri de coeur. That helps a *great* deal. I'm not sure that I have a solid understanding of the issues yet --- I never am! --- but I think I'm getting there. I'll need to chew over the posting a bit more and try some examples before I feel comfortable. One point that I'd like to spell out very explicitly, to make sure that I'm starting from the right square: The model that you start with in the Machines/Workers example is fm1 - lmer(score ~ Machine + (1|Worker) + (1|Machine:Worker), Machines) My understanding is that this is the ``only'' model that could be fitted by the Package-Which-Must-Not-Be-Named. I.e. this package *could not* fit the second, more complex model: fm2 - lmer(score ~ Machine + (Machine|Worker), Machines) (At least not directly.) Can you (or someone) confirm that I've got that right? It seems to me to be the key to why I've had such trouble in the past in grappling with mixed models in R. I.e. I've been thinking like the Package-Which-Must-Not-Be-Named --- that the simple, everything- independent model was the only possible model. Thanks again. cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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] Max consecutive increase in sequence
Hi all R helpers, I'm trying to comeup with nice and elegant way of detecting consecutive increases/decreases in the sequence of numbers. I'm trying with combination of which() and diff() functions but unsuccesifuly. For example: sq - c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1); I'd like to find way to calculate a) maximum consecutive increase = 3 (from 1 to 4) b) maximum consecutive decrease = 5 (from 6 to 1) All ideas are highly welcomed! -- This e-mail and any files transmitted with it are confid...{{dropped:14}} __ 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] Max consecutive increase in sequence
rle(diff(sq)) could be helpful here, best, Ingmar On May 13, 2008, at 11:19 PM, Marko Milicic wrote: Hi all R helpers, I'm trying to comeup with nice and elegant way of detecting consecutive increases/decreases in the sequence of numbers. I'm trying with combination of which() and diff() functions but unsuccesifuly. For example: sq - c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1); I'd like to find way to calculate a) maximum consecutive increase = 3 (from 1 to 4) b) maximum consecutive decrease = 5 (from 6 to 1) All ideas are highly welcomed! -- This e-mail and any files transmitted with it are confid... {{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question about how to save a txt file in .Rdata or .rda format
Hi Everybody, Suppose I have a *txt file*, named proof wich I have read it previously using the function *read.table( ). *And suppose I have an algorithm wich requires to load this file proof using the function *data ( ) * My problem is the following: how to store the file proof in *.Rdata* or.in .*rda* format in order to use the function data? Thanks in advance for your time and help, Best Regards,J. [[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] multiple plots over multiple pages
Hi, I would like to iterate over a dataframe and plot several graphs over several pages. For instance, an iteration over the dataframe will result in 20 plots. Since 20 plots in one page is too much (too many small plots) I would like to distribute them over 5 pages with each 4 plots. I know how to create multiple plots on one page with : par(mfrow=c(2,2)) -- View this message in context: http://www.nabble.com/multiple-plots-over-multiple-pages-tp17219274p17219274.html Sent from the R help mailing list archive at Nabble.com. __ 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] About Iterative Convex Minorant algorithm in R
Dear List, Does anybody have R code about Iterative Convex Minorant algorithm for Cox model with interval censored data and be willing to share? The R package intcox works well in simulation, while it has converge problem in a data analysis. Any information are highly appreciated. Thanks, Rui __ 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] Un-reproductibility of SVM classification with 'e1071' libSVM package
Hello, When calling several times the svm() function, I get different results. Do I miss something, or is there some random generation in the C library? In this second hypothesis, is it possible to fix an eventual seed? Thank you Pierre ### Example library('e1071') x = rnorm(100) # train set y = rnorm(100) c = runif(100)0.5 x2 = rnorm(100)# test set y2 = rnorm(100) # learning a svm model 2 times, predicting 2 times, and results differ ! set.seed(15) model = svm(data.frame(x, y), as.factor(c), probability=TRUE ) pred1 = predict( model, newdata = data.frame(x2, y2), probability=TRUE) probas1 = as.numeric(attr(pred1,probabilities)[,TRUE]) set.seed(15) model = svm(data.frame(x, y), as.factor(c), probability=TRUE ) pred2 = predict( model, newdata = data.frame(x2, y2), probability=TRUE) probas2 = as.numeric(attr(pred2,probabilities)[,TRUE]) sum(pred1 != pred2) # It should be 0 sum(probas1 != probas2) # It should be 0 plot(probas1,probas2,xlim=c(0.4,0.6),ylim=c(0.4,0.6),col=red) # redo the whole example to see some strange patterns! Especially around the 0.5 value. ## Technical details: I'm using lastest R version 2.7.0 on an up-to-date windows vista (same problem with another computer with windows XP) sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 attached base packages: [1] stats graphics grDevices utils datasets [6] methods base other attached packages: [1] e1071_1.5-18 class_7.2-41 loaded via a namespace (and not attached): [1] tools_2.7.0 [[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.
Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?
Hi Gabor, Thank you for your help, and thanks for making the excellent igraph package. The function below seems not generate an edge list that works for my data. I coerced a my data from a data frame using graph.data.frame. You asked in your previous post if 2-mode networks are bipartite. I believe the answer is yes. However, in Hanneman, Robert A. and Mark Riddle. 2005. Introduction to social network methods. Riverside, CA: University of California, Riverside ( published in digital form at http://faculty.ucr.edu/~hanneman/ ) I found the following: Two-mode data are sometimes stored in a second way, called the bipartite matrix. A bipartite matrix is formed by adding the rows as additional columns, and columns as additional rows. Did I need to convert my data frame to a bipartite matrix before applying the two.to.one function? Solomon -Original Message- From: Gabor Csardi [mailto:[EMAIL PROTECTED] Sent: Saturday, May 10, 2008 1:09 PM To: Messing, Solomon O. Cc: r-help@r-project.org Subject: Re: [R] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data? Solomon, if i understand two-mode networks properly (they're bipartite, right?), then this is not hard to do with igraph. Basically, for each vertex create an order=2 neighborhood, and then create a graph from the adjacency list, it is something like this: two.to.one - function(g, keep) { neis - neighborhood(g, order=2) neis - lapply(seq(neis), function(x) neis[[x]][ neis[[x]] != x-1]) ## drop self-loops neis - lapply(neis, function(x) x[ x %in% keep ]) ## keep only these neis - lapply(seq(neis), function(x) t(cbind(x-1, neis[[x]]))) ## create edge lists neis[-keep-1] - NULL ## these are not needed neis - matrix(unlist(neis), byrow=TRUE, nc=2) ## a single edge list neis - neis[ neis[,1] neis[,2], ] ## count an edge once only mode(neis) - character g2 - graph.edgelist(neis, dir=FALSE) V(g2)$id - V(g2)$name ## 'id' is used in Pajek g2 } It does not check that the graph is indeed two-mode, and it keeps the vertices given in the 'keep' argument. 'keep' is made of igraph vertex ids. You can use it like this: g - graph.ring(10) keep - seq(0,8,by=2) ## we keep the 'even' vertices g2 - two.to.one(g, keep) write.graph(two.to.one(g, keep), format=pajek, file=/tmp/a.net) I haven't tested it much. We'll have a better function in the next igraph version. Gabor On Fri, May 09, 2008 at 03:37:05PM -0400, Messing, Solomon O. wrote: Hi, Does anyone know of a package in R that has a function to convert network data (e.g. an adjacency matrix or ) from 2-mode to 1-mode? I am conducting social network analysis. I know that Pajek has this function under Net -- Transform -- 2-mode to 1-mode -- Rows. I have searched the documentation under packages 'sna', 'network', 'igraph', and 'dynamicgraph' but I was not able to identify a comparable function. I would just export my data to Pajek and import it to R, but I'm going to have to generate hundreds of these graphs, so it would take quite a bit of time to do it this way. Thanks, Solomon [[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. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ 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] [R-sig-ME] lme nesting/interaction advice
Hi Rolf, On Tue, May 13, 2008 at 1:59 PM, Rolf Turner [EMAIL PROTECTED] wrote: in response to Doug Bates' useful tutorial... Thanks very much for your long, detailed, patient, and lucid response to my cri de coeur. That helps a *great* deal. Hear Hear! snip One point that I'd like to spell out very explicitly, to make sure that I'm starting from the right square: The model that you start with in the Machines/Workers example is fm1 - lmer(score ~ Machine + (1|Worker) + (1|Machine:Worker), Machines) My understanding is that this is the ``only'' model that could be fitted by the Package-Which-Must-Not-Be-Named. I.e. this package *could not* fit the second, more complex model: fm2 - lmer(score ~ Machine + (Machine|Worker), Machines) (At least not directly.) Can you (or someone) confirm that I've got that right? Compare: ## R m4 Linear mixed model fit by REML Formula: score ~ Machine + (0 + Machine | Worker) Data: Machines AIC BIC logLik deviance REMLdev 228.3 248.2 -104.2216.6 208.3 Random effects: Groups Name Variance Std.Dev. Corr Worker MachineA 16.64098 4.07934 MachineB 74.39558 8.62529 0.803 MachineC 19.26646 4.38936 0.623 0.771 Residual 0.92463 0.96158 Number of obs: 54, groups: Worker, 6 ## The-Package proc mixed data = machines; class worker machine; model score = machine / solution; random machine / subject = worker type = un; run; Covariance Parameter Estimates Cov Parm SubjectEstimate UN(1,1) Worker 16.6405 UN(2,1) Worker 28.2447 UN(2,2) Worker 74.3956 UN(3,1) Worker 11.1465 UN(3,2) Worker 29.1841 UN(3,3) Worker 19.2675 Residual 0.9246 The two outputs report essentially the same thing. Note that e.g, UN(2,1) = 28.2477 approx= .803*4.07934*8.62529 (And, as usual, the fixed effects estimates match too once the contrasts and 'types' of SS for an ANOVA table are set up) UN is short for 'unstructured' - a term Doug has pointed out is not particularly fitting because the covariance matrix is symmetric positive definite. It seems to me to be the key to why I've had such trouble in the past in grappling with mixed models in R. I.e. I've been thinking like the Package-Which-Must-Not-Be-Named --- that the simple, everything-independent model was the only possible model. Although this may well not apply to you, another area of confusion arises not so much from differences between stats packages but by differences between methods. I'm not an expert in the estimation methods but, as I understand it, classic texts describe fitting mixed models in terms of ANOVA in the OLS framework, calculating method of moments estimators for the variances of the random effects by equating observed and expected mean squares (I believe using aov and lm with an 'Error' term would fall into this category, and proc anova and proc glm would also). Starting in the 90's these methods started falling out of fashion in favor of ML/REML/GLS methods (likelihood based), which offer more flexibility in structuring both the error and random effects covariance matrices, will not produce negative variance estimates, and have other nice properties that someone more 'mathy' than me could explain. Tools like lme, lmer, proc mixed and proc glimmix fall into this category. hoping this helps, Kingsford Jones Thanks again. cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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] CRAN and Multiple Linear Regression
I just have read the guide and I can do some small steps with cran but I still have no clue... I have data like this: X1 X2 X3 ... X21 Y 1 0 0 0 ... 18 -0,07254 2 1 0 0 ... 6 -0,14921 3 0 1 0 ... 12 -0,04165 4 0 0 0 ... 8 0,08359 5 ... ... ... ... ... ... 120 0 0 1 1 8 0,07928 My script is: require(stats); require(graphics) test = read.table(test.dat, header=T) x - test[, 1:21] y - test[, Y] lm(y ~ x) The error may be an invalid type (list) for variable x (see below): Fehler in model.frame.default(formula = y ~ x, drop.unused.levels = TRUE) : ungültiger Typ (list) für die Variable 'x' Then I tried: ... lm(data=test) Then I get a lot of coefficients, but I'm not sure. That cant be the result. Then I tried: summary(lm(data = wetter)) Call: lm(data = wetter) Residuals: ALL 120 residuals are 0: no residual degrees of freedom! Coefficients: (139 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept)0.044747 NA NA NA X2 0.660275 NA NA NA X3-0.097629 NA NA NA X4 0.647851 NA NA NA X5-3.305631 NA NA NA ...0.249788 NA NA NA I am confused... Best regards, Thomas __ 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] plotting different level of classficifaction
hello, useRs~ suppose i have a matrix as follows: itemcategory sub-category A 1 11 B 1 12 C 1 12 D 2 21 E 2 22 i like to draw a plot that represent the proportion of each category at each level. that is, i want a plot like this: +-+ +-+ || | 11 | || +-+ | 1 | | 12 | || || +-+ +-+ +-+ +-+ || | 21 | | 2 | +-+ || | 22 | +-+ +-+ category sub-cateory hope my plot makes sense. anyone know how to make such plot? any hint/suggestion would be much appreciate. thank you. -- View this message in context: http://www.nabble.com/plotting-different-level-of-classficifaction-tp17220264p17220264.html Sent from the R help mailing list archive at Nabble.com. __ 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] multiple plots over multiple pages
Just keep plotting them. You will get additional pages after every four plots. Now I know this is true when using PDF as the output device. On Tue, May 13, 2008 at 5:56 PM, Dirkheld [EMAIL PROTECTED] wrote: Hi, I would like to iterate over a dataframe and plot several graphs over several pages. For instance, an iteration over the dataframe will result in 20 plots. Since 20 plots in one page is too much (too many small plots) I would like to distribute them over 5 pages with each 4 plots. I know how to create multiple plots on one page with : par(mfrow=c(2,2)) -- View this message in context: http://www.nabble.com/multiple-plots-over-multiple-pages-tp17219274p17219274.html Sent from the R help mailing list archive at Nabble.com. __ 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[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.
Re: [R] CRAN and Multiple Linear Regression
Hi Thomas, Perhaps: test = read.table(test.dat, header=T, dec=',') x - test[,1:21] y - test[, Y] mymodel - lm(y ~ x) # Coefficients and more information summary(mymodel) # Plots for the residuals plotspar(mfrow=c(2,2)) plot(mymodel) See also ?lm HTH, Jorge On Tue, May 13, 2008 at 6:54 PM, Anja und Th. Sponsel [EMAIL PROTECTED] wrote: I just have read the guide and I can do some small steps with cran but I still have no clue... I have data like this: X1 X2 X3 ... X21 Y 1 0 0 0 ... 18 -0,07254 2 1 0 0 ... 6 -0,14921 3 0 1 0 ... 12 -0,04165 4 0 0 0 ... 8 0,08359 5 ... ... ... ... ... ... 120 0 0 1 1 8 0,07928 My script is: require(stats); require(graphics) test = read.table(test.dat, header=T) x - test[, 1:21] y - test[, Y] lm(y ~ x) The error may be an invalid type (list) for variable x (see below): Fehler in model.frame.default(formula = y ~ x, drop.unused.levels = TRUE) : ungültiger Typ (list) für die Variable 'x' Then I tried: ... lm(data=test) Then I get a lot of coefficients, but I'm not sure. That cant be the result. Then I tried: summary(lm(data = wetter)) Call: lm(data = wetter) Residuals: ALL 120 residuals are 0: no residual degrees of freedom! Coefficients: (139 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept)0.044747 NA NA NA X2 0.660275 NA NA NA X3-0.097629 NA NA NA X4 0.647851 NA NA NA X5-3.305631 NA NA NA ...0.249788 NA NA NA I am confused... Best regards, Thomas __ 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.
Re: [R] Plotting Frequency Distribution in R
Does something like this do it for you: x - read.table(textConnection( V1 V2 1 1 160.54% 2 1 201.59% 3 1 18.45% 4 1 179.03% 5 1 274.37% 6 1 0.00% 7 1 24.52% 8 1 39.17% 9 3 43.72% 10 1 53.06% 11 1 64.97% 12 1 79.84% 13 1 98.08% 14 1 115.32% 15 1 127.96% 16 1 155.38% 17 1 157.25% 18 1 193.17% 19 1 51.53% 20 15 99.32% 21 1 106.86% 22 1 219.44%), header=TRUE, as.is=TRUE) # change to numeric x$V2 - as.numeric(gsub(%, , x$V2)) plot(x$V2, x$V1, type='h', lwd=2) On Tue, May 13, 2008 at 10:25 AM, Sachin J [EMAIL PROTECTED] wrote: Hi, How can plot a frequency distribution curve for the following data. V1 V2 1 1 160.54% 2 1 201.59% 3 1 18.45% 4 1 179.03% 5 1 274.37% 6 1 0.00% 7 1 24.52% 8 1 39.17% 9 3 43.72% 10 1 53.06% 11 1 64.97% 12 1 79.84% 13 1 98.08% 14 1 115.32% 15 1 127.96% 16 1 155.38% 17 1 157.25% 18 1 193.17% 19 1 51.53% 20 15 99.32% 21 1 106.86% 22 1 219.44% Where V1 is count for each V2 value. for example there are 3 entries for 43.72% value. Thanks in advance for the help. Regards, Sachin [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[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] mfrow
Dear members, I want to create 8 graphs and write it into one page using mfrow=c(4,2). How to make all graphs (including the titles, legends, line types) to be scale down (resized proportionally). As an illustration, below is the code: pdf(testmfrow.pdf) par(mfrow=c(4,2)) x-seq(1:10) y1-rnorm(10) y2-rnorm(10,mean=2,sd=1) y3-rnorm(10,mean=3,sd=1) y4-rnorm(10,mean=4,sd=1) y5-rnorm(10,mean=5,sd=1) y6-rnorm(10,mean=6,sd=1) y7-rnorm(10,mean=7,sd=1) y8-rnorm(10,mean=8,sd=1) plot(x,y1,type='o', lty=1, main=I want this title is to be scaled down (resized)) plot(x,y2,type='o', lty=2, main=I want this title is to be scaled down (resized)) plot(x,y3,type='o', lty=3, main=I want this title is to be scaled down (resized)) plot(x,y4,type='o', lty=4, main=I want this title is to be scaled down (resized)) plot(x,y5,type='o', lty=5, main=I want this title is to be scaled down (resized)) plot(x,y6,type='o', lty=6, main=I want this title is to be scaled down (resized)) plot(x,y7,type='o', lty=7, main=I want this title is to be scaled down (resized)) plot(x,y8,type='o', lty=8, main=I want this title is to be scaled down (resized)) dev.off() Many thanks for any help/idea. Gusanto [[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] The try() function with read.delim().
I have written a function which reads data from files using read.delim (). The names of these files are complicated and are built using arguments to the wrapper function. Since the files in question may or may not exist, I thought to enclose the read.delim() call in a try(): file - complicated expression temp - try(read.delim(file)) if(inherits(temp,try-error)) { (Do something) } else { (Do something else) } But this doesn't work. If file doesn't exist, then I get an error, and the wrapper function terminates, despite the presence of the try(). The object ``temp'' never gets created. I can of course easily get around the problem by testing with file.exists(file) I just wondered --- why isn't try() working as expected here? Am I being silly to expect it to work? If so, what am I not understanding about try()? Thanks for any insights. cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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.