[R] RE: do0i4grjj40j09gjijgpd
Privitak je zaraen virusom. Kontaktirajte sistem administratora. An attachment is infected by virus. Contact administrator. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] French Curve
Michael == Michael A Miller [EMAIL PROTECTED] on Tue, 05 Apr 2005 10:28:21 -0500 writes: dream == dream home [EMAIL PROTECTED] writes: Does it sound like spline work do the job? It would be hard to persuave him to use some modern math technique but he did ask me to help him implement the French Curve so he can do his work in Excel, rather than PAPER. Michael Splines are useful for interpolating points with a Michael continuous curve that passes through, or near, the Michael points. not only! (see below) Michael If you are looking for a way to estimate a Michael curve with a noise component removed, I think you'd Michael be better off filtering your data, rather than Michael interpolating with a spline. yes for rather than interpolating no for with a spline There's the smooth.spline() *smoothing* spline function (with predict() methods, even for 1st and 2nd derivatives) which is liked by `many' and even prefered to other ``filters'' for diverse reasons, notably for the fact that spline smoothing corresponds to linear filtering with a curvature-adaptive varying bandwith. Michael Median (or mean) filtering may give results Michael similar to those from your chemist's manual method. Michael That is easy to do with running from the gtools Michael package. The validity of this is another question! Median filtering aka running medians has one distinctive advantage {over smooth.spline() or other so called linear smoothers}: It is robust i.e. not distorted by gross outliers. Running medians is implemented in runmed() {standard stats package} in a particularly optimized way rather than using the more general running(.) approach of package 'gtools'. 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
Re: [R] two methods for regression, two different results
On Tue, 2005-04-05 at 22:54 -0400, John Sorkin wrote: Please forgive a straight stats question, and the informal notation. let us say we wish to perform a liner regression: y=b0 + b1*x + b2*z There are two ways this can be done, the usual way, as a single regression, fit1-lm(y~x+z) or by doing two regressions. In the first regression we could have y as the dependent variable and x as the independent variable fit2-lm(y~x). The second regrssion would be a regression in which the residuals from the first regression would be the depdendent variable, and the independent variable would be z. fit2-lm(fit2$residuals~z) I would think the two methods would give the same p value and the same beta coefficient for z. The don't. Can someone help my understand why the two methods do not give the same results. Additionally, could someone tell me when one method might be better than the other, i.e. what question does the first method anwser, and what question does the second method answer. I have searched a number of textbooks and have not found this question addressed. John, Bill Venables already told you that they don't do that, because they are not orthogonal. Here is a simpler way of getting the same result as he suggested for the coefficients of z (but only for z): x - runif(100) z - x + rnorm(100, sd=0.4) y - 3 + x + z + rnorm(100, sd=0.3) mod - lm(y ~ x + z) mod2 - lm(residuals(lm(y ~ x)) ~ x + z) summary(mod) Call: lm(formula = y ~ x + z) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 2.964360.06070 48.836 2e-16 *** x0.962720.11576 8.317 5.67e-13 *** z1.089220.06711 16.229 2e-16 *** --- Residual standard error: 0.2978 on 97 degrees of freedom summary(mod2) Call: lm(formula = residuals(lm(y ~ x)) ~ x + z) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -0.157310.06070 -2.592 0.0110 * x -0.844590.11576 -7.296 8.13e-11 *** z1.089220.06711 16.229 2e-16 *** --- Residual standard error: 0.2978 on 97 degrees of freedom You can omit x from the outer lm only if x and z are orthogonal, although you already removed the effect of x... In orthogonal case the coefficient for x would be 0. Residuals are equal in these two models: range(residuals(mod) - residuals(mod2)) [1] -2.797242e-17 5.551115e-17 But, of course, fitted values are not equal, since you fit the mod2 to the residuals after removing the effect of x... cheers, jari oksanen -- Jari Oksanen [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
Re: [R] error messages on R CMD check
Hallo Uwe, Uwe Ligges schrieb: [...] In Johannes' case, the problem is different, because the error message is not that clear. Johannes, can you install and load the package? Is the DESCRIPTION file correct? If so, you might want to send the package in a private message... I have found the root of the error: I renamed some functions without renaming them in the export statement of the NAMESPACE file. Silly me. Thanks for offering help, and good thing I didn't send you the stuff. It would be good to add your suggestions to the R-exts document: If the error messages after R CMD check do not sound helpful, try building and loading the package and see what the system has to say about this. Greetings Johannes __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Help with three-way anova
OK, so I tried using lm() instead of aov() and they give similar results: My.aov - aov(IL.4 ~ Infected + Vaccinated + Lesions, data) My.lm - lm(IL.4 ~ Infected + Vaccinated + Lesions, data) If I do summary(My.lm) and summary(My.aov), I get similar results, but not identical. If I do anova(My.aov) and anova(My.lm) I get identical results. I guess that's to be expected though. Regarding the results of summary(My.lm), basically Intercept, Infected and Vaccinated are all significant at p=0.05. I presume the signifcance of the Intercept is that it is significantly different to zero? How do I interpret that? Many thanks Mick -Original Message- From: Federico Calboli [mailto:[EMAIL PROTECTED] Sent: 05 April 2005 16:33 To: michael watson (IAH-C) Cc: r-help Subject: Re: [R] Help with three-way anova On Tue, 2005-04-05 at 15:51 +0100, michael watson (IAH-C) wrote: So, what I want to know is: 1) Given my unbalanced experimental design, is it valid to use aov? I'd say no. Use lm() instead, save your analysis in an object and then possibly use drop1() to check the analysis 2) Have I used aov() correctly? If so, how do I get access results for interactions? The use of aov() per se seems fine, but you did not put any interaction in the model... for that use factor * factor. HTH, F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
Re: [R] Fitdistr and likelihood
{BCC'ed to VR's maintainer} Carsten == Carsten Steinhoff [EMAIL PROTECTED] on Tue, 5 Apr 2005 17:31:04 +0200 writes: Carsten Hi all, I'm using the function fitdistr (library Carsten MASS) to fit a distribution to given data. What I Carsten have to do further, is getting the Carsten log-Likelihood-Value from this estimation. Carsten Is there any simple possibility to realize it? yes. Actually, internally in fitdistr(), everything's already there. So you need to modify fitdistr() only slightly to also return the log likelihood. Furthermore, subsequent implementation of a logLik.fitdistr() method is trivial. Here are is the unified diff against VR_7.2-14 (VR/MASS/R/fitdistr.R) : --- /u/maechler/R/MM/STATISTICS/fitdistr.R 2004-01-22 02:16:04.0 +0100 +++ /u/maechler/R/MM/STATISTICS/fitdistr-improved.R 2005-04-06 10:20:25.0 +0200 @@ -1,3 +1,5 @@ + This is from VR_7.2-14 VR/MASS/R/fitdistr.R [improved by MM] + fitdistr - function(x, densfun, start, ...) { myfn - function(parm, ...) -sum(log(dens(parm, ...))) @@ -11,6 +13,7 @@ stop('x' must be a non-empty numeric vector) if(missing(densfun) || !(is.function(densfun) || is.character(densfun))) stop('densfun' must be supplied as a function or name) +n - length(x) if(is.character(densfun)) { distname - tolower(densfun) densfun - @@ -34,12 +37,13 @@ if(distname == normal) { if(!is.null(start)) stop(supplying pars for the Normal is not supported) -n - length(x) sd0 - sqrt((n-1)/n)*sd(x) -estimate - c(mean(x), sd0) +mx - mean(x) +estimate - c(mx, sd0) sds - c(sd0/sqrt(n), sd0/sqrt(2*n)) names(estimate) - names(sds) - c(mean, sd) -return(structure(list(estimate = estimate, sd = sds), +return(structure(list(estimate = estimate, sd = sds, n = n, + loglik = sum(dnorm(x, mx, sd0, log=TRUE))), class = fitdistr)) } if(distname == weibull is.null(start)) { @@ -89,15 +93,28 @@ parse(text = paste(densfun(x,, paste(parm[, 1:l, ], collapse = , ), , ...))) +res - if(log %in% args) -res - optim(start, mylogfn, x = x, hessian = TRUE, ...) +optim(start, mylogfn, x = x, hessian = TRUE, ...) else -res - optim(start, myfn, x = x, hessian = TRUE, ...) +optim(start, myfn, x = x, hessian = TRUE, ...) if(res$convergence 0) stop(optimization failed) sds - sqrt(diag(solve(res$hessian))) -structure(list(estimate = res$par, sd = sds), class = fitdistr) +structure(list(estimate = res$par, sd = sds, + loglik = - res$value, n = n), class = fitdistr) } +logLik.fitdistr - function(object, REML = FALSE, ...) +{ +if (REML) stop(only 'REML = FALSE' is implemented) +val - object$loglik +attr(val, nobs) - object$n +attr(val, df) - length(object$estimate) +class(val) - logLik +val +} + + print.fitdistr - function(x, digits = getOption(digits), ...) { __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] step error
an indirect solution is to use the following: pro - function(indep, dep){ d - data.frame(indep) form - formula(lm(dep~., data=d)) assign(d, d, envir=.GlobalEnv) res - step(lm(dep~X1, data=d), scope=form, trace=0, direction=f) rm(d, envir=.GlobalEnv) res } # m - rnorm(100*5); dim(m) - c(100, 5); colnames(m) - paste(X, 1:5, sep=) Y - as.vector(1 + m[, sample(5, 2)]%*%rnorm(2)) pro(m, Y) step(lm(Y~X1, data=data.frame(m)), scope=Y~X1+X2+X3+X4+X5, trace=0, direction=f) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: vasilis pappas [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, April 01, 2005 9:29 PM Subject: [R] step error Could anyone tell me what am I doing wrong? pro-function(indep,dep){ + d-data.frame(indep) + form-formula(lm(dep~.,data=d)) + forward-step(lm(dep~X1,data=d),scope=form,trace=0,direction='f') + return(forward) + } pro(m,q) Error in inherits(x, data.frame) : Object d not found Where q is a vector with the dependent variable's values and m is a matrix containing the values of the independent variables. While writing the above without a function form has no problem, that is : d-data.frame(m) form-formula(lm(q~.,data=d)) forward-step(lm(q~X1,data=d),scope=form,trace=0,direction='f') forward Call: lm(formula = q ~ X1 + X2 + X5, data = d) Coefficients: (Intercept) X1 X2 X5 -15.7988.7656.774 -4.245 Thank you in advance! Vasilis __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Help with three-way anova
On Wed, 2005-04-06 at 09:11 +0100, michael watson (IAH-C) wrote: OK, so I tried using lm() instead of aov() and they give similar results: My.aov - aov(IL.4 ~ Infected + Vaccinated + Lesions, data) My.lm - lm(IL.4 ~ Infected + Vaccinated + Lesions, data) Incidentally, if you want interaction terms you need lm(IL.4 ~ Infected * Vaccinated * Lesions, data) for all the possible interactions in the model (BUT you need enough degrees of freedom from the start to be able to do this). If I do summary(My.lm) and summary(My.aov), I get similar results, but not identical. If I do anova(My.aov) and anova(My.lm) I get identical results. I guess that's to be expected though. Regarding the results of summary(My.lm), basically Intercept, Infected and Vaccinated are all significant at p=0.05. I presume the signifcance of the Intercept is that it is significantly different to zero? How do I interpret that? I guess it's all due to the contrast matrix you used. Check with contrasts() the term(s) in the datafile you use as independent variables, and change the contrast matrix as you see fit. HTH, F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
RE: [R] Help with three-way anova
OK, now I am lost. I went from using aov(), which I fully understand, to lm() which I probably don't. I didn't specify a contrasts matrix in my call to lm() Basically I want to find out if Infected/Uninfected affects the level of IL.4, and if Vaccinated/Unvaccinated affects the level of IL.4, obviously trying to separate the effects of Infection from the effects of Vaccination. The documentation for specifying contrasts to lm() is a little convoluted, sending me to the help file for model.matrix.default, and the help there doesn't really give me much to go on when trying to figure out what contrasts matrix I need to use... Many thanks for your help Mick -Original Message- From: Federico Calboli [mailto:[EMAIL PROTECTED] Sent: 06 April 2005 10:15 To: michael watson (IAH-C) Cc: r-help Subject: RE: [R] Help with three-way anova On Wed, 2005-04-06 at 09:11 +0100, michael watson (IAH-C) wrote: OK, so I tried using lm() instead of aov() and they give similar results: My.aov - aov(IL.4 ~ Infected + Vaccinated + Lesions, data) My.lm - lm(IL.4 ~ Infected + Vaccinated + Lesions, data) Incidentally, if you want interaction terms you need lm(IL.4 ~ Infected * Vaccinated * Lesions, data) for all the possible interactions in the model (BUT you need enough degrees of freedom from the start to be able to do this). If I do summary(My.lm) and summary(My.aov), I get similar results, but not identical. If I do anova(My.aov) and anova(My.lm) I get identical results. I guess that's to be expected though. Regarding the results of summary(My.lm), basically Intercept, Infected and Vaccinated are all significant at p=0.05. I presume the signifcance of the Intercept is that it is significantly different to zero? How do I interpret that? I guess it's all due to the contrast matrix you used. Check with contrasts() the term(s) in the datafile you use as independent variables, and change the contrast matrix as you see fit. HTH, F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
[R] conditional selection with Factors
Hi All, I want to select a level of a factor variable from a dataset. I have the folowing data: dataset: use factor: month (use$month, levels=February, July) use[1:5,] month registration use department size 1 February KKG151GP Y Safety 1.6 To select February I tried: use[use$month==February] Error in [.data.frame(use, use$month == February) : undefined columns selected use[use$month == levels(use$month)[1]] Error in [.data.frame(use, use$month == levels(use$month)[1]) : undefined columns selected It seems if a logical variable is created, and the subsetting on a factor variable won't work directly.(It works directly for numeric variables) Can anyone help please. Regards Hennie Gerber Hennie Gerber Statistician UNISA - Research Support + 27 12 429 3188 Waarskuwing! Die sienings uitgespreek is my eie en nie noodwendig my werkgewer sin nie Warning! All views expressed are my own and not necessarily that of my employer. --- This message (and attachments) is subject to restrictions and a disclaimer. Please refer to http://www.unisa.ac.za/disclaimer for full details. --- gwavasig gwavasig [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R can not show plots (in Mac OS X terminal)
Hi, You should use X11. It doesn't work in Terminal. You can use the basic Xterm in X11 or like I do Aterm. David Ruau On Apr 5, 2005, at 20:12, Minyu Chen wrote: Dear all: I am a newbie in Mac. Just installed R and found R did not react on my command plot (I use command line in terminal). It did not give me any error message, either. All it did was just giving out a new command prompt--no reaction to the plot command. I suppose whenever I gives out a command of plot, it will invoke the AquaTerm for a small graph, as I experience in octave. What can I do for it? Many thanks, Minyu Chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Using kmeans given cluster centroids and data with NAs
Hello! I would suggest using some form of imputations, such as MICE package (http://web.inter.nl.net/users/S.van.Buuren/mi/hmtl/mice.htm) or similar (I heard that this can be also done with aregImpute function in the Hmisc package, although I have not tried it) to fill in the NA's. Then you can use k-means or any technique you which, since now you have a complete data-frame. However, for more reliable results, it is best to repeat imputations and analysis several times. I hope this helps! Ales Ziberna - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Monday, April 04, 2005 5:23 AM Subject: [R] Using kmeans given cluster centroids and data with NAs Hello Tom, Thanks for the reply. Unfortunately I do have many NAs in my data as not all vertical temperature profiles penetrated to the same depth level. In fact if I simply use na.omit my data matrix is reduced from 4977 to 480 observations, so such a simple solution is not very helpful I'm afraid. Any other ideas? Cheers, SB -Original Message- From: Mulholland, Tom [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 2:15 PM To: Bestley, Sophie (Marine, Hobart); r-help@stat.math.ethz.ch Subject: RE: [R] Using kmeans given cluster centroids and data with NAs Does ?na.omit help x - kmeans(na.omit(data),centres) of course if you have too many NAs you need to be sure that their removal does not unduly influence the results. Although I am a bit confused as I thought that agnes did not allow NAs. I assume that you are running an alternative clustering method using the results of the first process as the starting point for the partitioning process and are thus using the same initial data. Tom -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, 31 March 2005 11:33 AM To: r-help@stat.math.ethz.ch Subject: [R] Using kmeans given cluster centroids and data with NAs Hello, I have used the functions agnes and cutree to cluster my data (4977 objects x 22 variables) into 8 clusters. I would like to refine the solution using a k-means or similar algorithm, setting the initial cluster centres as the group means from agnes. However my data matrix has NA's in it and the function kmeans does not appear to accept this? dim(centres) [1] 8 22 dim(data) [1] 4977 22 x - kmeans(data,centres) Error in kmeans(data, centres) : NA/NaN/Inf in foreign function call (arg 1) I have looked extensively through the mail archives but cannot find if/where someone has provided the answer. Thanks in advance, SB Sophie Bestley Pelagic Fisheries and Ecosystems CSIRO Marine Research GPO Box 1538 Hobart, Tasmania 7001 AUSTRALIA Phone: +61 3 6232 5048 Fax: +61 3 6232 5053 Email: [EMAIL PROTECTED] Website: http://www.marine.csiro.au [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] nls.control
Hello everyone, I'm trying to test the accurracy of R on the Eckerle4 dataset from NIST and I don't understand how the control option of the nls function works. I tought nls(...) was equivalent to nls(...control=nls.control()) i.e nls.control() was the default value of control, but here is the error I get : n2=nls(V1~(b1/b2) * exp(-0.5*((V2-b3)/b2)^2),data=ecker,start=list(b1=1.5,b2=5,b3=450,control=nls.control())) Error in nlsModel(formula, mf, start) : singular gradient matrix at initial parameter estimates while I get no error without setting the control option with the same other parameters. I see that R didn't manage to solve the Eckerle4 regression problem from start one while Splus can do it with the nlregb option. Is there something equivalent for R now? Otherwise, I found that R 2.0.1 was performing better than SAS 9.1 on the NIST Datasets in general. Best regards, Anthony Landrevie - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] conditional selection with Factors
Hi On 6 Apr 2005 at 11:34, H J Gerber wrote: Hi All, I want to select a level of a factor variable from a dataset. I have the folowing data: dataset: use factor: month (use$month, levels=February, July) use[1:5,] month registration use department size 1 February KKG151GP Y Safety 1.6 To select February I tried: use[use$month==February] Error in [.data.frame(use, use$month == February) : undefined columns selected Dimensions! use[use$month==February,] shall show all columns where use$month = February Cheers Petr use[use$month == levels(use$month)[1]] Error in [.data.frame(use, use$month == levels(use$month)[1]) : undefined columns selected It seems if a logical variable is created, and the subsetting on a factor variable won't work directly.(It works directly for numeric variables) Can anyone help please. Regards Hennie Gerber Hennie Gerber Statistician UNISA - Research Support + 27 12 429 3188 Waarskuwing! Die sienings uitgespreek is my eie en nie noodwendig my werkgewer sin nie Warning! All views expressed are my own and not necessarily that of my employer. -- - This message (and attachments) is subject to restrictions and a disclaimer. Please refer to http://www.unisa.ac.za/disclaimer for full details. -- - gwavasig gwavasig [[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 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
RE: [R] Help with three-way anova
Dear Mick, For a three-way ANOVA, the difference between aov() and lm() is mostly in the print and summary methods -- aov() calls lm() but in its summary prints an ANOVA table rather than coefficient estimates, etc. You can get the same ANOVA table from the object returned by lm via the anova() function. The problem, however, is that for unbalanced data you'll get sequential sums of squares which likely don't test hypotheses of interest to you. If you didn't explicitly set the contrast coding, then the out-of-box default in R [options(contrasts)] is to use treatment.contr(), which produces dummy-coded (0/1) contrasts. In this case, the intercept represents the fitted value when all of the factors are at their baseline levels, and it's probably entirely uninteresting to test whether it is 0. More generally, however, it seems unreasonable to try to learn how to fit and interpret linear models in R from the help files. There's a brief treatment in the Introduction to R manual that's distributed with R, and many other more detailed treatments -- see http://www.r-project.org/other-docs.html. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of michael watson (IAH-C) Sent: Wednesday, April 06, 2005 4:31 AM To: [EMAIL PROTECTED] Cc: r-help Subject: RE: [R] Help with three-way anova OK, now I am lost. I went from using aov(), which I fully understand, to lm() which I probably don't. I didn't specify a contrasts matrix in my call to lm() Basically I want to find out if Infected/Uninfected affects the level of IL.4, and if Vaccinated/Unvaccinated affects the level of IL.4, obviously trying to separate the effects of Infection from the effects of Vaccination. The documentation for specifying contrasts to lm() is a little convoluted, sending me to the help file for model.matrix.default, and the help there doesn't really give me much to go on when trying to figure out what contrasts matrix I need to use... Many thanks for your help Mick -Original Message- From: Federico Calboli [mailto:[EMAIL PROTECTED] Sent: 06 April 2005 10:15 To: michael watson (IAH-C) Cc: r-help Subject: RE: [R] Help with three-way anova On Wed, 2005-04-06 at 09:11 +0100, michael watson (IAH-C) wrote: OK, so I tried using lm() instead of aov() and they give similar results: My.aov - aov(IL.4 ~ Infected + Vaccinated + Lesions, data) My.lm - lm(IL.4 ~ Infected + Vaccinated + Lesions, data) Incidentally, if you want interaction terms you need lm(IL.4 ~ Infected * Vaccinated * Lesions, data) for all the possible interactions in the model (BUT you need enough degrees of freedom from the start to be able to do this). If I do summary(My.lm) and summary(My.aov), I get similar results, but not identical. If I do anova(My.aov) and anova(My.lm) I get identical results. I guess that's to be expected though. Regarding the results of summary(My.lm), basically Intercept, Infected and Vaccinated are all significant at p=0.05. I presume the signifcance of the Intercept is that it is significantly different to zero? How do I interpret that? I guess it's all due to the contrast matrix you used. Check with contrasts() the term(s) in the datafile you use as independent variables, and change the contrast matrix as you see fit. HTH, F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Precision
How precise is R numerically? For example I wrote the following function for calculating the volume of the ball inscribed in the unit cube in m dimensions. In order to see what happens in 40 dimensions, I created an output of 24 digits. But how many are precise? Thanks Josef Eschgfäller Ferrara --- Vol = function (m) {if (m=1) 1 else Vol(m-2)*pi/(m+m)} for (m in 1:40) {x=sprintf('%2d %.24f',m,Vol(m)) print(x)} --- 1 1. 2 0.785398163397448278999491 3 0.523598775598298815658893 4 0.308425137534042437259529 5 0.164493406684822623953224 6 0.080745512188280771370685 7 0.036912234143214060766436 8 0.015854344243815498421979 9 0.006442400200661534299951 10 0.002490394570192719803786 11 0.000919972597358349329817 12 0.000325991886927389960208 13 0.00060736667881195885 14 0.36576204182177245747 15 0.11640725122781503579 16 0.03590860448591509251 17 0.01075600486123191399 18 0.00313361689037812061 19 0.00088923646984269168 20 0.00024611369504941992 21 0.6651473240385528 22 0.1757247673443401 23 0.0454265640598788 24 0.0115011591279740 25 0.0028542351985668 26 0.0006948453273887 27 0.0001660526728044 28 0.389807317126 29 0.089943078792 30 0.020410263397 31 0.004557492187 32 0.001001886462 33 0.000216936121 34 0.46287046 35 0.09736070 36 0.02019653 37 0.00413335 38 0.00083486 39 0.00016648 40 0.3278 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Help with three-way anova
Hi John Thanks for your help, that was a very clear answer. It looks as though, due to my design, the best way forward is: contrasts(il4$Infected) [,1] I-1 UI1 contrasts(il4$Vaccinated) [,1] UV -1 V 1 summary(lm(IL.4 ~ Infected * Vaccinated, il4)) Thanks Mick -Original Message- From: John Fox [mailto:[EMAIL PROTECTED] Sent: 06 April 2005 12:52 To: michael watson (IAH-C) Cc: 'r-help'; [EMAIL PROTECTED] Subject: RE: [R] Help with three-way anova Dear Mick, For a three-way ANOVA, the difference between aov() and lm() is mostly in the print and summary methods -- aov() calls lm() but in its summary prints an ANOVA table rather than coefficient estimates, etc. You can get the same ANOVA table from the object returned by lm via the anova() function. The problem, however, is that for unbalanced data you'll get sequential sums of squares which likely don't test hypotheses of interest to you. If you didn't explicitly set the contrast coding, then the out-of-box default in R [options(contrasts)] is to use treatment.contr(), which produces dummy-coded (0/1) contrasts. In this case, the intercept represents the fitted value when all of the factors are at their baseline levels, and it's probably entirely uninteresting to test whether it is 0. More generally, however, it seems unreasonable to try to learn how to fit and interpret linear models in R from the help files. There's a brief treatment in the Introduction to R manual that's distributed with R, and many other more detailed treatments -- see http://www.r-project.org/other-docs.html. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of michael watson (IAH-C) Sent: Wednesday, April 06, 2005 4:31 AM To: [EMAIL PROTECTED] Cc: r-help Subject: RE: [R] Help with three-way anova OK, now I am lost. I went from using aov(), which I fully understand, to lm() which I probably don't. I didn't specify a contrasts matrix in my call to lm() Basically I want to find out if Infected/Uninfected affects the level of IL.4, and if Vaccinated/Unvaccinated affects the level of IL.4, obviously trying to separate the effects of Infection from the effects of Vaccination. The documentation for specifying contrasts to lm() is a little convoluted, sending me to the help file for model.matrix.default, and the help there doesn't really give me much to go on when trying to figure out what contrasts matrix I need to use... Many thanks for your help Mick -Original Message- From: Federico Calboli [mailto:[EMAIL PROTECTED] Sent: 06 April 2005 10:15 To: michael watson (IAH-C) Cc: r-help Subject: RE: [R] Help with three-way anova On Wed, 2005-04-06 at 09:11 +0100, michael watson (IAH-C) wrote: OK, so I tried using lm() instead of aov() and they give similar results: My.aov - aov(IL.4 ~ Infected + Vaccinated + Lesions, data) My.lm - lm(IL.4 ~ Infected + Vaccinated + Lesions, data) Incidentally, if you want interaction terms you need lm(IL.4 ~ Infected * Vaccinated * Lesions, data) for all the possible interactions in the model (BUT you need enough degrees of freedom from the start to be able to do this). If I do summary(My.lm) and summary(My.aov), I get similar results, but not identical. If I do anova(My.aov) and anova(My.lm) I get identical results. I guess that's to be expected though. Regarding the results of summary(My.lm), basically Intercept, Infected and Vaccinated are all significant at p=0.05. I presume the signifcance of the Intercept is that it is significantly different to zero? How do I interpret that? I guess it's all due to the contrast matrix you used. Check with contrasts() the term(s) in the datafile you use as independent variables, and change the contrast matrix as you see fit. HTH, F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] nls.control
Anthony == Anthony Landrevie [EMAIL PROTECTED] on Wed, 6 Apr 2005 02:54:50 -0700 (PDT) writes: Anthony Hello everyone, I'm trying to test the accurracy of Anthony R on the Eckerle4 dataset from NIST Do you know that there's an R package 'NISTnls' (on CRAN) exactly for this purpose? After installing the package, library(NISTnls) example(Eckerle4) gives Eckrl4 data(Eckerle4) Eckrl4 plot(y ~ x, data = Eckerle4) Eckrl4 fm2 - nls(y ~ (b1/b2) * exp(-0.5 * ((x - b3)/b2)^2), data = Eckerle4, trace = TRUE, start = c(b1 = 1.5, b2 = 5, b3 = 450)) 0.05668291 :1.5 5.0 450.0 0.00722609 :1.563149 4.374689 451.974368 0.001525831 :1.551040 4.091636 451.488425 0.001463731 :1.554819 4.091467 451.541251 0.001463589 :1.554395 4.088899 451.541108 0.001463589 :1.554384 4.088839 451.541216 0.001463589 :1.554383 4.088832 451.541218 Eckrl4 fm4 - nls(y ~ (1/b2) * exp(-0.5 * ((x - b3)/b2)^2), data = Eckerle4, trace = TRUE, start = c(b2 = 5, b3 = 450), algorithm = plinear) 0.05086068 : 5.0 450.0 1.65696 0.004539377 : 4.471095 451.669974 1.621837 0.001478679 : 4.085508 451.514686 1.553734 0.001463615 : 4.089948 451.541333 1.554595 0.001463589 : 4.088856 451.541172 1.554387 0.001463589 : 4.088835 451.541217 1.554383 0.001463589 : 4.088832 451.541218 1.554383 -- where the fm2 - case looks pretty much like your example below Anthony and I don't understand how the control option of Anthony the nls function works. I tought nls(...) was Anthony equivalent to nls(...control=nls.control()) i.e Anthony nls.control() was the default value of control, but Anthony here is the error I get : n2=nls(V1~(b1/b2) * exp(-0.5*((V2-b3)/b2)^2),data=ecker,start=list(b1=1.5,b2=5,b3=450,control=nls.control())) Anthony Error in nlsModel(formula, mf, start) : singular Anthony gradient matrix at initial parameter estimates we cannot know, since we don't have your ecker. For me, with 'Eckerle4' from the NISTnls package, fm2. - nls(y ~ (b1/b2) * exp(-0.5 * ((x - b3)/b2)^2), data = Eckerle4, trace = TRUE, start = c(b1 = 1.5, b2 = 5, b3 = 450), control=nls.control()) 0.05668291 :1.5 5.0 450.0 0.00722609 :1.563149 4.374689 451.974368 0.001525831 :1.551040 4.091636 451.488425 0.001463731 :1.554819 4.091467 451.541251 0.001463589 :1.554395 4.088899 451.541108 0.001463589 :1.554384 4.088839 451.541216 0.001463589 :1.554383 4.088832 451.541218 I get exactly the same when I have added , control=nls.control() to the original call. So I wonder if you didn't accidentally change something more than just adding that. Anthony while I get no error without setting the control Anthony option with the same other parameters. Anthony I see that R didn't manage that's a pretty tough statement (and really wrong). I assume it should mean nls() didn't solve , at least not with default arguments specified and I think you are right: completely wrong starting values don't always work for nls() Anthony to solve the Eckerle4 regression problem from start one start one is the infamous non-sense of obviously completely wrongly specified starting values, right? Anthony while Splus can do it with the nlregb option. Is there something Anthony equivalent for R now? not equivalent probably, but yes, there are several alternatives for minimization/optimization, in base+recommended R, and more in other packages. Anthony Otherwise, I found that R 2.0.1 was performing Anthony better than SAS 9.1 on the NIST Datasets in Anthony general. where R 2.0.1 means using nls() in R 2.0.1, right? Thanks for letting us know. Anthony Best regards, Anthony Anthony Landrevie __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] French Curve
On Apr 6, 2005, at 1:48 AM, Martin Maechler wrote: Median filtering aka running medians has one distinctive advantage {over smooth.spline() or other so called linear smoothers}: It is robust i.e. not distorted by gross outliers. Running medians is implemented in runmed() {standard stats package} in a particularly optimized way rather than using the more general running(.) approach of package 'gtools'. Median smoothing splines are also implemented in the quantreg package see ?rqss, but they produce piecewise linear fitting so they may not appeal to those accustomed to french curves. url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R can not show plots (in Mac OS X terminal)
Hi On 6 Apr 2005, at 10:47, David Ruau wrote: Hi, You should use X11. It doesn't work in Terminal. To make Apple's Terminal use X11 first one should set the DISPLAY environment variable if you are using bash, put the following line in .bash_profile [[ -z $DISPLAY ]] export DISPLAY=:0.0 You can use the basic Xterm in X11 or like I do Aterm. David Ruau On Apr 5, 2005, at 20:12, Minyu Chen wrote: Dear all: I am a newbie in Mac. Just installed R and found R did not react on my command plot (I use command line in terminal). It did not give me any error message, either. All it did was just giving out a new command prompt--no reaction to the plot command. I suppose whenever I gives out a command of plot, it will invoke the AquaTerm for a small graph, as I experience in octave. What can I do for it? Many thanks, Minyu Chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Tony Han Bao [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
[R] how to estimate Type I, Type III SS
Howdy, R gurus I 'd like to know hwo to calculate or estimate SS of Type I and Type III in ANOVA or other anaysis in R. Thanks, -- Kum-Hoe Hwang, Ph.D. Kyonggi Research Institute, Korea (ROK) (Urban Planning and GIS) Phone : 82-31-250-3283 Email : [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Precision
On Wed, Apr 06, 2005 at 02:00:58PM +0200, Josef Eschgfaeller wrote: How precise is R numerically? For example I wrote the following function for calculating the volume of the ball inscribed in the unit cube in m dimensions. In order to see what happens in 40 dimensions, I created an output of 24 digits. But how many are precise? R uses IEEE-754 double precision floating point arithmetic (see capabilities()), which has a 52 bit mantissa, roughly corresponding to 15 decimal digits. This is how much information is available, how much of it is precise in the sense that it accurately reflects the quantity you're computing depends on the computation you're doing. Thanks Josef Eschgf?ller Ferrara --- Vol = function (m) {if (m=1) 1 else Vol(m-2)*pi/(m+m)} for (m in 1:40) {x=sprintf('%2d %.24f',m,Vol(m)) print(x)} --- For getting an impression of what happens, this looks ok to me. If you're concerned that precision wanes because you get less and less non-zero digits: that's not the case -- use the %e or %g format to see that the number of mantissa digits does not decrease. Best regards, Jan -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Precision
Josef Eschgfaeller wrote: How precise is R numerically? For example I wrote the following function for calculating the volume of the ball inscribed in the unit cube in m dimensions. In order to see what happens in 40 dimensions, I created an output of 24 digits. But how many are precise? For most floating point operations R uses double precision, which gives about 18-19 significant digit precision. Leading zeros don't count. Duncan Murdoch Thanks Josef Eschgfäller Ferrara --- Vol = function (m) {if (m=1) 1 else Vol(m-2)*pi/(m+m)} for (m in 1:40) {x=sprintf('%2d %.24f',m,Vol(m)) print(x)} --- 1 1. 2 0.785398163397448278999491 3 0.523598775598298815658893 4 0.308425137534042437259529 5 0.164493406684822623953224 6 0.080745512188280771370685 7 0.036912234143214060766436 8 0.015854344243815498421979 9 0.006442400200661534299951 10 0.002490394570192719803786 11 0.000919972597358349329817 12 0.000325991886927389960208 13 0.00060736667881195885 14 0.36576204182177245747 15 0.11640725122781503579 16 0.03590860448591509251 17 0.01075600486123191399 18 0.00313361689037812061 19 0.00088923646984269168 20 0.00024611369504941992 21 0.6651473240385528 22 0.1757247673443401 23 0.0454265640598788 24 0.0115011591279740 25 0.0028542351985668 26 0.0006948453273887 27 0.0001660526728044 28 0.389807317126 29 0.089943078792 30 0.020410263397 31 0.004557492187 32 0.001001886462 33 0.000216936121 34 0.46287046 35 0.09736070 36 0.02019653 37 0.00413335 38 0.00083486 39 0.00016648 40 0.3278 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Precision
Duncan Murdoch wrote: For most floating point operations R uses double precision, which gives about 18-19 significant digit precision. Leading zeros don't count. Oops, Jan Kim is right: double precision is only 15-16 digit precision. Sorry. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to estimate Type I, Type III SS
On Wed, 2005-04-06 at 21:40 +0900, Kum-Hoe Hwang wrote: Howdy, R gurus I 'd like to know hwo to calculate or estimate SS of Type I and Type III in ANOVA or other anaysis in R. Thanks, If memory seves me well, try Anova in the car package F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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
RE: [R] how to estimate Type I, Type III SS
Dear Federico and Kum-Hoe, The Anova function in the car package will compute Type II or Type III tests (with the former as the default); anova() computes Type I (sequential) tests. Be careful with the contrast coding for Type III tests. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Federico Calboli Sent: Wednesday, April 06, 2005 7:49 AM To: Kum-Hoe Hwang Cc: r-help Subject: Re: [R] how to estimate Type I, Type III SS On Wed, 2005-04-06 at 21:40 +0900, Kum-Hoe Hwang wrote: Howdy, R gurus I 'd like to know hwo to calculate or estimate SS of Type I and Type III in ANOVA or other anaysis in R. Thanks, If memory seves me well, try Anova in the car package F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Courses- May 2005***R/S-plus Programming Techniques
XLSolutions Corporation (www.xlsolutions-corp.com) is proud to announce our May-2005 2-day R/S-plus Fundamentals and Programming Techniques at 4 US locations: www.xlsolutions-corp.com/training.htm Philadelphia --- May 19-20 Raleigh May 19-20 San Francisco -- May 26-27 Seattle May 26-27 Reserve your seat now at the early bird rates! Payment due AFTER the class. Course Description: This two-day beginner to intermediate R/S-plus course focuses on a broad spectrum of topics, from reading raw data to a comparison of R and S. We will learn the essentials of data manipulation, graphical visualization and R/S-plus programming. We will explore statistical data analysis tools,including graphics with data sets. How to enhance your plots. We will perform basic statistics and fit linear regression models. Participants are encouraged to bring data for interactive sessions With the following outline: - An Overview of R and S - Data Manipulation and Graphics - Using Lattice Graphics - A Comparison of R and S-Plus - How can R Complement SAS? - Writing Functions - Avoiding Loops - Vectorization - Statistical Modeling - Project Management - Techniques for Effective use of R and S - Enhancing Plots - Using High-level Plotting Functions - Building and Distributing Packages (libraries) - Connecting to other software, ODBC, Tcl/Tk, Rweb,Rcgi Email us for group discounts. Email Sue Turner: [EMAIL PROTECTED] Phone: 206-686-1578 Visit us: www.xlsolutions-corp.com/training.htm Please let us know if you and your colleagues are interested in this classto take advantage of group discount. Register now to secure your seat! Interested in R/Splus Advanced course? email us. Cheers, Elvis Miller, PhD Manager Training. XLSolutions Corporation 206 686 1578 www.xlsolutions-corp.com [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
[R] Introduce a new function in a package?
R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
or you could create a package containing all these functions and edit .Rprofile to load it at start-up (see also ?.Startup). Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Luis Ridao Cruz [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, April 06, 2005 3:47 PM Subject: [R] Introduce a new function in a package? R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
See at http://cran.r-project.org/doc/manuals/R-intro.pdf at page 54. .First() can help you. Or create an own package (see http://cran.r-project.org/doc/manuals/exts.pdf ) and load the package, when needed. Best, Matthias -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Luis Ridao Cruz Gesendet: Mittwoch, 06. April 2005 15:48 An: r-help@stat.math.ethz.ch Betreff: [R] Introduce a new function in a package? R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Introduce a new function in a package?
Another approach, if making a package is a bit more than what you want to do, is: 1. Save those functions/objects in an image using save(). 2. attach() that image every time you start R. There are a few ways that you can do #2 above. See ?Startup. Andy From: Roger D. Peng I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] par(mfcol=2, mfrow=3) equivalent for trellis
Dear friends of lattice, I know how to position trellis plots with print(...,split,more=T) or (...position). Sometimes I wish I had something like the old par(mfcol=2, mfrow=3) mechanism, where the next free viewport is automatically chosen. I tried fiddling with grid-viewports, but could not find an easy solution. Did I miss something? Dieter Menne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
On Wed, Apr 06, 2005 at 09:57:00AM -0400, Roger D. Peng wrote: I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Alternatively, one can also write the function in question into one's ~/.Rprofile; then, it's automatically available in all R sessions. To avoid confusion, make sure that you choose a unique name, i.e. one that isn't used by any package, if possible. This method should be used only for functions intended to provide some convenience in interactive sessions, code in scripts should not rely on functions being provided by ~/.Rprofile. For scripting, an R package is definitely preferred. Best regards, Jan Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] par(mfcol=2, mfrow=3) equivalent for trellis
probably you want to use the layout argument, see its description in ?xyplot(). I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Dieter Menne [EMAIL PROTECTED] To: R-Help r-help@stat.math.ethz.ch Sent: Wednesday, April 06, 2005 4:06 PM Subject: [R] par(mfcol=2, mfrow=3) equivalent for trellis Dear friends of lattice, I know how to position trellis plots with print(...,split,more=T) or (...position). Sometimes I wish I had something like the old par(mfcol=2, mfrow=3) mechanism, where the next free viewport is automatically chosen. I tried fiddling with grid-viewports, but could not find an easy solution. Did I miss something? Dieter Menne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] the number of cluster
Are there any package that is using v-fold cross-validation algorithm to test the number the clusters? Thanks, Ming On Sat, Mar 19, 2005 at 12:44:42PM +0100, Uwe Ligges wrote: XP Sun wrote: hi, all, how to decide the number of cluster before you use kmeans and hclust? thank you in advance! Depends on your criterion. Best idea is always to use the brain and think about how many clusters are sensible for the particular task/problem/data. For hclust, you can also look at the dendrogram's height and distances of dissimilarities in order to cut. Uwe Ligges best -xpsun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
Expressions in .Rprofile are executed *before* any previously saved global environment is loaded (i.e., before the .RData file in the current working directory is loaded, causing the message [Previously saved workspace restored] to a appear). If you define a function in .Rprofile, and then later answer yes to the Save workspace image? question when you quit R, the function will exist in the saved workspace. When you next start R, the version that comes in from .Rprofile will be replaced by the version in the saved workspace -- because the saved workspace is loaded after .Rprofile is executed. This means that if you decide to change the function in .Rprofile, your changes will immediately be lost when the previously saved workspace is loaded, since that has the previous version. So defining personal utility functions in .Rprofile is not very effective. Much, much, better to create a package, and then require() that package in .Rprofile. And since creating a package is really very easy, I strongly recommend that option. Saving the functions in an image file and then attaching it is fine, but less convenient, in my opinion, since you have to keep track of where it is in the file system. -Don At 4:09 PM +0100 4/6/05, Jan T. Kim wrote: On Wed, Apr 06, 2005 at 09:57:00AM -0400, Roger D. Peng wrote: I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Alternatively, one can also write the function in question into one's ~/.Rprofile; then, it's automatically available in all R sessions. To avoid confusion, make sure that you choose a unique name, i.e. one that isn't used by any package, if possible. This method should be used only for functions intended to provide some convenience in interactive sessions, code in scripts should not rely on functions being provided by ~/.Rprofile. For scripting, an R package is definitely preferred. Best regards, Jan Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Error in hist.default(A) : `x' must be numeric
Dear everybody! I have load a list A of numbers and want a histogram to be drawn. on hist(Y) the Machine returns: Error in hist.default(A) : `x' must be numeric I found out, that the list is of type data.frame. Y-as.numeric(Y) returns Error in as.double.default(A) : (list) object cannot be coerced to double What schould I do? Than you in advance! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R can not show plots (in Mac OS X terminal)
On Wed, 6 Apr 2005, David Ruau wrote: Hi, You should use X11. It doesn't work in Terminal. You can use the basic Xterm in X11 or like I do Aterm. This is not actually true. It does work in Terminal, you just have to specify the DISPLAY, either in the shell before entering R % setenv DISPLAY :0 or when you call x11() x11(display=:0) -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
Re: [R] par(mfcol=2, mfrow=3) equivalent for trellis
On Wednesday 06 April 2005 09:06, Dieter Menne wrote: Dear friends of lattice, I know how to position trellis plots with print(...,split,more=T) or (...position). Sometimes I wish I had something like the old par(mfcol=2, mfrow=3) mechanism, where the next free viewport is automatically chosen. I tried fiddling with grid-viewports, but could not find an easy solution. Did I miss something? This is definitely not doable right now (since print.trellis by default plots on a new page), but it can be implemented if there's interest. The easiest solution would involve changing print.trellis to get the default 'split' from some sort of user defined setting. Most of the mechanism required for this is already in place. A grid level implementation of par(mfrow) may help, but I don't think that's in keeping with grid's design goals. 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
Re: [R] Error in hist.default(A) : `x' must be numeric
Mag. Ferri Leberl wrote: Dear everybody! I have load a list A of numbers and want a histogram to be drawn. on hist(Y) the Machine returns: Error in hist.default(A) : `x' must be numeric I found out, that the list is of type data.frame. Y-as.numeric(Y) returns Error in as.double.default(A) : (list) object cannot be coerced to double What schould I do? Than you in advance! Extract the relevant vector from your data frame Y (this is a very prbably guess). Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Error in hist.default(A) : `x' must be numeric
Mag. Ferri Leberl wrote on 4/6/2005 9:57 AM: Dear everybody! I have load a list A of numbers and want a histogram to be drawn. on hist(Y) the Machine returns: Error in hist.default(A) : `x' must be numeric I found out, that the list is of type data.frame. Y-as.numeric(Y) returns Error in as.double.default(A) : (list) object cannot be coerced to double What schould I do? Than you in advance! The error messages cannot be more explicit. Y is a list (or data.frame). If you're trying to plot a histogram of a component in Y, use the [[ or $ extractors. E.g. Y - data.frame(x = rnorm(100)) hist(Y$x) I would suggest you learn to use ?str if you don't know what Y is. --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
Re: [R] R can not show plots (in Mac OS X terminal)
Did you install R from source code, or did you install the binary? If you installed the binary, then you can start R by double-clicking on the R application icon. Then your default graphics device will not require X windows, and will be fully interactive (in the R sense). If you installed from source code, you may or may not have the double-clickable application, depending on what configuration options you specified. If you don't want to use the GUI interface provided by the binary download, then you will have the best results if you work in the X windows environment, in my opinion (there are other opinions). You can work in the X windows environment with either the binary installation, or if you installed from source. Obviously, however, you have to have X Windows installed in order to use it with R -- and if you installed R from source code, you need to install X Windows *before* installing R. I don't know if order matters if you installed the binary. If you don't want to use the GUI, and don't want to use X Windows, then you are operating outside of my experience. But try starting a graphics device using quartz() *before* issuing any plot() command. See also ?Devices I believe there may be alternatives to what I've outlined here, but I don't know what they are. -Don At 7:12 PM +0100 4/5/05, Minyu Chen wrote: Dear all: I am a newbie in Mac. Just installed R and found R did not react on my command plot (I use command line in terminal). It did not give me any error message, either. All it did was just giving out a new command prompt--no reaction to the plot command. I suppose whenever I gives out a command of plot, it will invoke the AquaTerm for a small graph, as I experience in octave. What can I do for it? Many thanks, Minyu Chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
Some other advantages of making your own package are: - you can use help.search to search for your own functions even if you don't load the package - if you can't even remember where your functions are (and I often can't) then you may not remember what they do either and packaging them gives a convenient way to associate documentation. Once you have found your function you can use ? to gets its documentation. - you get to use ' CMD check' whch is very helpful If you are doing it on Windows the amount of software you need to download and install first may be a bit offputting and you may need to sort out some path and latex problems but its probably worth it in the end if you do enough R development. On Apr 6, 2005 10:55 AM, Don MacQueen [EMAIL PROTECTED] wrote: Expressions in .Rprofile are executed *before* any previously saved global environment is loaded (i.e., before the .RData file in the current working directory is loaded, causing the message [Previously saved workspace restored] to a appear). If you define a function in .Rprofile, and then later answer yes to the Save workspace image? question when you quit R, the function will exist in the saved workspace. When you next start R, the version that comes in from .Rprofile will be replaced by the version in the saved workspace -- because the saved workspace is loaded after .Rprofile is executed. This means that if you decide to change the function in .Rprofile, your changes will immediately be lost when the previously saved workspace is loaded, since that has the previous version. So defining personal utility functions in .Rprofile is not very effective. Much, much, better to create a package, and then require() that package in .Rprofile. And since creating a package is really very easy, I strongly recommend that option. Saving the functions in an image file and then attaching it is fine, but less convenient, in my opinion, since you have to keep track of where it is in the file system. -Don At 4:09 PM +0100 4/6/05, Jan T. Kim wrote: On Wed, Apr 06, 2005 at 09:57:00AM -0400, Roger D. Peng wrote: I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Alternatively, one can also write the function in question into one's ~/.Rprofile; then, it's automatically available in all R sessions. To avoid confusion, make sure that you choose a unique name, i.e. one that isn't used by any package, if possible. This method should be used only for functions intended to provide some convenience in interactive sessions, code in scripts should not rely on functions being provided by ~/.Rprofile. For scripting, an R package is definitely preferred. Best regards, Jan Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that could be used anytime I run a different R project. Thank you in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
~/.Rprofile You could also write in .Rprofile soemthing like this: for (x in dir(Mylibrary,full.names=T,recursive=T)) source(x) where Mylibrary is a directory which contains your functions without making a package. Josef Eschgfäller__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Error in hist.default(A) : `x' must be numeric
From: Uwe Ligges Mag. Ferri Leberl wrote: Dear everybody! I have load a list A of numbers and want a histogram to be drawn. on hist(Y) the Machine returns: Error in hist.default(A) : `x' must be numeric I found out, that the list is of type data.frame. Y-as.numeric(Y) returns Error in as.double.default(A) : (list) object cannot be coerced to double What schould I do? Than you in advance! Extract the relevant vector from your data frame Y (this is a very prbably guess). I suspect Ferri might have the numbers in one line in a file, and read them into R with read.table(). That would put the numbers into a data frame with n variables and one observation. If that's the case, just replacing read.table() with scan() should do it. Andy Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R can not show plots (in Mac OS X terminal)
Thank you very much. This is very informative and I already save it for future reference. Now I got the double clicking icon (quite mysteriously, since I tried several ways recommended by others, so I don't know which one make it works). Thanks, Minyu Chen On 6 Apr 2005, at 16:11, Don MacQueen wrote: Did you install R from source code, or did you install the binary? If you installed the binary, then you can start R by double-clicking on the R application icon. Then your default graphics device will not require X windows, and will be fully interactive (in the R sense). If you installed from source code, you may or may not have the double-clickable application, depending on what configuration options you specified. If you don't want to use the GUI interface provided by the binary download, then you will have the best results if you work in the X windows environment, in my opinion (there are other opinions). You can work in the X windows environment with either the binary installation, or if you installed from source. Obviously, however, you have to have X Windows installed in order to use it with R -- and if you installed R from source code, you need to install X Windows *before* installing R. I don't know if order matters if you installed the binary. If you don't want to use the GUI, and don't want to use X Windows, then you are operating outside of my experience. But try starting a graphics device using quartz() *before* issuing any plot() command. See also ?Devices I believe there may be alternatives to what I've outlined here, but I don't know what they are. -Don At 7:12 PM +0100 4/5/05, Minyu Chen wrote: Dear all: I am a newbie in Mac. Just installed R and found R did not react on my command plot (I use command line in terminal). It did not give me any error message, either. All it did was just giving out a new command prompt--no reaction to the plot command. I suppose whenever I gives out a command of plot, it will invoke the AquaTerm for a small graph, as I experience in octave. What can I do for it? Many thanks, Minyu Chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] off-topic question: Latex and R in industries
Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
I tried making a package on windows and got a make error, so I was happy I was able to get source(mystuff.R) to work in .First(). Since my utility functions are pretty simple and few in number, this is good enough for me for now. But I got a curious error. I can submit the command memory.size(3*1024) at the command line and it works fine (I modified my header file to make R \LARGEADDRESSAWARE), but if I put that same command in .First R says it can't find a function memory.size in the environment. Can anyone recommend a cause and/or work around? Thanks, Roger On Apr 6, 2005 11:24 AM, Josef Eschgfaeller [EMAIL PROTECTED] wrote: ~/.Rprofile You could also write in .Rprofile soemthing like this: for (x in dir(Mylibrary,full.names=T,recursive=T)) source(x) where Mylibrary is a directory which contains your functions without making a package. Josef Eschgfäller __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] newman-keuls
Bonjour Je cherche à faire un test de newman-keuls sous R. Est-ce que quelqu'un peut m'aider ? En vous remerciant d'avance fawtzy __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
Better to attach a new environment and source() the files into that. local({ for (.x in dir(Mylibrary,full.names=T,recursive=T)) source(.x, local=T); rm(.x)}, env = attach(NULL, name=myenv)) for all the reasons why a package() is a good idea. Leaving an object `x' around from .Rprofile is not at all a good idea, BTW. On Wed, 6 Apr 2005, Josef Eschgfaeller wrote: ~/.Rprofile You could also write in .Rprofile soemthing like this: for (x in dir(Mylibrary,full.names=T,recursive=T)) source(x) where Mylibrary is a directory which contains your functions without making a package. Josef Eschgfäller -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
my favorite answer to this question is because there is no one to sue. url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 On Apr 6, 2005, at 10:38 AM, Wensui Liu wrote: Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
On Wed, 6 Apr 2005, roger bos wrote: I tried making a package on windows and got a make error, so I was happy I was able to get source(mystuff.R) to work in .First(). Since my utility functions are pretty simple and few in number, this is good enough for me for now. But I got a curious error. I can submit the command memory.size(3*1024) at the command line and it works fine (I modified my header file to make R \LARGEADDRESSAWARE), but if I put that same command in .First R says it can't find a function memory.size in the environment. Can anyone recommend a cause and/or work around? The last thing done in the startup is to load the default packages, so only base is loaded when .First is run. memory.size is in utils, so you need utils::memory.size. See ?Startup HOWEVER, it would be better to use --max-mem-size as part of the shortcut or alias you use to start R since saved data is loaded before .First is run. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Introduce a new function in a package?
Leaving an object `x' around from .Rprofile is not at all a good idea, Actually I thought to put it inside a function. Josef Eschgfäller __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] bootstrap vs. resampleing
Hi, I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. variance, median, etc. I have someone suggesting that by resampling certain proportion of the total samples (e.g. 80%) without replacement, we can also get the estimate of confidence intervals. Here we have an example of 1000 obsevations, we would like to estimate 95% confidence intervals for odds ratio for a diagnostic test, can I use resampling 80% of the observations without replacement, instead of bootstrap, to do this? If not, why is it wrong to do it this way? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
Ha -- that's a good one, Roger. Which demonstrates that most industrial people don't bother to read EULA's :-). (of course, it depends on which industry, and for some industries, which segment you are in ). On Apr 6, 2005 6:05 PM, roger koenker [EMAIL PROTECTED] wrote: my favorite answer to this question is because there is no one to sue. url:www.econ.uiuc.edu/~rogerRoger Koenker email [EMAIL PROTECTED] Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 On Apr 6, 2005, at 10:38 AM, Wensui Liu wrote: Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- best, -tony Commit early,commit often, and commit in a repository from which we can easily roll-back your mistakes (AJR, 4Jan05). A.J. Rossini [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
Re: [R] off-topic question: Latex and R in industries
On Wed, 2005-04-06 at 11:38 -0400, Wensui Liu wrote: Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. As Tony has referenced, the answer will depend upon what industry you are referring to. There is an article in R News (2004 Vol 4 Number 1) that you might find of interest entitled The Decision to Use R from a small medical consulting business perspective: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf There is a persistent rumor of a similar article from a large corporate medical industry environment that is due real soon now... ;-) You might also want to search the r-help archives as there have been some fairly lively discussions on this in the recent past, especially in healthcare applications when a certain other Statistical Analysis System is referenced as being the perceived standard... HTH, Marc library(fortunes) fortune(Schwartz) I use R. My company benefits from it. My clients benefit from it. ...and I sleep just fine (when I do sleep)... :-) -- Marc Schwartz, Medanalytics (about the `costs' of free software) R-help (June 2004) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] bootstrap vs. resampleing
I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. ^^ There's no such thing. You can estimate 95% CI's on population **parameters**, which is, I assume, what you mean. If you don't know what the difference is, stop here and consult a local statistician, as you are out of your depth. --- If you make it to here, I think you are referring to cross-validation vs resampling. Typically, X-validation is used to get an honest estimate of prediction error rather than confidence limits for a parameter. The correctness of bootstrapping for this purpose is based on asymptotic theory: loosely speaking, the data distribution approximates the population distribution; appropriate resampling (e.g. maybe stratified, moving blocks, ...) from the data corresponds to iid sampling (or whatever is appropriate..) from the population. It is actually a way to approximate the (itself approximate) asymptotic sampling distribution. AFAIK (experts, please correct) no such asymptotic theory holds for X-validation and so it would be problematic/wrong for CI's. -- 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 array chip Sent: Wednesday, April 06, 2005 10:19 AM To: r-help@stat.math.ethz.ch Subject: [R] bootstrap vs. resampleing Hi, I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. variance, median, etc. I have someone suggesting that by resampling certain proportion of the total samples (e.g. 80%) without replacement, we can also get the estimate of confidence intervals. Here we have an example of 1000 obsevations, we would like to estimate 95% confidence intervals for odds ratio for a diagnostic test, can I use resampling 80% of the observations without replacement, instead of bootstrap, to do this? If not, why is it wrong to do it this way? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] bootstrap vs. resampleing
What you're describing sounds like subsampling, about which John Hartigan has written a few papers. -roger array chip wrote: Hi, I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. variance, median, etc. I have someone suggesting that by resampling certain proportion of the total samples (e.g. 80%) without replacement, we can also get the estimate of confidence intervals. Here we have an example of 1000 obsevations, we would like to estimate 95% confidence intervals for odds ratio for a diagnostic test, can I use resampling 80% of the observations without replacement, instead of bootstrap, to do this? If not, why is it wrong to do it this way? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 2d plotting and colours
Mulholland, Tom [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Since I was only concentrating on colour issues and not on your specific problem I was just showing the possibilities. Does this code help n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) palette(rainbow(n)) barplot(1:25,col = 1:25) palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) barplot(1:25,col = 1:25) require(cluster) x - runif(100) * 8 + 2 cl - kmeans(x, n) palette(rainbow(n)) plot(x, col = cl$cluster) abline(h = cl$centers, lty = 2,col = grey ) palette(palette()[order(cl$centers)]) points(x,col = cl$cluster,pch = 20,cex = 0.4) Using Windows with R 2.0.1 this looks fine at first. But when I resize the graphic, copy the graphic to a metafile and paste it into Word, or go to an earlier graphic and come back using History, the colors ae all messed up. It's as if only the last palette is being used for all four plots in the figure. Oddly, if I copy the graphic as a bitmap, the colors are preseved in the bitmap. Is this a quirk of my machine or does this happen for others? Is it possible that the Windows palette manager is being used (which is such about obsolete) and that true color graphics are not being used (which is the easist way to avoid headaches from the Windows palette manager)? efg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] bootstrap vs. resampleing
On Wed, 6 Apr 2005, array chip wrote: Hi, I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. variance, median, etc. I have someone suggesting that by resampling certain proportion of the total samples (e.g. 80%) without replacement, we can also get the estimate of confidence intervals. Here we have an example of 1000 obsevations, we would like to estimate 95% confidence intervals for odds ratio for a diagnostic test, can I use resampling 80% of the observations without replacement, instead of bootstrap, to do this? If not, why is it wrong to do it this way? You can, provided you rescale correctly for the fact that you are working with a smaller sample. This is more like the jackknife, which also resamples a smaller number without replacement. There is quite a bit of literature on this sort of jackknife/bootstrap variant. One useful book is The Jackknife and Bootstrap by Shao and Tu. -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
Re: [R] off-topic question: Latex and R in industries
We have S+ at our company, but I choose to use R because I like it. There are two observations I have. One is that many people in IT don't seem to like open source software that much because either they don't trust it or they say there is no one who stands behind it. Second, equally important point, is that there is no R salesforce marking the product to companies. Commercial products have marketing budgets and aggresive salespeople who contact potential purchasers. Insightful will come in and give a company presentation. Who wants to volunteer to come into my company and demo R for my manager? I only learned about R a year ago when a friend of mine told me about it. The real question is, how to get more exposuRe? Thanks, Roger On Apr 6, 2005 2:09 PM, Marc Schwartz [EMAIL PROTECTED] wrote: On Wed, 2005-04-06 at 11:38 -0400, Wensui Liu wrote: Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. As Tony has referenced, the answer will depend upon what industry you are referring to. There is an article in R News (2004 Vol 4 Number 1) that you might find of interest entitled The Decision to Use R from a small medical consulting business perspective: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf There is a persistent rumor of a similar article from a large corporate medical industry environment that is due real soon now... ;-) You might also want to search the r-help archives as there have been some fairly lively discussions on this in the recent past, especially in healthcare applications when a certain other Statistical Analysis System is referenced as being the perceived standard... HTH, Marc library(fortunes) fortune(Schwartz) I use R. My company benefits from it. My clients benefit from it. ...and I sleep just fine (when I do sleep)... :-) -- Marc Schwartz, Medanalytics (about the `costs' of free software) R-help (June 2004) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] bootstrap vs. resampleing
Confidence intervals depend on the sample size - the bigger the sample the smaller the interval. Subsampling (resampling without replacement) gives smaller samples and underestimates confidence (overestimates confidence interval size) of parameters calculated on the original sample. Best Jens Oehlschlägel P.S.: I guess signing a question with your name makes answers more likely -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] insignificant factors in regression model
Hi list, I am building a regression model with categorical predictor variable coded by treatment contrasts. The summary of the regression model shows that some levels are significant while others are not. The significant ones show that they are statistically significant from the basis factor (at level 0). How do we generally deal with those insignificant levels? If they are used for prediction, sometimes they will produce strange results because their coefficient estimates have large variances. Do we just simply ignore them assuming they are not different from level 0? Or do we exclude them in factors (by treating them as zero's) and refit the model? any suggestions? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
Thank you all for the replies. I've used R and latex in graduate school and absolultely love them. After getting in the industry, everyone is using MS products or SPSS/SAS. But in term of quality, there is no comparison between MS word and Latex or between SAS/SPSS and R. On Apr 6, 2005 2:35 PM, roger bos [EMAIL PROTECTED] wrote: We have S+ at our company, but I choose to use R because I like it. There are two observations I have. One is that many people in IT don't seem to like open source software that much because either they don't trust it or they say there is no one who stands behind it. Second, equally important point, is that there is no R salesforce marking the product to companies. Commercial products have marketing budgets and aggresive salespeople who contact potential purchasers. Insightful will come in and give a company presentation. Who wants to volunteer to come into my company and demo R for my manager? I only learned about R a year ago when a friend of mine told me about it. The real question is, how to get more exposuRe? Thanks, Roger On Apr 6, 2005 2:09 PM, Marc Schwartz [EMAIL PROTECTED] wrote: On Wed, 2005-04-06 at 11:38 -0400, Wensui Liu wrote: Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. As Tony has referenced, the answer will depend upon what industry you are referring to. There is an article in R News (2004 Vol 4 Number 1) that you might find of interest entitled The Decision to Use R from a small medical consulting business perspective: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf There is a persistent rumor of a similar article from a large corporate medical industry environment that is due real soon now... ;-) You might also want to search the r-help archives as there have been some fairly lively discussions on this in the recent past, especially in healthcare applications when a certain other Statistical Analysis System is referenced as being the perceived standard... HTH, Marc library(fortunes) fortune(Schwartz) I use R. My company benefits from it. My clients benefit from it. ...and I sleep just fine (when I do sleep)... :-) -- Marc Schwartz, Medanalytics (about the `costs' of free software) R-help (June 2004) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- WenSui Liu, MS MA Senior Decision Support Analyst Division of Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] using command line flags with TINN-R
This is a TINN-R editor question rather than an R question, but can anyone tell me how to use command line flags with TINN-R. There is a space to fill in the path to Rgui, and I have C:\Program Files\R\rw2001pat\bin\Rgui.exe. If I try to add a command line flag after that, such as --no-save or --max-mem-size then TINN-R will not open the application. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] off-topic question: Latex and R in industries
It appears that more than a few people posting on this list are from industry... I use R for research into signal/image analysis and tomography. Most people doing this use Matlab. I prefer R for several reasons. First, I'm a long-time S user. Second, I'm involved in the administration and in this respect R is far more straightforward than Matlab. I really appreciate the effort that goes into making R configurable. R can be built on essentially anything, in several ways, to suit; Matlab is quite limited in the platforms it supports, and you pretty much take what you get. Third, R is very flexible and open and easy to customize. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Wednesday, April 06, 2005 11:39 AM To: r-help@stat.math.ethz.ch Subject: [R] off-topic question: Latex and R in industries Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
On Wed, 6 Apr 2005, roger bos wrote: Insightful will come in and give a company presentation. Who wants to volunteer to come into my company and demo R for my manager? I only learned about R a year ago when a friend of mine told me about it. The real question is, how to get more exposuRe? The other real question is Why?. I can see the motivation of people who want to use R and need to convince their management that it is safe, but inflicting R on people who haven't heard of it and are perfectly happy that way seems unnecessary. What would be the benefit? -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] newbie file size question
I've just recently started using R and have a very basic question. Sorry all, I've searched the postings and couldn't find the answer. I'm trying to read a very large ascii file 1,461,363 rows(data points) x 200 columns(time points) for a few hours now and R seems to be 'frozen'. I'm wondering if there are file size limits or if this is just a really large file and it's just going to be very slow. I believe my read.table syntax is correct - I had everything working just fine with a small subject of this data (only 20 rows x 200 columns). My data is stored and processes running on the University's High Performance Computing system (SUN machines) and believe it's using 4 CPUs. Any ideas? Thanks for the help, chris [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] off-topic question: Latex and R in industries
I think there may be a bit of an us vs. them perception in business as it views academia (and R is a product of academia). I discussed the use of R with a businessman not long ago and he raised two objections to its use. First, if they give it away for free, how good can it be? After all, you get what you pay for, and, second, Without a dedicated company standing behind it to take care problems and fix bugs, how can there be any quality control? (I asked him if he had ever heard of Microsoft.) Ben Fairbank -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu Sent: Wednesday, April 06, 2005 10:39 AM To: r-help@stat.math.ethz.ch Subject: [R] off-topic question: Latex and R in industries Latex and R are really cool stuff. I am just wondering how they are used in industry. But based on my own experience, very rare. Why? How about the opinion of other listers? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] insignificant factors in regression model
Weijie Cai wrote: Hi list, I am building a regression model with categorical predictor variable coded by treatment contrasts. The summary of the regression model shows that some levels are significant while others are not. The significant ones show that they are statistically significant from the basis factor (at level 0). How do we generally deal with those insignificant levels? If they are used for prediction, sometimes they will produce strange results because their coefficient estimates have large variances. Do we just simply ignore them assuming they are not different from level 0? Or do we exclude them in factors (by treating them as zero's) and refit the model? any suggestions? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html The fact that an estimated coefficient is not significant does not mean that it is negligible. The lower tail of the F-distribution can be used to help you decide whether or not to omit a term. -- Bob Wheeler --- http://www.bobwheeler.com/ ECHIP, Inc. --- Randomness comes in bunches. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] nnet classification using unbalanced classes
Hi everybody, I want to obtain a classification model using the nnet function for a simple two class problem. My problem is that number of samples in the first class (n1) is about twice higher than the one in class two (n2). I would like to use the weights argument in the nnet function to equalize the prior probabilities, but I am not sure which values I should assign. My first guess would be to set the weights of samples in the larger class to n2/n1 and those for the second class to 1. Is it the best thing to do? Any suggestion would be appreciated. Laurentiu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
On Wed, Apr 06, 2005 at 11:56:59AM -0700, Thomas Lumley wrote: On Wed, 6 Apr 2005, roger bos wrote: Insightful will come in and give a company presentation. Who wants to volunteer to come into my company and demo R for my manager? I only learned about R a year ago when a friend of mine told me about it. The real question is, how to get more exposuRe? The other real question is Why?. I can see the motivation of people who want to use R and need to convince their management that it is safe, but inflicting R on people who haven't heard of it and are perfectly happy that way seems unnecessary. What would be the benefit? Of course, it follows from the assumption of perfect happiness without R that there's no point in forcibly selling R to them. I suspect that the salesforces behind commercial software are not exclusively driven by such reason, however... Best regards, Jan -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Polynomiographic function in R :-)
Hi, people. Nothing too serious in this message. Nevertheless, all criticism or advice is welcome :-). Yesterday, I went to a conference by Bahman Kalantari (Rutgers University) about Polynomiography (the Fine Art and Science of Visualizing Polynomials). Since I'm starting my R learning, I decided to try using it for computing some (any!) polynomiograph. I was surprised about how easy and quick it was to get some results. Then I thought it was interesting to extend the drawing to any function, and not necessarily polynomials, yielding the function below: polygraph - function(expression, xrange=c(-1, 1), yrange=c(-1, 1), points=200, steps=20, display=image) { expression - substitute(expression) variable - all.vars(expression) stopifnot(length(variable) == 1) derivative - D(expression, variable) name - as.name(variable) expression - substitute(name - expression / derivative) assign(variable, outer(seq(xrange[1], xrange[2], length=points), seq(yrange[1], yrange[2], length=points) * 1i, '+')) for (step in 1:steps) { display(Arg(eval(name))) assign(variable, eval(expression)) } } which can be used this way, picking a function almost at random, say: polygraph(x^3 - sqrt(x) - 1, points=300) Here are a few random thoughts or remarks: * Once fully converged, there should be only one colour per root. Each pixel colour shows towards which root would converge the chosen root finding algorithm, starting at this particular point, or complex number. * Another nice choice for `display' could be `filled.contour', yet it computes more slowly. * The successive plots (20 by default) show the progressive refinement while finding equation roots, making a kind of animation. One might prefer moving the `display' call out of the loop, and show only the last refinement. * I did not know that root finding through Newton-Raphson could be merely extended to complex numbers, fun to see that it works! :-) * The conferencer told us that there a _lot_ of root finding algorithms, and they may yield different styles of art. I only picked the simplest one to play with. But you might do better! (There are also many other approaches than root finding for producing graphs out of polynomials.) * Really, the one thing that most amused me in this experiment is how I could use R for symbolically preparing the computation to do, without resorting to parsing and deparsing (which I'm instinctively tempted to avoid.) I'm quite far from understanding all I should about functions, expressions, calls and parse trees, but even knowing very little, it was satisfying being able to rather quickly debug the above function. * There are likely better ways than those I used. For example, even if unlikely, there might be clashes between the variables making up the expression given, and local variables of the function. I wonder if the expression variable could have been more fully abstracted. * Vectorisation worked surpringly well on that problem, speed-wise. However, because some regions of the plane converge faster than others (use `display=plot' and such while calling `polygraph' to study this), maybe they would be ways towards significant speed-ups. But since it is likely that one would loose a good part of vectorisability by doing so, and add a lot of complexity (with unavoidable bugs in the process), I wonder how worth it would be in practice. * Given a matrix of complex results, they should ideally be turned into N groups, each group being related to one of the N roots of the equation. I tried producing factors out of these results, but numerical approximation made that non-practical. I would guess that clustering, which I do not know, may be seen as a way to produce factors fuzzily. * As a counter-measure to the above difficulty, I used `Arg()' as a way to produce levels out of the results. Could have used `Im()' instead. It seems that `Mod()' and `Re()' are less productive. `image' is kind enough to turn those levels into colours without any effort from me! All in all, it is a fun way to explore R capabilities, and it also opens up all kind of ideas to toy with! :-) -- François Pinard http://pinard.progiciels-bpi.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] looking for a plot function
Dear useRs, I have a data frame and I want to plot all rows. Each row is represented as a line that links the values in each column. The plot looks like this: dfr - data.frame(A=sample(1:50,10),B=sample(1:50,10), C=sample(1:50,10),D=sample(1:50,10)) xa - 10*1:4 plot(c(10,40),c(0,50)) for (i in 1:nrow(dfr)) { lines(xa,dfr[i,],pch=20,type=o) } Things get more complicated because I want the columns to be rescaled so as to fit nicely on a graph (for example if A has values between 0 and 100 but B has values between 100 and 1000, then rescale A or B), labels etc. Is there a function that can do plots like this? Thank you, b. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] looking for a plot function
On Wednesday 06 April 2005 15:18, bogdan romocea wrote: Dear useRs, I have a data frame and I want to plot all rows. Each row is represented as a line that links the values in each column. The plot looks like this: dfr - data.frame(A=sample(1:50,10),B=sample(1:50,10), C=sample(1:50,10),D=sample(1:50,10)) xa - 10*1:4 plot(c(10,40),c(0,50)) for (i in 1:nrow(dfr)) { lines(xa,dfr[i,],pch=20,type=o) } Things get more complicated because I want the columns to be rescaled so as to fit nicely on a graph (for example if A has values between 0 and 100 but B has values between 100 and 1000, then rescale A or B), labels etc. Is there a function that can do plots like this? Not sure if it fits all your needs, but try 'parallel' in the lattice package. 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
RE: [R] looking for a plot function
If your data were in the long format you could use interaction.plot. But, I think trellis plots in lattice are much better than this approach. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bogdan romocea Sent: Wednesday, April 06, 2005 4:19 PM To: r-help@stat.math.ethz.ch Subject: [R] looking for a plot function Dear useRs, I have a data frame and I want to plot all rows. Each row is represented as a line that links the values in each column. The plot looks like this: dfr - data.frame(A=sample(1:50,10),B=sample(1:50,10), C=sample(1:50,10),D=sample(1:50,10)) xa - 10*1:4 plot(c(10,40),c(0,50)) for (i in 1:nrow(dfr)) { lines(xa,dfr[i,],pch=20,type=o) } Things get more complicated because I want the columns to be rescaled so as to fit nicely on a graph (for example if A has values between 0 and 100 but B has values between 100 and 1000, then rescale A or B), labels etc. Is there a function that can do plots like this? Thank you, b. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] looking for a plot function
I am not sure about the scaling, but doing simply matplot(xa, t(dfr), type=b) does most of what you want. Andy __ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 Doran, Harold [EMAIL PROTECTED] Sent by: To [EMAIL PROTECTED] bogdan romocea at.math.ethz.ch [EMAIL PROTECTED], r-help@stat.math.ethz.ch cc 04/06/2005 03:24 PMSubject RE: [R] looking for a plot function If your data were in the long format you could use interaction.plot. But, I think trellis plots in lattice are much better than this approach. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bogdan romocea Sent: Wednesday, April 06, 2005 4:19 PM To: r-help@stat.math.ethz.ch Subject: [R] looking for a plot function Dear useRs, I have a data frame and I want to plot all rows. Each row is represented as a line that links the values in each column. The plot looks like this: dfr - data.frame(A=sample(1:50,10),B=sample(1:50,10), C=sample(1:50,10),D=sample(1:50,10)) xa - 10*1:4 plot(c(10,40),c(0,50)) for (i in 1:nrow(dfr)) { lines(xa,dfr[i,],pch=20,type=o) } Things get more complicated because I want the columns to be rescaled so as to fit nicely on a graph (for example if A has values between 0 and 100 but B has values between 100 and 1000, then rescale A or B), labels etc. Is there a function that can do plots like this? Thank you, b. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is a .R script file name available inside the script?
That is useful, when calling the script like this: file - Rscript.R source(file) However, it does not work if we do this from the shell prompt: $ R --vanilla Rscript.R because the eval.parent statement attempts to access a base workspace that does not contain the file object/variable, as above. Is there a solution for this situation? Is the input script file an argument to R and therefore available in something like argv? On Mar 18, 2005 8:00 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: Darren Weber darrenleeweber at gmail.com http://gmail.com writes: : : Hi, : : if we have a file called Rscript.R that contains the following, for example: : : x - 1:100 : outfile = Rscript.Rout : sink(outfile) : print(x) : : and then we run : : source(Rscript.R) : : we get an output file called Rscript.Rout - great! : : Is there an internal variable, something like .Platform, that holds : the script name when it is being executed? I would like to use that : variable to define the output file name. : In R 2.0.1 try putting this in a file and sourcing it. script.description - function() eval.parent(quote(file), n = 3) print(basename(script.description())) If you are using R 2.1.0 (devel) then use this instead: script.description - function() showConnections() [as.character(eval.parent(quote(file), n = 3)), description] print((basename(script.description( __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] off-topic question: Latex and R in industries
Thomas Lumley wrote: The other real question is Why?. I can see the motivation of people who want to use R and need to convince their management that it is safe, but inflicting R on people who haven't heard of it and are perfectly happy that way seems unnecessary. What would be the benefit? Actually, I see it as part of my job to inflict R on people who are perfectly happy to have never heard of it. Happiness doesn't equal proficient and efficient. In some cases the proficiency of a person serves a greater good than their momentary happiness. Patrick Burns Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] bootstrap vs. resampleing
I may be misunderstanding the question, but I believe you want a pointwise confidence band for the conditional odds function. The issue here is less bootstrap versus some other resampling plan, and more how to do it at all. For example, if no matter what training data you feed in, you always get the same conditional odds estimate, no resampling will (by itself) reveal this bias (and you will have a confidence band of width 0). You could however use resampling together with nonparametric estimation in a variety of ways to address this. If you assume your conditional odds estimation to be unbiased, you could resample and look at the empirical distribution of conditional odds ratio estimates at a given covariate or feature value. You have to figure out how this is related to the population distribution; this is easiest with the bootstrap since you have the same sample size. In this case the simplest procedure is to treat the bootstrap distribution as the population distribution, but there are many alternatives. See the book Thomas Lumley recommended by Jun Shao and Dongsheng Tu. They treat estimation of regression functions in several places; those remarks are relevant for your case as well. Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of array chip Sent: Wednesday, April 06, 2005 1:19 PM To: r-help@stat.math.ethz.ch Subject: [R] bootstrap vs. resampleing Hi, I understand bootstrap can be used to estimate 95% confidence interval for some statistics, e.g. variance, median, etc. I have someone suggesting that by resampling certain proportion of the total samples (e.g. 80%) without replacement, we can also get the estimate of confidence intervals. Here we have an example of 1000 obsevations, we would like to estimate 95% confidence intervals for odds ratio for a diagnostic test, can I use resampling 80% of the observations without replacement, instead of bootstrap, to do this? If not, why is it wrong to do it this way? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] read.table with header and text data
Hi R! I am reading in a text file which has one column of alpha data and 5 columns of numeric data. There is a header row. I would like the alpha data column to just be character rather than factor. Is there a way to do this, please? I'm thinking that it might be I() but can't figure out exactly how. Thanks, Laura mailto: [EMAIL PROTECTED] R 2.0.1 Windows __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] read.table with header and text data
See ?read.table, especially the argument as.is. Cheers, Rich On Apr 7, 2005 9:55 AM, Laura Holt [EMAIL PROTECTED] wrote: Hi R! I am reading in a text file which has one column of alpha data and 5 columns of numeric data. There is a header row. I would like the alpha data column to just be character rather than factor. Is there a way to do this, please? I'm thinking that it might be I() but can't figure out exactly how. Thanks, Laura mailto: [EMAIL PROTECTED] R 2.0.1 Windows __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Rich FitzJohn rich.fitzjohn at gmail.com |http://homepages.paradise.net.nz/richa183 You are in a maze of twisty little functions, all alike __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] par(mfcol=2, mfrow=3) equivalent for trellis
Hi Deepayan Sarkar wrote: On Wednesday 06 April 2005 09:06, Dieter Menne wrote: Dear friends of lattice, I know how to position trellis plots with print(...,split,more=T) or (...position). Sometimes I wish I had something like the old par(mfcol=2, mfrow=3) mechanism, where the next free viewport is automatically chosen. I tried fiddling with grid-viewports, but could not find an easy solution. Did I miss something? This is definitely not doable right now (since print.trellis by default plots on a new page), but it can be implemented if there's interest. The easiest solution would involve changing print.trellis to get the default 'split' from some sort of user defined setting. Most of the mechanism required for this is already in place. A grid level implementation of par(mfrow) may help, but I don't think that's in keeping with grid's design goals. Right. Everything in grid happens in the current viewport and a viewport does not have to (and often does not) correspond to a plot. There is no obvious next viewport for grid to go to (in general). Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Importing SAS transport data
I have encountered a problem reading SAS transport files on both a Mac (OS X) and Linux (RedHat 9), both using R2.0.1. After loading foreign, the command: read.xport(V1622101_050304.xpt) yields: Error in lookup.xport(file) : File not in SAS transfer format In Linux, I can cat the file. The first few lines are: **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSEDLIB CONTROL WIN_PROBC[EMAIL PROTECTED] SAS8.2BCABD701DATALIB ACMBC9BVC30BC81CC14537BC85RL507BC871BC87S 0 0 20 CHAR In contrast, I can read.xport a different file successfully. That file (and others that I can import successfully) contains the following first line: HEADER RECORD***LIBRARY HEADER RECORD!!!00 SAS SAS SASLIB 6.12WIN_NT 21OCT02:13:30:0721OCT02:13:30:07 I know little about SAS but I wonder whether the problem relates to the export characteristics of different versions of SAS. If so, it appears that read.xport may not work with newer versions of SAS. If so, is there a new function to read SAS transport files? Thanks for any possible help. Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com [[alternative text/enriched version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 2d plotting and colours
Hi Earl F. Glynn wrote: Mulholland, Tom [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Since I was only concentrating on colour issues and not on your specific problem I was just showing the possibilities. Does this code help n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) palette(rainbow(n)) barplot(1:25,col = 1:25) palette(rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.))) barplot(1:25,col = 1:25) require(cluster) x - runif(100) * 8 + 2 cl - kmeans(x, n) palette(rainbow(n)) plot(x, col = cl$cluster) abline(h = cl$centers, lty = 2,col = grey ) palette(palette()[order(cl$centers)]) points(x,col = cl$cluster,pch = 20,cex = 0.4) Using Windows with R 2.0.1 this looks fine at first. But when I resize the graphic, copy the graphic to a metafile and paste it into Word, or go to an earlier graphic and come back using History, the colors ae all messed up. It's as if only the last palette is being used for all four plots in the figure. Oddly, if I copy the graphic as a bitmap, the colors are preseved in the bitmap. Is this a quirk of my machine or does this happen for others? Is it possible that the Windows palette manager is being used (which is such about obsolete) and that true color graphics are not being used (which is the easist way to avoid headaches from the Windows palette manager)? I think this is happening because the setting of the R graphics palette is not being recorded on the R graphics display list. Any window refresh will produce the effect. Even worse, the R graphics palette is global to the R session, not per-device, so simply recording the setting of the palette on the (per-device) display list would only create a more subtle undesirable effect. A possible solution is to make a per-device palette (and record the setting of the palette on the display list), but this is probably too big a change to get done for 2.1.0. A workaround is simply to avoid using the palette. For example, n - 5 par(mfrow = c(2,2)) palette(default) barplot(1:25,col = 1:25) barplot(1:25,col = rainbow(n)) cols - rgb((0:15)/15, g=0,b=0, names=paste(red,0:15,sep=.)) barplot(1:25,col = cols) Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R can not show plots (in Mac OS X terminal)
This is incorrect. x11(display=0:0) opens an x11 graphics device from the terminal assuming (1) that you have installed X11 from Apple's website and (2) that x11 is running. Cheers, George On 4/6/05 5:47 AM, David Ruau [EMAIL PROTECTED] wrote: Hi, You should use X11. It doesn't work in Terminal. You can use the basic Xterm in X11 or like I do Aterm. David Ruau On Apr 5, 2005, at 20:12, Minyu Chen wrote: Dear all: I am a newbie in Mac. Just installed R and found R did not react on my command plot (I use command line in terminal). It did not give me any error message, either. All it did was just giving out a new command prompt--no reaction to the plot command. I suppose whenever I gives out a command of plot, it will invoke the AquaTerm for a small graph, as I experience in octave. What can I do for it? Many thanks, Minyu Chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html == George W. GilchristEmail #1: [EMAIL PROTECTED] Department of Biology, Box 8795 Email #2: [EMAIL PROTECTED] College of William MaryPhone: (757) 221-7751 Williamsburg, VA 23187-8795Fax: (757) 221-6483 http://gwgilc.people.wm.edu/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is a .R script file name available inside the script?
It works for me. Suppose in.txt is a two line file with these two lines: file - Rscript.R source(file) and Rscript.R is a two line file with these two lines: script.description - function() eval.parent(quote(file), n = 3) print(basename(script.description())) Then here is the output on Windows: C:\Program Files\R\rw2001beta\binR --vanilla in.txt R : Copyright 2004, The R Foundation for Statistical Computing [snip] file - Rscript.R source(file) [1] Rscript.R Note that 'file' referred to in 'eval.parent' is not the variable that you called 'file' but is an internal variable within the 'source' program that is called 'file'. It has nothing to do with your 'file', which very well could have a different name. In fact you just do this on Windows: echo source(Rscript.R) | R --vanilla From: Darren Weber [EMAIL PROTECTED] That is useful, when calling the script like this: file - Rscript.R source(file) However, it does not work if we do this from the shell prompt: $ R --vanilla Rscript.R because the eval.parent statement attempts to access a base workspacethat does not contain the file object/variable, as above. Isthere a solution for this situation? Is the input script file anargument to R and therefore available in something like argv? On Mar 18, 2005 8:00 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: Darren Weber darrenleeweber at gmail.com writes: : : Hi, : : if we have a file called Rscript.R that contains the following, for example: : : x - 1:100 : outfile = Rscript.Rout : sink(outfile) : print(x) : : and then we run : : source(Rscript.R) : : we get an output file called Rscript.Rout - great! : : Is there an internal variable, something like .Platform, that holds : the script name when it is being executed? I would like to use that : variable to define the output file name. : In R 2.0.1 try putting this in a file and sourcing it. script.description - function() eval.parent(quote(file), n = 3) print(basename(script.description())) If you are using R 2.1.0 (devel) then use this instead: script.description - function() showConnections() [as.character(eval.parent(quote(file), n = 3)), description] print((basename(script.description( __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] newline in lattice axis label
Hi, I have a 3 panel xyplot with different variables in the y axis. I'm trying to insert a newline after Width (cm), in the ylab argument as in the example below. My goal is to have the y axis label broken into two lines, split after the string just mentioned. plotfun - function() { fakedf - data.frame(A = sample(1:100, 50), B = rnorm(50), C = rnorm(50), D = rnorm(50)) myplot - xyplot(B + C + D ~ A, data = fakedf, outer = TRUE, allow.multiple = TRUE, layout = c(1,3), ylab = list(expression(paste( VarB (cm ^2, ), VarC (cm),\n or VarD (cm, xlab = list(VarA (d))) postscript(testfig.eps) print(myplot) dev.off() } As you can see, this is not producing the desired result, which is probably associated with 3 warnings: Warning messages: 1: font metrics unknown for character 10 2: font metrics unknown for character 10 3: font metrics unknown for character 10 Any help defining the ylab argument in this case is greatly appreciated. Thanks in advance, -- Sebastian P. Luque __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] newline in lattice axis label
Sebastian Luque [EMAIL PROTECTED] wrote: I have a 3 panel xyplot with different variables in the y axis. I'm trying to insert a newline after Width (cm), Sorry, that should be VarC (cm), in the hypothetical example below! -- Sebastian P. Luque __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to do aggregate operations with non-scalar functions
On Tue, 5 Apr 2005, Gabor Grothendieck wrote: On Apr 5, 2005 6:59 PM, Itay Furman [EMAIL PROTECTED] wrote: Hi, I have a data set, the structure of which is something like this: a - rep(c(a, b), c(6,6)) x - rep(c(x, y, z), c(4,4,4)) df - data.frame(a=a, x=x, r=rnorm(12)) The true data set has 1 million rows. The factors a and x have about 70 levels each; combined together they subset 'df' into ~900 data frames. For each such subset I'd like to compute various statistics including quantiles, but I can't find an efficient way of [snip] I would like to end up with a data frame like this: a x 0%25% 1 a x -0.7727268 0.1693188 2 a y -0.3410671 0.1566322 3 b y -0.2914710 -0.2677410 4 b z -0.8502875 -0.6505710 [snip] One can use do.call(rbind, by(df, list(a = a, x = x), f)) where f is the appropriate function. In this case f can be described in terms of df.quantile which is like quantile except it returns a one row data frame: df.quantile - function(x,p) as.data.frame(t(data.matrix(quantile(x, p f - function(df, p = c(0.25, 0.5)) cbind(df[1,1:2], df.quantile(df[,r], p)) Thanks! Just what I wanted. A minor point is that for some reason the row numbers in the final data frame are not sequential (see below -- this is not a consequence of my changes). Actually, seeing your code I became greedy and decided to extract more summary statistics in one blow like this: df.summary - function(x, qtils=(0:4)/4) cbind(data.frame(mean=mean(x), var=var(x), length=length(x)), as.data.frame(t(data.matrix(quantile(x, qtils) f - function(x, qtils=(0:4)/4) cbind(x[1,1:2], df.summary(x[,r], qtils)) do.call(rbind, by(df, list(a = a, x = x), f)) a x mean var length 0%25%50% 1 a x 0.2901207 0.522191469 4 -0.7727268 0.1693188 0.5523356 5 a y 0.6543314 1.981636402 2 -0.3410671 0.1566322 0.6543314 7 b y -0.2440109 0.004504928 2 -0.2914710 -0.2677410 -0.2440109 9 b z 0.4523763 1.841469995 4 -0.8502875 -0.6505710 0.4717093 75% 100% 1 0.6731375 0.8285385 5 1.1520307 1.6497299 7 -0.2202808 -0.1965508 9 1.5746565 1.7163741 What remains a puzzle to me is why R has a native subsetting function that returns a scalar per subset [aggregate()], another one that returns a list [by()], but no function that is able to return a vector per subset. Is there a less demand to such operation (like extracting summary statistics in one blow)? Is it less general? Or technically more difficult to achieve? I'm just curious. Itay [EMAIL PROTECTED] / +1 (206) 543 9040 / U of Washington __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to do aggregate operations with non-scalar functions
On Wed, 6 Apr 2005, Rich FitzJohn wrote: [snip] ## This does the hard work of calculating the statistics over your ## combinations, and over the values in `p' y - lapply(p, function(y) tapply(df$r, list(a=a, x=x), quantile, probs=y)) Rich, thank you for your reply. Gabor G has proposed a different solution that seem to me to be easier to maintain and scale up. Please see my follow up to his reply. Your solution introduced to me some R functions I was not familiar with: expand.grid(), colSums(), and names(). Thanks for that, too. ## Then, we need to work out what combinations of a x are possible: ## these are the header columns. aggregate() does this in a much more ## complicated way, which may handle more difficult cases than this ## (e.g. if there are lots of missing values points, or something). vars - expand.grid(dimnames(y[[1]])) In Gabor G's solution this is magically done (I think!) by do.call(). Thanks, Itay [EMAIL PROTECTED] / +1 (206) 543 9040 / U of Washington __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] newline in lattice axis label
Sebastian Luque a écrit : Hi, I have a 3 panel xyplot with different variables in the y axis. I'm trying to insert a newline after Width (cm), in the ylab argument as in the example below. My goal is to have the y axis label broken into two lines, split after the string just mentioned. plotfun - function() { fakedf - data.frame(A = sample(1:100, 50), B = rnorm(50), C = rnorm(50), D = rnorm(50)) myplot - xyplot(B + C + D ~ A, data = fakedf, outer = TRUE, allow.multiple = TRUE, layout = c(1,3), ylab = list(expression(paste( VarB (cm ^2, ), VarC (cm),\n or VarD (cm, xlab = list(VarA (d))) postscript(testfig.eps) print(myplot) dev.off() } As you can see, this is not producing the desired result, which is probably associated with 3 warnings: Warning messages: 1: font metrics unknown for character 10 2: font metrics unknown for character 10 3: font metrics unknown for character 10 Any help defining the ylab argument in this case is greatly appreciated. Thanks in advance, library(lattice) plotfun - function() { fakedf - data.frame(A = sample(1:100, 50), B = rnorm(50), C = rnorm(50), D = rnorm(50)) myplot - xyplot(B + C + D ~ A, data = fakedf, outer = TRUE, allow.multiple = TRUE, layout = c(1,3), ylab = expression(atop(paste(VarB (, cm^2, ), VarC (cm)), VarD (cm))), xlab = VarA (d)) postscript(testfig.eps) print(myplot) dev.off() } plotfun() Best, Renaud -- Dr Renaud Lancelot, vétérinaire C/0 Ambassade de France - SCAC BP 834 Antananarivo 101 - Madagascar e-mail: [EMAIL PROTECTED] tel.: +261 32 40 165 53 (cell) +261 20 22 665 36 ext. 225 (work) +261 20 22 494 37 (home) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to do aggregate operations with non-scalar functions
On Wed, 6 Apr 2005 [EMAIL PROTECTED] wrote: Here is a method that I use in this situation. I work with the indices of the rows so that copies are not made and it is fast. Result - lapply(split(seq(nrow(df)), df$a), function(.a){ # partition on the first variable lapply(split(.a, df$z[.a]), function(.z){ # partition on the second variable -- notice the subsetting c(quantile(df$r[.z]), ...anything else you want to compute) }) }) Result - do.call('rbind', Result) # create a matrix - now you have your results Jim Jim, Thank you for your reply. For some reason, when I try your proposed solution I get: Error in sort(unique.default(x), na.last = TRUE) : `x' must be atomic Eventually, I used the solution proposed by Gabor G in this thread. One advantage of his solution is that it is easier to scale up I believe; for example in the case you have 3 factors that together subset the data frame. Regards, Itay [EMAIL PROTECTED] / +1 (206) 543 9040 / U of Washington __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] using command line flags with TINN-R
roger bos wrote: This is a TINN-R editor question rather than an R question, but can anyone tell me how to use command line flags with TINN-R. There is a space to fill in the path to Rgui, and I have C:\Program Files\R\rw2001pat\bin\Rgui.exe. If I try to add a command line flag after that, such as --no-save or --max-mem-size then TINN-R will not open the application. No that does not work, but you can consider working in the other way: starting Tinn-R while you start R. Then you have all the flexibility to define whatever command line argument you want for R. There are many ways to do so, but I personally use the following one: 1) I define: options(IDE = c:/program files/tinn-R/bin/tinn-R.exe) (of course, the path should reflect the place you actually installed Tinn-R!) and then, I start the svGUI package (from the SciViews bundle available on CRAN). library(svGUI) Tinn-R is started (if not already running), and also, the R call-tip server (live calculation of call-tips for the syntax of R functions) is activated behind the scene. If you are happy with this, and would like to start Tinn-R and activate the R call-tip server automatically everytime you start R, just add those two lines of code in your 'Rprofile' file (the general 'Rprofile' is in /etc subdirectory of the R directory). Once it is done, do not worry about starting Tinn-R, or R from within Tinn-R, just start R with all the command line options you like, and you get Tinn-R started automatically (if it is not running yet)! Note that this tip is in FAQ 3.8, in the new version of Tinn-R FAQ to be released soon, together with the latest stable Tinn-R 1.15.1.7 next week or so ;-) Best, Philippe ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( (Academie Universitaire Wallonie-Bruxelles ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( ( ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54 ( ( ( ( (email: [EMAIL PROTECTED] ) ) ) ) ) ( ( ( ( (web: http://www.umh.ac.be/~econum ) ) ) ) ) http://www.sciviews.org ( ( ( ( ( .. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html