[R] plotmath overstrikes in output on a Linux system
I've been testing plotmath. But I'm getting some funny output one one computer. The problem is that characters are 'jumbled' and overstrike when symbols are introduced. Sample code: mu - 440.0 sigma - 12.5 myx - seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) myDensity - dnorm(myx,mean=mu,sd=sigma) # Here's one way to retrieve the values of mu and sigma and insert them into an expression t1t2 - bquote (paste(Normal(, mu== .(mu), ',', sigma== .(sigma),)) ) plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) I have tested this code and it works on two desktop Fedora Linux 8 systems to make a nice figure, but on a Dell Laptop with Fedora Linux 8 and R 2.6.2, something funny happens: the characters overstrike each other. The Greek letter mu is printed several spaces to the left of the ( that it is supposed to follow. I made an itty bitty picture of the figure title to show you: http://pj.freefaculty.org/R/plotmath_problem.png I can force in spaces to re-arrange the symbols so they do not overstrike. The following looks fine in the output. t1t2 - bquote (paste(Normal ( , mu== .(mu), ' , ', sigma== .(sigma), )) ) ### Note spaces manually inserted above are needed, otherwise plotmath overlaps l of plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) What do you suppose is wrong? The X configuration? -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error using method ls.ranking.capa.ident
Good Day I'm trying to run the generalized least square approach for my 2-additive problem, unfortunately this error appeared. I have tried to figure out the error from the mailing list but couldn't find the solution. Any help is highly appreciated. This is my source code: a1 - c(76.18, 61.84, 60.4, 69.09) a2 - c(51.01, 50.39, 87.62, 52.03) a3 - c(80.08, 48.49, 90.86, 76.11) a4 - c(57.71, 38.99, 88.7, 53.12) a5 - c(71.93, 82.04, 83.05, 85.99) a6 - c(60.94, 71.12, 63.61, 69.47) ##preference threshold relative ## to the preorder of the alternatives C- rbind (a1, a2, a3, a4, a5, a6) overall - c (79, 78, 79.5, 77.5, 80, 78.5) rk.proto - rbind (c(5,3), c(3,1), c(1,6), c(6,4), c(4,2)) Asp -rbind (c(1,2,-delta.S), c(2,1,-delta.S), c(3, 4,-delta.S), c(4, 3, -delta.S)) ## an interaction preorder constraint matrix delta.I - 0.05 Aii - rbind (c(1,2,-1,-delta.I), c(1,3,delta.I, 1), c (1,4,-1,-delta.I), + c(2,3, delta.I,1), c(2, 4,-1,-delta.I), c(3,4,delta.I, 1)) gls -ls.ranking.capa.ident(4,2,C, rk.proto,0.5, A.Shapley.preorder = Asp, A.interaction.interval = Aii) Error in drop(.Call(La_dgesv, a, as.matrix(b), tol, PACKAGE = base)) : system is computationally singular: reciprocal condition number = 4.68861e-18 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] pie graphic
Marco Chiapello wrote: Hi, My problem is: I have many data to plot as pie-chart, so the labels are not readable! Is there a way to solve my problem? For example is it possible move the labels more far to the graphic? Hi Marco, The essence of a pie chart is simplicity. You can do what you want with floating.pie and pie.labels from the plotrix package, but the result may not be as informative as it could be. If you are interested in showing the differences between your quantities, fan.plot is a better bet, although if many is more than about ten, you will be stretching that one, too. Bar plots are better at displaying large numbers of quantities, and are usually well tolerated by audiences. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matching pairs from two data frame
a so simple solution ... thanks a lot ! Henrique Dallazuanna wrote: Try: merge(DATA1, DATA2) On Mon, Apr 7, 2008 at 11:20 AM, solea [EMAIL PROTECTED] wrote: I am looking for a solution to match 2 dataframes from pairs of values (x and y) as indicated thereafter : First dataframe : DATA1 xy a 1 30 400.2 2 21 130 0.3 Second dataframe DATA2 xy b 1 30 401 2 40 303 3 20 407 4 1130 2 5 130 250 15 6 21130 17 expected Results : DATA3 xy a b 1 30 400.21 2 21 130 0.3 17 Many thanks in advance fo your help -- View this message in context: http://www.nabble.com/Matching-pairs-from-two-data-frame-tp16537467p16537467.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Matching-pairs-from-two-data-frame-tp16537467p16548091.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotmath overstrikes in output on a Linux system
Looks likes the the laptop is using different fonts with incorrect font metrics. This could happen because it has a different screen resolution, or one of the systems is set to use scalable fonts or it is giving metrics for one fonts and using another or BTW, this is probably nothing to do with plotmath per se -- the issue is most likely the device (presumably X11(), but you did not say) and its handling of font metric requests. It looks to me as if the widths of normal text strings (and not symbols) is the problem. I have seen something similar where there was a long-standing bug in plotmath (fixed in r44534), but this only manifested itself when text was kerned, which the X11() device in 2.6.2 does not ask for. My best guess is that the font selected is (to use the technical terms) returning glyph widths without left/right bearings. Please try 2.7.0 beta, which has a different X11() device (and the above bug fixed). That ought to solve the problem for you, but otherwise you'll need to debug what the X11 metricInfo callback is giving you. On Tue, 8 Apr 2008, Paul Johnson wrote: I've been testing plotmath. But I'm getting some funny output one one computer. The problem is that characters are 'jumbled' and overstrike when symbols are introduced. Sample code: mu - 440.0 sigma - 12.5 myx - seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) myDensity - dnorm(myx,mean=mu,sd=sigma) # Here's one way to retrieve the values of mu and sigma and insert them into an expression t1t2 - bquote (paste(Normal(, mu== .(mu), ',', sigma== .(sigma),)) ) plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) I have tested this code and it works on two desktop Fedora Linux 8 systems to make a nice figure, but on a Dell Laptop with Fedora Linux 8 and R 2.6.2, something funny happens: the characters overstrike each other. The Greek letter mu is printed several spaces to the left of the ( that it is supposed to follow. I made an itty bitty picture of the figure title to show you: http://pj.freefaculty.org/R/plotmath_problem.png I can force in spaces to re-arrange the symbols so they do not overstrike. The following looks fine in the output. t1t2 - bquote (paste(Normal ( , mu== .(mu), ' , ', sigma== .(sigma), )) ) ### Note spaces manually inserted above are needed, otherwise plotmath overlaps l of plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) What do you suppose is wrong? The X configuration? -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Legend on plots when using Cairo
Dear all, I am trying to use the Cairo package to avoid some X11 issues and it works very well. However, when I want to add a legend to my plots, I receive an error message from Cairo: library(Cairo) CairoPNG(file=test.png) plot(1:100) dev.off() null device 1 This works fine. But: CairoPNG(file=test.png) plot(1:100) legend(50,50,test) Error in strwidth(legend, units = user, cex = cex) : font 2147483647 not recognized in Rcairo_setup_font dev.off() null device 1 Does anyone know how to obtain a plot with legend using Cairo? I have tried it on two different environments, so here are the two sessionInfo(): sessionInfo() R version 2.8.0 Under development (unstable) (2008-04-07 r45137) i686-pc-linux-gnu locale: C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Cairo_1.4-2fortunes_1.3-3 ### sessionInfo() R version 2.8.0 Under development (unstable) (2008-04-07 r45137) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.ISO-8859-1;LC_NUMERIC=C;LC_TIME=en_US.ISO-8859-1;LC_COLLATE=en_US.ISO-8859-1;LC_MONETARY=C;LC_MESSAGES=en_US.ISO-8859-1;LC_PAPER=en_US.ISO-8859-1;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.ISO-8859-1;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Cairo_1.4-2fortunes_1.3-3 Best regards, Audrey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about nlminb
Dear All, I wanted to post some more details about the query I sent to s-news last week. I have a vector with a constraint. The constraint is that the sum of the vector must add up to 1 - but not necessarily positive, i.e. x[n] - 1 -(x[1] + ...+x[n-1]) I perform the optimisation on the vector x such that x - c(x, 1-sum(x)) In other words, fn - function(x){ x - c(x, 1 - sum(x)) # other calculations here } then feed this into nlminb() out - nlminb(x, fn) out.x - out$parameters out.x - c(out.x, 1 - sum(out.x)) out.x I would like to calculate standard errors for each of the components of x. Is this possible by outputing the Hessian matrix? Furthermore, how would I calculate this for the last component (if this is indeed possible) which has the restriction (i.e. 1-sum(out.x))? Any help would be much appreciated. Regards, John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sample size for log-rank test with more than 2 groups
Hi everyone, I was wondering whether extension of the current spower function for Hmisc were existing? My current focus is to calculate sample size based on the log-rank test with more than 2 groups (with/without trend) Taking into account the loss of follow up and the accrual processes. A SPSS library (ART) is existing but can't find anything in R Any information is welcome ! Many thanks Laurent [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to access the attributes of a ggplot?
Hi Hadley, Thanks for replying. I know that I can directly modify some of the properties of the plot object, but I was more interested in querying the current plot properties, something like: xlimits - getggopts(pobj, x_scale_limits) Is there anything like this implemented? I tried to drill down the structure of the plot object using grid, but wasn't very successful... It gets a bit complicated, so I decided to ask if you have implemented something like that above... On Tue, Apr 8, 2008 at 5:04 AM, hadley wickham [EMAIL PROTECTED] wrote: Hi Tribo, I found 'ggopts', but it only returns some of the properties. Say I want to get the x- and y-axis limits, the tickmark locations, legend current position, the legend box and background color and set them to new values. Are these properties easily accessible (and modifiable) from the object? Some of them are: * the x and y axis limits are properties of the scales (e.g. + scale_x_continuous(limits=c(5, 10)) * the tickmark locations and labels are also properties of the scales (e.g. + scale_x_continuous(breaks=c(5, 10), labels=c(five,ten)) * the legend position is set by ggopt() Some of them aren't: * legend fill and outline colours can only be changed by modifying the underlying grid object - see the last chapter of the ggplot book to see how to do this. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Weibull maximum likelihood estimates for censored data
Hello! I have a matrix with data and a column indicating whether it is censored or not. Is there a way to apply weibull and exponential maximum likelihood estimation directly on the censored data, like in the paper: Backtesting Value-at-Risk: A Duration-Based Approach, P Chrisoffersen and D Pelletier (October 2003) page 8? The problem is that if I type out the code as below the likelihood ratio is greater than one. Interest D C 1 17 1 2 10 0 3 15 0 42 0 5 42 0 6 53 0 7 193 0 8 11 0 92 0 10 8 0 11 12 1 library(stats4) dur_ind_test = function (CDMatrix)# Matrix with durations and censores { lLnw - function(b){ D = CDMatrix NT = nrow(D) a =((NT-D[1,2]-D[NT,2])/ sum(D[,1]^b))^(1/b) f = sum(log((a^b)*b*(D[2:(NT-1),1]^(b-1))*exp(-((a*D[2:(NT-1),1])^b fd1 = (a^b)*b*(D[1,1]^(b-1))*exp(-(a*D[1,1])^b) fdn = (a^b)*b*(D[NT,1]^(b-1))*exp(-(a*D[NT,1])^b) S1 = exp(-(a*D[1,1])^b) SN = exp(-(a*D[NT,1])^b) -(D[1,2]*log(S1)+(1-D[1,2])*log(fd1)+ f + D[NT,2]*log(SN)+ (1-D[NT,2])*log(fdn)) } lLne - function(A){ D = CDMatrix NT = nrow(D) b=1 f = sum(log(A*b*(D[2:(NT-1),1]^(b-1))*exp(-(A^(1/b)*D[2:(NT-1),1])^b))) fd1 = A*b*(D[1,1]^(b-1))*exp(-(A^(1/b)*D[1,1])^b) fdn = A*b*(D[NT,1]^(b-1))*exp(-(A^(1/b)*D[NT,1])^b) S1 = exp(-(A^(1/b)*D[1,1])^b) SN = exp(-(A^(1/b)*D[NT,1])^b) lLw = D[1,2]*log(S1)+(1-D[1,2])*log(fd1)+ f + D[NT,2]*log(SN)+ (1-D[NT,2])*log(fdn) -(D[1,2]*log(S1)+(1-D[1,2])*log(fd1)+ f + D[NT,2]*log(SN)+ (1-D[NT,2])*log(fdn)) } fit1 - mle(lLnw,start = list(b = 0.5))# Estimate parameters using ml fit2 - mle(lLne,start = list(A = 0.02)) Lw - lLnw(coef(fit1)) # Maximum log likelihood : Weibull Le - lLne(coef(fit2)) # Maximum log likelihood : Exponential LR0 - (Le/Lw)# Likelihood ratio with duration sample NSimM - cbind(as.matrix(sort(rchisq(nsim,1,0))),runif(nsim,0,1))# chi-square df1 simulations, uniform rvs Uniftest - runif(1,0,1) firstrow - cbind(LR0,Uniftest) # use sample LR as LR NSimM - rbind(firstrow,NSimM) Test - matrix(rep(0,2*(nsim+1)),nrow=(nsim+1)) NSimM - cbind(NSimM,Test) for(i in 2:nsim+1) { # indicates the number of simulation above the sample if (NSimM[i,1] LR0)NSimM[i,3]- 1 # likelihood ratio else if(NSimM[i,1]== LR0)if(NSimM[i,2]= Uniftest)NSimM[i,4]-1 # if equal, only indicate if rv for simulation } # is larger that rv for sample LR Gn - 1-(sum(NSimM[,3]))/nsim + sum(NSimM[,4])/nsim pval - (nsim*Gn+1)/(nsim+1) #Calculate Monte Carlo p-value out - c(pval,confint(fit1)) now - c(Le,Lw) LR0 }} test_1 - dur_ind_test(CDMatrix = Interest,nsim=1000) Profiling... test_1 Ab 42.32406 41.59035 = likelihood ratio = 1.017641 Could someone please help? http://www.investec.com/EmailDisclaimer/emaildisclaimer.htm The disclaimer also provides our corporate information and names of our directors as required by law. The disclaimer is deemed to form part of this message in terms of Section 11 of the Electronic Communications and Transactions Act 25 of 2002. If you cannot access the disclaimer, please obtain a copy thereof from us by sending an email to: [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply
try this: mat - matrix(rnorm(1000), 100, 10) ind - gl(4, 25) rowsum(mat, ind) / rep(table(ind), each = ncol(mat)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Manuel Montes [EMAIL PROTECTED] To: r-help@r-project.org Sent: Tuesday, April 08, 2008 11:14 AM Subject: [R] tapply Does anyone have something like tapply for matrices? I would like to average the contents of columns according to factors but tapply works only with one column at each time. Is something available to do everything in one step? Many thanks. Manuel Montes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotmath overstrikes in output on a Linux system
Paul Johnson wrote: I've been testing plotmath. But I'm getting some funny output one one computer. The problem is that characters are 'jumbled' and overstrike when symbols are introduced. Sample code: mu - 440.0 sigma - 12.5 myx - seq( mu - 4*sigma, mu+ 4*sigma, length.out=500) myDensity - dnorm(myx,mean=mu,sd=sigma) # Here's one way to retrieve the values of mu and sigma and insert them into an expression t1t2 - bquote (paste(Normal(, mu== .(mu), ',', sigma== .(sigma),)) ) plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) I have tested this code and it works on two desktop Fedora Linux 8 systems to make a nice figure, but on a Dell Laptop with Fedora Linux 8 and R 2.6.2, something funny happens: the characters overstrike each other. The Greek letter mu is printed several spaces to the left of the ( that it is supposed to follow. I made an itty bitty picture of the figure title to show you: http://pj.freefaculty.org/R/plotmath_problem.png I can force in spaces to re-arrange the symbols so they do not overstrike. The following looks fine in the output. t1t2 - bquote (paste(Normal ( , mu== .(mu), ' , ', sigma== .(sigma), )) ) ### Note spaces manually inserted above are needed, otherwise plotmath overlaps l of plot(myx, myDensity, type=l, xlab=X, ylab=Probability Density , main=t1t2) What do you suppose is wrong? The X configuration My guess would be that something is wrong with the font metrics on one system. If the length of Normal( is miscalculated, that would explain the rest. Do you see the same thing if you do something like plot(0, main=quote(paste(Lengthy string, A))) It could be related to dpi settings; I seem to recall that this can do weird things on wide-screen displays. Doex xdpyinfo provide any clues? Look for lines like this screen #0: dimensions:1024x768 pixels (260x195 millimeters) resolution:100x100 dots per inch You could also play with the pointsize argument to X11() and see if the problem disappears at different sizes. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] tapply
Does anyone have something like tapply for matrices? I would like to average the contents of columns according to factors but tapply works only with one column at each time. Is something available to do everything in one step? Many thanks. Manuel Montes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help
Partha Saha wrote: theil inequality measure with sub-group decomposability. Hi Partha, Are you referring to the Gini coefficient? If so, have a look at the ineq and reldist packages. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. findGlobals doesn't try to tell what mean is; it's just reporting on how you've used it. Your usage means that the interpreter will treat it as a variable, getting a copy of its value and passing it as an argument to apply. (That's an oversimplification, of course: it's very unlikely that an actual copy will be made, but it will act as if one was made.) Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You can still use it to detect that kind of typo, but you need a second step where you check whether the globals exist in the environment of the function or not. That test won't be perfect either: it will miss cases where you meant to type a local variable, but by mistake typed the name of some global. Most uses of mean as a variable would fall into that category; unfortunately (?) apply means some of them are legitimate. I think the best you'll ever be able to do is to get some suggestions of errors, with both false positives and false negatives. If there were cases where some usage was definitely an error, the parser would probably catch it. Duncan Murdoch Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to pack my stuff into a package (library, collection)?
Tribo Laboy wrote: Thanks all for the help and suggestions. I am little by little finding my way. I have another question to the people who use the R packaging system. Say I have a function called myfun.R. Where am I supposed to write the help to that function? When I use promt(myfun) or package.skeleton(myfun) I get a skeleton of the .Rd file which contains both help and R source. The R source in the Rd file is there instead of an example, you should replace it. Note that Rd stands for R documentation, it should not include code sources, just documentation sources. What do you do with the original .R source file then - do you delete it? I suppose it is not necessary No, it must be there in the package sources, otherwise you won't have any functions in your package. Uwe Ligges anymore and all changes to R source and help can be done simultaneously in the .Rd file. Then it can be used to generate all the help and R files to be run. But then .Rd files cannot be run directly from R, so each time a change is done to the source, it must be re-exported in an .R file and run. Please tell me if I am wrong. Do you keep R-souce and R-help in separate files while developing and then combine them in a single .Rd file when you're finished? Yours still confused, TL On Mon, Apr 7, 2008 at 3:13 PM, Tribo Laboy [EMAIL PROTECTED] wrote: Hello, I am new useR, I have written some functions, which I currently use by source-ing them from the files. That's OK, but when I my functions start counting in the tens and hundreds I'd be glad to be able to type help.search(my_obscure_fun) and get a sensible reply. I also want to be able to load them as a package at startup and not have to source each one individually. I read through the Writing R Extensions file, but I am overwhelmed with the vast amount of prescribed detail that Extension Authors must follow - directory structure, file structure, etc. Luckily, I found the prompt function, which helps in writing of help-files in the form of fill-in the blanks. But that's only for the help-files. Reading further, it gets even more complicated. The user is referred to the R Installation and Administration document, which says that: If you want to build R or add-on packages from source in Windows, you will need to collect, install and test an extensive set of tools. These seem to include among others Perl and compiler. But R is an interpreted and cross-platform language, I don't understand the need for additional platform specific tools just to call a user collection of R-files. Anyone knows of a smooth introduction to these topics? Rgards, TL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Install spatstat package on gentoo
Anybody know how to install R-spatstat package on a gentoo based system? Thanks you Luca -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Una BMW Z4 Roadster a 10? Prova gratis su Bidplaza.it! * Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7673d=8-4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply
On 4/8/2008 5:14 AM, Manuel Montes wrote: Does anyone have something like tapply for matrices? I would like to average the contents of columns according to factors but tapply works only with one column at each time. Is something available to do everything in one step? Many thanks. Manuel Montes How about aggregate()? For example: aggregate(iris[,c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)], by = list(Species = iris$Species), FUN = mean) Species Sepal.Length Sepal.Width Petal.Length Petal.Width 1 setosa5.006 3.4281.462 0.246 2 versicolor5.936 2.7704.260 1.326 3 virginica6.588 2.9745.552 2.026 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question Regarding 'pipe'
On Mon, Apr 07, 2008 at 07:42:50PM -0500, [EMAIL PROTECTED] wrote: Can anyone point out why this is not working? y-read.table(pipe(' awk '{ n = $1; sub( .* $1 ,) ; while ( n-- ) ^ print }' temp.txt ')) ^ one problem is that your single-quoted R string contains single quotes which I've pointed to with ^ above. You probably intend these single quotes to be part of the awk command line, but R can\'t know that unless you escape them... ;-) In the future, can you please describe explicitly how it is not working, and also give a bit more context, such as a few lines of description of the content of temp.txt, and why you're trying to use awk (rather than R itself) to achieve whatever you're trying to achieve? Best regards, Jan -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to pack my stuff into a package (library, collection)?
Yesterday I wrote: I took a look at this today. You get an error message but the package is still installed without the CHM compiler, so that's less urgent. I did add a menu entry to install a source package from a directory: Packages | Install source package from local folder... to the alpha version. I don't guarantee this will survive testing: it gives a fairly ugly error message if you don't have Rtools installed. It didn't survive. We'll be looking at a more complete solution for 2.8.0, but we're out of time for 2.7.0. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend on plots when using Cairo
Why are you using Cairo 'to avoid some X11 issues' for an unreleased version of R that does not use X11 for its png() device? I see this under Cairo, but not under png(type =cairo) (the default). The R posting guide asked you to discuss package problems with the maintainer, so if you have not already done so, please do so. On Tue, 8 Apr 2008, audrey wrote: Dear all, I am trying to use the Cairo package to avoid some X11 issues and it works very well. However, when I want to add a legend to my plots, I receive an error message from Cairo: library(Cairo) CairoPNG(file=test.png) plot(1:100) dev.off() null device 1 This works fine. But: CairoPNG(file=test.png) plot(1:100) legend(50,50,test) Error in strwidth(legend, units = user, cex = cex) : font 2147483647 not recognized in Rcairo_setup_font dev.off() null device 1 Does anyone know how to obtain a plot with legend using Cairo? I have tried it on two different environments, so here are the two sessionInfo(): sessionInfo() R version 2.8.0 Under development (unstable) (2008-04-07 r45137) i686-pc-linux-gnu locale: C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Cairo_1.4-2fortunes_1.3-3 ### sessionInfo() R version 2.8.0 Under development (unstable) (2008-04-07 r45137) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.ISO-8859-1;LC_NUMERIC=C;LC_TIME=en_US.ISO-8859-1;LC_COLLATE=en_US.ISO-8859-1;LC_MONETARY=C;LC_MESSAGES=en_US.ISO-8859-1;LC_PAPER=en_US.ISO-8859-1;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.ISO-8859-1;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Cairo_1.4-2fortunes_1.3-3 Best regards, Audrey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about nlminb
Dear All, I wanted to post some more details about the query I sent to s-news last week. I have a vector with a constraint. The constraint is that the sum of the vector must add up to 1 - but not necessarily positive, i.e. x[n] - 1 -(x[1] + ...+x[n-1]) I perform the optimisation on the vector x such that x - c(x, 1-sum(x)) In other words, fn - function(x){ x - c(x, 1 - sum(x)) # other calculations here } then feed this into nlminb() out - nlminb(x, fn) out.x - out$parameters out.x - c(out.x, 1 - sum(out.x)) out.x I would like to calculate standard errors for each of the components of x. Is this possible by outputing the Hessian matrix? Furthermore, how would I calculate this for the last component (if this is indeed possible) which has the restriction (i.e. 1-sum(out.x))? Any help would be much appreciated. Regards, John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
I think what he is referring to is that findGlobals lists mean under variables rather than functions when you do this with his f: findGlobals(f, FALSE) $functions [1] { apply $variables [1] mean On Tue, Apr 8, 2008 at 7:14 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. findGlobals doesn't try to tell what mean is; it's just reporting on how you've used it. Your usage means that the interpreter will treat it as a variable, getting a copy of its value and passing it as an argument to apply. (That's an oversimplification, of course: it's very unlikely that an actual copy will be made, but it will act as if one was made.) Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You can still use it to detect that kind of typo, but you need a second step where you check whether the globals exist in the environment of the function or not. That test won't be perfect either: it will miss cases where you meant to type a local variable, but by mistake typed the name of some global. Most uses of mean as a variable would fall into that category; unfortunately (?) apply means some of them are legitimate. I think the best you'll ever be able to do is to get some suggestions of errors, with both false positives and false negatives. If there were cases where some usage was definitely an error, the parser would probably catch it. Duncan Murdoch Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
On Tue, 8 Apr 2008, Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. You are missing some points about R and findGlobals. In R, functions are first class values: they can be assigned to variables, passed as arguments, and returned as results, just like vectors. In contrast to many other languages there is not special mechanism for defining functions and associating them with a name -- the way you define a function is foo - function(...) ... which creates a function value and assigns it to a variable. findGlobals just looks at the function body and arguments and determines which of the variables used would have their definitions looked up in the global environment if this code is run. It does not try to detect which of these have values or not, never mind what the types of those falues are. The result returned by findGlobals with merge=FALSE separates into variables that are explicitly used as funcitons, i.e foo in foo(x) and ones that are not. One could argue that findGlobals should know enough about apply() to realize that the FUN argument is implicitly used as a function; if this change were made then apply(x, 2, pi) pi would be listed as a function because it is _used_ that way. Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You need to do some extra work to get this -- checking which globals have values, and maybe whether those that are used as functions have values that are functions. checkUsage does this, among other things. For this example checkUsage produces checkUsage(f) anonymous: no visible binding for global variable âmObjectâ luke Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question Regarding 'pipe'
Reason, I need to do this in awk and not R: Let's say 'x' is the tabular representation of a sparse contingency table x x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 Freq 10 0 0 2 2 2 0 2 0 2 54 51 0 0 2 2 2 0 2 1 21 61 0 1 0 2 2 0 2 0 2 137 71 0 1 1 2 1 0 1 0 1 14 10 1 0 1 1 2 2 0 2 1 2 110 I need to generate that dataset from which such a contingency table could be made. That dataset would have sum(x$Freq) = 316 rows. Note that this is only a sample example. Real examples that I could be dealing with would have up to 50 variables and tens of thousands of cases. I can definitely make a dataset in R itself by replicating the first row 54 times, the third row 137 times and so on (for a real example, each replication could be a 1000 times), but I bet this is going to be as inefficient way of doing things as it could be. However, if I write 'x' to file and then call the awk script above, I get my dataset within fraction of seconds (including the time to write and read files on the OS). Any suggestions now on how to get the 'pipe' command work? Thanks On Tue, Apr 8, 2008 at 4:45 AM, Jan T. Kim [EMAIL PROTECTED] wrote: On Mon, Apr 07, 2008 at 07:42:50PM -0500, [EMAIL PROTECTED] wrote: Can anyone point out why this is not working? y-read.table(pipe(' awk '{ n = $1; sub( .* $1 ,) ; while ( n-- ) ^ print }' temp.txt ')) ^ one problem is that your single-quoted R string contains single quotes which I've pointed to with ^ above. You probably intend these single quotes to be part of the awk command line, but R can\'t know that unless you escape them... ;-) In the future, can you please describe explicitly how it is not working, and also give a bit more context, such as a few lines of description of the content of temp.txt, and why you're trying to use awk (rather than R itself) to achieve whatever you're trying to achieve? Best regards, Jan -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sample size for log-rank test with more than 2 groups
Essioux, Laurent wrote: Hi everyone, I was wondering whether extension of the current spower function for Hmisc were existing? My current focus is to calculate sample size based on the log-rank test with more than 2 groups (with/without trend) Taking into account the loss of follow up and the accrual processes. A SPSS library (ART) is existing but can't find anything in R Any information is welcome ! Many thanks Laurent spower only implements the two-sample problem. Frank [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install spatstat package on gentoo
Luca Penasa wrote: Anybody know how to install R-spatstat package on a gentoo based system? Same as on any other system, see the manual R Installation and Administration and please do read the posting guide. Best, Uwe Ligges Thanks you Luca -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Una BMW Z4 Roadster a 10€? Prova gratis su Bidplaza.it! * Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7673d=8-4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Metropolis acceptance rates
Is there a way to recover Metropolis-step acceptance rates AFTER completing posterior draws? The immediate application is in the probit.bayes and logit.bayes models used by Zelig... which I believe is merely calling MCMCpack. So one strategy, to which I am fixing to resort, is to call, say, MCMClogit with verbose set to mcmc (or mcmc divided by an integer) and then look at my screen. But it seems odd that this datum is not being put into output objects, so I wonder if I'm missing something. Plus sometimes I can save the output object, but then the power goes out and what's on screen is gone forever. Thanks, Michael Michael Margolis Profesor Investigador Escuela de Economía Universidad de Guanajuato UCEA-Campus Marfil, Fracc 1 El Establo, Guanajuato, Gto. CP 36250 Mexico (52)(473) 735 29 25 Ext. 2858 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to pack my stuff into a package (library, collection)?
On 08/04/2008 7:08 AM, Tribo Laboy wrote: Thanks all for the help and suggestions. I am little by little finding my way. I have another question to the people who use the R packaging system. Say I have a function called myfun.R. I guess you mean you have a source file myfun.R, containing a definition of a function myfun. You would put this in the R subdirectory of the package. (You could have a function named myfun.R, but it looks a little strange.) Where am I supposed to write the help to that function? When I use promt(myfun) or package.skeleton(myfun) I get a skeleton of the .Rd file which contains both help and R source. What do you do with the original .R source file then - do you delete it? I suppose it is not necessary anymore and all changes to R source and help can be done simultaneously in the .Rd file. No, definitely not. The source is copied to the Rd file just to remind you of what the function looks like, so that you can write documentation that is correct. By the time you're finished editing that file, you'll have actual working examples in the Examples section, not the function definition. You'll put the .Rd file into the man subdirectory of the package; R uses the \alias{myfun} line at the top to find the connection to your myfun function. There is a proposal on the Google Summer of Code page to mix documentation with definitions in the .R file, but so far we don't do that. Then it can be used to generate all the help and R files to be run. But then .Rd files cannot be run directly from R, so each time a change is done to the source, it must be re-exported in an .R file and run. Please tell me if I am wrong. Do you keep R-souce and R-help in separate files while developing and then combine them in a single .Rd file when you're finished? No, they are separate from the beginning, and stay separate. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to pack my stuff into a package (library, collection)?
okey-dokey, one more problem resolved. Keeping one documentation .Rd file for each R source file. Thanks! TL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] permutation test assumption?
Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] permutation test assumption?
Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens João Fadista Verzonden: dinsdag 8 april 2008 15:18 Aan: r-help@r-project.org Onderwerp: [R] permutation test assumption? Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] basehaz and newdata
The 'basehaz' function is just a wrapper for survfit, and includes only some of the arguments of the former. It's main reason for existence is that another more well known (but inferior :-) package uses that term. I don't understand the final comment in the exchange, however: I had been hoping the tedious alignment of the baseline curve with the value of the variables in the new data set would be [somehow] handled for me. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Change the position of panel strips in a lattice plot.
Hi all, In lattice plots, is there any option to position the panel strips with text below each subgraph, instead of above? i.e. in: Depth - equal.count(quakes$depth, number=8, overlap=.1) xyplot(lat ~ long | Depth, data = quakes) ,is there any way to make Depth appear below the subgraphs, instead of above? I've been looking through the lattice documentation and the list archive but have not found such a thing. Many thanks in advance, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to access the attributes of a ggplot?
Thanks for replying. I know that I can directly modify some of the properties of the plot object, but I was more interested in querying the current plot properties, something like: xlimits - getggopts(pobj, x_scale_limits) Is there anything like this implemented? Ah, that's much more tricky. The problem is that many of these values are not calculated until you actually draw the plot, and then they are immediately thrown away because of the copy-on-modify semantics that I'm following (to match the rest of R). You can access some info about the scales by looking at str(pobj$scales), but most of the interesting stuff isn't calculated until draw time. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Practical Data Limitations with R
We are new to R and evaluating if we can use it for a project we need to do. We have read that R is not well suited to handle very large data sets. Assuming we have the data prepped and stored in an RDBMS (Oracle, Teradata, SQL Server), what can R reasonably handle from a volume perspective? Are there some guidelines on memory/machine sizing based on data volume? We need to be able to handle Millions of Rows from several sources. Any advice is much appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Practical Data Limitations with R
Dear Jeff, R works fine for 22 rows that i tested on a home PC with XP . Memory is limited to hardware that you have. I suggest beefing up RAM to 2 GB and hard disk space and then working it out. I evaluated R too on my site www.decisionstats.com and I found it comparable if not better to SPSS , SAS. As a beginner , and in corporate projects try using the *GUI* R Commander or the *Data Mining GUI Rattle *, its faster and will help you skip some steps, you can also look at code generated side by side to learn the language. I am not sure on the server client version, but that should work too .. Also look at the book http://oit.utk.edu/scc/RforSASSPSSusers.pdf that helps you as a reference guide. Rest of details are on my site www.decisionstats.com Also *try the software WPS* http://www.teamwpc.co.uk/products/wps, which uses SAS language and provides the same functionality at 10-20 % of cost for millions of rows. Hope this helps, Ajay On Tue, Apr 8, 2008 at 7:56 PM, Jeff Royce [EMAIL PROTECTED] wrote: We are new to R and evaluating if we can use it for a project we need to do. We have read that R is not well suited to handle very large data sets. Assuming we have the data prepped and stored in an RDBMS (Oracle, Teradata, SQL Server), what can R reasonably handle from a volume perspective? Are there some guidelines on memory/machine sizing based on data volume? We need to be able to handle Millions of Rows from several sources. Any advice is much appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Practical Data Limitations with R
On Tue, Apr 08, 2008 at 09:26:22AM -0500, Jeff Royce wrote: We are new to R and evaluating if we can use it for a project we need to do. We have read that R is not well suited to handle very large data sets. Assuming we have the data prepped and stored in an RDBMS (Oracle, Teradata, SQL Server), what can R reasonably handle from a volume perspective? Are there some guidelines on memory/machine sizing based on data volume? We need to be able to handle Millions of Rows from several sources. As so often the answer is it depends. R does not have an inherent maximum number of rows it can deal with - the available memory determines how big a dataset you can fit into RAM. So often the answer would be yes - just buy more RAM. A couple million rows are no problem at all if you don't have too many columns (done that). If you realy have a very large set of data which you cannot fit into memory, you may still be able to use R: Do you really need ALL data in memory at the same time? Often, very large datasets actually contain many different subsets of data which you want to analyze separately, anyway. The solution of storing the full data in an RDBMS and selecting the required subsets as needed is the best solution. In your situation, I would simply load the full dataset into R and see what happens. cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Lehrstuhl für Genomorientierte Bioinformatik Fax. +49-8161-71 2186 Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany and Institut für Bioinformatik und Systembiologie / MIPS Helmholtz Zentrum München - Deutsches Forschungszentrum für Gesundheit und Umwelt Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question Regarding 'pipe'
On Tue, Apr 08, 2008 at 06:52:33AM -0500, [EMAIL PROTECTED] wrote: Reason, I need to do this in awk and not R: Let's say 'x' is the tabular representation of a sparse contingency table x x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 Freq 10 0 0 2 2 2 0 2 0 2 54 51 0 0 2 2 2 0 2 1 21 61 0 1 0 2 2 0 2 0 2 137 71 0 1 1 2 1 0 1 0 1 14 10 1 0 1 1 2 2 0 2 1 2 110 I need to generate that dataset from which such a contingency table could be made. That dataset would have sum(x$Freq) = 316 rows. Note that this is only a sample example. Real examples that I could be dealing with would have up to 50 variables and tens of thousands of cases. I can definitely make a dataset in R itself by replicating the first row 54 times, the third row 137 times and so on (for a real example, each replication could be a 1000 times), but I bet this is going to be as inefficient way of doing things as it could be. However, if I write 'x' to file and then call the awk script above, I get my dataset within fraction of seconds (including the time to write and read files on the OS). Any suggestions now on how to get the 'pipe' command work? Escape the quotes that you want to include in the string by preceding them with a backslash. Otherwise R will interpret them to terminate or start a string -- essentially as awk would do with double quotes just the same. I'm still not convinced, though, that running that while loop using awk has any advantages over programming it in R, but it's your choice... Best regards, Jan On Tue, Apr 8, 2008 at 4:45 AM, Jan T. Kim [EMAIL PROTECTED] wrote: On Mon, Apr 07, 2008 at 07:42:50PM -0500, [EMAIL PROTECTED] wrote: Can anyone point out why this is not working? y-read.table(pipe(' awk '{ n = $1; sub( .* $1 ,) ; while ( n-- ) ^ print }' temp.txt ')) ^ one problem is that your single-quoted R string contains single quotes which I've pointed to with ^ above. You probably intend these single quotes to be part of the awk command line, but R can\'t know that unless you escape them... ;-) In the future, can you please describe explicitly how it is not working, and also give a bit more context, such as a few lines of description of the content of temp.txt, and why you're trying to use awk (rather than R itself) to achieve whatever you're trying to achieve? Best regards, Jan -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to check if a variable is preferentially present in a sample
Dear All, I do apologise if this question is out of place for this list but I've tried searching mailing lists and read Introductory Statistics with R by Peter Dalgaard, but couldn't find any hints on solving my question below: I have a data frame (d) of values which I will rank in decreasing order of val. Each value belongs to a group, either 'A', 'B', 'C', 'D', or 'E'. I then take the first 10 entries in data frame 'd' and count the number of occurrences for each of the groups. I want to test if certain groups occur more frequently than by chance in my first 10 entries. Would a chi-square test or a hypergeometric test be more suitable? If neither, what would be an alternative solution in R? Below is my data: ## data L5 - LETTERS[1:5] d - data.frame(cbind(val= rnorm(1:10)^2, group=sample(L5,100, repl=TRUE))) str(d) ##'data.frame': 100 obs. of 2 variables: ##$ val : Factor w/ 10 levels 0.000169268449333046,..: 10 3 5 6 1 2 7 8 4 9 ... ##$ group: Factor w/ 5 levels A,B,C,D,..: 4 4 4 5 3 1 5 2 1 2 ... Many thanks in advance and apologies again, tania D. phil student Department of Physiology, Anatomy and Genetics University of Oxford __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Practical Data Limitations with R
We are new to R and evaluating if we can use it for a project we need to do. We have read that R is not well suited to handle very large data sets. Assuming we have the data prepped and stored in an RDBMS (Oracle, Teradata, SQL Server), what can R reasonably handle from a volume perspective? Are there some guidelines on memory/machine sizing based on data volume? We need to be able to handle Millions of Rows from several sources. Any advice is much appreciated. Thanks. The most important thing is what type of analysis do you want to do with the data? Is the algorithm that implements the analysis O(n), O(n log n) or O(n^2) ? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help me about singular error nls
Dear List I have that problem: this is file : PBS.txt TimeRFU 0. 27.3021 0.0800 26.1565 0.1600 25.4836 0.2400 25.2104 0.3200 24.7967 0.4000 24.6310 0.4800 24.3472 0.5600 24.2905 0.6400 24.1394 0.7200 24.0244 0.8000 23.8532 0.8800 23.7908 0.9600 23.6668 1.0400 23.7458 1.1200 23.6787 1.2000 23.5651 1.2800 23.4757 1.3600 23.5172 1.4400 23.4748 1.5200 23.6037 1.6000 23.4516 1.6800 23.5655 1.7600 23.4365 1.8400 23.3553 1.9200 23.5021 2. 23.4123 rm(list=ls()) print(ls()) #carica Dati con file di testo b -read.table(PBS.txt, sep=\t, header= TRUE) print(b) b nlmod1 - nls(RFU ~ A + (B+c*Time)/(1+exp(k*(e-Time))), data = b, start = list(A = 1, c = 1, B = 1, k =1, e = 1), trace = TRUE)) #- 13413478 : 1 1 1 1 1 Errore in nls(RFU ~ A + (B + c * Time)/(1 + exp(k * (e - Time))), data = b, : gradiente singolare Could you help me? The plot of data I don`t found errors and I don`t know why sometimes in similar data function and sometimes not. thanks for the help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Change the position of panel strips in a lattice plot.
On 4/8/08, Gustaf Rydevik [EMAIL PROTECTED] wrote: Hi all, In lattice plots, is there any option to position the panel strips with text below each subgraph, instead of above? No. -Deepayan i.e. in: Depth - equal.count(quakes$depth, number=8, overlap=.1) xyplot(lat ~ long | Depth, data = quakes) ,is there any way to make Depth appear below the subgraphs, instead of above? I've been looking through the lattice documentation and the list archive but have not found such a thing. Many thanks in advance, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re garding Garch prediction mechanism
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. In particular, I suggest you use a published data set from a package like tseries, fEcofin, or FinTS. If you want to compare results with Matlab, please provide code you used in both R and Matlab, along with an explanation of which versions of each you used including any add-on packages. For R, you can get this version information with 'sessionInfo()'. Please include comparable information from Matlab. Without this, it is usually more difficult for someone to understand your question, and any answers are less likely to help you. Hope this helps. Spencer rocky787 wrote: Hi, I am having some confusion.It has been said that we can only estimate the future values using meanForecast +/- 2*standardDeviation. with 95% confidence.This means using this garch model we can only have a upper and lower limit of the values within which the next actual value is expected to lie.Then how come in research papers they plot the actual and predicted value so neatly.The simple problem i am finding is that i am having say 200 data values in time series and say i take 150 values for model parameter estimation.Now what i get in matlab is the mean and variance forecast of 51,52nd etc intervals.Now i need to plot the graph showing the closenes of the predicted and actual return values and not the variance .How can i do so???Plzz help in this regard.Will be of great help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RSPerl threads
Hi all, I'm trying to use the RSPerl module in a script that uses threads. I am able to call R functions without a problem when I don't use threads. However, using threads, I get varying errors depending on how I call the R functions. If I call the R::initR function in the boss thread and then try to call R functions from a worker thread, I get the following error: Error: C stack usage is too close to the limit Caught error in R::call() However, if I move the use declarations for R RReferences to the worker thread, along with the initR call, I get this: Fatal error: R home directory is not defined I've attached some code for your reference. Is there any way to get this module working with Perl threads? Thanks in advance for your help. -Jay #!/usr/bin/perl use warnings; use strict; #use R; #use RReferences; #R::initR(--silent); use threads; use threads::shared; use Thread::Queue; our $queue : shared = Thread::Queue-new; our $hold : shared; my $thr = threads-new (\command_runner); $hold =1; $queue-enqueue(ls); while ($hold) { sleep(1); } $queue-enqueue(end); $thr-join(); # Thread for processing functions sub command_runner { use R; use RReferences; R::initR(--silent); my $run = 1; # run until return while ($run) { # This call will block until the main thread sends the job my $job = $queue-dequeue; print j: $job\n; if ($job eq ls){ R::ls(); } elsif ($job eq end) { $run = 0 } { lock $hold; $hold = 0; } } } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RSPerl threads II
My previous post seems to have been eaten by the server because of embedded code. You can now find that code at: http://tinyurl.com/3o88j2 I aoplogize for the double-posting... -Jay Hi all, I'm trying to use the RSPerl module in a script that uses threads. I am able to call R functions without a problem when I don't use threads. However, using threads, I get varying errors depending on how I call the R functions. If I call the R::initR function in the boss thread and then try to call R functions from a worker thread, I get the following error: Error: C stack usage is too close to the limit Caught error in R::call() However, if I move the use declarations for R RReferences to the worker thread, along with the initR call, I get this: Fatal error: R home directory is not defined I've attached some code for your reference. Is there any way to get this module working with Perl threads? Thanks in advance for your help. -Jay __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Practical Data Limitations with R
Millions of rows can be a problem if all is loaded into memory, depending on type of data. Numeric should be fine but if you have strings and you would want to process based on that column (string comparisons etc) then it would be slow. You may want to combine sources outside - stored procedures maybe - and then load to R. Joining of data within R code can be costly if you are selecting from a data frame based on a string. I have, personally, run into 'out of memory' problems only beyond 1G of data on a windows 32 bit system with 3 GB RAM. That happens with C++ also. Regarding speed, I find MATLAB faster than R for matrix operations. In other areas they are in same range. R is much better to program as it is has a much more complete programming language. R can use multiple cores / cpus with a suitable multi threaded linear algebra library. Though this will only be for linear algebra operations. 64 bit binary for R is not available for windows. Sankalp Jeff Royce wrote: We are new to R and evaluating if we can use it for a project we need to do. We have read that R is not well suited to handle very large data sets. Assuming we have the data prepped and stored in an RDBMS (Oracle, Teradata, SQL Server), what can R reasonably handle from a volume perspective? Are there some guidelines on memory/machine sizing based on data volume? We need to be able to handle Millions of Rows from several sources. Any advice is much appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] post hoc statistical power
On Tue, 8 Apr 2008, Yuelin Li wrote: I remember reading about post hoc statistical power on R-help. But I can't seem to find them with RSiteSearch(post hoc statistical power) and variations of it. I would like to learn more about post hoc statistical power, its meaningfulness, advantages and disadvantages. I thought the issue was settled after Tukey's 1993 paper about post hoc statistical power being essentially meaningless once the experiment has been done. But they seem to be used, and sometimes encouraged (e.g., http://www.informaworld.com/smpp/content~content=a787469931). I do not intend to start a debate. I simply would like to learn more. Can anyone suggest a few articles? Thanks, Start here: Hoenig, John M. and Heisey, Dennis M. (2001) The abuse of power: The pervasive fallacy of power calculations for data analysis The American Statistician, 55, 19-24 Keywords: bioequivalence testing; BURDEN OF PROOF; OBSERVED POWER; RETROSPECTIVE POWER ANALYSIS; statistical power; Type II error CISid: 222509 HTH, Chuck Yuelin. Tukey JW. Tightening the clinical trial. Control Clin Trials. 1993;14:266-285. = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help me about singular error nls
jarod_v6 jarod_v6 at libero.it writes: I have that problem: this is file : PBS.txt Time RFU 0.27.3021 0.080026.1565 rm(list=ls()) print(ls()) #carica Dati con file di testo b -read.table(PBS.txt, sep=\t, header= TRUE) print(b) b nlmod1 - nls(RFU ~ A + (B+c*Time)/(1+exp(k*(e-Time))), data = b, start = list(A = 1, c = 1, B = 1, k =1, e = 1), trace = TRUE)) Thanks for providing a self-running example. There are two reasons for the lack of success. First, your starting values were totally off (the curve was rising strongly). Always plot the curve with the starting values together with the data to be fitted, to be sure, that your are at least coming close. Note that your data level off at around 22, so having A=22 is a good first choice. With the starting values shown below, the iteration starts quite well, but ends in a step factor reduced ... error. This almost always means: you want to much from your data. The algorithm cannot decide, what combination of the FIVE coefficients you ask to be estimated is the right one. You have a very smooth curve with little personality, so I would never use more than 2 or 3 coefficients to fit these. Or, less polite: your model is nonsense; try a simpler one, for example as shown below. And in case you are sure that your model is the only truth: if you have a whole set of curves, for example from a series of pharmacological tests, you might try nlme; it may work, but not from the beginning. In case you should argue that software XX does give results (I know a few packages that do): these are wrong. If you are lucky, the software gives you the standard error of the coefficients, possibly in the order of 10^7, which should make you think it over. Dieter b -read.table(PBS.txt, sep=\t, header= TRUE) print(b) b A = 22 c = -0.1 B = 10 k = -2 e = 0 Time = seq(0,2,by=0.1) plot(b$Time,b$RFU) lines(Time, A + (B+c*Time)/(1+exp(k*(e-Time nlmod1 - nls(RFU ~ A + (B+c*Time)/(1+exp(k*(e-Time))), data = b,start = list(A = A, c = c, B = B, k =k, e = e), trace = TRUE) nlmod2 - nls(RFU ~A - B*exp(k*Time), data = b,start = list(A = A, B = B, k =k), trace = TRUE) lines(b$Time,predict(nlmod2),col=red) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
Yes, based on that it seems understandable although initially suprising. On Tue, Apr 8, 2008 at 12:56 PM, Duncan Murdoch [EMAIL PROTECTED] wrote: On 4/8/2008 7:42 AM, Gabor Grothendieck wrote: I think what he is referring to is that findGlobals lists mean under variables rather than functions when you do this with his f: findGlobals(f, FALSE) $functions [1] { apply $variables [1] mean Yes, I understood that, and I think it's reasonable behaviour. findGlobals analyzes the syntax, not the semantics. Duncan Murdoch On Tue, Apr 8, 2008 at 7:14 AM, Duncan Murdoch [EMAIL PROTECTED] wrote: Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. findGlobals doesn't try to tell what mean is; it's just reporting on how you've used it. Your usage means that the interpreter will treat it as a variable, getting a copy of its value and passing it as an argument to apply. (That's an oversimplification, of course: it's very unlikely that an actual copy will be made, but it will act as if one was made.) Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You can still use it to detect that kind of typo, but you need a second step where you check whether the globals exist in the environment of the function or not. That test won't be perfect either: it will miss cases where you meant to type a local variable, but by mistake typed the name of some global. Most uses of mean as a variable would fall into that category; unfortunately (?) apply means some of them are legitimate. I think the best you'll ever be able to do is to get some suggestions of errors, with both false positives and false negatives. If there were cases where some usage was definitely an error, the parser would probably catch it. Duncan Murdoch Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Metropolis acceptance rates
Hi Michael, If you are using the standard logit or probit model, it is fairly easy to save the acceptance rate after each draw. I would recommend using the bayesm package as the source code is easy to manipulate. For instance in the probit function (rbprobitGibbs), you need to include a couple of lines of code to save the acceptance rate. I'm sure it is possible with the other packages as well. HTH Anup Michael Margolis [EMAIL PROTECTED] wrote: Is there a way to recover Metropolis-step acceptance rates AFTER completing posterior draws? The immediate application is in the probit.bayes and logit.bayes models used by Zelig... which I believe is merely calling MCMCpack. So one strategy, to which I am fixing to resort, is to call, say, MCMClogit with verbose set to mcmc (or mcmc divided by an integer) and then look at my screen. But it seems odd that this datum is not being put into output objects, so I wonder if I'm missing something. Plus sometimes I can save the output object, but then the power goes out and what's on screen is gone forever. Thanks, Michael Michael Margolis Profesor Investigador Escuela de Economía Universidad de Guanajuato UCEA-Campus Marfil, Fracc 1 El Establo, Guanajuato, Gto. CP 36250 Mexico (52)(473) 735 29 25 Ext. 2858 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and confidence intervals
Cristian Carranza cristiancarranza_1 at hotmail.com writes: After fitting a mixed effects model to repeated measurements data set, and after several unsuccessful atempts to make a simple plot of the confidence interval for the fitted model, I gave up and now I am asking for help in this useful list. Could anyone be so kind to give me some code lines in order to make a plot of the fitted equation and the correspondent confidence interval? The fitted equation is simple: use predict in its variations. For the confidence interval, most people on the list will ask back what it means. But I know my colleagues, they or their reviewers insist on having error bar in the graphics, and don't care about the interpretation. Dimitri has given an approach that could be used to produce some reviewer-satisfaction plots limited borborygmy. http://finzi.psych.upenn.edu/R/Rhelp02a/archive/118174.html Note that his method is meant to estimate well-defined confidence intervals for the coefficients, but you can use the profiled fits and compute the confidence intervals at the data points. Alternatively, you could use mcmc to get a range of curves for averaging. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot function / par() settings
Dear all; I'm trying to create a 2 x 3 plot (something I know like lattice can do better) using the plot function. However; I'm not sure how to make the width of the plots to be the same on each column. I guess the answer maybe obvious but I haven't been able to figure it out. I'll appreciate any suggestion. Here is the (highly inefficient) code for the first row: par(mfrow = c(2, 3)) par(omi = c(0.60, 0.60, 0.60, 0.10)) par(mai = c(0.00, 0.50, 0.50, 0.00)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, col = blue); axis(3, at = seq(1:5), labels = rep(, 5)) par(mai = c(0.00, 0.00, 0.50, 0.00)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = seq(1:5)) par(mai = c(0.00, 0.00, 0.50, 0.50)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = rep(, 5)) axis(4, at = seq(1:5), labels = rep(, 5)) Thanks PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotmath overstrikes in output on a Linux system
On Tue, Apr 8, 2008 at 4:29 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: Looks likes the the laptop is using different fonts with incorrect font metrics. This could happen because it has a different screen resolution, or one of the systems is set to use scalable fonts or it is giving metrics for one fonts and using another or BTW, this is probably nothing to do with plotmath per se -- the issue is most likely the device (presumably X11(), but you did not say) and its handling of font metric requests. It looks to me as if the widths of normal text strings (and not symbols) is the problem. I have seen something similar where there was a long-standing bug in plotmath (fixed in r44534), but this only manifested itself when text was kerned, which the X11() device in 2.6.2 does not ask for. My best guess is that the font selected is (to use the technical terms) returning glyph widths without left/right bearings. Please try 2.7.0 beta, which has a different X11() device (and the above bug fixed). That ought to solve the problem for you, but otherwise you'll need to debug what the X11 metricInfo callback is giving you. I installed R-latest from the beta directory. Following your leads, I've got some information that may help you see if this is purely an isolated X11 problem on my computer or something you might fix in R. On screen, I see this bad looking plot: http://pj.freefaculty.org/R/png-screenshot-notOK.png Using a png device to write the graph to file, either with dev.copy(png ... ) or png (file = ) plot ( ) dev.off() The saved file is GOOD: http://pj.freefaculty.org/R/png-output-OK.png http://pj.freefaculty.org/R/png_dev_copy_OK.png More details about this laptop. The display has a native resolution of 1680x1050, and IF I put the X11 display at that resolution, then the on-screen X11 display of that particular graph is fine. However, if I change the display to another value, the one I prefer is 1400x1050, and re-start, then I see the bad on-screen display. In both cases, however, I have confirmed that the DPI settings in xdpyinfo are correctly representing pixels/inches. That leads me back to Prof. Ripley's suggestion that I've got a mismatch in fonts between what X11 really wants and what it gets. The font configuration on these systems is becoming so complicated I'm completely bewildered, as Fedora has both traditional linux font server and xft fonts and pango/cairo and freetype and apparently anything else they can think of. I'm going to keep studying the R admin guide to see how to debug it. off topic Finally, something came up that I don't want to forget. It is an RPM building question for R fans. This concerns my experience with R-beta-20080407.r45159. R built installed without any apparent trouble, and I decided to try to make an RPM package of it so other Fedora people can test. I took the spec file from the existing Fedora 8 updates R package, and made a few changes to suit the new file name for R, and I built RPMS. The build proceeds without noticeable trouble, but when I try to install the RPM, I get this error $ sudo rpm -ivh R-2.7.20080407.r45159-1fc8.1.i386.rpm Password: error: Failed dependencies: perl(R::Dcf) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Logfile) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Rd) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Rdconv) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Rdtools) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Utils) is needed by R-2.7.20080407.r45159-1fc8.1.i386 perl(R::Vars) is needed by R-2.7.20080407.r45159-1fc8.1.i386 As you can see, the package does have the perl modules, but something has gone wrong in the scripting process that takes note of them: $ rpm -qilp R-2.7.20080407.r45159-1fc8.1.i386.rpm | grep perl /usr/share/R/perl /usr/share/R/perl/File /usr/share/R/perl/File/Copy /usr/share/R/perl/File/Copy/Recursive.pm /usr/share/R/perl/R /usr/share/R/perl/R/Dcf.pm /usr/share/R/perl/R/Logfile.pm /usr/share/R/perl/R/Rd.pm /usr/share/R/perl/R/Rdconv.pm /usr/share/R/perl/R/Rdlists.pm /usr/share/R/perl/R/Rdtools.pm /usr/share/R/perl/R/Utils.pm /usr/share/R/perl/R/Vars.pm /usr/share/R/perl/Text /usr/share/R/perl/Text/DelimMatch.pm /usr/share/R/perl/build-help-windows.pl /usr/share/R/perl/build-help.pl /usr/share/R/perl/massage-Examples.pl I'm contacting the RPM maintainer from redhat to see if he knows. But if you know, please let me know. -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fit points to plane
Is there a function for obtaining the best-fitting plane from a large number of points (something like 25.000 points)? Thank you... Luca -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Gioca con i Supereroi Marvel sul cellulare! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7752d=8-4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] diagonally fill a rectangle with color gradient
Hi, Is it possible to diagonally fill a rectangle with a color gradient? I noticed that the gradient.rect of plotrix could fill a rect either up and down or from side to side. I am looking for something similar but fills diagonally instead, e.g., from the upper left corner to the bottom right. Does anyone know how to do it in R? Thanks, -- Tom [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] distance matrix as text file - how to import?
Dear all, I have -hopefully- a tiny problem. I was sent a text file containing a distance matrix à la: 1 2 3 4 5 6 Now I wanted to import these data into a dist object to, let's say, do 'plot(hclust(v))'. My first naïve approach was to scan the text file in order to get a vector v. Then I did: class(v) - dist attr(v, Size) - 4 But, of course, I got this: 1 2 4 3 5 6 I wonder if there's an elegant way to do it. The only way I know of is very very stony one. I'd be very appreciated for any hint. Cheers, --Hans __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Combining many csv files into one and adding a column with an id of each csv file read
Dear R experts, I have been looking into the help-pages and old questions from the R-Help site, but the options offered there don't seem to work in my case. First of all, I am working on Windows XP, using R version 2.6.2. I am attaching two csv files as an example of how the data I am traying to put together is delivered to us. On the first row of every csv file is the name of the file, along with the pathfile. This is what I have been doing with every csv files (per seprate), which of course is not the most efficient way to do it; basically, it reads the csv file, then deletes the first 3 rows and some columns that we don't need and finally I add another column that identifies all the rows of the csv file as belonging to one subject only, I have to do this for further manipulations with all the data: filename-'1_504_d0.csv' dat-read.csv(filename, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat-dat[,1:3] dat$id-as.character(filename) Since I have multiple csv files to read and I need to have them consolidated in one data frame, how can I apply the above manipulations to all the csv files and at the same time put them in one files? At the end, I need a big data frame that has 4 columns 'Time', 'T1', T2', 'id' I hope I have provided enough information. Thank you in advance for your help, Judith [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reading in a Fortran binary array
Greetings -- I'd like to avoid converting a Fortran array of floats into ASCII and back reading it in R. Furthermore it's much faster to dump large arrays in binary, as they take up much less space with full precision -- many decimal points take up many bytes in ASCII versus four or eight per float in raw. Is there a way to read such a Fortran unformatted file back into R? Cheers, Alexy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] simple graphing question
#copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot function / par() settings
On Tue, Apr 8, 2008 at 12:47 PM, Pedro Mardones [EMAIL PROTECTED] wrote: Dear all; I'm trying to create a 2 x 3 plot (something I know like lattice can do better) using the plot function. However; I'm not sure how to make the width of the plots to be the same on each column. I guess the answer maybe obvious but I haven't been able to figure it out. I'll appreciate any suggestion. Here is the (highly inefficient) code for the first row: Dear Pedro: I played around with the layout function and I think this does what you want. Because I set the widths exactly, there is no squishing of the outer plots anymore. Try this: nf - layout(matrix(c(1,2,3,4,5,6),2,3,byrow=TRUE), widths=c(lcm(5), lcm(5), lcm(5)), heights=c(1,1), TRUE) layout.show(nf) par(mar=c(1,0,0,0)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, col = blue); axis(3, at = seq(1:5), labels = rep(, 5)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = seq(1:5)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = rep(, 5)) axis(4, at = seq(1:5), labels = rep(, 5)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, col = blue); axis(3, at = seq(1:5), labels = rep(, 5)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = seq(1:5)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = rep(, 5)) axis(4, at = seq(1:5), labels = rep(, 5)) par(mfrow = c(2, 3)) par(omi = c(0.60, 0.60, 0.60, 0.10)) par(mai = c(0.00, 0.50, 0.50, 0.00)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, col = blue); axis(3, at = seq(1:5), labels = rep(, 5)) par(mai = c(0.00, 0.00, 0.50, 0.00)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = seq(1:5)) par(mai = c(0.00, 0.00, 0.50, 0.50)) plot(1:5, 1:5, xlab = , ylab = , xaxt = n, yaxt = n, col = red); axis(3, at = seq(1:5), labels = rep(, 5)) axis(4, at = seq(1:5), labels = rep(, 5)) Thanks PM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple graphing question
Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple graphing question
On Tue, Apr 8, 2008 at 3:52 PM, stephen sefick [EMAIL PROTECTED] wrote: Sorry, to have the x-axis to go from 200 to 0 or to reverse the x points- the line starts on the left hand side of the graph at x=215, y=0.10301103 ... and end with x=61, y=0.13828610. does this make sense? reverse order x-axis in excel is what I would use if this helps On Tue, Apr 8, 2008 at 3:43 PM, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple graphing question
This is maybe not the most elegant way, but it does de job. You first put f$RM values in negative form. Then you plot your graph without the x axis labels. After, you create the labels you want. Try this : f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) f$rms=f$RM*(-1) plot(f$TKN~f$rms ,xaxt=n, type=b) axis(side=1, seq(min(pretty(f$rms,n=3)),max(pretty(f$rms,n=3)),50), labels=seq(min(pretty(f$rm,n=3))*(-1),max(pretty(f$rm,n=3))*(-1),-50)) Benoit Bruneau Canada On Apr 8, 2008, at 3:52 PM, stephen sefick wrote: On Tue, Apr 8, 2008 at 3:52 PM, stephen sefick [EMAIL PROTECTED] wrote: Sorry, to have the x-axis to go from 200 to 0 or to reverse the x points- the line starts on the left hand side of the graph at x=215, y=0.10301103 ... and end with x=61, y=0.13828610. does this make sense? reverse order x-axis in excel is what I would use if this helps On Tue, Apr 8, 2008 at 3:43 PM, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fit points to plane
On 9/04/2008, at 8:28 AM, Luca Penasa wrote: Is there a function for obtaining the best-fitting plane from a large number of points (something like 25.000 points)? ?lm ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Split
I have data in the form of a column such as 1234. 2345. 3435. 4343. I want to have the data in this form ..i.e to remove the dot at the end of each number above. 1234 2345 3435 4343 I am trying to use split but it is not working. Any suggestions? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] save multiple pages lattice-plot
Dear R-helper, I am trying to save some plots I made with lattice, but I have several pages printed for each call. My layout is something like c(col=2,row=4,pages=12) and I didn't find a way to save those plots, because I am usually using savePlot() which from what I saw can only save one page/device a the time. Is there an easy way to save all the plots? or should I use a loop and cut my dataframe along my conditioning variables to make different calls and then save 1 page per call? Thanks for your help, Katell -- Katell HAMON Doctorante / PhD student IFREMER-Brest Departement d'économie maritime / Marine Economics Department Technopole Brest Iroise B.P. 70 29280 Plouzané France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Separate y-limits in xYplot panels II
Hello, I have been trying to use xYplot in Hmisc to graph plots, allowing each panel to have a y-axis dependent on the data in the panel. Following the advice from the R-Help list, message: [R] separate y-limits in xYplot panels on Wed, 30 May 2007 08:12:06 -0700 (PDT), I used scales=list(y=list(relation=free). However, it does not seem to work. Please see below code, where the scale of the y-axis of the 2 panels stays the same despite the scales function. Does anyone know how to get around this? Thanks, John x1=seq(1,30,0.5) y1=x1^2 y2=10*(x1^2) ycomb=c(y1,y2) y.up=ycomb+0.1*ycomb y.low=ycomb-0.1*ycomb grp=rep(c(1,2),each=length(x1)) dat=as.data.frame(cbind(ycomb, y.up, y.low, grp, rep(x1,2))) colnames(dat)=c(ycomb,y.up,y.low,grp,x1) with(dat, xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp), data=dat,type=l, method=bands, scales=list(y=list(relation=free), x=list(alternating=c(1,1,1) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with NA data when computing standard error
Hey, I want to compute means and standard errors as two tables like this: se-function(x)sqrt(var(x)/length(x)) object1-as.data.frame.table(tapply(Data[Year==1999],na.rm=T,list(Group[Year==1999],Season[Year==1999]),mean)) object2-as.data.frame.table(tapply(Data[Year==1999],na.rm=T,list(Group[Year==1999],Season[Year==1999]),se)) Part of the data is labeled as NA, therfore the na.rm=T. I succeed in creating the table for the means, but not for the standard errors. The message is Error in FUN(X[[1L]], ...) : unused argument(s) (na.rm = TRUE). Does anyone have an idea how to get the standard error computed? Thx! -- View this message in context: http://www.nabble.com/Problem-with-NA-data-when-computing-standard-error-tp16569057p16569057.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fit points to plane
But probably not a good idea, as there are likely to be some scientfically interesting local inhomogeneities that an appropriate nonparametric smoother (e.g. splines,...) could reveal. -- Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rolf Turner Sent: Tuesday, April 08, 2008 1:16 PM To: Luca Penasa Cc: r-help@r-project.org Subject: Re: [R] fit points to plane On 9/04/2008, at 8:28 AM, Luca Penasa wrote: Is there a function for obtaining the best-fitting plane from a large number of points (something like 25.000 points)? ?lm ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] simple graphing question
On Tue, Apr 8, 2008 at 2:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? Hello, Stephen: It appears you might be new in R, so let me point out a couple of things. First, this works: f - data.frame( TKN = c(0.103011025, 0.018633208, 0.104235702,0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61), row.names = 25:29) plot(TKN~RM, data=f, type=b, xlim=rev(range(f$RM))) Note that I've created your data frame in a more usual way and I've reversed the x axis in the plot by reversing the range of the X variable. I've also used the data option to plot Second, I had reversed an axis before, but I quickly learned how by typing the following command: RSiteSearch(reverse axis) That opened up the web browser and it listed many items, the second of which was this: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/66958.html thread, the title of which is How to reverse the sequence of axis Y ? Generally, if you try RSiteSearch() and don't find what you need after exploring a page or two of threads, then you can post here and ask questions without people saying go read the posting guide before posting questions. Good luck PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Smoothing 3 D data
Hey. I have a set of data points (x1,y1,z1; x2,y2,z2;...xn,yn,zn). I need to smooth these in 3D. For example if these were in 2 D then one would use inverse distance weighting or moving averages. Does anyone know of any funtion in R that can be used to do this (Using 3D data as mine)? -- View this message in context: http://www.nabble.com/Smoothing-3-D-data-tp16571189p16571189.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] diagonally fill a rectangle with color gradient
Hi tom soyer wrote: Hi, Is it possible to diagonally fill a rectangle with a color gradient? I noticed that the gradient.rect of plotrix could fill a rect either up and down or from side to side. I am looking for something similar but fills diagonally instead, e.g., from the upper left corner to the bottom right. Does anyone know how to do it in R? Do you mean something like this ... ? library(grid) pushViewport(viewport(width=.5, height=.5, clip=on)) pushViewport(viewport(width=2, height=2, angle=45)) grid.rect(y=100:1/100, just=top, gp=gpar(col=NA, fill=colorRampPalette(c(blue, green), space=Lab)(100))) 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fit points to plane
Rolf Turner wrote: On 9/04/2008, at 8:28 AM, Luca Penasa wrote: Is there a function for obtaining the best-fitting plane from a large number of points (something like 25.000 points)? ?lm what does it mean? ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ## -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Scopri le tue passioni con Leonardo.it! * Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7614d=8-4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fit points to plane
Bert Gunter wrote: But probably not a good idea, as there are likely to be some scientfically interesting local inhomogeneities that an appropriate nonparametric smoother (e.g. splines,...) could reveal. ok... im working on laser scanner cloud of points... the model im working with is something like a plane... i need to project the points over a straight plane so i think it would be a good idea to use the best-fitting plane for this. maybe is there a function to decimate the points?? so i can use this function: http://www.csse.uwa.edu.au/~pk/research/matlabfns/Robust/fitplane.m starting it on 25000 points give an out of memory... sorry for my english :-) thanks -- Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rolf Turner Sent: Tuesday, April 08, 2008 1:16 PM To: Luca Penasa Cc: r-help@r-project.org Subject: Re: [R] fit points to plane On 9/04/2008, at 8:28 AM, Luca Penasa wrote: Is there a function for obtaining the best-fitting plane from a large number of points (something like 25.000 points)? ?lm ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Scopri le tue passioni con Leonardo.it! * Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7613d=8-4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to check if a variable is preferentially present in a sample
Hi Tania, I think it could be. I tried a solution based on your data set using a chi-squared approach. Here is what I got: # # Data set set.seed(123) d - data.frame(cbind(val=rnorm(1:10)^2, group=sample(LETTERS[1:5],100,repl=TRUE))) d[,val]-as.numeric(as.character(d$val)) # Ranking d in decreasing order based on val and counting the number of observation in each group TABLE=table(d[order(val,decreasing=TRUE),][1:10,group]) TABLE A B C D E 3 2 3 1 1 # Chi-squared cht=chisq.test(TABLE) cht Chi-squared test for given probabilities data: TABLE X-squared = 2, df = 4, p-value = 0.7358 cht$p.value [1] 0.7357589 Hope this helps, Jorge On Tue, Apr 8, 2008 at 11:24 AM, Tania Oh [EMAIL PROTECTED] wrote: Dear All, I do apologise if this question is out of place for this list but I've tried searching mailing lists and read Introductory Statistics with R by Peter Dalgaard, but couldn't find any hints on solving my question below: I have a data frame (d) of values which I will rank in decreasing order of val. Each value belongs to a group, either 'A', 'B', 'C', 'D', or 'E'. I then take the first 10 entries in data frame 'd' and count the number of occurrences for each of the groups. I want to test if certain groups occur more frequently than by chance in my first 10 entries. Would a chi-square test or a hypergeometric test be more suitable? If neither, what would be an alternative solution in R? Below is my data: ## data L5 - LETTERS[1:5] d - data.frame(cbind(val= rnorm(1:10)^2, group=sample(L5,100, repl=TRUE))) str(d) ##'data.frame': 100 obs. of 2 variables: ##$ val : Factor w/ 10 levels 0.000169268449333046,..: 10 3 5 6 1 2 7 8 4 9 ... ##$ group: Factor w/ 5 levels A,B,C,D,..: 4 4 4 5 3 1 5 2 1 2 ... Many thanks in advance and apologies again, tania D. phil student Department of Physiology, Anatomy and Genetics University of Oxford __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] distance matrix as text file - how to import?
On Tue, Apr 8, 2008 at 1:50 PM, Hans-Jörg Bibiko [EMAIL PROTECTED] wrote: Dear all, I have -hopefully- a tiny problem. I was sent a text file containing a distance matrix à la: 1 2 3 4 5 6 Try this! I put your test data in text.txt and voila: mat - matrix(0, 3,3) mat[row(mat) = col(mat)] - scan(test.txt) I found this Idea after RSiteSearch(scan triangular) led to this item as the very first link: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/22369.html PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with NA data when computing standard error
Hi there, Perhaps se-function(x)sqrt(var(x,na.rm=T)/sum(!is.na(x))) object1-as.data.frame.table(tapply(Data[Year==1999],list(Group[Year==1999],Season[Year==1999]),mean)) object2-as.data.frame.table(tapply(Data[Year==1999],list(Group[Year==1999],Season[Year==1999]),se)) Hope this helps, Jorge On Tue, Apr 8, 2008 at 1:44 PM, LeCzar [EMAIL PROTECTED] wrote: Hey, I want to compute means and standard errors as two tables like this: se-function(x)sqrt(var(x)/length(x)) object1-as.data.frame.table(tapply(Data[Year==1999],na.rm=T,list(Group[Year==1999],Season[Year==1999]),mean)) object2-as.data.frame.table(tapply(Data[Year==1999],na.rm=T,list(Group[Year==1999],Season[Year==1999]),se)) Part of the data is labeled as NA, therfore the na.rm=T. I succeed in creating the table for the means, but not for the standard errors. The message is Error in FUN(X[[1L]], ...) : unused argument(s) (na.rm = TRUE). Does anyone have an idea how to get the standard error computed? Thx! -- View this message in context: http://www.nabble.com/Problem-with-NA-data-when-computing-standard-error-tp16569057p16569057.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading in a Fortran binary array
See ?readBin The format of a Fortran unformatted file is compiler- and OS-dependent, but if you know what it is, readBin() can read it. On Tue, 8 Apr 2008, Alexy Khrabrov wrote: Greetings -- I'd like to avoid converting a Fortran array of floats into ASCII and back reading it in R. Furthermore it's much faster to dump large arrays in binary, as they take up much less space with full precision -- many decimal points take up many bytes in ASCII versus four or eight per float in raw. Is there a way to read such a Fortran unformatted file back into R? Cheers, Alexy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] save multiple pages lattice-plot
On 4/8/08, Katell HAMON [EMAIL PROTECTED] wrote: Dear R-helper, I am trying to save some plots I made with lattice, but I have several pages printed for each call. My layout is something like c(col=2,row=4,pages=12) and I didn't find a way to save those plots, because I am usually using savePlot() which from what I saw can only save one page/device a the time. Is there an easy way to save all the plots? Use a suitable graphics device: e.g., see ?png and ?pdf -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with NA data when computing standard error
On Tue, Apr 8, 2008 at 12:44 PM, LeCzar [EMAIL PROTECTED] wrote: Hey, I want to compute means and standard errors as two tables like this: se-function(x)sqrt(var(x)/length(x)) The missings are not your main problem. The command var computes the variance-covariance matrix. Some covariance values can be negative. Trying to take square roots is a mistake. For example, run example(var) to get some matrices to work with. C1[3,4] - NA C1[3,5] - NA Observe you can calculate var(C1, na.rm=T) but you cannot take sqrt of that because it would try to apply sqrt to negative values. To get the standard errors, it is necessary to reconsider the problem, do something like diag(var(C1, na.rm=T)) That will give the diagonals, which are positive, so sqrt(diag(var(C1, na.rm=T))) Works as well. But you have the separate problem of dividing each one by the square root of the length, and since there are missings that is not the same for every column. Maybe somebody knows a smarter way, but this appears to give the correct answer: validX - colSums( ! is.na(C1)) This gives the roots: sqrt(validX) Put that together, it seems to me you could try se - function(x) { myDiag - sqrt(diag(var(x, na.rm=T))) validX - colSums(! is.na(x)) myDiag/sqrt(validX) } That works for me: se(C1) Fertility Agriculture ExaminationEducation 50.740226 110.80861439.39061139.303898 Catholic Infant.Mortality 328.272207 4.513863 -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
Hi Luke Thanks for all these explanation, things are clearer. Let me go back on my initial problem, that was, as a programmer, I would like to have a tool to detect typo by detecting globals variables: I get that findGlobals is not design for that. I did not realy understand the use of checkUsage (sorry for that, I am not a high level programmer). But I find an example on which checkUsage does not detect the typo either: mObjBis - 3 f - function(myOb){ myObBis - myOb^2 plot(myObBis) return(mObjBis) } checkUsage(f,all=TRUE) So, my question is a more general question : is there a function that can detect global variable with exclusion of the function and the reserved word? For example: g - function(x)return(x+pi) we don't want pi to be considere as a global variable since it is a constant... Is there a function that can deal with that ? Christophe On Tue, 8 Apr 2008, Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. You are missing some points about R and findGlobals. In R, functions are first class values: they can be assigned to variables, passed as arguments, and returned as results, just like vectors. In contrast to many other languages there is not special mechanism for defining functions and associating them with a name -- the way you define a function is foo - function(...) ... which creates a function value and assigns it to a variable. findGlobals just looks at the function body and arguments and determines which of the variables used would have their definitions looked up in the global environment if this code is run. It does not try to detect which of these have values or not, never mind what the types of those falues are. The result returned by findGlobals with merge=FALSE separates into variables that are explicitly used as funcitons, i.e foo in foo(x) and ones that are not. One could argue that findGlobals should know enough about apply() to realize that the FUN argument is implicitly used as a function; if this change were made then apply(x, 2, pi) pi would be listed as a function because it is _used_ that way. Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You need to do some extra work to get this -- checking which globals have values, and maybe whether those that are used as functions have values that are functions. checkUsage does this, among other things. For this example checkUsage produces checkUsage(f) anonymous: no visible binding for global variable ‘mObject’ luke Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] permutation test assumption?
Dear Thierry, Thanks for the reply. But as you may read in the paper http://bioinformatics.oxfordjournals.org/cgi/content/abstract/22/18/2244 when the sample sizes are not the same there may be an increase in the Type I error rate. Comments will be appreciated. Best regards, João Fadista De: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Enviada: ter 08-04-2008 15:27 Para: João Fadista; r-help@r-project.org Assunto: RE: [R] permutation test assumption? Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens João Fadista Verzonden: dinsdag 8 april 2008 15:18 Aan: r-help@r-project.org Onderwerp: [R] permutation test assumption? Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] permutation test assumption?
On Wed, 9 Apr 2008, João Fadista wrote: Dear Thierry, Thanks for the reply. But as you may read in the paper http://bioinformatics.oxfordjournals.org/cgi/content/abstract/22/18/2244 when the sample sizes are not the same there may be an increase in the Type I error rate. No, this is false and not what the reference above says. Please read more carefully. Comments will be appreciated. The basic assumption for permutation tests is exchangeability of the observations (regardless of sample sizes). The reference above describes a situation when this assumption is violated. Z Best regards, João Fadista De: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Enviada: ter 08-04-2008 15:27 Para: João Fadista; r-help@r-project.org Assunto: RE: [R] permutation test assumption? Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens João Fadista Verzonden: dinsdag 8 april 2008 15:18 Aan: r-help@r-project.org Onderwerp: [R] permutation test assumption? Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Overlapping distributions (populations) - assigning an individual to a population?
People, Say a particular measure of an attribute for individuals in different populations gives a set of overlapping normal distributions (one distribution per population). If I then measure this attribute in a new individual - how do I assess the likelihood of this new individual belonging to each of the different populations? Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Fax: +61:(0)2-8221-9599 E-mail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Separate y-limits in xYplot panels II
Hello, I have been trying to use xYplot in Hmisc to graph plots, allowing each panel to have a y-axis dependent on the data in the panel. Following the advice from the R-Help list, message: [R] separate y-limits in xYplot panels on Wed, 30 May 2007 08:12:06 -0700 (PDT), I used scales=list(y=list(relation=free). However, it does not seem to work. Please see below code, where the scale of the y-axis of the 2 panels stays the same despite the scales function. Does anyone know how to get around this? Thanks, John x1=seq(1,30,0.5) y1=x1^2 y2=10*(x1^2) ycomb=c(y1,y2) y.up=ycomb+0.1*ycomb y.low=ycomb-0.1*ycomb grp=rep(c(1,2),each=length(x1)) dat=as.data.frame(cbind(ycomb, y.up, y.low, grp, rep(x1,2))) colnames(dat)=c(ycomb,y.up,y.low,grp,x1) with(dat, xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp), data=dat,type=l, method=bands, scales=list(y=list(relation=free), x=list(alternating=c(1,1,1) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] permutation test assumption?
But in that paper they refer to another (http://www.bepress.com/cgi/viewcontent.cgi?article=1053context=ucbbiostat) where they say that permutation distribution produces an asymptotically correct null distribution if (i) the sample sizes are equal Best regards, João De: Achim Zeileis [mailto:[EMAIL PROTECTED] Enviada: qua 09-04-2008 0:26 Para: João Fadista Cc: ONKELINX, Thierry; r-help@r-project.org Assunto: Re: [R] permutation test assumption? On Wed, 9 Apr 2008, João Fadista wrote: Dear Thierry, Thanks for the reply. But as you may read in the paper http://bioinformatics.oxfordjournals.org/cgi/content/abstract/22/18/2244 when the sample sizes are not the same there may be an increase in the Type I error rate. No, this is false and not what the reference above says. Please read more carefully. Comments will be appreciated. The basic assumption for permutation tests is exchangeability of the observations (regardless of sample sizes). The reference above describes a situation when this assumption is violated. Z Best regards, João Fadista De: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Enviada: ter 08-04-2008 15:27 Para: João Fadista; r-help@r-project.org Assunto: RE: [R] permutation test assumption? Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens João Fadista Verzonden: dinsdag 8 april 2008 15:18 Aan: r-help@r-project.org Onderwerp: [R] permutation test assumption? Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] findGlobals on apply
On Wed, 9 Apr 2008, Christophe Genolini wrote: Hi Luke Thanks for all these explanation, things are clearer. Let me go back on my initial problem, that was, as a programmer, I would like to have a tool to detect typo by detecting globals variables: I get that findGlobals is not design for that. I did not realy understand the use of checkUsage (sorry for that, I am not a high level programmer). But I find an example on which checkUsage does not detect the typo either: mObjBis - 3 f - function(myOb){ myObBis - myOb^2 plot(myObBis) return(mObjBis) } checkUsage(f,all=TRUE) I don't see how a general tool can detect a problem here. If you know the only global variables you will ever use are functions then you can write your own tool to reflect that style, but for common styles there is no clear reason I can see to detect a problem here. A C compiler could not detect a problem here unless the function was declared to have a different return type than the global variable. So, my question is a more general question : is there a function that can detect global variable with exclusion of the function and the reserved word? For example: g - function(x)return(x+pi) we don't want pi to be considere as a global variable since it is a constant... But in R pi is a global variable. checkUsage doesn't warn about its use because it has a binding. Is there a function that can deal with that ? If you know what you want you can write one, something like myGlobals - function(f, exclude = c(pi, T, F)) { isGlobFun - function(s) ! (exists(s, .GlobalEnv) is.function(get(s,.GlobalEnv))) g - findGlobals(f) setdiff(g[sapply(g, isGlobFun)], exclude) } I would suggest you use this sort of thing in conjunction with checkUsage since that checks for other kinds of errors; for example look at what it does with the variant f - function(myOb){ myObBis - myOb^2 plot(mObjBis) return(mObjBis) } Best, luke Christophe On Tue, 8 Apr 2008, Christophe Genolini wrote: f - function(x){apply(x,2,mean)} findGlobals(f) mean is a global variable, so findGlobals gets it right. That sound strange to me: a variable is something that vary... mean does not vary. maen will ge an argument that is a line of x and will make some calculous on it, that is the comportement of a function. Of course, mean is an argument of an other function, but I do not think this is a reason good enouth to say that mean is a variable. You are missing some points about R and findGlobals. In R, functions are first class values: they can be assigned to variables, passed as arguments, and returned as results, just like vectors. In contrast to many other languages there is not special mechanism for defining functions and associating them with a name -- the way you define a function is foo - function(...) ... which creates a function value and assigns it to a variable. findGlobals just looks at the function body and arguments and determines which of the variables used would have their definitions looked up in the global environment if this code is run. It does not try to detect which of these have values or not, never mind what the types of those falues are. The result returned by findGlobals with merge=FALSE separates into variables that are explicitly used as funcitons, i.e foo in foo(x) and ones that are not. One could argue that findGlobals should know enough about apply() to realize that the FUN argument is implicitly used as a function; if this change were made then apply(x, 2, pi) pi would be listed as a function because it is _used_ that way. Furthemore, I use findGlobals to detect some typo. In f - function(myObject){return(mObject^2)} findGlobals will detect that mObject is a global so I know there is a typo somewhere. Considering mean as a globals do not let us use findGlobals this way. You need to do some extra work to get this -- checking which globals have values, and maybe whether those that are used as functions have values that are functions. checkUsage does this, among other things. For this example checkUsage produces checkUsage(f) anonymous: no visible binding for global variable ???mObject??? luke Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu__ R-help@r-project.org mailing list
Re: [R] Separate y-limits in xYplot panels II
Hi John, I think even with scales=list(y=list(relation=free) you have to specify the y-limits for each panel, i.e. add something like ylim=list(c(0,1200),c(0,1)) to your code. Best regards, Christoph Wednesday, April 9, 2008, 12:37:43 AM, you wrote: Hello, I have been trying to use xYplot in Hmisc to graph plots, allowing each panel to have a y-axis dependent on the data in the panel. Following the advice from the R-Help list, message: [R] separate y-limits in xYplot panels on Wed, 30 May 2007 08:12:06 -0700 (PDT), I used scales=list(y=list(relation=free). However, it does not seem to work. Please see below code, where the scale of the y-axis of the 2 panels stays the same despite the scales function. Does anyone know how to get around this? Thanks, John x1=seq(1,30,0.5) y1=x1^2 y2=10*(x1^2) ycomb=c(y1,y2) y.up=ycomb+0.1*ycomb y.low=ycomb-0.1*ycomb grp=rep(c(1,2),each=length(x1)) dat=as.data.frame(cbind(ycomb, y.up, y.low, grp, rep(x1,2))) colnames(dat)=c(ycomb,y.up,y.low,grp,x1) with(dat, xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp), data=dat,type=l, method=bands, scales=list(y=list(relation=free), x=list(alternating=c(1,1,1) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** Dr. Christoph Meyer Institute of Experimental Ecology University of Ulm Albert-Einstein-Allee 11 D-89069 Ulm Germany Phone: ++49-(0)731-502-2675 Fax:++49-(0)731-502-2683 Mobile: ++49-(0)1577-156-7049 E-mail: [EMAIL PROTECTED] http://www.uni-ulm.de/nawi/nawi-bio3.html *** ==End of original message text=== *** Dr. Christoph Meyer Institute of Experimental Ecology University of Ulm Albert-Einstein-Allee 11 D-89069 Ulm Germany Phone: ++49-(0)731-502-2675 Fax:++49-(0)731-502-2683 Mobile: ++49-(0)1577-156-7049 E-mail: [EMAIL PROTECTED] http://www.uni-ulm.de/nawi/nawi-bio3.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combining many csv files into one and adding a column with an id of each csv file read
Here is one way of doing it. Read the data into a list and then use 'do.call(rbind...': filenames - Sys.glob(*.csv) # however you get the list of file allData - lapply(filenames, function(.file){ dat-read.csv(filename, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat - dat[,1:3] dat$id-as.character(filename) dat# return the dataframe }) # combine into a single dataframe myDF - do.call(rbind, allData) On Tue, Apr 8, 2008 at 3:11 PM, Judith Flores [EMAIL PROTECTED] wrote: Dear R experts, I have been looking into the help-pages and old questions from the R-Help site, but the options offered there don't seem to work in my case. First of all, I am working on Windows XP, using R version 2.6.2. I am attaching two csv files as an example of how the data I am traying to put together is delivered to us. On the first row of every csv file is the name of the file, along with the pathfile. This is what I have been doing with every csv files (per seprate), which of course is not the most efficient way to do it; basically, it reads the csv file, then deletes the first 3 rows and some columns that we don't need and finally I add another column that identifies all the rows of the csv file as belonging to one subject only, I have to do this for further manipulations with all the data: filename-'1_504_d0.csv' dat-read.csv(filename, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat-dat[,1:3] dat$id-as.character(filename) Since I have multiple csv files to read and I need to have them consolidated in one data frame, how can I apply the above manipulations to all the csv files and at the same time put them in one files? At the end, I need a big data frame that has 4 columns 'Time', 'T1', T2', 'id' I hope I have provided enough information. Thank you in advance for your help, Judith [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combining many csv files into one and adding a column with an id of each csv file read
I blew it. Forgot to use the parameter. Here is the revised copy: filenames - Sys.glob(*.csv) # however you get the list of file allData - lapply(filenames, function(.file){ dat-read.csv(.file, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat - dat[,1:3] dat$id-as.character(.file) dat# return the dataframe }) # combine into a single dataframe myDF - do.call(rbind, allData) On Tue, Apr 8, 2008 at 7:12 PM, jim holtman [EMAIL PROTECTED] wrote: Here is one way of doing it. Read the data into a list and then use 'do.call(rbind...': filenames - Sys.glob(*.csv) # however you get the list of file allData - lapply(filenames, function(.file){ dat-read.csv(filename, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat - dat[,1:3] dat$id-as.character(filename) dat# return the dataframe }) # combine into a single dataframe myDF - do.call(rbind, allData) On Tue, Apr 8, 2008 at 3:11 PM, Judith Flores [EMAIL PROTECTED] wrote: Dear R experts, I have been looking into the help-pages and old questions from the R-Help site, but the options offered there don't seem to work in my case. First of all, I am working on Windows XP, using R version 2.6.2. I am attaching two csv files as an example of how the data I am traying to put together is delivered to us. On the first row of every csv file is the name of the file, along with the pathfile. This is what I have been doing with every csv files (per seprate), which of course is not the most efficient way to do it; basically, it reads the csv file, then deletes the first 3 rows and some columns that we don't need and finally I add another column that identifies all the rows of the csv file as belonging to one subject only, I have to do this for further manipulations with all the data: filename-'1_504_d0.csv' dat-read.csv(filename, header=F) dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)] names(dat)-c('time','T1','T2') dat-dat[,1:3] dat$id-as.character(filename) Since I have multiple csv files to read and I need to have them consolidated in one data frame, how can I apply the above manipulations to all the csv files and at the same time put them in one files? At the end, I need a big data frame that has 4 columns 'Time', 'T1', T2', 'id' I hope I have provided enough information. Thank you in advance for your help, Judith [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split
Assuming that this data is character, then this will work: (it removes the last period in the string) x - scan('clipboard', what='') Read 4 items x [1] 1234. 2345. 3435. 4343. sub(\\.$, , x) [1] 1234 2345 3435 4343 On Tue, Apr 8, 2008 at 11:30 AM, Kris Ghosh [EMAIL PROTECTED] wrote: I have data in the form of a column such as 1234. 2345. 3435. 4343. I want to have the data in this form ..i.e to remove the dot at the end of each number above. 1234 2345 3435 4343 I am trying to use split but it is not working. Any suggestions? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] permutation test assumption?
On Wed, 9 Apr 2008, João Fadista wrote: But in that paper they refer to another (http://www.bepress.com/cgi/viewcontent.cgi?article=1053context=ucbbiostat) where they say that permutation distribution produces an asymptotically correct null distribution if (i) the sample sizes are equal I haven't read that paper in detail (but so do you, it seems). From looking at abstract and intro, my understanding is that they also study the behaviour of tests under weaker assumptions than exchangeability. Z Best regards, João De: Achim Zeileis [mailto:[EMAIL PROTECTED] Enviada: qua 09-04-2008 0:26 Para: João Fadista Cc: ONKELINX, Thierry; r-help@r-project.org Assunto: Re: [R] permutation test assumption? On Wed, 9 Apr 2008, João Fadista wrote: Dear Thierry, Thanks for the reply. But as you may read in the paper http://bioinformatics.oxfordjournals.org/cgi/content/abstract/22/18/2244 when the sample sizes are not the same there may be an increase in the Type I error rate. No, this is false and not what the reference above says. Please read more carefully. Comments will be appreciated. The basic assumption for permutation tests is exchangeability of the observations (regardless of sample sizes). The reference above describes a situation when this assumption is violated. Z Best regards, João Fadista De: ONKELINX, Thierry [mailto:[EMAIL PROTECTED] Enviada: ter 08-04-2008 15:27 Para: João Fadista; r-help@r-project.org Assunto: RE: [R] permutation test assumption? Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens João Fadista Verzonden: dinsdag 8 april 2008 15:18 Aan: r-help@r-project.org Onderwerp: [R] permutation test assumption? Dear all, Can I do a permutation test if the number of individuals in one group is much bigger than in the other group? I searched the literature but I didin´t find any assumption that refers to this subject for permutation tests. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ DJF now offers new degree programmes http://www.agrsci.org/content/view/full/34133 . News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] preferred version of Linux for R?
There are binaries on CRAN for several distros. There is the R-sig-debian list for debian users. As far as I know, there are no mailing lists for other distros. This may indicate a preference for debian among R users. Or it may mean that debian is so difficult to use with R that it requires a mailing list. :-) As a debian user, I prefer the first explanation. Cheers, Simon. On Tue, 2008-04-08 at 13:36 -0700, Thomas Pujol wrote: Is there a recommended/preferred version of Linux for using with R? Is there one version of Linux that R-users prefer, and/or that works better with R? I am working with large datasets, and hope to take advantage of as much RAM as reasonable (8-32gb?). Thanks in advance! - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] preferred version of Linux for R?
If your criterion is use of resources, then you might be more interested in which flavor of Linux makes it easy to turn the X-window server off. No windows or mouse, more RAM and CPU cycles for R. As I recall, the only Linux where that might be a problem is Ubuntu, because there's no convenient way to kill the X-server. Also look at Puppy Linux --http://puppylinux.org/wikka/Puppy300 -- which has a rep for very small use of resources. On Tue, Apr 8, 2008 at 4:36 PM, Thomas Pujol [EMAIL PROTECTED] wrote: Is there a recommended/preferred version of Linux for using with R? Is there one version of Linux that R-users prefer, and/or that works better with R? I am working with large datasets, and hope to take advantage of as much RAM as reasonable (8-32gb?). Thanks in advance! - [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- I can answer any question. I don't know is an answer. I don't know yet is a better answer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] chi-square test
Hi R-users, I would like to find the goodness of fit using Chi-suare test for my data below: xobs=observed data, xtwe=predicted data using tweedie, xgam=predicted data using gamma xobs - c(223,46,12,5,7,17) xtwe - c(217.33,39,14,18.33,6.67,14.67) xgam - c(224.67,37.33,12.33,15.33,5.33,15) chisq.test(xobs, xtwe = xtwe, rescale.p = TRUE) Error in chisq.test(xobs, xtwe = xtwe, rescale.p = TRUE) : unused argument(s) (xtwe = c(217.33, 39, 14, 18.33, 6.67, 14.67)) chisq.test(x, p = p, rescale.p = TRUE) I'm not sure what's wrong with it. Thank you so much for your help. You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Overlapping distributions (populations) - assigning an individual to a population?
Rolf, On Wed, 2008-04-09 at 10:57 +1200, Rolf Turner wrote: On 9/04/2008, at 10:30 AM, Phil Rhoades wrote: People, Say a particular measure of an attribute for individuals in different populations gives a set of overlapping normal distributions (one distribution per population). If I then measure this attribute in a new individual - how do I assess the likelihood of this new individual belonging to each of the different populations? You have a mixture of distributions. Let the density be k f(x) = SUM lambda_i * f_i(x) i=1 where the f_i(x) are the densities for the individual components in the mixture, and the lambda_i are the mixing probabilities. The probability that an individual with observation x is from component i is lambda_i * f_i(x) - f(x) Thanks for the quick response but I think I need to put some numbers on this so I can see what you mean. Say I have two pops with individual values: 1 2 3 4 5 3 4 5 6 7 and a new individual with value 5 - what is the likelihood of assignment to each of the populations? BTW, I say populations, but to keep it simple I didn't go into more detail - there is no physical overlap in space or time of the populations/distributions - so there are no gradients from interbreeding of sub-populations or anything like that. Regards, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Fax: +61:(0)2-8221-9599 E-mail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] post hoc statistical power
Dear Yuelin, Another paper critical of post-hoc power calculations is Hoenig and Heisey, 2001. The Abuse of Power: The Pervasive Fallacy of Power Calculations for Data Analysis. The American Statistician, 55, 19-24. Hoenig and Heisey show that so-called observed power is simply a re-expression of the p-value. I hope this helps, John John Fox, Professor 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] project.org] On Behalf Of Yuelin Li Sent: April-08-08 12:47 PM To: r-help@r-project.org Subject: [R] post hoc statistical power I remember reading about post hoc statistical power on R-help. But I can't seem to find them with RSiteSearch(post hoc statistical power) and variations of it. I would like to learn more about post hoc statistical power, its meaningfulness, advantages and disadvantages. I thought the issue was settled after Tukey's 1993 paper about post hoc statistical power being essentially meaningless once the experiment has been done. But they seem to be used, and sometimes encouraged (e.g., http://www.informaworld.com/smpp/content~content=a787469931). I do not intend to start a debate. I simply would like to learn more. Can anyone suggest a few articles? Thanks, Yuelin. Tukey JW. Tightening the clinical trial. Control Clin Trials. 1993;14:266-285. = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Overlapping distributions (populations) - assigning an individual to a population?
Rolf, On Wed, 2008-04-09 at 10:57 +1200, Rolf Turner wrote: On 9/04/2008, at 10:30 AM, Phil Rhoades wrote: People, Say a particular measure of an attribute for individuals in different populations gives a set of overlapping normal distributions (one distribution per population). If I then measure this attribute in a new individual - how do I assess the likelihood of this new individual belonging to each of the different populations? You have a mixture of distributions. Let the density be k f(x) = SUM lambda_i * f_i(x) i=1 where the f_i(x) are the densities for the individual components in the mixture, and the lambda_i are the mixing probabilities. The probability that an individual with observation x is from component i is lambda_i * f_i(x) - f(x) Thanks for the quick response but I think I need to put some numbers on this so I can see what you mean. Say I have two pops with individual values: 1 2 3 4 5 3 4 5 6 7 and a new individual with value 5 - what is the likelihood of assignment to each of the populations? Phil, for an application and more detailed explanation you can check the article: A Test for Long-Term Cyclical Clustering of Stock Market Regimes John Powell, Rubén Roa, Jing Shi, Viliphonh Xayavong Australian Journal of Management, vol. 32(2), 2007, available for free download from the journal website: http://www.agsm.edu.au/~eajm/current.html I provide there a quotation to a book by Hamilton on time series, where this technique is further explained. By the way, the computation suggested is a conditional probability. Rubén __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] preferred version of Linux for R?
On 8 April 2008 at 19:06, Mitchell Maltenfort wrote: | If your criterion is use of resources, then you might be more | interested in which flavor of Linux makes it easy to turn the X-window | server off. No windows or mouse, more RAM and CPU cycles for R. As I | recall, the only Linux where that might be a problem is Ubuntu, | because there's no convenient way to kill the X-server. That conjecture is easily disproved by example: 'sudo /etc/init.d/gdm stop' and finding the correct forms for kdm and xdm is left as an exercise for the reader. The /etc/init.d scripts have been working all those fourteen years I've been using Debian and Ubuntu Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.