Re: [R] vector-factor operation
G'day Murray, MJ == Murray Jorgensen [EMAIL PROTECTED] writes: MJ I found myself wanting to average a vector [vec] within each MJ level of a factor [Fac], returning a vector of the same length MJ as vec. I presume that the vector that you want as result should not just have the same length as vec, should it? :-) MJ But there must be another way to do this, and it would be good MJ to be able to apply other functions than mean() in this way. Something like: Fac - sample(gl(2,4)) Fac [1] 2 1 1 2 2 1 1 2 Levels: 1 2 vec - rnorm(length(Fac)) tapply(vec, Fac, mean) 1 2 -0.6435816 -0.9267021 tapply(vec, Fac, mean)[Fac] 2 1 1 2 2 1 1 -0.9267021 -0.6435816 -0.6435816 -0.9267021 -0.9267021 -0.6435816 -0.6435816 2 -0.9267021 tapply(vec, Fac, sum)[Fac] 2 1 1 2 2 1 1 2 -3.706808 -2.574326 -2.574326 -3.706808 -3.706808 -2.574326 -2.574326 -3.706808 Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Mathematics and Statistics+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: [EMAIL PROTECTED] Australiahttp://www.maths.uwa.edu.au/~berwin __ R-help@stat.math.ethz.ch 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] Guidance on step() with large dataset (750K) solicited...
On Thu, 13 Apr 2006, roger koenker wrote: Jeff, I don't know whether this is likely to be feasible, but if you could replace calls to lm() with calls to a sparse matrix version of lm() either slm() in SparseM or something similar in Matrix, then I would think that you should safe from memory problems. Adapting step might be more than you really bargained for though, I don't know the code It's a simple wrapper that has been used for many model-fitting classes. All you need is an extractAIC method. Roger 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 13, 2006, at 2:41 PM, Jeffrey Racine wrote: Hi. Background - I am working with a dataset involving around 750K observations, where many of the variables (8/11) are unordered factors. The typical model used to model this relationship in the literature has been a simple linear additive model, but this is rejected out of hand by the data. I was asked to model this via kernel methods, but first wanted to play with the parametric specification out of curiosity. I thought it would be interesting to see what type of model stepwise BIC would yield, and have been playing with the step() function (on R-beta due to the factor.scope() problem that has been fixed in the patched and beta version). I am running this on a 64bit box with 32GB of RAM and tons of swap, but am hitting the memory wall as occasionally memory needs grow to ungodly proportions (in the early iterations the program starts out around 8GB but quickly grows to 15GB, then grows from there). This is not due to my using the beta version, as this also arises under R-2.2.1 for what that is worth. My question is whether or not there is some simple way to substantially reduce the memory footprint for this procedure. I took a look at previous posts for step() and memory issues, but still wonder whether there might be a switch or possibly better way of constructing my model that would overcome the memory issues. I include the code below, and any comments or suggestions would be most welcome (besides `what type of idiot lets information criteria determine their model ;-)') Thanks ever so much in advance. -- Jeff Begin ## Read in the full data set (n=745466 observations) data - read.table(../data_header.dat,header=TRUE) ## Create a data frame with all categorical variables declared as ## unordered factors data - data.frame(logrprice=data$logrprice, cgt=factor(data$cgt), cag=factor(data$cag), gstann=factor(data$gstann), fhogann=factor(data$fhogann), gstfhog=factor(data$gstfhog), luc=factor(data$luc), municipality=factor(data$municipality), time=factor(data$time), distance=data$distance, logr=data$logr, loginc=data$loginc) ## Estimate a simple linear model (used repeatedly in the literature, ## fails the most simple of model specification tests e.g., ## resettest()) model.linear - lm(logrprice~.,data=data) ## Now conduct stepwise (BIC) regression using the step() function in ## the stats library. The lower model is the unconditional mean of y, ## the upper having polynomials of up to order 6 in the three ## continuous covariates, with interaction among all variables of ## order 2. n - nrow(data) model.bic - step(model.linear, scope=list( lower=~ 1, upper=~ (. +I(logr^2) +I(logr^3) +I(logr^4) +I(logr^5) +I(logr^6) +I(distance^2) +I(distance^3) +I(distance^4) +I(distance^5) +I(distance^6) +I(loginc^2) +I(loginc^3) +I(loginc^4) +I(loginc^5) +I(loginc^6)) ^2), trace=TRUE, k=log(n) ) summary(model.bic) End -- Professor J. S. Racine Phone: (905) 525 9140 x 23825 Department of EconomicsFAX:(905) 521-8232 McMaster Universitye-mail: [EMAIL PROTECTED] 1280 Main St. W.,Hamilton, URL: http://www.economics.mcmaster.ca/racine/ Ontario, Canada. L8S 4M4 `The generation of random numbers is too important to be left to chance.' __
Re: [R] another memory size question
On Fri, 14 Apr 2006, Alexander Nervedi wrote: Hi. I am having trouble figuring this out. Please help if you know what I am goffing up on. rm(list=ls(all=TRUE)) dat-expand.grid(village.code = c(1,2,3), household.id = 1:99, member.id = 1:41, year.code = 75:85, DOI = 1:366) Error: cannot allocate vector of size 191502 Kb memory.limit() [1] 3145728000 Shouldn't I have ample memory to greate this gigantic grid? No. It has 3*99*41*11*366 = 50m rows, and 5 columns needing 24 bytes per row (1 double plus 4 integer cols, I believe), plus rowmanes. Now normally rownames are a character vector, and a character vector of that size needs over 2Gb of storage (on a 32-bit machine), but expand.grid `cheats' (actually, it is a bug) by using integer rownames and hence you would have 28 bytes per row, 1.4GB in total. You do have enough memory to store that, but not enough address space. BTW, you seem to be on Windows (but failed to mention it): please consult the rw-FAQ as the memory limit is not necessarily the limiting factor here (the address space is probably 2GB). mucho gracias el signors and signioritas, Alnerdy -- 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] Vector
Hi On 13 Apr 2006 at 19:33, Gabor Csardi wrote: Date sent: Thu, 13 Apr 2006 19:33:30 -0400 From: Gabor Csardi [EMAIL PROTECTED] To: Barbora Kocúrová [EMAIL PROTECTED] Copies to: r-help@stat.math.ethz.ch Subject:Re: [R] Vector Let n=20 and k=10. v - 1:20 v[-10] [1] 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 This is what you want? Gabor or maybe this? v - runif(20)*50 n - length(v) vn [1] FALSE FALSE TRUE TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE v[vn] [1] 19.999718 16.267608 10.134613 6.084596 12.274426 7.165219 11.981471 2.946719 v[!vn] [1] 21.73297 35.62573 37.85436 35.55606 32.11441 43.81346 38.94573 39.86544 22.76372 20.50420 40.54351 30.24666 HTH Petr On Fri, Apr 14, 2006 at 01:24:59AM +0200, Barbora KocĂşrová wrote: Hello. I have a vector which length is n. And I would need to put off the item of the vector with index k which is less then n. Could you please advise me? Thanks Barbora K. hry.atlas.cz - SvÄtovÄ proslulá karetnĂ hra Poker Texas Hold´em online __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ R-help@stat.math.ethz.ch 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] another very simple loop question
Hi What about some example data? I presume you could use some apply, tapply, aggregate or similar function but without knowing what you **really** want to do and how your previous attempts failed it is hard to give any definite answer. e.g. mydf-data.frame(year=sample(1:4,100,rep=T), student=sample(letters[1:4],100, rep=T), result=runif(100)) aggregate(mydf$result,list(year=mydf$year,student=mydf$student), mean) year student x 1 1 a 0.4026579 2 2 a 0.4690311 ... 153 d 0.5316301 164 d 0.4401949 HTH Petr On 14 Apr 2006 at 0:09, Brian Quinif wrote: Date sent: Fri, 14 Apr 2006 00:09:32 -0400 From: Brian Quinif [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] another very simple loop question I have a dataset with 4 years of students, and normally I want to estimate things using each individual year, so I have a for loop as follows for (i in 1:4){} However, the only way I know how to calculate estimates using all four years of data is to put the estimations outside of the loop. Is there anyway to make a for loop that uses all four years at once, then uses each individual year? Thanks, BQ __ R-help@stat.math.ethz.ch 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] vector-factor operation
Hi vec-runif(100) fac-factor(sample(letters[1:4],100, rep=T)) tap-tapply(vec, fac, mean) new.vec-tap[fac] lm1 - lm(vec ~ fac) all.equal(as.numeric(predict(lm1)),as.numeric(new.vec)) [1] TRUE HTH Petr On 14 Apr 2006 at 17:46, Murray Jorgensen wrote: Date sent: Fri, 14 Apr 2006 17:46:12 +1200 From: Murray Jorgensen [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] vector-factor operation I found myself wanting to average a vector [vec] within each level of a factor [Fac], returning a vector of the same length as vec. After a while I realised that lm1 - lm(vec ~ Fac) fitted(lm1) did what I want. But there must be another way to do this, and it would be good to be able to apply other functions than mean() in this way. Cheers, Murray -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch 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] Plotting positions in qqnorm?
On Thu, 13 Apr 2006, Spencer Graves wrote: Do you know of a reference that discusses alternative choices for plotting positions for a normal probability plot? The documentation for qqnorm says it calls ppoints, which returns qnorm((1:m-a)/(m+1-2*a)) with a = ifelse(n=10, 3/8, 1/2)? The help pages for qqnorm and ppoints just refer to Becker, Chambers and Wilks (1988) The New S Language (Wadsworth Brooks/Cole), and I couldn't find any discussion of this. I seem to recall that this was discussed in 1960 or earlier in a paper by Anscombe, but I can't find a reference and I wonder if someone might suggest something else. I've been asked to comment on specialized software that allows the user to select a = +/-0.5, 0, 0.3, and 0.3175 (but not 0.375 = 3/8, curiously). I'd also be interested in any examples of real data sets where the choice of a actually made a difference. When I've had so few data points that the choice for a might make a difference, a normal probability plot was not very informative, anyway, and I get more information from a simple dot plot. If your experience is different, I'd like to know. Thanks, Spencer Graves I suspect that what you are looking for is this paper: Hyndman, Rob J. and Fan, Yanan (1996) Sample quantiles in statistical packages The American Statistician, 50, 361-365 which discusses different definitions of sample quantiles. See also the documentation for quantile. David Scott _ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 AucklandNEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: [EMAIL PROTECTED] Graduate Officer, Department of Statistics ASC/NZSA 2006: Statistical Connections The joint conference of the Statistical Society of Australia Inc. and the New Zealand Statistical Association, July 3--6, 2006 in Auckland. Go to: http://www.statsnz2006.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] Getting SVM minimized function value
Hello, I have been searching a way to get the resulting optimized function value of a trained SVM model (svm from the package e1071) but I have not succeed. Does anyone knows a way to get that value? Pau __ R-help@stat.math.ethz.ch 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] vector-factor operation
Look at ?ave ave(vec, Fac) ave(vec, Fac, FUN = mean) # same ave(vec, Fac, FUN = sd) On 4/14/06, Murray Jorgensen [EMAIL PROTECTED] wrote: I found myself wanting to average a vector [vec] within each level of a factor [Fac], returning a vector of the same length as vec. After a while I realised that lm1 - lm(vec ~ Fac) fitted(lm1) did what I want. But there must be another way to do this, and it would be good to be able to apply other functions than mean() in this way. Cheers, Murray -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: [EMAIL PROTECTED]Fax 7 838 4155 Phone +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862 __ R-help@stat.math.ethz.ch 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] Plotting positions in qqnorm?
On Fri, 14 Apr 2006, David Scott wrote: On Thu, 13 Apr 2006, Spencer Graves wrote: Do you know of a reference that discusses alternative choices for plotting positions for a normal probability plot? The documentation for qqnorm says it calls ppoints, which returns qnorm((1:m-a)/(m+1-2*a)) with a = ifelse(n=10, 3/8, 1/2)? The help pages for qqnorm and ppoints just refer to Becker, Chambers and Wilks (1988) The New S Language (Wadsworth Brooks/Cole), and I couldn't find any discussion of this. It's there, on the printed help page for ppoints. I seem to recall that this was discussed in 1960 or earlier in a paper by Anscombe, but I can't find a reference and I wonder if someone might suggest something else. I've been asked to comment on specialized software that allows the user to select a = +/-0.5, 0, 0.3, and 0.3175 (but not 0.375 = 3/8, curiously). I'd also be interested in any examples of real data sets where the choice of a actually made a difference. When I've had so few data points that the choice for a might make a difference, a normal probability plot was not very informative, anyway, and I get more information from a simple dot plot. If your experience is different, I'd like to know. Thanks, Spencer Graves I suspect that what you are looking for is this paper: Hyndman, Rob J. and Fan, Yanan (1996) Sample quantiles in statistical packages The American Statistician, 50, 361-365 which discusses different definitions of sample quantiles. See also the documentation for quantile. The adjustment is for the population and not the sample quantiles. But the article is in a small part relevant as it discusses definitions of QQ plots, and refers to the work of Blom (see below). The usual reason given is that 1-sample QQ plots should be against not the population quantiles but against the expected order statistics of a sample of size n from the population. That's where the adjustment comes from, and is related to the type 9 in ?quantile (although that I think needs to say what they are supposed to be unbiased estimators of). Unfortunately the CVS data is no longer available for package stats prior to its split from base. But see the thread starting http://www.r-project.org/nocvs/mail/r-devel/1998/0587.html which is unfortunately typical of the misrepresentation that is far too prevalent here: MASS2 says what the values _were_ in S, not what they should be. This is a Blue Book function, and that contains a reference to G. Blom (1958) Statistical Estimates and Transformed Beta Variables. Wiley. That's not readily available to me (it is in the library stacks), but maybe someone interested would like to look it up to expand on the brief mention in Hyndman Fan. Incidentally, S-PLUS (= 6.2) differs from S and uses a=1/2. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] suse 10.0
I downloaded the free CD's and installed Suse 10.0. When I tried to install the latest RPM for R, the Yast installer complained that two files were missing. I was told that I can install from the internet, and started the process, but found I must supply the name of the server and the name of the directory. I tried several combinations unsuccessfully. Can anyone help me? __ R-help@stat.math.ethz.ch 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] Dotplot x-axis
Here's a small dataset: type - c('hierarchical','partial','single','complete','single +hierarchical','single+partial','partial+hierarchical','single+partial +hierarchical') freq - c(1455,729,688,65,29,28,16,17) lodds - log(freq/(3027 - freq)) dotplot(type~lodds) I would like to have the x-axis have ticks at nice, close to equally- spaced values, of the proportions rather than at round log-odds values, which appear as -5:0. For example: perhaps have ticks at c (0.007, 0.02, 0.05, 0.12, 0.27, 0.5), which are approximate values of exp(-5:0)/(1+exp(-5:0)) Advice? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Penalized Splines as BLUPs using lmer?
Me, opaque (it is rare that I say too little). Well, your assumption below is correct. This structure assumes a general covariance matrix for the random effects. As for the documentation, it is rather sparse at this time. There are really two places to look. One would be the vignette in the mlmRev package vignette(MlmSoftRev) and the other would be the article below: @Article{Rnews:Bates:2005, author = {Douglas Bates}, title= {Fitting Linear Mixed Models in {R}}, journal = {R News}, year = 2005, volume = 5, number = 1, pages= {27--30}, month= {May}, url = {http://CRAN.R-project.org/doc/Rnews/}, } Harold -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joran Elias Sent: Thursday, April 13, 2006 7:03 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] Penalized Splines as BLUPs using lmer? I've been wondering the same thing (how to specify restricted covariance structures with lmer()), and this response seemed a little opaque to me, so I was wondering if anyone could clarify. 1.) Is there currently any documentation for lmer() that explains how the model formula in lmer() specifies the cov structure of the random effects, as inquired about below? Am I correct in thinking that lmer(response ~ time +(time|id),data) would result in assuming an unconstrained cov matrix for the random effects? 2.) When lmer() is finished (thank you, by the way!), will we be able to specify the cov structure of the random effects similarly to what was done in lme(), i.e. using pdMat objects and so forth? Thanks! joran On Apr 13, 2006, at 3:34 PM, Doran, Harold wrote: I think you want the random effects to be independent. If so then you need lmer(response ~ time +(time|id) + (time-1|id), data) Harold -Original Message- From: [EMAIL PROTECTED] on behalf of Matthias Kormaksson Sent: Thu 4/13/2006 4:04 PM To: r-help@stat.math.ethz.ch Cc: Subject: [R] Penalized Splines as BLUPs using lmer? Dear R-list, I´m trying to use the lmer of the lme4 package to fit a linear mixed model of the form Y = Xb + Zu + e and I can´t figure out how to control the covariance structure of u. I want u ~ N(0,sigma^2*I). More precisely I´m trying to smooth a curve through data using the Penalized Splines as BLUPs method as described in Ruppert, Wand Carroll (2003). So I have Z = [Z1 Z2 ... Z11] where Z1,...,Z11 is a linear spline basis and X = [1 t] where t is time column in my case. I have tried various things and read a lot of the online literature but I can´t seem to find anything useful. I know the old way of fitting this using lme is: fit - lme(y~-1+X,random=pdIdent(~-1+Z)) and then extracting the u vector with u.hat - unlist(fit$coef$random) Is there anyone who could possibly help me and provide me with a code using the lmer? Is it possible to fit this using lmer without specifying the Z and the X matrix and instead just use the columns t and Z1, Z2, ..., Z11? Thanks in advance, Matthias Matthias Kormaksson, Ph.D Student, Department of Statistics, Cornell University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting- guide.html [[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
Re: [R] Dotplot x-axis
maybe something like: dotplot(type ~ lodds, scales = list(x = list(at = -5:0, labels = round(plogis(-5:0), 3 could do the trick; I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Michael Kubovy [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, April 14, 2006 3:29 PM Subject: [R] Dotplot x-axis Here's a small dataset: type - c('hierarchical','partial','single','complete','single +hierarchical','single+partial','partial+hierarchical','single+partial +hierarchical') freq - c(1455,729,688,65,29,28,16,17) lodds - log(freq/(3027 - freq)) dotplot(type~lodds) I would like to have the x-axis have ticks at nice, close to equally- spaced values, of the proportions rather than at round log-odds values, which appear as -5:0. For example: perhaps have ticks at c (0.007, 0.02, 0.05, 0.12, 0.27, 0.5), which are approximate values of exp(-5:0)/(1+exp(-5:0)) Advice? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R: Dotplot x-axis
Take a look at the scales argument in dotpolot. Maybe you need something like: position-exp(-5:0)/(1+exp(-5:0)) dotplot(type~freq/(3027-freq), scales=list(x=list(log=T, at=position, lab=round(position, 3))) ) Stefano -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] conto di Michael Kubovy Inviato: 14 April 2006 15:29 A: r-help@stat.math.ethz.ch Oggetto: [R] Dotplot x-axis Here's a small dataset: type - c('hierarchical','partial','single','complete','single +hierarchical','single+partial','partial+hierarchical','sing le+partial +hierarchical') freq - c(1455,729,688,65,29,28,16,17) lodds - log(freq/(3027 - freq)) dotplot(type~lodds) I would like to have the x-axis have ticks at nice, close to equally- spaced values, of the proportions rather than at round log-odds values, which appear as -5:0. For example: perhaps have ticks at c (0.007, 0.02, 0.05, 0.12, 0.27, 0.5), which are approximate values of exp(-5:0)/(1+exp(-5:0)) Advice? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] suse 10.0
louis homer [EMAIL PROTECTED] writes: I downloaded the free CD's and installed Suse 10.0. When I tried to install the latest RPM for R, the Yast installer complained that two files were missing. I was told that I can install from the internet, and started the process, but found I must supply the name of the server and the name of the directory. I tried several combinations unsuccessfully. Can anyone help me? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Have you looked here: http://lib.stat.cmu.edu/R/CRAN/bin/linux/suse/10.0/RPMS/i586/ I'm sure you can add it to your yast. But I'm not running suse so I can't tell exactly. -- Leon __ R-help@stat.math.ethz.ch 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] The object argument of NextMethod.
My question is when the object argument of NexthMethod be used? In the following example, weather object argument is used will not affects the result. ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) { x=x+1;class(x)-ncls NextMethod() } foo.ncls=function(x) { cat(ncls\n) } foo.cls2=function(x) { cat(cls2\n);print(x) } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1;class(x)-ncls + NextMethod(,x) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls Thank you very much. -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The object argument of NextMethod.
In section 5.5 of the language manual it says: It is important to realize that the choice of the next method depends on the current values of .Generic and .Class and not on the object. So changing the object in a call to NextMethod affects the arguments received by the next method but does not affect the choice of the next method. I think this needs to be put into ?NextMethod too since the current wording in ?NextMethod appears to contract the language manual: object: an object whose class will determine the method to be dispatched. Defaults to the first argument of the enclosing function. At any rate, try using .Class to direct it to the appropriate method like this: foo - function(x) UseMethod(foo) foo.cls1 - function(x) { x - x+1; .Class - class(x) - ncls; NextMethod() } foo.ncls - function(x) cat(ncls\n) foo.cls2=function(x) { cat(cls2\n); print(x) } a - 1; class(a) - c(cls1,cls2) foo(a) ncls On 4/14/06, ronggui [EMAIL PROTECTED] wrote: My question is when the object argument of NexthMethod be used? In the following example, weather object argument is used will not affects the result. ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) { x=x+1;class(x)-ncls NextMethod() } foo.ncls=function(x) { cat(ncls\n) } foo.cls2=function(x) { cat(cls2\n);print(x) } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1;class(x)-ncls + NextMethod(,x) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls Thank you very much. -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] Dotplot x-axis
I asked: Here's a small dataset: type - c('hierarchical','partial','single','complete','single +hierarchical','single+partial','partial+hierarchical','single +partial +hierarchical') freq - c(1455,729,688,65,29,28,16,17) lodds - log(freq/(3027 - freq)) dotplot(type~lodds) I would like to have the x-axis have ticks at nice, close to equally- spaced values, of the proportions rather than at round log-odds values, which appear as -5:0. For example: perhaps have ticks at c (0.007, 0.02, 0.05, 0.12, 0.27, 0.5), which are approximate values of exp(-5:0)/(1+exp(-5:0)) Advice? Dimitris Rizopoulos suggested: dotplot(type ~ lodds, scales = list(x = list(at = -5:0, labels = round(plogis(-5:0), 3 It works like a charm. Thank you so much. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] vector-factor operation
On Fri, 14 Apr 2006, Murray Jorgensen wrote: I found myself wanting to average a vector [vec] within each level of a factor [Fac], returning a vector of the same length as vec. After a while I realised that lm1 - lm(vec ~ Fac) fitted(lm1) did what I want. But there must be another way to do this, and it would be good to be able to apply other functions than mean() in this way. ave(vec,Fac) and, yes, it can take a different function as an argument. -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] The object argument of NextMethod.
在 06-4-14,Gabor Grothendieck[EMAIL PROTECTED] 写道: In section 5.5 of the language manual it says: It is important to realize that the choice of the next method depends on the current values of .Generic and .Class and not on the object. So changing the object in a call to NextMethod affects the arguments received by the next method but does not affect the choice of the next method. Can anyone give an example to demostrated affects the arguments received by the next method?In my example NextMethod(foo) and NextMethod(foo,x) give the same result too. foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1 + NextMethod(foo) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] cls1 cls2 foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1 + NextMethod(foo,x) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] cls1 cls2 I think this needs to be put into ?NextMethod too since the current wording in ?NextMethod appears to contract the language manual: object: an object whose class will determine the method to be dispatched. Defaults to the first argument of the enclosing function. At any rate, try using .Class to direct it to the appropriate method like this: foo - function(x) UseMethod(foo) foo.cls1 - function(x) { x - x+1; .Class - class(x) - ncls; NextMethod() } foo.ncls - function(x) cat(ncls\n) foo.cls2=function(x) { cat(cls2\n); print(x) } a - 1; class(a) - c(cls1,cls2) foo(a) ncls On 4/14/06, ronggui [EMAIL PROTECTED] wrote: My question is when the object argument of NexthMethod be used? In the following example, weather object argument is used will not affects the result. ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) { x=x+1;class(x)-ncls NextMethod() } foo.ncls=function(x) { cat(ncls\n) } foo.cls2=function(x) { cat(cls2\n);print(x) } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1;class(x)-ncls + NextMethod(,x) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls Thank you very much. -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R: On using gam(gam).
Dear R users, I am using R-function gam(gam) to fit additive models, more specifically partially linear models. Say, Y~x1+x2+s(z,df=d). Is there a way to extract the smoother matrix for the smoothing term z, or is there a way to extract the overall hat matrix H such that Y_hat=HY. Thank you in advance! Sincerely, Song Song Liu School of Statistics 313 FordH 224 Church St. SE Minneapolis,MN 55455 __ R-help@stat.math.ethz.ch 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 count the columns of a data.frame
Hi, I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. Can someone tell me how to do it? My best regards, Giacomo Moro - [[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] editor for Ubuntu
camille wrote: I am new on Ubuntu. I would like to use R, but I tried Kate and Scite. The first one keeps trying to use KDE applications,while the other does not understand the language. I have searched for another editor for hours, in vain. Which editor should work with Ubuntu? I use emacs (which is a general purpose editor and much more) and ess (Emacs statistics mode, supporting R,S and others). To install ess in ubuntu do $ sudo apt-get install ess There's a bit of a learning curve to emacs, but it's a good tool, especially if you are writing documents in LaTex too. -- Ramón Casero Cañas http://www.robots.ox.ac.uk/~rcasero/wiki http://www.robots.ox.ac.uk/~rcasero/blog __ R-help@stat.math.ethz.ch 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 count the columns of a data.frame
giacomo moro wrote: I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. Can someone tell me how to do it? ncol(data.frame) -- Ramón Casero Cañas http://www.robots.ox.ac.uk/~rcasero/wiki http://www.robots.ox.ac.uk/~rcasero/blog __ R-help@stat.math.ethz.ch 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 count the columns of a data.frame
da-data.frame(x=rnorm(10),y=rnorm(10)) ncol(da) [1] 2 or dim(da)[2] [1] 2 2006/4/15, giacomo moro [EMAIL PROTECTED]: Hi, I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. Can someone tell me how to do it? My best regards, Giacomo Moro - [[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 -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to count the columns of a data.frame
?ncol ncol(data.frame(x=-1, y=0, z=1)) [1] 3 giacomo moro wrote: Hi, I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. Can someone tell me how to do it? My best regards, Giacomo Moro - [[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 -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch 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 count the columns of a data.frame
Hi, I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. ... If you knew how to count the rows, you would have known about nrow which has the same man page as ncol. Also help.search('number of rows') would have immediately given you your answers. So please do your homework before posting in future by using R's extensive built-in documentation. -- Bert Gunter __ R-help@stat.math.ethz.ch 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] editor for Ubuntu
Or you can try JGR, http://stats.math.uni-augsburg.de/JGR/. A nice unified Graphical User Interface for R with integrated editor. à bientôt...Rod. On 13/04/06, camille [EMAIL PROTECTED] wrote: Hello, I am new on Ubuntu. I would like to use R, but I tried Kate and Scite. The first one keeps trying to use KDE applications,while the other does not understand the language. I have searched for another editor for hours, in vain. Which editor should work with Ubuntu? I am looking forward to your answer, thanks, Camille __ R-help@stat.math.ethz.ch 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] The object argument of NextMethod.
On Fri, 14 Apr 2006, ronggui wrote: My question is when the object argument of NexthMethod be used? Looking at the C code, I don't think it is. But look at do_nextmethod in src/main/objects.c yourself. Note that in your examples it would not make any difference as 'x' is re-evaluated in the current frame, and so passing it explicitly will find the same value. As far as I can tell, in NextMethod(generic, object, ...), 'generic' is only used if not invoked via a generic, and only named arguments in ... are used, to replace or append to the argument list of the current method. This is an area where R-lang is only a draft, and the definitive documentation is the C code. The lack of precision seems not to be doing anyone much harm, as it is normally inadvisable to use NextMethod if you want to do anything convoluted (especially if you want it to work in both S and R). In the following example, weather object argument is used will not affects the result. ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) { x=x+1;class(x)-ncls NextMethod() } foo.ncls=function(x) { cat(ncls\n) } foo.cls2=function(x) { cat(cls2\n);print(x) } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls ### foo=function(x) {UseMethod(foo)} foo.cls1=function(x) + { + x=x+1;class(x)-ncls + NextMethod(,x) + } foo.ncls=function(x) + { + cat(ncls\n) + } foo.cls2=function(x) + { + cat(cls2\n);print(x) + } a=1;class(a)=c(cls1,cls2) foo(a) cls2 [1] 2 attr(,class) [1] ncls Thank you very much. -- »ÆÈÙ¹ó Deparment of Sociology Fudan University -- 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] how to count the columns of a data.frame
That was not a very helpful reply to someone who asked a question. He could be counting the rows by asking for the length of a full variable in that data frame, and not be aware of nrow(x). And one could know about nrow() without knowing about its page in the manual.. There is no need to jump all over someone who asks a question--some people are just starting out. On 4/14/06 11:16 AM, Berton Gunter [EMAIL PROTECTED] wrote: Hi, I would like to count the columns of a data.frame. I know how to count the rows, but not the columns. ... If you knew how to count the rows, you would have known about nrow which has the same man page as ncol. Also help.search('number of rows') would have immediately given you your answers. So please do your homework before posting in future by using R's extensive built-in documentation. -- Bert Gunter __ R-help@stat.math.ethz.ch 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] Adding values to top of bars in barchart
Given the following data frame (freq.sp), str(freq.sp) `data.frame': 42 obs. of 4 variables: $ behav : Factor w/ 6 levels approach,bowride,..: 1 1 1 1 1 1 1 2 2 2 ... $ species: Factor w/ 7 levels COAST_SPOT,EAST_SPINR,..: 1 2 3 4 5 6 7 1 2 3 ... $ n : int 193 194 563 357 570 369 74 194 208 633 ... $ pct: num 0.725 0.340 0.252 0.381 0.072 ... I create a trellis barchart with the following command, barchart(pct ~ behav | species, data=freq.sp, as.table=TRUE, xlab=Behavior, ylab=Frequency, ylim=c(0,1), main=Frequencies of Behaviors, scales=list(x=list(rot=45))) In this graph, I would like to include the sample sizes (the value of freq.sp$n corresponding to each freq.sp$pct) at the top of each bar. I don't see a specific command in barchart that will allow me to do this and am fairly new to lattice graphics. I've done RSiteSearches on keywords that I could think of, but didn't run across anything I recognized as useful. Any pointers on how to accomplish this would be greatly appreciated. Thanks in advance. Cheers, eric -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] Lighthouses are more helpful than churches. - Benjamin Franklin Cogita tute - Think for yourself __ R-help@stat.math.ethz.ch 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 object argument of NextMethod.
On 4/14/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Fri, 14 Apr 2006, ronggui wrote: My question is when the object argument of NexthMethod be used? Looking at the C code, I don't think it is. But look at do_nextmethod in src/main/objects.c yourself. Note that in your examples it would not make any difference as 'x' is re-evaluated in the current frame, and so passing it explicitly will find the same value. As far as I can tell, in NextMethod(generic, object, ...), 'generic' is only used if not invoked via a generic, and only named arguments in ... are used, to replace or append to the argument list of the current method. This is an area where R-lang is only a draft, and the definitive documentation is the C code. The lack of precision seems not to be doing anyone much harm, I spent a lot of time fighting with NextMethod in writing the dyn package so its definitely doing significant harm in terms of time spent in development since it does not work as documented. __ R-help@stat.math.ethz.ch 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] Adding values to top of bars in barchart
On 4/14/06, Eric Archer [EMAIL PROTECTED] wrote: Given the following data frame (freq.sp), str(freq.sp) `data.frame': 42 obs. of 4 variables: $ behav : Factor w/ 6 levels approach,bowride,..: 1 1 1 1 1 1 1 2 2 2 ... $ species: Factor w/ 7 levels COAST_SPOT,EAST_SPINR,..: 1 2 3 4 5 6 7 1 2 3 ... $ n : int 193 194 563 357 570 369 74 194 208 633 ... $ pct: num 0.725 0.340 0.252 0.381 0.072 ... I create a trellis barchart with the following command, barchart(pct ~ behav | species, data=freq.sp, as.table=TRUE, xlab=Behavior, ylab=Frequency, ylim=c(0,1), main=Frequencies of Behaviors, scales=list(x=list(rot=45))) In this graph, I would like to include the sample sizes (the value of freq.sp$n corresponding to each freq.sp$pct) at the top of each bar. I don't see a specific command in barchart that will allow me to do this and am fairly new to lattice graphics. I've done RSiteSearches on keywords that I could think of, but didn't run across anything I recognized as useful. Any pointers on how to accomplish this would be greatly appreciated. Thanks in advance. Here's an example using the barley data. For more flexible placement of the text, use grid.text from the grid package directly (instead of panel.text): library(lattice) barchart(I(yield / sum(yield)) ~ variety | site, barley, subset = (year == 1931), scales = list(x = list(rot = 45)), label = round(barley$yield), panel = function(x, y, label, subscripts, ...) { lab - label[subscripts] panel.barchart(x, y, ..., subscripts = subscripts) panel.text(x = x, y = y + 0.001, lab = lab, cex = 0.5) }) Deepayan -- http://www.stat.wisc.edu/~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] Questions on formula in princomp
Gabor Grothendieck [EMAIL PROTECTED] wrote: Sasha Pustota [EMAIL PROTECTED] wrote: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) I'm trying to understand the meaning of expressions like ~ a+b+c+d, used with princomp, e.g. princomp(~ a+b+c+d, data=lir, cor=T) By inspection, it looks like the result is the same as in princomp(lir, cor = T). Yes, princomp.formula just takes the model matrix of the formula and passes it to princomp.default. Thanks. A further question. If I set some values to NA, a call princomp(~., data=mir, cor=T, na.action=na.omit)$scores indicates there have been predicted values imputed in place of NA. The documentation says 'napredict' is used but I can't find details. My guess is that these are predicted from linear multiple regression of other columns on NAs. However, what method is used exactly, in the case of princomp? (and how do I find out these things?) __ R-help@stat.math.ethz.ch 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] Questions on formula in princomp
Just use model.frame to examine what is passed: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) lir[1,1] - NA mf - model.frame(~., lir,na.action=na.omit) head(mf) ab c d 2 1.589235 1.098612 0.3364722 -1.6094379 3 1.547563 1.163151 0.2623643 -1.6094379 4 1.526056 1.131402 0.4054651 -1.6094379 5 1.609438 1.280934 0.3364722 -1.6094379 6 1.686399 1.360977 0.5306283 -0.9162907 7 1.526056 1.223775 0.3364722 -1.2039728 head(lir) ab c d 1 NA 1.252763 0.3364722 -1.6094379 2 1.589235 1.098612 0.3364722 -1.6094379 3 1.547563 1.163151 0.2623643 -1.6094379 4 1.526056 1.131402 0.4054651 -1.6094379 5 1.609438 1.280934 0.3364722 -1.6094379 6 1.686399 1.360977 0.5306283 -0.9162907 On 4/14/06, Sasha Pustota [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] wrote: Sasha Pustota [EMAIL PROTECTED] wrote: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) I'm trying to understand the meaning of expressions like ~ a+b+c+d, used with princomp, e.g. princomp(~ a+b+c+d, data=lir, cor=T) By inspection, it looks like the result is the same as in princomp(lir, cor = T). Yes, princomp.formula just takes the model matrix of the formula and passes it to princomp.default. Thanks. A further question. If I set some values to NA, a call princomp(~., data=mir, cor=T, na.action=na.omit)$scores indicates there have been predicted values imputed in place of NA. The documentation says 'napredict' is used but I can't find details. My guess is that these are predicted from linear multiple regression of other columns on NAs. However, what method is used exactly, in the case of princomp? (and how do I find out these things?) __ R-help@stat.math.ethz.ch 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] Adding values to top of bars in barchart
Deepayan, Thanks much! That works perfectly! Cheers, eric Deepayan Sarkar wrote: On 4/14/06, Eric Archer [EMAIL PROTECTED] wrote: Given the following data frame (freq.sp), str(freq.sp) `data.frame': 42 obs. of 4 variables: $ behav : Factor w/ 6 levels approach,bowride,..: 1 1 1 1 1 1 1 2 2 2 ... $ species: Factor w/ 7 levels COAST_SPOT,EAST_SPINR,..: 1 2 3 4 5 6 7 1 2 3 ... $ n : int 193 194 563 357 570 369 74 194 208 633 ... $ pct: num 0.725 0.340 0.252 0.381 0.072 ... I create a trellis barchart with the following command, barchart(pct ~ behav | species, data=freq.sp, as.table=TRUE, xlab=Behavior, ylab=Frequency, ylim=c(0,1), main=Frequencies of Behaviors, scales=list(x=list(rot=45))) In this graph, I would like to include the sample sizes (the value of freq.sp$n corresponding to each freq.sp$pct) at the top of each bar. I don't see a specific command in barchart that will allow me to do this and am fairly new to lattice graphics. I've done RSiteSearches on keywords that I could think of, but didn't run across anything I recognized as useful. Any pointers on how to accomplish this would be greatly appreciated. Thanks in advance. Here's an example using the barley data. For more flexible placement of the text, use grid.text from the grid package directly (instead of panel.text): library(lattice) barchart(I(yield / sum(yield)) ~ variety | site, barley, subset = (year == 1931), scales = list(x = list(rot = 45)), label = round(barley$yield), panel = function(x, y, label, subscripts, ...) { lab - label[subscripts] panel.barchart(x, y, ..., subscripts = subscripts) panel.text(x = x, y = y + 0.001, lab = lab, cex = 0.5) }) Deepayan -- http://www.stat.wisc.edu/~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 -- Eric Archer, Ph.D. NOAA-SWFSC 8604 La Jolla Shores Dr. La Jolla, CA 92037 858-546-7121,7003(FAX) [EMAIL PROTECTED] Lighthouses are more helpful than churches. - Benjamin Franklin Cogita tute - Think for yourself __ R-help@stat.math.ethz.ch 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] Random specification in LMER
(see inline) Arnaud Ghilain wrote: Hello, Can anybody help me understand the difference between the three different codes in specifying the slope in the random part of a mixed model using LMER? Here are the codes: (age | id) (1 + age | id) SG: These to are the same: For each level of id, both estimate random deviations for intercept and slope for age plus a covariance matrix for these two random parameters. (age - 1 | id) SG: For each level of id, this estimates only a random deviation for slope for age plus a variance for that random slope. SG: (1|id)+(age-1|id): For each level of id, this estimates a random deviation for both intercept and slope for age plus a variance for each term assuming their covariance is 0. SG: See Douglas Bates (2005) Fitting linear mixed models in R, R News, 5(1):27-30 (www.r-project.org - Documentation: Newsletter). Also, if you haven't already done this, you might want to review the vignette in library(MlmRev). hope this helps. spencer graves Thank you in advance Arnaud __ R-help@stat.math.ethz.ch 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] Questions on formula in princomp
Ok, that was just my wishful thinking. Is there a way to plot repeated labels that identify groups, e.g. factor(c(rep(s,50),rep(c,50),rep(v,50))) instead of 1--150 row indices, using something like biplot(princomp(lir)) ? Gabor Grothendieck [EMAIL PROTECTED] wrote: Just use model.frame to examine what is passed: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) lir[1,1] - NA mf - model.frame(~., lir,na.action=na.omit) head(mf) ab c d 2 1.589235 1.098612 0.3364722 -1.6094379 head(lir) ab c d 1 NA 1.252763 0.3364722 -1.6094379 __ R-help@stat.math.ethz.ch 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] Calling variables dynamically
I've looked in the online documentation for this, but have been unable to find an answer. I can name variables dynamically, but I cannot call them dynamically. Either a direct answer or a reference to an online resource that has the answer would be great. I'm trying to write a script that imports and compares results from various IR (information retrieval systems). Each imported file will contain results for multiple (50+) queries, each query can have 2000+ results. My immediate task is to import the files and assign the scores for each query to its own variable (e.g. File1-Query1, File1-Query2, etc) I've written code that reads in the data files and enters them as variables: res.paths -file.path(choose.files(c:/res/*.*)) num.files- NROW(res.paths) for (j in 1: num.files) { assign(paste(res,j, sep=), read.table(res.paths[j])) This gives me variables named res1, res2, etc, one for each file. So far so good. But the next line of code is designed to find out how many unique values are in the first column (i.e. number of queries) of the file I just imported: assign(paste(res.count,j, sep=_), NROW(unique(res[j]$V1))) } What I expected is a variable named e.g. res.count_1. However, I get an error: Error in unique(res[j]$V1) : object res not found How can I dynamically call res1, res2, etc? I've also tried using quotes and paste, but with no success. Any help is appreciated. Andrew Noyes SCILS Rutgers University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Calling variables dynamically [Broadcast]
1. The FAQ entry advise you to use a list, instead of using assign() in a loop. Have you considered that? 2. See ?get. Andy From: [EMAIL PROTECTED] I've looked in the online documentation for this, but have been unable to find an answer. I can name variables dynamically, but I cannot call them dynamically. Either a direct answer or a reference to an online resource that has the answer would be great. I'm trying to write a script that imports and compares results from various IR (information retrieval systems). Each imported file will contain results for multiple (50+) queries, each query can have 2000+ results. My immediate task is to import the files and assign the scores for each query to its own variable (e.g. File1-Query1, File1-Query2, etc) I've written code that reads in the data files and enters them as variables: res.paths -file.path(choose.files(c:/res/*.*)) num.files- NROW(res.paths) for (j in 1: num.files) { assign(paste(res,j, sep=), read.table(res.paths[j])) This gives me variables named res1, res2, etc, one for each file. So far so good. But the next line of code is designed to find out how many unique values are in the first column (i.e. number of queries) of the file I just imported: assign(paste(res.count,j, sep=_), NROW(unique(res[j]$V1))) } What I expected is a variable named e.g. res.count_1. However, I get an error: Error in unique(res[j]$V1) : object res not found How can I dynamically call res1, res2, etc? I've also tried using quotes and paste, but with no success. Any help is appreciated. Andrew Noyes SCILS Rutgers University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] writing a glm link function
Hello all. I could really use some help in writing a new glm link function in order to run an analysis of daily nest survival rates. I've struggled with this for weeks now, but I'm afraid I can't figure out even how to get started (fairly new at R, complete beginner in writing functions in R!). Essentially, all I will be doing is running a logistic regression, but with a different link function. The link function is a modification of the logit link: g(theta) = natural log( (theta ^(1/t)) / (1- (theta ^(1/t)) ) ; where t is the length of the interval between nest checks. Could anyone help? I hope the answer is rather simple, since this just adds the exponent (1/t) to the logit link function; but I have yet to figure out how to do this. Thanks in advance for any help. cheers, Jessi Brown Program in Ecology, Evolution, and Conservation Biology University of Nevada-Reno [[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] Questions on formula in princomp
One of the components of the returned princomp() objects can be $scores, the matrix of scores. You can plot these as usual using any characters you like via the 'pch' parameter of plot: e.g. ## groups is a factor giving the groups for each data value.Assuming three groups myscores-[princomp(...,scores=TRUE)$scores plot(myscores[,1:2],pch=c('s','c','v')[groups]) Of course, this is not quite a biplot, but it's close. -- 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 Sasha Pustota Sent: Friday, April 14, 2006 3:35 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] Questions on formula in princomp Ok, that was just my wishful thinking. Is there a way to plot repeated labels that identify groups, e.g. factor(c(rep(s,50),rep(c,50),rep(v,50))) instead of 1--150 row indices, using something like biplot(princomp(lir)) ? Gabor Grothendieck [EMAIL PROTECTED] wrote: Just use model.frame to examine what is passed: ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3]) lir - data.frame(log(ir)) names(lir) - c(a,b,c,d) lir[1,1] - NA mf - model.frame(~., lir,na.action=na.omit) head(mf) ab c d 2 1.589235 1.098612 0.3364722 -1.6094379 head(lir) ab c d 1 NA 1.252763 0.3364722 -1.6094379 __ R-help@stat.math.ethz.ch 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] Questions on formula in princomp
Berton Gunter [EMAIL PROTECTED] wrote: plot(myscores[,1:2],pch=c('s','c','v')[groups]) Thanks, this works. How to understand the result of the expression c(1,2,'3)[groups] [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 where groups - factor(c(rep(X,5), rep(Y,5), rep(Z,5))) ? Sorry if it's too basic. __ R-help@stat.math.ethz.ch 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] Questions on formula in princomp
Sasha Pustota [EMAIL PROTECTED] wrote: Berton Gunter [EMAIL PROTECTED] wrote: plot(myscores[,1:2],pch=c('s','c','v')[groups]) Thanks, this works. How to understand the result of the expression c(1,2,'3)[groups] [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 where groups - factor(c(rep(X,5), rep(Y,5), rep(Z,5))) bzz... this should be groups - factor(c(rep(Z,5),rep(X,5),rep(Y,5))) __ R-help@stat.math.ethz.ch 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] Questions on formula in princomp
does this explain it? groups - factor(c(rep(Z,5),rep(X,5),rep(Y,5))) groups [1] Z Z Z Z Z X X X X X Y Y Y Y Y Levels: X Y Z as.integer(groups) [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 c(1,2,3)[groups] [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 On 4/14/06, Sasha Pustota [EMAIL PROTECTED] wrote: Sasha Pustota [EMAIL PROTECTED] wrote: Berton Gunter [EMAIL PROTECTED] wrote: plot(myscores[,1:2],pch=c('s','c','v')[groups]) Thanks, this works. How to understand the result of the expression c(1,2,'3)[groups] [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 where groups - factor(c(rep(X,5), rep(Y,5), rep(Z,5))) bzz... this should be groups - factor(c(rep(Z,5),rep(X,5),rep(Y,5))) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? [[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] Questions on formula in princomp
jim holtman [EMAIL PROTECTED] wrote: does this explain it? groups - factor(c(rep(Z,5),rep(X,5),rep(Y,5))) groups [1] Z Z Z Z Z X X X X X Y Y Y Y Y Levels: X Y Z as.integer(groups) [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 c(1,2,3)[groups] [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 I did notice the lexicographical ordering of Z,X,Y. I don't understand the meaning of c(1,2,3) subscription by a factor. I understand subscription by an integer, or by a single item as in associative arrays. Or does [] have a different meaning here? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] matching identical row names
dear group, i have a sample matrix name v1 v2 v3 v4 cat 1011 12 15 dog 3 12 10 14 cat 9 12 12 15 cat 5 12 10 11 dog 12113 123 31 ... since cat is repeated 3 times, I want a mean value for it. Like wise for every element of the name column. cat v1 = mean(c(10,9,5)) cat v3 = mean(c(11,12,13)) ..etc. name v1 v2 v3 v4 cat 8 11.6 11.3 13.6 dog 7.5 62.5 66.5 22.5 could any one help me in solving this mystery. thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html