[R] Any examples of a frailty model actually used for prediction ?
Hi everyone, I'm looking for any examples of useful frailty models, in particular any situation in which a cox proportional hazards model with frailty outperforms a regular cox proportional hazards model with respect to prediction of the time to event (or the X-year risk of an event). I have defined my own gamma-frailty cox PH model in R but on my simulated data sample it does not predict any better than a regular cox model. In fact the predictions of the frailty model are often worse, *even* when I purposely add gamma-distributed frailty to the simulated sample (as I have previously posted). Can anyone help me, e.g. by pointing me to some R code in which the performance of models with and without frailty component are assessed ? Also any examples in which the actual estimated individual frailty values are used for predictions are very much welcome. Thanks. Erik Koffijberg. = Julius Center for Health Sciences and Primary Care University Medical Center Utrecht Str. 6.131 P.O.Box 85500, 3508 GA Utrecht, The Netherlands Tel:+31 30 250 3013, Fax:+31 30 250 5480 E-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to generating diagnal blocks ?
Hi, I am trying to creat a matrix with diagnal blocks, say, I have a matrix X of any dimension (nxm) ,and would like to have: X X X . otherwise space filled with 0's. Is there a handy way to do this ? Thanks a lot in advance. best __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help on Dates in R again
Hello R Experts, I want to aggregate parameters by week. But our production week ends Friday night instead of Sunday Night which is the default value in R. In order to solve the problem I want to substract two days from the current data and than use the R function test$week-format(test$dates,%U); with a testdates format equal to 2006-09-21. How do I substract the two days from the test$dates column in the data.frame? Thanks a lot for your help Thorsten __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pooled Covariance Matrix
Hi, Can some one please explain me with an example what is Symbolic Number Coding in R. Thanks and Regards, Pratap - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Different result from nls in R-2.2.1 and R-2.3.1
Short story: January 2006 I did some analysis in R-2.2.1 using nls. Repeating the exercise in R-2.3.1 yesterday produced somewhat different results. After some debugging I found that either nls is the problem or that mine understanding of environments or scoping rules is lacking something. This is a short reproducing example. x - seq(0,5,len=20) n - 1 y - 2*x^2 + n + rnorm(x) xy - data.frame(x=x,y=y) myf - function(x,a,b,n){ res - a*x^b + n ## a print for debugging purpose print(n) res } ## This works as I expect it to do in R-2.2.1 but doesn't work in R-2.3.1. ## n is somehow sat to nrow(xy) inside nls() ## Note that x and y is defined in the dataframe xy, whereas n is found in the global environment. fit - nls(y ~ myf(x,a,b,n), data=xy, start=c(a=1,b=1), trace=TRUE) ## this works in both versions ## x,y,n found in the .GlobalEnv fit - nls(y ~ myf(x,a,b,n), start=c(a=1,b=1), trace=TRUE) ## this works in both versions. ## x, y, n found in dataframe xyn xyn - data.frame(xy,n=n) fit - nls(y ~ myf(x,a,b,n), data=xyn, start=c(a=1,b=1), trace=TRUE) ## this works in both versions ## Now using the variable .n instead of n ## .n is found in .GlobaEnv .n - 1 fit - nls(y ~ myf(x,a,b,.n), data=xy, start=c(a=1,b=1), trace=TRUE) In my real case and the example above, I do have three or more parameters of which fitting is done only on few of theme. Is this a problem? Or should I ask, why is this a problem in R-2.3.1 but not in R-2.2.1? Is my problem related to this difference between lines of code from nls: R-2.2.1: mf - as.list(eval(mf, parent.frame())) R-2.3.1: mf - eval.parent(mf) n - nrow(mf) mf - as.list(mf) where n is being defined in the scope of nls in the latest version? Best regards Frede Aakmann Tøgersen Danish Institute of Agricultural Sciences Research Centre Foulum Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: [EMAIL PROTECTED] Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from DIAS is not allowed. If you are not the intended recipient, please notify DIAS immediately and delete this email. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help on Dates in R again
On Thu, 21 Sep 2006, Thorsten Muehge wrote: Hello R Experts, I want to aggregate parameters by week. But our production week ends Friday night instead of Sunday Night which is the default value in R. The default in ISO8601, not just in R, but that is %W, not %U as used below. In order to solve the problem I want to substract two days from the current data and than use the R function test$week-format(test$dates,%U); with a testdates format equal to 2006-09-21. How do I substract the two days from the test$dates column in the data.frame? You have not told us what class test$dates is! Assuming it is Date, test$dates-2. *However*, to do what you ask, you need to add 1: dates - seq(as.Date(2006-09-21), by=1, len=7) format(dates+1, %U) [1] 38 38 39 39 39 39 39 There is a potential problem here at year ends (there is anyway in the ISO8601 definition). Another way is just (unclass(dates) - 2) %/% 7 which orders weeks across years. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Statitics Textbook - any recommendation?
GS == Gavin Simpson [EMAIL PROTECTED] on Thu, 21 Sep 2006 00:08:17 +0100 writes: GS On Wed, 2006-09-20 at 18:56 -0400, Charles Annis, P.E. wrote: Recommending a good book on statistics is like recommending a good book on sports: Which sports? A good book for learning statistical concepts (and learning R at the same time), one that assumes you understand algebra but are new to statistics, is Peter Dalgaard's _Introductory Statistics with R_ (Springer 2002). The writing is relaxed and succinct, not condescending as some texts might appear to a newcomer. It's just a good book. GS I couldn't agree more. A number of my colleagues have bought Peter GS Dalgaard's book to a) learn some R and b) learn some statistics. They GS have found it very useful indeed. Yes! I'm pretty sure it has been the first book of its kind (Intro Stats + R), and in my view is still the best. Martin Maechler, ETH Zurich Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Nielsen Sent: Wednesday, September 20, 2006 6:36 PM To: Berton Gunter Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Statitics Textbook - any recommendation? Excellent characterization. MASS is a very good book, but I'm not sure I would describe it as a statistics textbook, much less one of the basic variety. While I certainly wouldn't presume to speak for Prof. Ripley and Dr. Venables, it seems unlikely their intent in writing MASS was to teach statistics, but rather, as the name of the book might suggest, to explain how S+ (and R) can be applied to modern statistical techniques. My experience with this book is that it assumes considerable background knowledge. By all means, buy MASS, but if you need guidance on the how and why of statistical techniques, you may wish to shop Amazon to find a supplement. Regards, Mike On 9/20/06, Berton Gunter [EMAIL PROTECTED] wrote: Not withstanding Prof. Heiberger's admirable enthusiasm, I think the canonical answer is probably MASS (Modern Applied Statistics with S) by Venables and Ripley. It is very comprehensive, but depending on your background, you may find it too telegraphic. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski Sent: Wednesday, September 20, 2006 1:22 PM To: r-help@stat.math.ethz.ch Subject: [R] Statitics Textbook - any recommendation? I would like to buy a basic statistics book (experimental design, sampling, ANOVA, regression, etc.) with examples in R. Or download it in PDF or html format. I went to the CRAN contributed documentation, but there were only R textbooks, that is, textbooks where R is the focus, not the statistics. And I would like to find the opposite. Other text I am trying to find is multivariate data analysis (EFA, cluster, mult regression, MANOVA, etc.) with examples with R. Any recommendation? Thank you in advance, Iuri. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Regards, Mike Nielsen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible
Re: [R] How to generating diagnal blocks ?
If I remember well, there should be a package including the function bdiag() making the job..but I am not able to remember its name.. However a quick search via RSiteSearch(bdiag) yields http://finzi.psych.upenn.edu/R/Rhelp02a/archive/40393.html Hope this helps you, vito Tong Wang wrote: Hi, I am trying to creat a matrix with diagnal blocks, say, I have a matrix X of any dimension (nxm) ,and would like to have: X X X . otherwise space filled with 0's. Is there a handy way to do this ? Thanks a lot in advance. best __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Statitics Textbook - any recommendation?
Martin Maechler [EMAIL PROTECTED] writes: GS I couldn't agree more. A number of my colleagues have bought Peter GS Dalgaard's book to a) learn some R and b) learn some statistics. They GS have found it very useful indeed. Yes! I'm pretty sure it has been the first book of its kind (Intro Stats + R), and in my view is still the best. Thanks for the kind words, but... I went to the CRAN contributed documentation, but there were only R textbooks, that is, textbooks where R is the focus, not the statistics. And I would like to find the opposite. and that does to some extent apply to my book too. Perhaps have a look at Maindonald Braun as well. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generating diagnal blocks ?
Hello You need adiag(), which is now part of the magic package: library(magic) adiag(matrix(1:6,2,3),matrix(1:9,3,3)) [,1] [,2] [,3] [,4] [,5] [,6] [1,]135000 [2,]246000 [3,]000147 [4,]000258 [5,]000369 the function also has extra functionality over the one Vito points to in the archives. HTH rksh On 21 Sep 2006, at 08:14, vito muggeo wrote: If I remember well, there should be a package including the function bdiag() making the job..but I am not able to remember its name.. However a quick search via RSiteSearch(bdiag) yields http://finzi.psych.upenn.edu/R/Rhelp02a/archive/40393.html Hope this helps you, vito Tong Wang wrote: Hi, I am trying to creat a matrix with diagnal blocks, say, I have a matrix X of any dimension (nxm) ,and would like to have: X X X . otherwise space filled with 0's. Is there a handy way to do this ? Thanks a lot in advance. best __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] uniform integer RNG 0 to t inclusive
Prof Ripley, You are absolutely correct, this code will not work at all - for starters, M isn't correctly initialized, etc. I edited my code in tinn-r and never ran it before posting... my apologies, I always seem to be too quick off the mark to reply - despite the 4*runif(1) suggestion in the posting guide... I hadn't realized before what significant difference the replace=TRUE would make to the runtime... Now I can just use the sample() code you suggested and remove my runif() code altogether, as sample(t+1, 1, replace=TRUE) - 1 will work fine with t - 2e9 which is considerably more that I need. Thanks again to both Prof Ripley and Duncan Murdoch, Sean O'Riordain affiliation - NULL On 19/09/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue, 19 Sep 2006, Sean O'Riordain wrote: Hi Duncan, Thanks for that. In the light of what you've suggested, I'm now using the following: # generate a random integer from 0 to t (inclusive) if (t 1000) { # to avoid memory problems... M - sample(t, 1) } else { while (M t) { M - as.integer(urand(1,min=0, max=t+1-.Machine$double.eps)) } } sample(t, 1) is a sample from 1:t, not 0:t. You need sample(t+1, 1, replace=TRUE) - 1 which works in all cases up to INT_MAX-1, and beyond that you need to worry about the resolution of the RNG (and to use floor not as.integer). There is no such thing as urand in base R cheers and Thanks, Sean On 18/09/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 9/18/2006 3:37 AM, Sean O'Riordain wrote: Good morning, I'm trying to concisely generate a single integer from 0 to n inclusive, where n might be of the order of hundreds of millions. This will however be used many times during the general procedure, so it must be reasonably efficient in both memory and time... (at some later stage in the development I hope to go vectorized) The examples I've found through searching RSiteSearch() relating to generating random integers say to use : sample(0:n, 1) However, when n is large this first generates a large sequence 0:n before taking a sample of one... this computer doesn't have the memory for that! You don't need to give the whole vector: just give n, and you'll get draws from 1:n. The man page is clear on this. So what you want is sample(n+1, 1) - 1. (Use replace=TRUE if you want a sample bigger than 1, or you'll get sampling without replacement.) When I look at the documentation for runif(n, min, max) it states that the generated numbers will be min = x = max. Note the = max... Actually it says that's the range for the uniform density. It's silent on the range of the output. But it's good defensive programming to assume that it's possible to get the endpoints. How do I generate an x such that the probability of being (the integer) max is the same as any other integer from min (an integer) to max-1 (an integer) inclusive... My attempt is: urand.int - function(n,t) { as.integer(runif(n,min=0, max=t+1-.Machine$double.eps)) } # where I've included the parameter n to help testing... Because of rounding error, t+1-.Machine$double.eps might be exactly equal to t+1. I'd suggest using a rejection method if you need to use this approach: but sample() is better in the cases where as.integer() will work. Duncan Murdoch is floor() better than as.integer? Is this correct? Is the probability of the integer t the same as the integer 1 or 0 etc... I have done some rudimentary testing and this appears to work, but power being what it is, I can't see how to realistically test this hypothesis. Or is there a a better way of doing this? I'm trying to implement an algorithm which samples into an array, hence the need for an integer - and yes I know about sample() thanks! :-) { incidentally, I was surprised to note that the maximum value returned by summary(integer_vector) is pretty and appears to be rounded up to a nice round number, and is not necessarily the same as max(integer_vector) where the value is large, i.e. of the order of say 50 million } Is version etc relevant? (I'll want to be portable) version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Many thanks in advance for your help. Sean O'Riordain affiliation - NULL __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __
Re: [R] Spliting a huge vector
Hi On 20 Sep 2006 at 14:19, Dave Evens wrote: Date sent: Wed, 20 Sep 2006 14:19:04 -0700 (PDT) From: Dave Evens [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Spliting a huge vector Dear R users, I have a huge vector that I would like to split into unequal slices. However, the only way I can do this is to create another huge vector to define the groups that are used to split the original vector, e.g. # my vector is this a.vector - seq(2, by=5, length=100) should not it be a.vector - seq(2, by=5, length=803) # indices where I would like to slice my vector cut.values - c(30, 50, 100, 109, 300, 601, 803) # so I have to create another vector of similar length # to use the split() command, i.e. x - rep(1:length(cut.values), times=diff(c(0, cut.values)) here it throws syntactic error so I assume it shall have one more parentheses # this means I can use split() split(a.vector, x) then times - diff(c(0,cut.values)) do.call(function(x, y, times) split(x,rep(y, times=times)), list(x=a.vector, y= cut.values, times=times)) or split(a.vector,rep(1:length(cut.values), times=times)) is this what you want? However I am not sure that some vector is not created internally. HTH Petr This seems to be a waste in terms of memory usage as I'm creating another vector (here x) to split the original vector. Is there a better way to split a huge vector than this? Any help is much appreciated. Best, Dave. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Beginners manual for emacs and ess
Thanks for all of your information. I will look into all of them Rainer Gavin Simpson wrote: On Wed, 2006-09-20 at 17:03 +0200, Rainer M Krug wrote: Hi I heard so much about Emacs and ESS that I decided to try it out - but I am stuck at the beginning. Is there anywhere a beginners manual for Emacs ESS to be used with R? even M-x S tells me it can't start S-Plus - obviously - but I want it to start R... Er, M-x R starts R (after you've chosen a working directory) unless I misunderstood your question? Have you tried: http://ess.r-project.org/ And the ESS manual contained there? If not, that would be my first port of call. Any help welcome (otherwise I will be stuck with Eclipse and R) Rainer G -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Beginners manual for emacs and ess
On Wednesday 20 September 2006 17:16, Marc Schwartz (via MN) wrote: On Wed, 2006-09-20 at 17:03 +0200, Rainer M Krug wrote: Hi I heard so much about Emacs and ESS that I decided to try it out - but I am stuck at the beginning. Is there anywhere a beginners manual for Emacs ESS to be used with R? even M-x S tells me it can't start S-Plus - obviously - but I want it to start R... While following Mark's suggestions, try doing M-x R and that might start R. Then, you can do: C-x 2 (split the screen as is said in other editors) move to the one without the running R, and open there an R file (or you can just create it on the fly: C-x C-f and in the minibuffer type anything, e.g., one-file.R (without the quotes). Then, type C-h m and you'll get a list of stuff related to the ESS mode. And I think you will then really need to look at the ESS doc and go through the (X)Emacs tutorial (which is available from the help, in (X)Emacs). HTH, R. Any help welcome (otherwise I will be stuck with Eclipse and R) Rainer There are some reference materials on the main ESS site at: http://ess.r-project.org/ In addition, there is a dedicated ESS mailing list, with more info here: https://stat.ethz.ch/mailman/listinfo/ess-help HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ramón Díaz-Uriarte Bioinformatics Centro Nacional de Investigaciones Oncológicas (CNIO) (Spanish National Cancer Center) Melchor Fernández Almagro, 3 28029 Madrid (Spain) Fax: +-34-91-224-6972 Phone: +-34-91-224-6900 http://ligarto.org/rdiaz PGP KeyID: 0xE89B3462 (http://ligarto.org/rdiaz/0xE89B3462.asc) **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Significant integer digits in summary.default
On R 2.3.1 I was surprised to see the following results from summary.default(): R x - scan() 1: 12148 10426 10912 9116 13226 11663 11781 10680 8457 10788 12605 10591 11040 14: 10815 12962 11644 10047 10478 10108 12353 11778 11092 11673 8758 11145 11495 27: Read 26 items R summary(x) Min. 1st Qu. MedianMean 3rd Qu.Max. 8460 10500 11100 11100 11800 13200 R max(x) [1] 13226 Clearly, these are being rounded; help(summary) shows the digits= option. If I now ask for all five digits (n.b. I have to know the magnitude of the numbers to know how many integer digits) I get: R summary(x, digits=5) Min. 1st Qu. MedianMean 3rd Qu.Max. 8457 10506 11066 11068 11752 13226 which now shows the actual maximum etc. help(summary) shows options: digits = max(3, getOption(digits)-3) R getOption(digits) [1] 5 So in my case I get three digits... but I had thought this applied to decimal digits, not integer digits, and that rounding would only occur in decimal places, according to the digits option. Question: is this behaviour of summary.default what is expected? If so, it seems non-intuitive to me. Thank you, D. G. Rossiter Senior University Lecturer Department of Earth Systems Analysis International Institute for Geo-Information Science and Earth Observation (ITC) Enschede, The Netherlands __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remotely saving an R session
On Wed, 20 Sep 2006, Jeffrey Horner wrote: Gamal Azim wrote: Is it possible to remotely save an R session then terminate R? Of course the destructive task after 'then' is rather straightforward by itself. Yes. Sending the process a SIGUSR1 signal: $ kill -USR1 pid will save the global environment in the file .RData, but you'll need to remember the current working directory of the process to find it. That is indeed what this is documented to do (and I mentioned in an R-devel posting yesterday). Unfortunately it currently does not always work: try it on a session running try(repeat{1}) to see the problem. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Statitics Textbook - any recommendation?
On Wednesday 20 September 2006 22:21, Iuri Gavronski wrote: I would like to buy a basic statistics book (experimental design, sampling, ANOVA, regression, etc.) with examples in R. Or download it in PDF or html format. I went to the CRAN contributed documentation, but there were only R textbooks, that is, textbooks where R is the focus, not the statistics. And I would like to find the opposite. Other text I am trying to find is multivariate data analysis (EFA, cluster, mult regression, MANOVA, etc.) with examples with R. Any recommendation? I'd say the situation is actually the opposite. Anyway, the recent book by Brian Everitt and Torsten Hothorn (A handbook of statistical analyses using R. Chapman Hall) is an excellent (and affordable) place to start. (I think that this book's context emphasizes that it is stats with R as the language: Everitt has (co)authored a bunch of others in other languages ---SAS, Stata, SPSS, etc). Of course, there are many others that probably deserver a place on your (or your library's) shelves: P. Dalgaard's MASS Maindonald Braun Heiberger Holland etc HTH, R. Thank you in advance, Iuri. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ramón Díaz-Uriarte Bioinformatics Centro Nacional de Investigaciones Oncológicas (CNIO) (Spanish National Cancer Center) Melchor Fernández Almagro, 3 28029 Madrid (Spain) Fax: +-34-91-224-6972 Phone: +-34-91-224-6900 http://ligarto.org/rdiaz PGP KeyID: 0xE89B3462 (http://ligarto.org/rdiaz/0xE89B3462.asc) **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Statitics Textbook - any recommendation?
Hi all, I am very fond of Using R for Introductory Statistics by John Verzani, 2005, Chapman Hall. Regards D. Trenkler -- Dietrich Trenkler c/o Universitaet Osnabrueck Rolandstr. 8; D-49069 Osnabrueck, Germany email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] transforming factor back to numbers
Hi I generate a new dataframe by doing: npl.agg - aggregate(npl$DensPlants, list(year=npl$year, sim=npl$sim), mean, na.rm=TRUE ) Now I want to plot it by using coplot(npl.agg$x ~ npl.agg$year | npl.agg$sim, type=l) but, as npl.agg$year is seen as a factor, the order of the points on the x-axis (time axis) does not follow the numerical sorting 1...100, but rather the text sorting of the factor npl.agg$year Is there any way that I can 'defactor' npl.agg$year so that I have again the numerical values for year? Thanks Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transforming factor back to numbers
That's an FAQ: 7.10 How do I convert factors to numeric? It may happen that when reading numeric data into R (usually, when reading in a file), they come in as factors. If f is such a factor object, you can use as.numeric(as.character(f)) to get the numbers back. More efficient, but harder to remember, is as.numeric(levels(f))[as.integer(f)] In any case, do not call as.numeric() or their likes directly for the task at hand (as as.numeric() or unclass() give the internal codes). On 21/09/06, Rainer M Krug [EMAIL PROTECTED] wrote: Hi I generate a new dataframe by doing: npl.agg - aggregate(npl$DensPlants, list(year=npl$year, sim=npl$sim), mean, na.rm=TRUE ) Now I want to plot it by using coplot(npl.agg$x ~ npl.agg$year | npl.agg$sim, type=l) but, as npl.agg$year is seen as a factor, the order of the points on the x-axis (time axis) does not follow the numerical sorting 1...100, but rather the text sorting of the factor npl.agg$year Is there any way that I can 'defactor' npl.agg$year so that I have again the numerical values for year? Thanks Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot correlation matrix
Dear useRs, While exploring new R packages, I have found the Rattle. This screenshot http://rattle.togaware.com/rattle-correlation.png is very interesting (others are in http://rattle.togaware.com/rattle-screenshots.html ). Which function was used to produce this plot? Is such plotting of the correlation matrix a unique Rattle's feature? Unfortunately I have some weird problems with RGtk2 package and therefore cannot run Rattle. I have sent the question about this problem to the maintainer of the RGtk2 a few hours ago. When I try to load library(RGtk2) I get the message The procedure entry point atk_relation_add_target could not be located in the dynamic link library libatk-1.0-0.dll. --- Best regards, Vladimirmailto:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] transforming factor back to numbers
Thanks a lot David. Just a suggestion - it might help if this is added to the help of factor() Rainer David Barron wrote: That's an FAQ: 7.10 How do I convert factors to numeric? It may happen that when reading numeric data into R (usually, when reading in a file), they come in as factors. If f is such a factor object, you can use as.numeric(as.character(f)) to get the numbers back. More efficient, but harder to remember, is as.numeric(levels(f))[as.integer(f)] In any case, do not call as.numeric() or their likes directly for the task at hand (as as.numeric() or unclass() give the internal codes). On 21/09/06, Rainer M Krug [EMAIL PROTECTED] wrote: Hi I generate a new dataframe by doing: npl.agg - aggregate(npl$DensPlants, list(year=npl$year, sim=npl$sim), mean, na.rm=TRUE ) Now I want to plot it by using coplot(npl.agg$x ~ npl.agg$year | npl.agg$sim, type=l) but, as npl.agg$year is seen as a factor, the order of the points on the x-axis (time axis) does not follow the numerical sorting 1...100, but rather the text sorting of the factor npl.agg$year Is there any way that I can 'defactor' npl.agg$year so that I have again the numerical values for year? Thanks Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] remotely saving an R session
Jeffrey Horner wrote: $ kill -USR1 pid will save the global environment in the file .RData, but you'll need to remember the current working directory of the process to find it. Remember? With a computer, you never need to remember! $ ls -l /proc/$pid/cwd is a symlink to the current working directory. Even if you change it with setwd() in R, it is still correct. Barry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] survival function with a Weibull dist
Hi I am using R to fit a survival function to my data (with a weibull distribution). Data: Survival of individuals in relation to 4 treatments ('a','b','c','g') syntax: survreg(Surv(date2)~males2, dist='weibull') But I have some problems interpreting the outcome and getting the parameters for each curve. - Value Std. Error z p - (Intercept) 2.788 0.147 19.022 1.13e-80 - males2b -0.107 0.207 -0.519 6.04e-01 - males2c -0.486 0.586 -0.831 4.06e-01 - males2g 0.580 0.207 2.798 5.15e-03 - Log(scale) -1.116 0.139 -8.007 1.18e-15 - - Scale= 0.328 I know from Venables Ripley (2002) that the parameters of this function should be two: lambda = z (presumably Value in R for each treatment) alpha = k (scale in R) Survival function (S): S(t)= exp-(zt)^k I don't quite understand how to use the intercept. First I thought adding it to each other treatment value, for example: Survival Males2a (t) = exp ((intercept + 0) * t) ^ k Survival Males2b (t) = exp ((intercept + zb)* t) ^ k But the curves I get using this interpretation are not similar to my data Does anyone use this function and could help me to interpret the results? many thanks Anaid __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Command area in SciViews 0.8.9 - second try
Dear all I am writing again with a question I posted a few weeks ago (to no avail). I have a problem with SciViews for R. It's probably a slightly stupid question but I cannot find a solution to a very elementary problem. I am using SciViews 0.8.9 on with R 2.3.1pat on a Windows XP Home machine. R is set to SDI mode, I start R, enter library(svGUI), SciViews starts properly, I can access the docks and everything so the installation is ok. But: (i) the command area at the bottom cannot be found (ii) the regular R window cannot be minimized/maximized anymore. I don't know what to do to get the command area back. I have checked the web but all I could come up with (http://tolstoy.newcastle.edu.au/R/help/05/12/16841.html) is the recommendation to click on Misc: Toolbars: Command. But I did that and it's still not visible. Am I making some kind of stupid mistake? I have uploaded a screenshot to my website at http://www.linguistics.ucsb.edu/faculty/stgries/other/sciviews.png to show you what's happening. Any ideas would be greatly appreciated. Thank you very much in advance for your time and all the best, STG --- University of California, Santa Barbara http://www.linguistics.ucsb.edu/faculty/stgries __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R data query
Dear Sir/Madam, I am encountering one of those alien computer momements one finds every so often in life. See the sequence below: fish3.fis -read.csv(emperor2.csv, check.names = TRUE, strip.white = TRUE) colnames(fish3.fis) [1] Month YearFishingArea SumOfTotalCatch CPUE [6] rCPUE PA LatitudeLongitude Depth [11] SST hist(CPUE) Error in hist(CPUE) : Object CPUE not found So, the system knows CPUE exists, but will not do a hist or a gam model using the term - but for some strange reason it will do a plot. I have created a completely different data file and that same problem is happening. The imported files are exactly the same as I was using quite happily last month. As you will see from the above I've tried adding check.names and strip.white in the reading in process to avoid the unseen effect of blank spaces. Any ideas what I might do next? Have you come across this issue at all? Thanks Lubna Al-Kharusi PhD student (GIS) Department of Geography University of Leicester University Road Leicester LE1 7RH mobile # 07886990332 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Other editor with completion apart from emacs?
Hi is there any other editor for Linux, apart from emacs, which has the completion feature (i.e. I enter libTAB and it offers me among other options library) Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R data query
On Thu, 21 Sep 2006, Al-Kharusi, L. wrote: Dear Sir/Madam, I am encountering one of those alien computer momements one finds every so often in life. See the sequence below: fish3.fis -read.csv(emperor2.csv, check.names = TRUE, strip.white = TRUE) colnames(fish3.fis) [1] Month YearFishingArea SumOfTotalCatch CPUE [6] rCPUE PA LatitudeLongitude Depth [11] SST hist(CPUE) Error in hist(CPUE) : Object CPUE not found hist(fish3.fis$CPUE) CPUE is inside the data.frame object and so cannot be seen in the workspace. Reviewing: http://cran.r-project.org/doc/manuals/R-intro.html#Data-frames may help. So, the system knows CPUE exists, but will not do a hist or a gam model using the term - but for some strange reason it will do a plot. I have created a completely different data file and that same problem is happening. The imported files are exactly the same as I was using quite happily last month. As you will see from the above I've tried adding check.names and strip.white in the reading in process to avoid the unseen effect of blank spaces. Any ideas what I might do next? Have you come across this issue at all? Thanks Lubna Al-Kharusi PhD student (GIS) Department of Geography University of Leicester University Road Leicester LE1 7RH mobile # 07886990332 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R data query
On Thu, 2006-09-21 at 13:07 +0100, Al-Kharusi, L. wrote: Dear Sir/Madam, I am encountering one of those alien computer momements one finds every so often in life. See the sequence below: fish3.fis -read.csv(emperor2.csv, check.names = TRUE, strip.white = TRUE) colnames(fish3.fis) [1] Month YearFishingArea SumOfTotalCatch CPUE [6] rCPUE PA LatitudeLongitude Depth [11] SST hist(CPUE) Error in hist(CPUE) : Object CPUE not found So, the system knows CPUE exists, but will not do a hist or a gam model using the term - but for some strange reason it will do a plot. I have created a completely different data file and that same problem is happening. The imported files are exactly the same as I was using quite happily last month. As you will see from the above I've tried adding check.names and strip.white in the reading in process to avoid the unseen effect of blank spaces. Any ideas what I might do next? Have you come across this issue at all? Thanks CPUE is not found, as it is a column within the R data frame object fish3.fis. There are (at least) 5 ways to do a histogram on CPUE: 1. attach() the data frame, which puts it in the search path and you can then use the column name alone: attach(fish3.fis) hist(CPUE) detach(fish3.fis) 2. Identify the column using the '$' function: hist(fish3.fis$CPUE) 3. Use with() to evaluate the hist() call within the environment of the data frame: with(fish3.fis, hist(CPUE)) 4. Use the [ function: hist(fish3.fis[, CPUE]) 5. Use the [[ function: hist(fish3.fis[[CPUE]]) This is covered in An Introduction to R. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Other editor with completion apart from emacs?
JGR support completion. It can runs under Linux,though JGR is more than a editor. On 9/21/06, Rainer M Krug [EMAIL PROTECTED] wrote: Hi is there any other editor for Linux, apart from emacs, which has the completion feature (i.e. I enter libTAB and it offers me among other options library) Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 黄荣贵 Department of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Command area in SciViews 0.8.9 - second try
On Thu, 2006-09-21 at 13:58 +0200, [EMAIL PROTECTED] wrote: Dear all I am writing again with a question I posted a few weeks ago (to no avail). STG Perhaps the main reason you received no replies is that you failed to read to the posting guide and act appropriately. Sciviews is *not* part of R, it is a contributed package. As such you are asked to contact the maintainer directly. Please do so. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html ^ Sorry I can't be any more help - I have never used Sciviews. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC ENSIS, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] newie help needed
hi, I am a system admin who has just set up R-2.3.1 in suse 9.1 (opteron) for a previous windows user. Please forgive any obvious stupid questions :) We are struggling with a number of things. 1. is there a gui interface ? How do we use it ? R --gui just gets us to the command line. 2. how do we do unix commands like cd ? 3. can we define default directories - eg for data files ? 4. we want to use this mainly in batch mode once we get our act together - are there any good examples of batch scripts we can use as crib sheets. 5. I installed some packages earlier - but now I am obviously doing something wrong install.packages(gnomeGui) Error in install.packages(gnomeGui) : object gnomeGui not found thanks, Julie -- Escience Support Team, ITCS Unix Support ENV (please contact [EMAIL PROTECTED]) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Statitics Textbook - any recommendation?
MJ Crawley Statistics: An Introduction Using R, received a good review in Journal of the Royal Statistical Society, Vol 169. Dan Bebber Dr. Daniel P. Bebber Department of Plant Sciences University of Oxford South Parks Road Oxford OX1 3RB UK [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] newie help needed
Julie Harold [EMAIL PROTECTED] writes: hi, I am a system admin who has just set up R-2.3.1 in suse 9.1 (opteron) for a previous windows user. Please forgive any obvious stupid questions :) We are struggling with a number of things. 1. is there a gui interface ? How do we use it ? R --gui just gets us to the command line. Not really. The incantation is R --gui=tk or gnome or X11 but the two former are quite sketchy (proof of concept, really). The last one is the default, but not with menus etc., just windows for graphics. 2. how do we do unix commands like cd ? Any shell command can be executed via system(). This is in a subshell, so of course cd has no effect on return: look up setwd() 3. can we define default directories - eg for data files ? Not in any standard way AFAIK. There is a number of ways you could create your own convention (e.g. via environment variables), though. 4. we want to use this mainly in batch mode once we get our act together - are there any good examples of batch scripts we can use as crib sheets. Depends on what you want to do. There are quite a few documents around with example code and several books have their scripts made public. 5. I installed some packages earlier - but now I am obviously doing something wrong install.packages(gnomeGui) Error in install.packages(gnomeGui) : object gnomeGui not found Quotes needed. In general, do your self a favour and read at least the Intro and Admin manuals from. http://cran.r-project.org/manuals.html -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Other editor with completion apart from emacs?
Hi Thanks for the tip - sounds interesting. I installed JGR, but I can't get it to work. I installed it as mentioned on via install.packages() and if I try to load it, I get the following: library(JGR) Loading required package: rJava Loading required package: JavaGD Loading required package: iplots *** caught segfault *** address 0xc, cause 'memory not mapped' Traceback: 1: .External(RinitJVM, classpath, parameters, PACKAGE = rJava) 2: .jinit(cp, parameters = -Xmx512m, silent = TRUE) 3: f(libname, pkgname) 4: firstlib(which.lib.loc, package) 5: try(firstlib(which.lib.loc, package)) 6: library(pkg, character.only = TRUE, logical = TRUE, lib.loc = lib.loc) 7: .getRequiredPackages2(pkgInfo) 8: library(JGR) Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: I updated the packages to the versions on http://www.rosuda.org/R , but still the same. Any ideas? Rainer ronggui wrote: JGR support completion. It can runs under Linux,though JGR is more than a editor. On 9/21/06, Rainer M Krug [EMAIL PROTECTED] wrote: Hi is there any other editor for Linux, apart from emacs, which has the completion feature (i.e. I enter libTAB and it offers me among other options library) Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] newie help needed
Hi I am not familiar with linux version but On 21 Sep 2006 at 13:56, Julie Harold wrote: Date sent: Thu, 21 Sep 2006 13:56:06 +0100 From: Julie Harold [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] newie help needed hi, I am a system admin who has just set up R-2.3.1 in suse 9.1 (opteron) for a previous windows user. Please forgive any obvious stupid questions :) We are struggling with a number of things. 1. is there a gui interface ? How do we use it ? R --gui just gets us to the command line. AFAIK there is not a GUI in a sense of other statistical packages directly ot of a box. 2. how do we do unix commands like cd ? From R command line? see system 3. can we define default directories - eg for data files ? yes, see setwd, getwd help page 4. we want to use this mainly in batch mode once we get our act together - are there any good examples of batch scripts we can use as crib sheets. 5. I installed some packages earlier - but now I am obviously doing something wrong install.packages(gnomeGui) Error in install.packages(gnomeGui) : object gnomeGui not found install.packages(gnomeGui) Try to go through some manuals located in doc directory and/or on web pages of R project HTH Petr thanks, Julie -- Escience Support Team, ITCS Unix Support ENV (please contact [EMAIL PROTECTED]) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating a new Access database with R
First of all, since this is my first posting, I would like to thank anybody who works/has worked on R, and made it such a beautiful open source package! My question is: how do I create a new Access database with R? I need a channel before I can do anything, but if the mdb-file doesn't exist, I can't connect to it with odbcConnectAccess. I've looked at the RODBC.pdf on CRAN, searched the mailing-lists, and looked at test.R file in the package. But probably I've overlooked something. It is of course possible to keep a clean new mdb-file somewhere and then copy it to the required directory with: shell(copy EmptyDB.mdb NewLocation.mdb) But that isn't very elegant... Thanks in advance, Uri Shimron *** This email and any files transmitted with it are confidentia...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Covariance matrix for first canonical variate
Does anyone know how to get a meaningful estimate of the covariance matrix for the first canonical variate coefficients for the right-hand (X) side of a canonical regression? cancor returns coefficients but not precisions. This would have to be subject to some constraint because of identifiability problems (arbitrary scaling). I think that SPSS attempts to do this but seems to condition on the Y-coefficients which ignores a major source of uncertainty. Thanks Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] newie help needed
Julie Harold j.m.harold at uea.ac.uk writes: 1. is there a gui interface ? How do we use it ? R --gui just gets us to the command line. Look at SciViews. Not a 100% menu driven GUI, but can be useful to new users. 3. can we define default directories - eg for data files ? I think you can, because sys-admin at my former university did so some years ago. May be using a symbolic link---I am not sure though. 4. we want to use this mainly in batch mode once we get our act together - are there any good examples of batch scripts we can use as crib sheets. creating a new and simplified batch command for users may be helpful, rather than allowing them to use the system batch, at or related commands. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Command area in SciViews 0.8.9 - second try
On 9/21/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: (i) the command area at the bottom cannot be found (ii) the regular R window cannot be minimized/maximized anymore. I cannot duplicate these problems with R 2.3.1, SciViews 0.8-9, Win XP(current). jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot correlation matrix
Vladimir Eremeev [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dear useRs, While exploring new R packages, I have found the Rattle. This screenshot http://rattle.togaware.com/rattle-correlation.png is very interesting Which function was used to produce this plot? library(ellipse) ?plotcorr Look at the third example for the color plot. Earl F. Glynn Bioinformatics Stowers Institute for Medical Research __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mail Server timeout of 1--2 hours
Because of the replacement of the current NAS (Networked Disk Server), there will be a mail server timeout from 18:00 till about 20:00 Swiss time, i.e. UTC+2 This will also effect cran.CH.r-project.org, our ftp server and http://ESS.r-project.org/ but *not* the subversion server svn.r-project.org (because that is completely independent with no mounted file systems). Martin Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Exponentiate a matrix
Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. Thanks, Harold [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] binom
Please stop posting your homework problems to R-help! The posting guide quite explictly does not allow it. M.Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate a matrix
On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. I don't think there's anything built in, but it's easy to write your own: %^% - function(mat, pow) { stopifnot(length(pow) == 1, all.equal(pow, round(pow)), nrow(mat) == ncol(mat)) pow - round(pow) if (pow 0) { mat - solve(mat) pow - abs(pow) } result - diag(nrow(mat)) while (pow 0) { result - result %*% mat pow - pow - 1 } result } Now P %^% 3 will give you the matrix cube. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot correlation matrix
On 9/21/06, Earl F. Glynn [EMAIL PROTECTED] wrote: Which function was used to produce this plot? library(ellipse) ?plotcorr Look at the third example for the color plot. That's pretty nice. I have been using symnum(). Are there any other neat visualisations for correlation matrices? jab -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] frequency table
Dear all, I have a vector like this: z = rep(c(M,F),c(50,60)) How can I get the following frequency table: Sex counts % F60 54.5 M 50 45.5 I try: DD- function(data,...) { n - nobs(data) out - c(Frequency = n, k = n/length(data)) return(out) } mApply(z,z,DD) but Best regards _ Insta-le agora o Windows Live Messenger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] survival function with a Weibull dist
On Thu, 21 Sep 2006, Anaid Diaz wrote: Hi I am using R to fit a survival function to my data (with a weibull distribution). Data: Survival of individuals in relation to 4 treatments ('a','b','c','g') syntax: survreg(Surv(date2)~males2, dist='weibull') But I have some problems interpreting the outcome and getting the parameters for each curve. - Value Std. Error z p - (Intercept) 2.788 0.147 19.022 1.13e-80 - males2b -0.107 0.207 -0.519 6.04e-01 - males2c -0.486 0.586 -0.831 4.06e-01 - males2g 0.580 0.207 2.798 5.15e-03 - Log(scale) -1.116 0.139 -8.007 1.18e-15 - - Scale= 0.328 I know from Venables Ripley (2002) that the parameters of this function should be two: this function being which function? As help(survreg.distributions) says The Weibull distribution is not parameterised the same way as in 'rweibull'. In your model the survival time is a variable whose logarithm has distribution 2.788-0.107males2b-0.486males2c+0.580males2g+epsilon*0.328 where epsilon has cdf F=1-e^{-e^t}. As in the example on help(survreg.distributions) shows, a survreg Weibull model with linear predictor M and scale S corresponds to R's weibull distribution with scale exp(M) and shape 1/S. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot correlation matrix
BBands a écrit : That's pretty nice. I have been using symnum(). Are there any other neat visualisations for correlation matrices? Although very simple, I find often image() sufficient. Plus some ordering if needed. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate a matrix
Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. I don't think there's anything built in, but it's easy to write your own: I think there was function mtx.exp() in the Malmig package, but it seems that this package has been withdrawn from CRAN. An old version appears to exist in: http://r.meteo.uni.wroc.pl/src/contrib/Descriptions/Malmig.html Best, Dimitris %^% - function(mat, pow) { stopifnot(length(pow) == 1, all.equal(pow, round(pow)), nrow(mat) == ncol(mat)) pow - round(pow) if (pow 0) { mat - solve(mat) pow - abs(pow) } result - diag(nrow(mat)) while (pow 0) { result - result %*% mat pow - pow - 1 } result } Now P %^% 3 will give you the matrix cube. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variable im Data Frame Namen
At 12:03 20/09/2006, Thorsten Muehge wrote: Hello R Experts, how can I incorporate a variable in a data frame definition? Thorsten, you have already had a reply about this, but I wonder whether you _really_ want to do this. You do not say what the scientific question is you are trying to answer, but I find that when I am tempted to do this it is almost always better to make a list (in your case of data frames) and then access the elements of the list Example: week - 28 test(week) - data.frame(a,b,s,c); test28 Michael Dewey http://www.aghmed.fsnet.co.uk __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot Confidence Interval for Regression
Dear R-friends I fitted a regression using GLM and plotted fitted values agaist X axis. Now I need plot upper and lower confidence intervals (95%) for this fit. Acoording to ?lm help and can use something like : [ predict.lm(mod, se.fit=T, interval = confidence, level=.95) ] to estimate confidence intervals. In fact this command run fine, but I can´t plot upper and lower C.I. lines. Any help, Kind regards Miltinho - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate a matrix
There is also mexp in the Matrix package and MatrixExp in the msm package. Andreas - Original Message - From: Dimitrios Rizopoulos [EMAIL PROTECTED] To: Duncan Murdoch [EMAIL PROTECTED] Cc: Doran, Harold [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Thursday, September 21, 2006 4:26 PM Subject: Re: [R] Exponentiate a matrix Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. I don't think there's anything built in, but it's easy to write your own: I think there was function mtx.exp() in the Malmig package, but it seems that this package has been withdrawn from CRAN. An old version appears to exist in: http://r.meteo.uni.wroc.pl/src/contrib/Descriptions/Malmig.html Best, Dimitris %^% - function(mat, pow) { stopifnot(length(pow) == 1, all.equal(pow, round(pow)), nrow(mat) == ncol(mat)) pow - round(pow) if (pow 0) { mat - solve(mat) pow - abs(pow) } result - diag(nrow(mat)) while (pow 0) { result - result %*% mat pow - pow - 1 } result } Now P %^% 3 will give you the matrix cube. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exponentiate a matrix
On 9/21/06, Dimitrios Rizopoulos [EMAIL PROTECTED] wrote: Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. I don't think there's anything built in, but it's easy to write your own: I think there was function mtx.exp() in the Malmig package, but it seems that this package has been withdrawn from CRAN. An old version appears to exist in: http://r.meteo.uni.wroc.pl/src/contrib/Descriptions/Malmig.html Best, Dimitris Is that function for matrix powers or for the exponential of a matrix (which is what I initally thought that Harold wanted)? There is a function expm in the Matrix package, patterned on the octave function of the same name, the calculates the matrix exponential for a square matrix. %^% - function(mat, pow) { stopifnot(length(pow) == 1, all.equal(pow, round(pow)), nrow(mat) == ncol(mat)) pow - round(pow) if (pow 0) { mat - solve(mat) pow - abs(pow) } result - diag(nrow(mat)) while (pow 0) { result - result %*% mat pow - pow - 1 } result } Now P %^% 3 will give you the matrix cube. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] delete a entire vector of a dataframe
delete a entire vector of a dataframe Hello, i want to delete a vector and tried rm (t.d$V712). This did not work, message was, could not find variable. I thought the $ defines the vectro in a dataframe, when I just type t.d$V712 the content of this vector is displayed. Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] frequency table
And look at ?prop.table too. On 21/09/06, lamack lamack [EMAIL PROTECTED] wrote: Dear all, I have a vector like this: z = rep(c(M,F),c(50,60)) How can I get the following frequency table: Sex counts % F60 54.5 M 50 45.5 I try: DD- function(data,...) { n - nobs(data) out - c(Frequency = n, k = n/length(data)) return(out) } mApply(z,z,DD) but Best regards _ Insta-le agora o Windows Live Messenger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to ignore NA or replace it by another value
Hello, I`m a newbie to R so maybe this question is boring, but I have a large table with several empty missing values, which come out as NA. How can i ignore them or replace them by another number? Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Installing packages with R v.2.3.1 on MAC OS X -- Error: Cannot chdir: No such file or directory
Dear all, I'm working on MAC OS X 10.4.7 using R version 2.3.1 (June 2006) and platform powerpc-apple-darwin8.6.0. Since I installed the new version of R I cannot install packages any more (but it worked fine before) and get the following message every time. I can, however, install packages from the command line if I get them as precompiled binaries. -- install.packages(foreign, lib=~/libs/Rlibs) trying URL 'http://www.biometrics.mtu.edu/CRAN/bin/macosx/powerpc/ contrib/2.3/foreign_0.8-15.tgz' Content type 'application/x-gzip' length 268096 bytes opened URL == downloaded 261Kb tar: ~/libs/Rlibs/file77a4044d: Cannot chdir: No such file or directory tar: Error is not recoverable: exiting now gzip: stdout: Broken pipe Error in sprintf(gettext(fmt, domain = domain), ...) : argument is missing, with no default --- The command did create the directory (i.e. ~/libs/Rlibs/file77a4044d) on my system and has open priviledges (i.e. drwxr-xr-x) but is empty. I've tried 'sudo R' but that does not help and cannot find anything helpful on this in the R-help archives or FAQ. Thanks in advance for your help, I would really appreciate any help in solving this, best regards, Snaebjorn __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] frequency table
You might want to look at the CrossTable function in the gmodels package (in the gregmisc bundle). On 21/09/06, lamack lamack [EMAIL PROTECTED] wrote: Dear all, I have a vector like this: z = rep(c(M,F),c(50,60)) How can I get the following frequency table: Sex counts % F60 54.5 M 50 45.5 I try: DD- function(data,...) { n - nobs(data) out - c(Frequency = n, k = n/length(data)) return(out) } mApply(z,z,DD) but Best regards _ Insta-le agora o Windows Live Messenger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing the index of a histogram
Dear everybody! I am trying to make up a histogram of marks of a recent test I have corrified. Say I have a vector points and a vektor breaks to segregate the marks. Finally there is a vector marks. hist(points, breaks=breaks) leaves me with two problems: At first the width of the bars of the histogram corresponds with the width of the intervall. This will look confusing and not very elaborated when in the end the index shall not be breaks, but marks. At second, you guessed it, I have the problem to exchange breaks for marks on the y-axis, at least surfacially. A glance into old mailing list brought me plot(table(cut(points,breaks=breaks,right=FALSE,include.lowest=TRUE))) as a good solution to the first matter (except that right=FALSE seems contradictory ;) I would be very glad if you could give me a hint to solve the second problem, most preferably such, that the first would be circumvaded by transforming the variable intervals of breaks into the uniform ones of marks and then employing hist(). Thank you in advance. Yours, Mag. Ferri Leberl __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] cairoDevice 1.2 on CRAN
The cairoDevice package has recently been released on CRAN. cairoDevice is an R graphics device based on the cairo (http://www.cairographics.org) vector graphics library. It is distinguished from many other devices in its ability to render high quality anti-aliased graphics. It is available on all three major platforms (Windows, Mac, and Linux) and requires the GTK+ 2.8.0 library and its dependencies. For the current users, version 1.2 fixes many bugs. cairoDevice is capable of rendering in three different ways: to the screen inside a GTK+ window, to an arbitrary GtkDrawingArea that is part of an RGtk2 GUI, or to any GdkDrawable, allowing for example the output of png and jpg images derived from R graphics using the GdkPixbuf bindings from RGtk2. cairoDevice is interactive in that it supports the locator tool as well as the getGraphicsEvent() functionality, which previously was available only from the Windows device. To obtain the requisite GTK+ (= 2.8.0) libraries: Windows: Download and run the installer from http://gladewin32.sf.net. Mac: DarwinPorts Linux: packages from your distribution Please enjoy the package and let me know if you have any problems, Michael Lawrence ___ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to ignore NA or replace it by another value
It depends a bit on what function you are using. For example, set.seed(1) xx - c(NA, rnorm(10)) mean(xx) [1] NA mean(xx, na.rm=TRUE) [1] 0.1322028 Is how you would use this to compute a mean. Harold -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Preuth Sent: Thursday, September 21, 2006 1:59 PM To: r-help@stat.math.ethz.ch Subject: [R] how to ignore NA or replace it by another value Hello, I`m a newbie to R so maybe this question is boring, but I have a large table with several empty missing values, which come out as NA. How can i ignore them or replace them by another number? Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems with making a complex graphic
Hola! maybe someone can see what is wrong in the following graphics code. The data needed for the example (printed with dump) is at the end of the message. I make 3 pages with multipanel plot, and want each page to have a subtitle explaining the common x-axis, with the command: title(sub=aleles(bp), outer=TRUE,adj=0.5,col=snow3) but nothing appears. What is wrong? Here is the code: par(ask=TRUE) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6, cex.lab=0.6, yaxt=n) for (i in 1:6) { barplot( tab107[,i], names.arg=c(182, 196, 200, 202, 206, 210, 220, 248) , col=snow3 , main=pops[i] ,xlab=, ylab= ) } for (i in 1:6) { barplot(tab02[,i], names.arg=c(140, 148, 152, 172, 178, 180, 196, 198, 206, 210, 230), col=snow3, main=pops[i] , xlab=, ylab=)} title(main=paste(alelos[1], ,alelos[2]), outer=TRUE, cex=1.5, col=red) title(sub=aleles(bp), outer=TRUE,adj=0.5,col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6, cex.lab=0.6,yaxt=n) for (i in 1:6) { barplot( tab137[,i], names.arg=c(128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 164, 180), col=snow3, main=pops[i] ,xlab=, ylab=)} for (i in 1:6) { barplot( tab110[,i], names.arg=c(158, 162, 164, 168, 172, 176, 180, 198) , col=snow3, main=pops[i], xlab=,ylab=) } title(main=paste(alelos[3], ,alelos[4]), outer=TRUE,cex=1.5, col=red) title(sub=aleles(bp), outer=TRUE, adj=0.5, col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6,cex.lab=0.6, yaxt=n) for (i in 1:6) { barplot( tab28[,i], names.arg=c(120, 124, 128, 130, 132, 134) , col=snow3, main=pops[i], xlab=, ylab=) } title(main=paste(alelos[5], ), outer=TRUE,cex=1.5, col='red') title(sub=aleles(bp), outer=TRUE,adj=0.5, col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) Here is the sessionInfo: R version 2.4.0 alpha (2006-09-16 r39365) i386-pc-mingw32 locale: LC_COLLATE=Spanish_Bolivia.1252;LC_CTYPE=Spanish_Bolivia.1252;LC_MONETARY=Spanish_Bolivia.1252;LC_NUMERIC=C;LC_TIME=Spanish_Bolivia.1252 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Here is the necessary data: alelos - c(ADC107, ADC02, ADC137, ADC110, ADC28) pops - c(Prado, P. Rico, Guayaramerin, C. Esperanza, R. de Yata, S. Miguel) tab02 - structure(list(V3 = c(0.012, 0.183, 0, 0.195, 0.012, 0.049, 0.012, 0.305, 0.232, 0, 0), V4 = c(0.024, 0.476, 0, 0.012, 0, 0.073, 0.024, 0.171, 0.171, 0.049, 0), V5 = c(0.014, 0.111, 0.014, 0.236, 0.111, 0.194, 0, 0.042, 0.236, 0.028, 0.014), V6 = c(0.024, 0.214, 0, 0.202, 0.024, 0.167, 0.06, 0.071, 0.202, 0.036, 0), V7 = c(0.038, 0.449, 0, 0.128, 0.077, 0.038, 0, 0, 0.192, 0.077, 0), V8 = c(0, 0.338, 0, 0.113, 0.125, 0.138, 0, 0.038, 0.125, 0.075, 0.05)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), class = data.frame) tab107 - structure(list(V3 = c(0.079, 0.421, 0.118, 0.158, 0.079, 0.079, 0.066, 0), V4 = c(0.053, 0.5, 0.066, 0.118, 0.211, 0.039, 0.013, 0), V5 = c(0.222, 0.444, 0.069, 0.181, 0.042, 0.014, 0.028, 0 ), V6 = c(0.138, 0.625, 0.113, 0.1, 0.013, 0.013, 0, 0), V7 = c(0.135, 0.541, 0.041, 0.095, 0.149, 0.014, 0.014, 0.014), V8 = c(0.212, 0.53, 0.061, 0.076, 0.03, 0.03, 0.03, 0.03)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8), class = data.frame) tab110 - structure(list(V3 = c(0.088, 0.25, 0.338, 0.213, 0.038, 0, 0.075, 0), V4 = c(0.107, 0.393, 0.333, 0.095, 0.024, 0, 0.048, 0), V5 = c(0.162, 0.351, 0.27, 0.149, 0.014, 0.014, 0.041, 0), V6 = c(0.012, 0.14, 0.535, 0.186, 0.07, 0, 0.058, 0), V7 = c(0.027, 0.23, 0.392, 0.149, 0.095, 0, 0.081, 0.027), V8 = c(0, 0.125, 0.475, 0.263, 0.088, 0, 0.025, 0.025)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8), class = data.frame) tab137 - structure(list(V3 = c(0.111, 0.069, 0.097, 0.167, 0.014, 0.069, 0.278, 0.153, 0.028, 0, 0.014, 0, 0, 0), V4 = c(0.05, 0.063, 0.038, 0.213, 0, 0.075, 0.3, 0.125, 0.1, 0, 0.013, 0, 0.013, 0.013), V5 = c(0.103, 0.167, 0.064, 0.115, 0, 0.064, 0.333, 0.064, 0.026, 0.013, 0.051, 0, 0, 0), V6 = c(0, 0.026, 0.079, 0.171, 0.026, 0.118, 0.289, 0.158, 0.053, 0.013, 0.039, 0.026, 0, 0), V7 = c(0, 0.063, 0.075, 0.2, 0.1, 0.125, 0.225, 0.163, 0.038, 0, 0, 0.013, 0, 0), V8 = c(0, 0.075, 0.038, 0.113, 0.063, 0.188, 0.188, 0.238, 0.075, 0, 0.025, 0, 0, 0)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), class = data.frame
Re: [R] Exponentiate a matrix
Quoting Douglas Bates [EMAIL PROTECTED]: On 9/21/06, Dimitrios Rizopoulos [EMAIL PROTECTED] wrote: Quoting Duncan Murdoch [EMAIL PROTECTED]: On 9/21/2006 10:40 AM, Doran, Harold wrote: Suppose I have a square matrix P P - matrix(c(.3,.7, .7, .3), ncol=2) I know that P * P Returns the element by element product, whereas P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. I don't think there's anything built in, but it's easy to write your own: I think there was function mtx.exp() in the Malmig package, but it seems that this package has been withdrawn from CRAN. An old version appears to exist in: http://r.meteo.uni.wroc.pl/src/contrib/Descriptions/Malmig.html Best, Dimitris Is that function for matrix powers or for the exponential of a matrix (which is what I initally thought that Harold wanted)? There is a function expm in the Matrix package, patterned on the octave function of the same name, the calculates the matrix exponential for a square matrix. this function calculates the n-th power of a matrix, and this is what I thought Harold wanted, i.e., P %*% P %*% P %*% P should be equal to mtx.exp(P, 4) %^% - function(mat, pow) { stopifnot(length(pow) == 1, all.equal(pow, round(pow)), nrow(mat) == ncol(mat)) pow - round(pow) if (pow 0) { mat - solve(mat) pow - abs(pow) } result - diag(nrow(mat)) while (pow 0) { result - result %*% mat pow - pow - 1 } result } Now P %^% 3 will give you the matrix cube. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] delete a entire vector of a dataframe
There is a function remove.vars in the gdata package, or you can do this: dt-data.frame(a=(1:5),b=(6:10),c=(11:15)) dt a b c 1 1 6 11 2 2 7 12 3 3 8 13 4 4 9 14 5 5 10 15 dt[[a]] - NULL dt dt b c 1 6 11 2 7 12 3 8 13 4 9 14 5 10 15 If you know it is the first column that you want to remove, you can also use dt[,-1]. On 21/09/06, Thomas Preuth [EMAIL PROTECTED] wrote: delete a entire vector of a dataframe Hello, i want to delete a vector and tried rm (t.d$V712). This did not work, message was, could not find variable. I thought the $ defines the vectro in a dataframe, when I just type t.d$V712 the content of this vector is displayed. Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to ignore NA or replace it by another value
Most R functions have arguments of the form na.action or na.rm that allow you to specify how you treat NA's. In general, it's not a good idea to replace NA's with numbers. See also ?na.omit, ?na.action. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Preuth Sent: Thursday, September 21, 2006 10:59 AM To: r-help@stat.math.ethz.ch Subject: [R] how to ignore NA or replace it by another value Hello, I`m a newbie to R so maybe this question is boring, but I have a large table with several empty missing values, which come out as NA. How can i ignore them or replace them by another number? Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [ROracle] error loading (undefined symbol: sqlclu)
Hi Marc, thanks for the answer, but that wasn't the problem. I set my LD_LIBRARY_PATH in my .cshrc. I solve my problem by compiling the library manually. It created me a file (ROracle.so) of ~14mb (instead of the one of ~150K) that I replaced with the other one. I guess R compilation did something wrong. Thanks, Mathieu Marc Schwartz (via MN) wrote: On Wed, 2006-09-20 at 15:15 -0400, Mathieu Drapeau wrote: I have this error when I load the library ROracle: library(ROracle) Loading required package: DBI Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/usr/local/lib/R/site-library/ROracle/libs/ROracle.so': /usr/local/lib/R/site-library/ROracle/libs/ROracle.so: undefined symbol: sqlclu Error in library(ROracle) : .First.lib failed for 'ROracle' Also, my LD_LIBRARY_PATH seems to be set correctly: drapeau:~ echo $LD_LIBRARY_PATH /home/drapeau/lib:/opt/oracle/xe/app/oracle/product/10.2.0/client/lib I installed the big database applications (10g) and ROracle 0.5-7 Your help will be very appreciated to help me solve this error, Thank you, Mathieu Where did you set LD_LIBRARY_PATH? If in one of your shell config files, it is likely that it is being stepped on during your login and thus not being seen within the R session. I had this problem previously and set the variable in /etc/ld.so.conf (though I am using RODBC instead). Edit that file (as root), add the path: /opt/oracle/xe/app/oracle/product/10.2.0/client/lib and then run [/sbin/]ldconfig to update the current settings. Be sure also that $ORACLE_HOME is set to /opt/oracle/xe/app/oracle/product/10.2.0/client Then try to load ROracle in a new R session. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to ignore NA or replace it by another value
On Thu, 2006-09-21 at 19:58 +0200, Thomas Preuth wrote: Hello, I`m a newbie to R so maybe this question is boring, but I have a large table with several empty missing values, which come out as NA. How can i ignore them or replace them by another number? Greetings, Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Ignoring NAs depends on what functions you want to ignore them in. As for replacing NAs with another number, this will replace all NAs with 0 # some example data dat - as.data.frame(matrix(rnorm(100), nrow = 10)) # add some NAs dat[sample(1:10, 3), sample(1:10, 3)] - NA dat # replace missing values with 0 dat - sapply(dat, function(x) {x[is.na(x)] - 0; x}) dat HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% *Note new Address and Fax and Telephone numbers from 10th April 2006* %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/ WC1E 6BT [w] http://www.ucl.ac.uk/~ucfagls/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] delete a entire vector of a dataframe
On Thu, 2006-09-21 at 20:01 +0200, Thomas Preuth wrote: delete a entire vector of a dataframe Hello, i want to delete a vector and tried rm (t.d$V712). This did not work, message was, could not find variable. I thought the $ defines the vectro in a dataframe, when I just type t.d$V712 the content of this vector is displayed. Greetings, Thomas You can't do that, and that is not what the error message said exactly - which should have told you something was wrong with your thinking as it also said 1: remove: variable $ was not found. Instead, copy over the object, minus the column you want to delete: dat - as.data.frame(matrix(rnorm(100), nrow = 10)) names(dat) - paste(Var, 1:10, sep = _) dat # now we don't want column Var_6 dat - dat[, -6] # or if we don't know which column is Var_6 you could do not.want - which(names(dat) %in% Var_7) # now don't want Var_7 dat - dat[, -not.want] dat This can be extended to many variables: not.want - which(names(dat) %in% c(Var_10, Var_2, Var_8)) dat - dat[, -not.want] dat # only 1, 3, 4, 5, 9 left HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% *Note new Address and Fax and Telephone numbers from 10th April 2006* %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/ WC1E 6BT [w] http://www.ucl.ac.uk/~ucfagls/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Matrix from a vector?
Hi, Is there some function, which generates this kind of n x n -matrix from a vector? rhset [1] 1792 256 13312 512 1024 2048 8192 4096 m=matrix(nrow=length(rhset),ncol=length(rhset)) for(i in 1:length(rhset)) + { + m[,i]=rhset + rhset=c(rhset[length(rhset)], rhset[2:length(rhset)-1]) + } m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1792 4096 8192 2048 1024 512 13312 256 [2,] 256 1792 4096 8192 2048 1024 512 13312 [3,] 13312 256 1792 4096 8192 2048 1024 512 [4,] 512 13312 256 1792 4096 8192 2048 1024 [5,] 1024 512 13312 256 1792 4096 8192 2048 [6,] 2048 1024 512 13312 256 1792 4096 8192 [7,] 8192 2048 1024 512 13312 256 1792 4096 [8,] 4096 8192 2048 1024 512 13312 256 1792 Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with making a complex graphic
I'm not sure why it doesn't work, perhaps something to do with how you have set the mar and oma parameters? But why not use mtext(side=1,text=aleles(bp),outer=TRUE,col=snow3) On 21/09/06, Kjetil Halvorsen [EMAIL PROTECTED] wrote: Hola! maybe someone can see what is wrong in the following graphics code. The data needed for the example (printed with dump) is at the end of the message. I make 3 pages with multipanel plot, and want each page to have a subtitle explaining the common x-axis, with the command: title(sub=aleles(bp), outer=TRUE,adj=0.5,col=snow3) but nothing appears. What is wrong? Here is the code: par(ask=TRUE) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6, cex.lab=0.6, yaxt=n) for (i in 1:6) { barplot( tab107[,i], names.arg=c(182, 196, 200, 202, 206, 210, 220, 248) , col=snow3 , main=pops[i] ,xlab=, ylab= ) } for (i in 1:6) { barplot(tab02[,i], names.arg=c(140, 148, 152, 172, 178, 180, 196, 198, 206, 210, 230), col=snow3, main=pops[i] , xlab=, ylab=)} title(main=paste(alelos[1], ,alelos[2]), outer=TRUE, cex=1.5, col=red) title(sub=aleles(bp), outer=TRUE,adj=0.5,col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6, cex.lab=0.6,yaxt=n) for (i in 1:6) { barplot( tab137[,i], names.arg=c(128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 164, 180), col=snow3, main=pops[i] ,xlab=, ylab=)} for (i in 1:6) { barplot( tab110[,i], names.arg=c(158, 162, 164, 168, 172, 176, 180, 198) , col=snow3, main=pops[i], xlab=,ylab=) } title(main=paste(alelos[3], ,alelos[4]), outer=TRUE,cex=1.5, col=red) title(sub=aleles(bp), outer=TRUE, adj=0.5, col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) par(mfcol=c(6,2),mar=c(2,2,3,0)+0.1 ,bg=gray3, col.axis=snow3, col.lab=snow3, col.main=snow3, col.sub=snow3, oma=c(4,3,4,0), cex.axis=0.6, cex.main=0.8, cex.sub=0.6,cex.lab=0.6, yaxt=n) for (i in 1:6) { barplot( tab28[,i], names.arg=c(120, 124, 128, 130, 132, 134) , col=snow3, main=pops[i], xlab=, ylab=) } title(main=paste(alelos[5], ), outer=TRUE,cex=1.5, col='red') title(sub=aleles(bp), outer=TRUE,adj=0.5, col=snow3) mtext(side=2,text=Frecuencias, outer=TRUE,adj=0.5) Here is the sessionInfo: R version 2.4.0 alpha (2006-09-16 r39365) i386-pc-mingw32 locale: LC_COLLATE=Spanish_Bolivia.1252;LC_CTYPE=Spanish_Bolivia.1252;LC_MONETARY=Spanish_Bolivia.1252;LC_NUMERIC=C;LC_TIME=Spanish_Bolivia.1252 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base Here is the necessary data: alelos - c(ADC107, ADC02, ADC137, ADC110, ADC28) pops - c(Prado, P. Rico, Guayaramerin, C. Esperanza, R. de Yata, S. Miguel) tab02 - structure(list(V3 = c(0.012, 0.183, 0, 0.195, 0.012, 0.049, 0.012, 0.305, 0.232, 0, 0), V4 = c(0.024, 0.476, 0, 0.012, 0, 0.073, 0.024, 0.171, 0.171, 0.049, 0), V5 = c(0.014, 0.111, 0.014, 0.236, 0.111, 0.194, 0, 0.042, 0.236, 0.028, 0.014), V6 = c(0.024, 0.214, 0, 0.202, 0.024, 0.167, 0.06, 0.071, 0.202, 0.036, 0), V7 = c(0.038, 0.449, 0, 0.128, 0.077, 0.038, 0, 0, 0.192, 0.077, 0), V8 = c(0, 0.338, 0, 0.113, 0.125, 0.138, 0, 0.038, 0.125, 0.075, 0.05)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), class = data.frame) tab107 - structure(list(V3 = c(0.079, 0.421, 0.118, 0.158, 0.079, 0.079, 0.066, 0), V4 = c(0.053, 0.5, 0.066, 0.118, 0.211, 0.039, 0.013, 0), V5 = c(0.222, 0.444, 0.069, 0.181, 0.042, 0.014, 0.028, 0 ), V6 = c(0.138, 0.625, 0.113, 0.1, 0.013, 0.013, 0, 0), V7 = c(0.135, 0.541, 0.041, 0.095, 0.149, 0.014, 0.014, 0.014), V8 = c(0.212, 0.53, 0.061, 0.076, 0.03, 0.03, 0.03, 0.03)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8), class = data.frame) tab110 - structure(list(V3 = c(0.088, 0.25, 0.338, 0.213, 0.038, 0, 0.075, 0), V4 = c(0.107, 0.393, 0.333, 0.095, 0.024, 0, 0.048, 0), V5 = c(0.162, 0.351, 0.27, 0.149, 0.014, 0.014, 0.041, 0), V6 = c(0.012, 0.14, 0.535, 0.186, 0.07, 0, 0.058, 0), V7 = c(0.027, 0.23, 0.392, 0.149, 0.095, 0, 0.081, 0.027), V8 = c(0, 0.125, 0.475, 0.263, 0.088, 0, 0.025, 0.025)), .Names = c(V3, V4, V5, V6, V7, V8), row.names = c(1, 2, 3, 4, 5, 6, 7, 8), class = data.frame) tab137 - structure(list(V3 = c(0.111, 0.069, 0.097, 0.167, 0.014, 0.069, 0.278, 0.153, 0.028, 0, 0.014, 0, 0, 0), V4 = c(0.05, 0.063, 0.038, 0.213, 0, 0.075, 0.3, 0.125, 0.1, 0, 0.013, 0, 0.013, 0.013), V5 = c(0.103, 0.167, 0.064, 0.115, 0, 0.064, 0.333, 0.064, 0.026, 0.013, 0.051, 0, 0, 0), V6 = c(0, 0.026, 0.079, 0.171, 0.026, 0.118, 0.289,
Re: [R] Matrix from a vector?
kone said the following on 9/21/2006 2:30 PM: Hi, Is there some function, which generates this kind of n x n -matrix from a vector? rhset [1] 1792 256 13312 512 1024 2048 8192 4096 m=matrix(nrow=length(rhset),ncol=length(rhset)) for(i in 1:length(rhset)) + { + m[,i]=rhset + rhset=c(rhset[length(rhset)], rhset[2:length(rhset)-1]) + } m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1792 4096 8192 2048 1024 512 13312 256 [2,] 256 1792 4096 8192 2048 1024 512 13312 [3,] 13312 256 1792 4096 8192 2048 1024 512 [4,] 512 13312 256 1792 4096 8192 2048 1024 [5,] 1024 512 13312 256 1792 4096 8192 2048 [6,] 2048 1024 512 13312 256 1792 4096 8192 [7,] 8192 2048 1024 512 13312 256 1792 4096 [8,] 4096 8192 2048 1024 512 13312 256 1792 Atte Tenkanen University of Turku, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Does this work for you? rhsel - c(1792, 256, 13312, 512, 1024, 2048, 8192, 4096) n - length(rhsel) i - sapply(1:n, function(i) (1:n - i)%%n + 1) matrix(rhsel[i], n, n) HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing packages with R v.2.3.1 on MAC OS X -- Error: Cannot chdir: No such file or directory
Are you trying to install a package from source? Try adding type='source' when you call install.packages(). The help page for install.packages() indicates the need for this on a Mac. You might also check and see if ~/libs exists, and you have write privileges, but take care of the source vs. binary issue first. Notice the 'bin' in the URL path it mentions. -Don At 12:16 PM -0400 9/21/06, Snaebjorn Gunnsteinsson wrote: Dear all, I'm working on MAC OS X 10.4.7 using R version 2.3.1 (June 2006) and platform powerpc-apple-darwin8.6.0. Since I installed the new version of R I cannot install packages any more (but it worked fine before) and get the following message every time. I can, however, install packages from the command line if I get them as precompiled binaries. -- install.packages(foreign, lib=~/libs/Rlibs) trying URL 'http://www.biometrics.mtu.edu/CRAN/bin/macosx/powerpc/ contrib/2.3/foreign_0.8-15.tgz' Content type 'application/x-gzip' length 268096 bytes opened URL == downloaded 261Kb tar: ~/libs/Rlibs/file77a4044d: Cannot chdir: No such file or directory tar: Error is not recoverable: exiting now gzip: stdout: Broken pipe Error in sprintf(gettext(fmt, domain = domain), ...) : argument is missing, with no default --- The command did create the directory (i.e. ~/libs/Rlibs/file77a4044d) on my system and has open priviledges (i.e. drwxr-xr-x) but is empty. I've tried 'sudo R' but that does not help and cannot find anything helpful on this in the R-help archives or FAQ. Thanks in advance for your help, I would really appreciate any help in solving this, best regards, Snaebjorn __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing packages with R v.2.3.1 on MAC OS X -- Error: Cannot chdir: No such file or directory
Hi Don, type=source solved the problem. Thanks very much for your help, best, Snaebjorn On Sep 21, 2006, at 3:59 PM, Don MacQueen wrote: Are you trying to install a package from source? Try adding type='source' when you call install.packages(). The help page for install.packages() indicates the need for this on a Mac. You might also check and see if ~/libs exists, and you have write privileges, but take care of the source vs. binary issue first. Notice the 'bin' in the URL path it mentions. -Don At 12:16 PM -0400 9/21/06, Snaebjorn Gunnsteinsson wrote: Dear all, I'm working on MAC OS X 10.4.7 using R version 2.3.1 (June 2006) and platform powerpc-apple-darwin8.6.0. Since I installed the new version of R I cannot install packages any more (but it worked fine before) and get the following message every time. I can, however, install packages from the command line if I get them as precompiled binaries. - --- -- install.packages(foreign, lib=~/libs/Rlibs) trying URL 'http://www.biometrics.mtu.edu/CRAN/bin/macosx/powerpc/ contrib/2.3/foreign_0.8-15.tgz' Content type 'application/x-gzip' length 268096 bytes opened URL == downloaded 261Kb tar: ~/libs/Rlibs/file77a4044d: Cannot chdir: No such file or directory tar: Error is not recoverable: exiting now gzip: stdout: Broken pipe Error in sprintf(gettext(fmt, domain = domain), ...) : argument is missing, with no default - --- --- The command did create the directory (i.e. ~/libs/Rlibs/ file77a4044d) on my system and has open priviledges (i.e. drwxr-xr- x) but is empty. I've tried 'sudo R' but that does not help and cannot find anything helpful on this in the R-help archives or FAQ. Thanks in advance for your help, I would really appreciate any help in solving this, best regards, Snaebjorn __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] frequency table
Robert W. Baer, Ph.D. Associate Professor Department of Physiology A. T. Still University of Health Science 800 W. Jefferson St. Kirksville, MO 63501-1497 USA - Original Message - z = rep(c(M,F),c(50,60)) How can I get the following frequency table: Sex counts % F60 54.5 M 50 45.5 How about: data.frame(table(z),percent=100*as.vector(table(z)/sum(table(z HTH, Rob __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Spliting a huge vector
Dear R users, Sorry, I made a mistake in my specification of problem, should be: # my vector is this a.vector - seq(2, by=5, length=1000) # so my cut values are cut.values - c(30, 50, 100, 109, 300, 601, 803, 1000) # and x should have an extra ) at the end x - rep(1:length(cut.values), times=diff(c(0, cut.values))) Thanks for all the responses so far. Any additional responses are welcome. Many thanks, Dave --- Dave Evens [EMAIL PROTECTED] wrote: Dear R users, I have a huge vector that I would like to split into unequal slices. However, the only way I can do this is to create another huge vector to define the groups that are used to split the original vector, e.g. # my vector is this a.vector - seq(2, by=5, length=100) # indices where I would like to slice my vector cut.values - c(30, 50, 100, 109, 300, 601, 803) # so I have to create another vector of similar length # to use the split() command, i.e. x - rep(1:length(cut.values), times=diff(c(0, cut.values)) # this means I can use split() split(a.vector, x) This seems to be a waste in terms of memory usage as I'm creating another vector (here x) to split the original vector. Is there a better way to split a huge vector than this? Any help is much appreciated. Best, Dave. __ Do You Yahoo!? protection around http://mail.yahoo.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Adding .R to source file keeps R from reading it?
Hi, I'm updating the LMGene package from Bioconductor. Writing R Extensions suggests that all source files (the ones in the R directory) have a .R ending, so I added it to the (one) source file. The next time I installed and ran R, R didn't understand any of the functions. I tried various things and eventually went back to the file and dropped the .R ending, installed, ran R. It worked! For purposes of distributing the package, do I want to leave the name without the .R, or add the .R and change something else? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'help' information not modified when I modify man files
I am updating the Bioconductor package, LMGene. Thus I am modifying someone else's package, editing or writing new documentation, etc. When I modify the man files in LMGene and install the library, it doesn't change the 'help' that R gives you. The 'help' you actually get in R is the same as before. I haven't been able to find an explanation in Writing R Extensions. The package I'm working with also contains a 'help' directory, which is not mentioned in WRE. When installing a package, how do I make sure that the 'man' files get used to generate the 'help' files? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] summarry.lm and NA values
Gentlemen, (I am using R 2.2.1 in a Windows environment.) I apologize but I did not fully comprehend all of your answer. I have a dataframe called data1. I run several liner regression using the lm function similar to: reg - ( lm(lm(data1[,2] ~., data1[,2:4])) ) I see from generous answers below how I can use coef(reg) to extract the coefficient estimates. (If the coefficient for a variable is for some reason NA, coef(reg) returns NA for that coefficient, which is what I want.) My question: What is the best way to get the standard errors, including NA values that go with each of these coefficient estimates? (i.e. If the coefficient estimate is NA, I similarly want the standard error to come back as NA, so that the length of coef(reg) is the same as the length of the vector that contains the standard errors. ) Thanks very much for all your help, and I apologize for my need of additional assistance. --- Berton Gunter [EMAIL PROTECTED] wrote: Is there a way to... always has the answer yes in R (or C or any language for that matter). The question is: Is there a GOOD way...? where good depends on the specifics of the situation. So after that polemic, below is an effort to answer, (adding to what Petr Pikal already said): -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of r user Sent: Tuesday, August 15, 2006 7:01 AM To: rhelp Subject: [R] question re: summarry.lm and NA values Is there a way to get the following code to include NA values where the coefficients are NA? ((summary(reg))$coefficients) BAAAD! Don't so this. Use the extractor on the object: coef(reg) This suggests that you haven't read the documentation carefully, which tends to arouse the ire of would-be helpers. explanation: Using a loop, I am running regressions on several subsets of data1. reg - ( lm(lm(data1[,1] ~., data1[,2:l])) ) ??? There's an error here I think. Do you mean update()? Do you have your subscripting correct? My regression has 10 independent variables, and I therefore expect 11 coefficients. After each regression, I wish to save the coefficients and standard errors of the coefficients in a table with 22 columns. I successfully extract the coefficients using the following code: reg$coefficients Use the extractor, coef() I attempt to extract the standard errors using : aperm((summary(reg))$coefficients)[2,] BAAAD! Use the extractor vcov(): sqrt(diag(vcov(reg))) ((summary(reg))$coefficients) My problem: For some of my subsets, I am missing data for one or more of the independent variables. This of course causes the coefficients and standard erros for this variable to be NA. Not it doesn't, as Petr said. One possible approach: Assuming that a variable is actually missing (all NA's), note that coef(reg) is a named vector, so that the character string names of the regressors actually used are available. You can thus check for what's missing and add them as NA's at each return. Though I confess that I see no reason to put things ina matrix rather than just using a list. But that's a matter of personal taste I suppose. Is there a way to include the NA standard errors, so that I have the same number of standard erros and coefficients for each regression, and can then store the coefficients and standard erros in my table of 22 columns? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] summarry.lm and NA values
?vcov -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: r user [mailto:[EMAIL PROTECTED] Sent: Thursday, September 21, 2006 2:11 PM To: Berton Gunter; 'rhelp' Subject: summarry.lm and NA values Gentlemen, (I am using R 2.2.1 in a Windows environment.) I apologize but I did not fully comprehend all of your answer. I have a dataframe called data1. I run several liner regression using the lm function similar to: reg - ( lm(lm(data1[,2] ~., data1[,2:4])) ) I see from generous answers below how I can use coef(reg) to extract the coefficient estimates. (If the coefficient for a variable is for some reason NA, coef(reg) returns NA for that coefficient, which is what I want.) My question: What is the best way to get the standard errors, including NA values that go with each of these coefficient estimates? (i.e. If the coefficient estimate is NA, I similarly want the standard error to come back as NA, so that the length of coef(reg) is the same as the length of the vector that contains the standard errors. ) Thanks very much for all your help, and I apologize for my need of additional assistance. --- Berton Gunter [EMAIL PROTECTED] wrote: Is there a way to... always has the answer yes in R (or C or any language for that matter). The question is: Is there a GOOD way...? where good depends on the specifics of the situation. So after that polemic, below is an effort to answer, (adding to what Petr Pikal already said): -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of r user Sent: Tuesday, August 15, 2006 7:01 AM To: rhelp Subject: [R] question re: summarry.lm and NA values Is there a way to get the following code to include NA values where the coefficients are NA? ((summary(reg))$coefficients) BAAAD! Don't so this. Use the extractor on the object: coef(reg) This suggests that you haven't read the documentation carefully, which tends to arouse the ire of would-be helpers. explanation: Using a loop, I am running regressions on several subsets of data1. reg - ( lm(lm(data1[,1] ~., data1[,2:l])) ) ??? There's an error here I think. Do you mean update()? Do you have your subscripting correct? My regression has 10 independent variables, and I therefore expect 11 coefficients. After each regression, I wish to save the coefficients and standard errors of the coefficients in a table with 22 columns. I successfully extract the coefficients using the following code: reg$coefficients Use the extractor, coef() I attempt to extract the standard errors using : aperm((summary(reg))$coefficients)[2,] BAAAD! Use the extractor vcov(): sqrt(diag(vcov(reg))) ((summary(reg))$coefficients) My problem: For some of my subsets, I am missing data for one or more of the independent variables. This of course causes the coefficients and standard erros for this variable to be NA. Not it doesn't, as Petr said. One possible approach: Assuming that a variable is actually missing (all NA's), note that coef(reg) is a named vector, so that the character string names of the regressors actually used are available. You can thus check for what's missing and add them as NA's at each return. Though I confess that I see no reason to put things ina matrix rather than just using a list. But that's a matter of personal taste I suppose. Is there a way to include the NA standard errors, so that I have the same number of standard erros and coefficients for each regression, and can then store the coefficients and standard erros in my table of 22 columns? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding .R to source file keeps R from reading it?
On 9/21/06, John Tillinghast [EMAIL PROTECTED] wrote: Hi, I'm updating the LMGene package from Bioconductor. Writing R Extensions suggests that all source files (the ones in the R directory) have a .R ending, so I added it to the (one) source file. The next time I installed and ran R, R didn't understand any of the functions. I tried various things and eventually went back to the file and dropped the .R ending, installed, ran R. It worked! For purposes of distributing the package, do I want to leave the name without the .R, or add the .R and change something else? I'm guessing that the source you are working on has been obtained by unzipping the windows binary zip file. Despite appearances, that is not the source code. For the proper source code, download the file that's marked as source. In this case, http://bioconductor.org/packages/1.8/bioc/html/LMGene.html clearly labels the following as Source (and the corresponding zip file as Windows Binary) http://bioconductor.org/packages/1.8/bioc/src/contrib/LMGene_1.0.0.tar.gz This likely answers your other question as well. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding .R to source file keeps R from reading it?
On 9/21/2006 5:01 PM, John Tillinghast wrote: Hi, I'm updating the LMGene package from Bioconductor. Writing R Extensions suggests that all source files (the ones in the R directory) have a .R ending, so I added it to the (one) source file. The next time I installed and ran R, R didn't understand any of the functions. I tried various things and eventually went back to the file and dropped the .R ending, installed, ran R. It worked! For purposes of distributing the package, do I want to leave the name without the .R, or add the .R and change something else? You aren't giving us very much information, but I would guess you edited the installed copy of the package rather than the source. (Where did you find the file with the source in it? If it was in $(RHOME)/library/LMGene/R, then that's the installed copy, and you shouldn't edit it.) When R installs a package, it copies all the source into one file and doesn't put the .R extension on it. I imagine if you try running after renaming such a file, R wouldn't see it. Your other message about seeing a help directory confirms this. You should get the source to the LMGene package, and make modifications to that, or just write your own functions and put them in your own file. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding .R to source file keeps R from reading it?
Hmm... sounds like you're on Windows and have the Explorer setup such that it is hiding file extensions. You can try to use list.files() from R to see if the files actually have file extension. If this is your problem, open My Computer - Tools - Folder Options... and select tab View. Make sure that Hide extensions for known file types is *NOT* selected. /H On 9/21/06, John Tillinghast [EMAIL PROTECTED] wrote: Hi, I'm updating the LMGene package from Bioconductor. Writing R Extensions suggests that all source files (the ones in the R directory) have a .R ending, so I added it to the (one) source file. The next time I installed and ran R, R didn't understand any of the functions. I tried various things and eventually went back to the file and dropped the .R ending, installed, ran R. It worked! For purposes of distributing the package, do I want to leave the name without the .R, or add the .R and change something else? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding .R to source file keeps R from reading it?
Yes, this was exactly the problem: I was using the unzipped package, not the source. Now it works! -- Forwarded message -- From: Deepayan Sarkar [EMAIL PROTECTED] Date: Sep 21, 2006 2:58 PM Subject: Re: [R] Adding .R to source file keeps R from reading it? To: John Tillinghast [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch On 9/21/06, John Tillinghast [EMAIL PROTECTED] wrote: Hi, I'm updating the LMGene package from Bioconductor. Writing R Extensions suggests that all source files (the ones in the R directory) have a .R ending, so I added it to the (one) source file. The next time I installed and ran R, R didn't understand any of the functions. I tried various things and eventually went back to the file and dropped the .R ending, installed, ran R. It worked! For purposes of distributing the package, do I want to leave the name without the .R, or add the .R and change something else? I'm guessing that the source you are working on has been obtained by unzipping the windows binary zip file. Despite appearances, that is not the source code. For the proper source code, download the file that's marked as source. In this case, http://bioconductor.org/packages/1.8/bioc/html/LMGene.html clearly labels the following as Source (and the corresponding zip file as Windows Binary) http://bioconductor.org/packages/1.8/bioc/src/contrib/LMGene_1.0.0.tar.gz This likely answers your other question as well. -Deepayan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to store recursive results
Hi all, How to store recursive resutls from a function for each step without using global operators -? Thanks ahead. Xiaohui Chen Dept. of Statistics UBC, Canada _ Dont waste time standing in linetry shopping online. Visit Sympatico / MSN __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.