Re: [R] proc summary in R?: follow up
Emilie Berthiaume wrote: I found out that for want I want to do I must use the function summarize. My only problem now is that I don't understand how to summarize two vectors at a time. For exemple, I wanted to get the sum of RThr and effortwt per day per year so I've tried this: RTyrday - with(RT.sub,summarize(cbind(RThr,effortwt), llist(year,jjulian), FUN=sum)) But the output combine RThr and effortwt instead of doing two separate column with those vectors. What am I missing? Thanks for your help, Emilie See the example I posted 2 hours ago, especially how you need to specify FUN. FH - Original Message - From: Frank E Harrell Jr [EMAIL PROTECTED] To: Emilie Berthiaume [EMAIL PROTECTED] Cc: R-help@stat.math.ethz.ch Sent: Wednesday, March 01, 2006 12:16 PM Subject: Re: [R] How to do a proc summary in R? Emilie Berthiaume wrote: Hi, I'm a SAS user trying to convert myself to R but I still have problems with some pretty simple commands. First I wanted to add up a number of red-tailed hawks seen per day (julian day) per year. So I tried: RTyrday - tapply(RThr,list(year,julian),sum) And then I tried the following regression: mod1 - glm(RTyrday~julian+year, family=gaussian (link=identity),data=RT) Wich didn't work since my vector RTyrday and julian don't have the same length. My question is: How can I create a new data sheet with the output of my function tapply ? Something I could have done in SAS by giving an output out to my proc summary Thank you, Emilie One of many ways is at http://biostat.mc.vanderbilt.edu/SasByMeansExample (especially for SAS users). The example uses the R Hmisc package. Frank Emilie Berthiaume Graduate Student Biology Department Sherbooke University Sherbrooke, Québec CANADA [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] prepared query with RODBC ?
Well, I may not have been clear enough. My experience with database drivers is so far mostly limited to JDBC, Perl's DBI, and some other things with Python. I am rather new to (R)ODBC. What I am after is something like: ## -- dummy R code pq - prepareQuery(SELECT * FROM foo WHERE bar = ?, dbHandle) res - runQuery(pq, allMyBars, dbHandle) ## then fetch the query if needed (may be not the case if 'pq' ## is about updating tables). (as I am just told, this is may be more something like a BATCH query than a prepared query stricto senso). I have tracked down things to the C level, with the function RODBCUpdate, that appear to do something related ( res = SQLPrepare( thisHandle-hStmt, (SQLCHAR *) cquery, strlen(cquery) ); can be spotted around line 960) but the documentation is rare down there, so I was asking if anyone had experience on the topic. If I understand correctly your suggestion, the idea would be to build a complete set of (Visual Basic ?) instructions into a (potentially very long) string and send them to the SQL server ? Thanks. Laurent On 3/1/06, McGehee, Robert [EMAIL PROTECTED] wrote: I may be misunderstanding you, but why can't you execute a prepared query the same in RODBC as you would directly on your SQL server? In Microsoft SQL server, for instance, I would just set up an ADO application and set the Prepared and CommandText properties before running the query. Here is an example from the Microsoft SQL help page. In this example, I would try storing all of the below as a string in R, and simply pass this into the odbcQuery or sqlQuery. However, see the help for your specific SQL application. Note that (for at least SQL server) one can disable the prepare/execute model, so you might have to check your ODBC settings before running. --Robert Dim cn As New ADODB.Connection Dim cmdPrep1 As New ADODB.Command Dim prm1 As New ADODB.Parameter Dim prm2 As New ADODB.Parameter Dim strCn As String strCn = Server=MyServerName;Database=pubs;Trusted_Connection=yes cn.Provider = sqloledb cn.Open strCn Set cmdPrep1.ActiveConnection = cn cmdPrep1.CommandText = UPDATE titles SET type=? WHERE title_id =? cmdPrep1.CommandType = adCmdText cmdPrep1.Prepared = True Set prm1 = cmdPrep1.CreateParameter(Type, adChar, adParamInput, 12, New Bus) cmdPrep1.Parameters.Append prm1 Set prm2 = cmdPrep1.CreateParameter(ProductID, adInteger, adParamInput, 4, 3) cmdPrep1.Parameters.Append prm2 cmdPrep1.Execute cmdPrep1(Type) = New Cook cmdPrep1(title_id) = TC cmdPrep1.Execute cn.Close -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Laurent Gautier Sent: Monday, February 27, 2006 9:38 AM To: r-help@stat.math.ethz.ch Subject: [R] prepared query with RODBC ? Dear List, Would anyone know how to perform prepared queries with ROBC ? I had a shot with some of the internal (non-exported) functions of the package but ended up with a segfault, so I prefer asking around before experimenting further... Thanks, Laurent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Optimization problem: selecting independent rows to maximizethe mean
Le Wed, 01 Mar 2006 13:07:07 -0800, Berton Gunter a écrit : 2) That the mean and sd can be simultaneously optimized as you describe-- what if the subset with maximum mean also has bigger than minimal sd? Then you have two choices : 1) balance the two objectives with weights, according to the importance you give to each one 2) get a list of non-dominated solutions (a Pareto front) Does R have packages for such multi-objectives optimization problems ? Moreover, does it have a package for difficult (i.e. NP-hard) problems ? -- nojhan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Skip last NA's?
I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply take x[1:6]? I have several vectors a couple of thousand observations long with varying numbers of NA's in the end. I'd prefer not to search through all of these one at a time.) Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] finding ncp for t distribution
Dear R-users, I am wondering whether R implements a function returning the non central parameter of a t distribution (equivalent of the TnoncT function from SAS), given /x/ a value from a t distribution, /df /the degrees of freedom and /p/ the probability of x under this distribution. Thanks a lot, Matthieu -- Matthieu Dubois, /Ph.D/. /Student/ Cognitive Neuroscience Unit, UCL, Belgium [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] PayPal Notification Message-ID: [EMAIL PROTECTED] From: Customer Support [EMAIL PROTECTED] Content-Type: text/html html head meta name=GENERATOR content=Microsoft FrontPage 5.0 me
__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] aboutRiply's K functionand envelope
Zhang Jian writes: I did Riply's K function and envelope in the package SPATSTAT. When the species number is less, it can work well and it is quickly. But when the species number is more(example:2000), it told mememory limit. If you have a query about a specific package, please ask the package maintainer. (In the case of `spatstat', that is me.) The help page help(envelope) explains that the default action when you type `envelope(X))' is to calculate the K functions using Kest(). help(Kest) explains that the spatstat command Kest calculates multiple estimates of the K function. By default, Kest calculates estimates of K by three or four different edge corrections (border, isotropic, translation, ...). Of course this makes the system run slower. You can accelerate the calculation by telling Kest to calculate only one of the estimates. For example: envelope(X, correction=translate) runs about 5 times faster than envelope(X) This is explained in help(envelope). For a very large point pattern, Kest runs slowly because it creates n * n matrices where n is the number of points. An alternative to Kest is Kest.fft which calculates a smoothed estimate of the K function using the Fast Fourier Transform. So if you type envelope(X, Kest.fft, sigma=.) this will run 10 to 50 times faster than using Kest. You have to specify the value of the smoothing parameter sigma as explained in Kest.fft. I apologise that the function Kest.fft is not mentioned in the help page for envelope. We will fix that. Also please note that there is a bug in spatstat 1.8-6 which causes some functions to run slower. It is fixed in 1.8-7 which will be released this week. regards Adrian Baddeley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problems to get a ctree plot (library party) in a file via jpeg/png
Carlos: I am using library party and I have found a curious/strange behaviour when trying to save the output of a ctree in a file via jpeg/png command. thanks for reporting this. We've seen this problem before with the vcd package. The reason is that the default background is usually transparent whereas for jpeg() and png() devices it is white. That has the effect that the grid.rect() command at the end of node_boxplot() not only draws the bounding rectangle but also fills it with white, thus hiding the actual boxplots. The fix is to use grid.rect(gp = gpar(fill = transparent)) instead. We'll commit a fixed party to CRAN asap. Best wishes, Z __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] finding ncp for t distribution
you could try the following: f - function(delta, pr, x, df) pt(x, df = df, ncp = delta) - pr out - uniroot(f, c(0, 37.62), pr = 0.18, x = 0.9, df = 4) ##3 out$root pt(0.9, 4, out$root) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Matthieu Dubois [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, March 02, 2006 9:39 AM Subject: [R] finding ncp for t distribution Dear R-users, I am wondering whether R implements a function returning the non central parameter of a t distribution (equivalent of the TnoncT function from SAS), given /x/ a value from a t distribution, /df /the degrees of freedom and /p/ the probability of x under this distribution. Thanks a lot, Matthieu -- Matthieu Dubois, /Ph.D/. /Student/ Cognitive Neuroscience Unit, UCL, Belgium [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Skip last NA's?
A fairly standard trick for such situations is to use rle(is.na(x)) In your case you want to see if the last value is TRUE. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Robert Lundqvist wrote: I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply take x[1:6]? I have several vectors a couple of thousand observations long with varying numbers of NA's in the end. I'd prefer not to search through all of these one at a time.) Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Skip last NA's?
Hi probably not the best solution but if(tail(is.na(x), n=1)) x[1 : (length(x) - (tail(rle(is.na(x))$lengths, n=1)))] else x shall do what you want. HTH Petr On 2 Mar 2006 at 9:29, Robert Lundqvist wrote: Date sent: Thu, 2 Mar 2006 09:29:49 +0100 (MET) From: Robert Lundqvist [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject:[R] Skip last NA's? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply take x[1:6]? I have several vectors a couple of thousand observations long with varying numbers of NA's in the end. I'd prefer not to search through all of these one at a time.) Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] repeated measures ANOVA
A big thank you to all those of you who helped me with this problem. I really appreciated your advice! Cheers, Christian -- Dr. Christian Gold, PhD http://www.hisf.no/~chrisgol __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] bVar slot of lmer objects and standard errors
Vielen Dank, Spencer. I could not find a published example where both the original data and conditional posterior variances were available. Instead, I toyed around a little with artificial data, and the (pretty pathetic) result below is the closest I came to Monte Carlo-ing. I'm afraid I lack the statistical and R skills to do it properly (in a reasonable amount of time). Still, the result looks about right. I started with a some simple artificial data: y-rep(100,100)+rep(c(-10,-5,2,15),c(20,30,40,10))+rnorm(100,0,15) f-factor(rep(c(1,2,3,4),c(20,30,40,10))) fy.df-data.frame(f,y) To which I then fitted a simple model: fy.lmer-lmer(y~1 + (1 | f), data=fy.df) Now to get independent estimates of the conditional posterior variances, I used the bootstrap, re-fitting the model to 100 resampled dataframes (sampled independently for each group) and storing the resulting random effect estimates in a matrix: boots-matrix(NA,100,4) colnames(boots)-levels(fy.df$f) for (i in 1:nrow(boots)) { + resampled.df-do.call(rbind, lapply(split(fy.df, fy.df$f),# + function(x) x[sample(nrow(x), nrow(x), replace=TRUE),])) + boots[i,]-ranef(update(fy.lmer,data=resampled.df))[1]$f + } Finally, I compared the bootstrap estimates to those provided by lmer: s-attr(VarCorr(fy.lmer),sc) rbind([EMAIL PROTECTED],,]*s^2,apply(boots,2,var)) 1234 [1,] 7.908634 5.448064 4.155261 14.42237 [2,] 5.935841 4.501380 5.367947 14.04685 Which looks quite good. I tried this for several artificial datasets, and the result always looked ok. Spencer Graves wrote: I shall provide herewith an example of what I believe is the conditional posterior variance of a random effect. I hope someone more knowledgeable will check this and provide a correction if it's not correct. I say this in part because my simple rationality check (below) didn't match as closely as I had hoped. I don't have easy access to the hlmframe of your example, so I used the example in the lmer documentation: library(lme4) (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) Formula: Reaction ~ Days + (Days | Subject) Data: sleepstudy AIC BIClogLik MLdeviance REMLdeviance 1753.628 1769.593 -871.8141 1751.986 1743.628 Random effects: Groups NameVariance Std.Dev. Corr Subject (Intercept) 612.090 24.7405 Days 35.072 5.9221 0.066 Residual 654.941 25.5918 # of obs: 180, groups: Subject, 18 snip I think we want the Residual Variance of 654.941 (Std.Dev. of 25.5918). To get this, let's try VarCorr: (vC.fm1 - VarCorr(fm1)) $Subject 2 x 2 Matrix of class dpoMatrix (Intercept) Days (Intercept) 612.09032 9.60428 Days9.60428 35.07165 attr(,sc) [1] 25.59182 Our desired 25.5918 is 'attr(,sc)' here. We get that as follows: (s. - attr(vC.fm1, sc)) [1] 25.59182 Next, by studying 'str(fm1)' and earlier emails you cite, we get the desired conditional posterior covariance matrix as follows: (condPostCov - (s.^2)[EMAIL PROTECTED]) , , 1 [,1] [,2] [1,] 145.7051 -21.32 [2,] 0. 5.312275 snip , , 18 [,1] [,2] [1,] 145.7051 -21.32 [2,] 0. 5.312275 This actually gives us only the upper triangular portion of the desired covariance matrices. The following will make them all symmetric: condPostCov[2,1,] - condPostCov[1,2,] As a check, I computed the covariance matrix of the estimated random effects. To get this, I reviewed str(ranef(fm1)), which led me to the following: var([EMAIL PROTECTED]) (Intercept) Days (Intercept) 466.38503 31.04874 Days 31.04874 29.75939 These numbers are all much larger than condPostCov. However, I believe this must be a random bounce -- unless it's a deficiency in my understanding (in which case, I hope someone will provide a correction). Ulrich: Would you mind checking this either with a published example or a Monte Carlo and reporting the results to us? Viel Glück, spencer graves __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] repeated measures ANOVA
Christian Gold [EMAIL PROTECTED] writes: A big thank you to all those of you who helped me with this problem. I really appreciated your advice! I don't think anyone pointed you towards the anova.mlm features; you might find them quite close to what SPSS does. For now, the easiest way to learn about them is probably to run example(anova.mlm) and study the output - an R News paper is planned if and when I get out of my current swamp... -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Handling outliers?
I am sitting with this fairly big material (20 variables, max length of vectors about 3200 observations and a substantial amount of missing values). In some cases there are also outliers. Some are obvious, others are not that clear. So far, I have replaced some of the outliers with NA's. However, I would like to have a good working procedure where outliers where not excluded permanently but rather temporarily. Some way of marking observations and still keep them seems both preferable and possible. Any suggestions for a good working practice for cases like this? How do *you* work? Is there any standard package to use? Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Handling outliers?
It is not clear what sort of analysis you are doing, and for example robust/resistant regression is a way of identifying and downweighting outliers in a regression analysis. Also, multivariate outliers are a very different concept from univariate ones, and the difference may or may not matter depending on the analysis. On Thu, 2 Mar 2006, Robert Lundqvist wrote: I am sitting with this fairly big material (20 variables, max length of vectors about 3200 observations and a substantial amount of missing values). In some cases there are also outliers. Some are obvious, others are not that clear. So far, I have replaced some of the outliers with NA's. However, I would like to have a good working procedure where outliers where not excluded permanently but rather temporarily. Some way of marking observations and still keep them seems both preferable and possible. Depends what `keep' means, but in one sense that is what na.action = na.exclude does. Any suggestions for a good working practice for cases like this? How do *you* work? Is there any standard package to use? Robert -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Class Method, S3 / S4
Hi Martin Thanks a lot for your short example. If you input test(testObj) it will return 22 However, how is it possible that the value will be saved in the object i.e. (does not work currently!!??) setMethod(test, signature=c(connect), function( obj ) { [EMAIL PROTECTED][EMAIL PROTECTED] / 2 }) so that test(testObj) will save a new value to [EMAIL PROTECTED] or [EMAIL PROTECTED] will return 22. Thanks. Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Skip last NA's?
Do you mean you wish to create a vector without the trailing NAs but with the others? If so, try: library(zoo) head(x, length(na.locf(x, rev = TRUE))) or library(zoo) head(x, length(na.locf(rev(x On 3/2/06, Robert Lundqvist [EMAIL PROTECTED] wrote: I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply take x[1:6]? I have several vectors a couple of thousand observations long with varying numbers of NA's in the end. I'd prefer not to search through all of these one at a time.) Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Class Method, S3 / S4
Again, R has a different paradigm from what you're used to. R is a 'pass by value' language. So 'obj' inside the method is a *copy* of testObj, and your assignment changes the 'value' slot of the copy. An R way of doing this might be setMethod(test, signature=c(connect), function( obj ) { [EMAIL PROTECTED] - [EMAIL PROTECTED] / 2 ## and other manipulations... obj }) testObj - test( testObj ) I 'know' these things by reading Chambers' Programming with Data, and by looking at exsiting code (ok, and maybe some other ways, too ;). There are some example packages suggested in this thread https://stat.ethz.ch/pipermail/r-devel/2005-November/035370.html If you have an R source distribution, look in, for instance, PATH-TO-R-SRC/src/library/stats4/R At the R command prompt, do something like library(stats4) library(help=stats4) ?update-methods getMethods(update) A warning, I guess, is that looking at complicated code (and the help pages for the methods package) can be confusing without the kind of foundation that Chambers' book provides. Maybe others on the list will provide some hints for introductory documentation on S4 classes and methods. Hope that's enough to get you going! Martin Dominik Locher [EMAIL PROTECTED] writes: Hi Martin Thanks a lot for your short example. If you input test(testObj) it will return 22 However, how is it possible that the value will be saved in the object i.e. (does not work currently!!??) setMethod(test, signature=c(connect), function( obj ) { [EMAIL PROTECTED][EMAIL PROTECTED] / 2 }) so that test(testObj) will save a new value to [EMAIL PROTECTED] or [EMAIL PROTECTED] will return 22. Thanks. Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Drop1 and weights
It looks like at some point weighted.residuals() was changed, and broke this. The models are fitted correctly, but AIC is wrong. However, note that it does work correctly for a glm() fit which gives you a workaround. You example is not reproducible, so I was unable to test the workaround nor the correction which will short;y be in R-patched. On Wed, 1 Mar 2006, Yan Wong wrote: Hi, If I used drop1 in a weighted lm fit, it seems to ignore the weights in the AIC calculation of the dropped terms, see the example below. Can this be right? Yan library(car) unweighted.model - lm(trSex ~ (river+length +depth)^2- length:depth, dno2) Anova(unweighted.model) Anova Table (Type II tests) Response: trSex Sum Sq Df F value Pr(F) river0.1544 1 3.3151 0.07100 . length 0.1087 1 2.3334 0.12911 depth0.1917 1 4.1145 0.04461 * river:length 0.0049 1 0.1049 0.74652 river:depth 0.3008 1 6.4567 0.01226 * Residuals5.9168 127 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 drop1(unweighted.model) Single term deletions Model: trSex ~ (river + length + depth)^2 - length:depth Df Sum of Sq RSS AIC none 5.92 -401.97 river:length 1 0.0048895.92 -403.86 river:depth 1 0.306.22 -397.37 ### Both drop1 Anova suggest dropping river:length ### Compare with the following: weighted.model - lm(trSex ~ (river+length +depth)^2-length:depth, dno2, weights=males+females) Anova(weighted.model) Anova Table (Type II tests) Response: trSex Sum Sq Df F value Pr(F) river 1.471 1 3.3775 0.06843 . length1.002 1 2.2999 0.13187 depth 2.974 1 6.8295 0.01005 * river:length 0.075 1 0.1733 0.67790 river:depth 2.020 1 4.6397 0.03313 * Residuals55.303 127 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 drop1(weighted.model) Single term deletions Model: trSex ~ (river + length + depth)^2 - length:depth Df Sum of Sq RSS AIC none 55.30 -104.71 river:length 1-49.335.97 -402.79 river:depth 1-49.046.26 -396.39 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Drop1 and weights
On 2 Mar 2006, at 13:25, Prof Brian Ripley wrote: It looks like at some point weighted.residuals() was changed, and broke this. The models are fitted correctly, but AIC is wrong. However, note that it does work correctly for a glm() fit which gives you a workaround. Thank you. You example is not reproducible, so I was unable to test the workaround nor the correction which will short;y be in R-patched. Indeed, I realised this, but assumed that the problem could be understood even without my dataset. I'll test my data on the patched version when it becomes available, and re-post then. Thanks again Yan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library file for R's nmath routines
Dear Professor Ripley, These are FC4 RPMs. So, there is a separate RPM called libRmath? I was not aware of that. Btw, it is not in libR.so. Sorry, I did not realize that the installation was important to post. Best, GT --- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 1 Mar 2006, someone claiming to be `Globe Trotter' wrote: Hi, I am wondering where the library file for R's nmath routines are? Doing a search on libR gave me the following: /usr/lib/libRKC16.so.1.2.0 /usr/lib/libRKC.so.1.2.0 /usr/lib/R/lib/libRlapack.so /usr/lib/R/lib/libR.so /usr/lib/libRKC.so.1 /usr/lib/libRKC16.so.1 None of these have the functions in nmath. libR.so must have if this is a functional build of R. But you have missed so much it is hard to help you. You have not followed the posting guide and told us anything about your R installation. If you installed from sources, you missed src/nmath/standalone/README. If this were a RedHat RPM, you missed separate RPMs for libRmath. And so on. Any help? Many thanks and best wishes! GT PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help with lme code
Dear R - Users I have some problems fitting a linear mixed effects model using the lme function (from the library nlme). A sample data is as shown at the bottom of this mail. I fit my linear mixed model using the following R code: bmr -lme (outcome~ -1 + as.factor(endpoint)+ as.factor(endpoint):trt, data=datt, random=~-1 + as.factor(endpoint) + as.factor(endpoint):trt|as.factor(Trial), correlation = corSymm(form=~subject|as.factor(endpoint)), weights=varIdent(form=~subject|endpoint)) With this code, i want to obtain random effects for each Trial. ALso my residuals are correlated, and the correlated residuals are heteroscedastic over endpoint. That is, each endpoint has a different constant variance. However, I recieve the following error message using the code above: Error in lme.formula(outcome ~ -1 + as.factor(endpoint) + as.factor(endpoint):trt, : Incompatible formulas for groups in random and correlation May someone kindly inform me how to correct this code. Does this imply that the grouping factor in the correlation formula must be the same grouping factor in the random formula ? If so, is there a way of getting pass this restriction ? Best regards Pryseley Sample data: RowNames Trial subject VISUAL0 TRT VISUAL24 VISUAL52 TREAT outcome endpoint trt 4 11003 65 4 65 55 2 01 1 8 11007 67 1 64 68 2 -31 -1 12 21110 59 4 53 42 2 -61 1 14 2 64 1 72 65 2 81 -1 16 21112 39 1 37 37 2 -21 -1 18 21115 59 4 54 58 2 -51 1 24 31806 46 4 27 24 2 -191 1 26 31813 31 4 33 48 2 21 1 28 31815 64 1 67 64 2 31 -1 4 11003 65 4 65 55 2 -10 -1 1 8 11007 67 1 64 68 2 1 -1 -1 12 21110 59 4 53 42 2 -17 -1 1 14 2 64 1 72 65 2 1 -1 -1 16 21112 39 1 37 37 2 -2 -1 -1 18 21115 59 4 54 58 2 -1 -1 1 24 31806 46 4 27 24 2 -22 -1 1 26 31813 31 4 33 48 2 17 -1 1 28 31815 64 1 67 64 2 0 -1 -1 - Bring photos to life! New PhotoMail makes sharing a breeze. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] prepared query with RODBC ?
Well, I'm still not sure what you're trying to do, specifically because I don't understand your distinction here between preparing and running a query, especially if you do not mean preparing in the traditional sense, i.e. pre-process a dynamic SQL query so that it can be run multiple times without re-processing. Certainly, however, you can run a query and fetch its results in two different steps using RODBC, and this can actually be quite useful for fine-tuning performance and inserting error control in complex queries. One does this by first using the odbcQuery() function to run the query and then the sqlGetResults() function to fetch the rows (if as you said, there are rows to be fetched). If you are more interested in batch processing multiple SQL queries, which is not the same as preparing a query, an easy way to do this is to just define a stored procedure and then run the stored procedure using sqlQuery or odbcQuery, or alternatively use transaction control. You can send an entire batch statement as a single string to sqlQuery. Lastly, a previous version of RODBC had a function odbcDirectQuery which I made use of in the past to toggle between direct execution and batch execution for multiple queries. This was most useful for me if I wanted to make use of temporary tables. However, the odbcDirectQuery function is no longer supported in the current version of RODBC, probably because it was not stable across SQL platforms. That said, you might take a look at the C code for ideas. HTH, Robert -Original Message- From: Laurent Gautier [mailto:[EMAIL PROTECTED] Sent: Thursday, March 02, 2006 3:20 AM To: McGehee, Robert Cc: r-help@stat.math.ethz.ch Subject: Re: [R] prepared query with RODBC ? Well, I may not have been clear enough. My experience with database drivers is so far mostly limited to JDBC, Perl's DBI, and some other things with Python. I am rather new to (R)ODBC. What I am after is something like: ## -- dummy R code pq - prepareQuery(SELECT * FROM foo WHERE bar = ?, dbHandle) res - runQuery(pq, allMyBars, dbHandle) ## then fetch the query if needed (may be not the case if 'pq' ## is about updating tables). (as I am just told, this is may be more something like a BATCH query than a prepared query stricto senso). I have tracked down things to the C level, with the function RODBCUpdate, that appear to do something related ( res = SQLPrepare( thisHandle-hStmt, (SQLCHAR *) cquery, strlen(cquery) ); can be spotted around line 960) but the documentation is rare down there, so I was asking if anyone had experience on the topic. If I understand correctly your suggestion, the idea would be to build a complete set of (Visual Basic ?) instructions into a (potentially very long) string and send them to the SQL server ? Thanks. Laurent On 3/1/06, McGehee, Robert [EMAIL PROTECTED] wrote: I may be misunderstanding you, but why can't you execute a prepared query the same in RODBC as you would directly on your SQL server? In Microsoft SQL server, for instance, I would just set up an ADO application and set the Prepared and CommandText properties before running the query. Here is an example from the Microsoft SQL help page. In this example, I would try storing all of the below as a string in R, and simply pass this into the odbcQuery or sqlQuery. However, see the help for your specific SQL application. Note that (for at least SQL server) one can disable the prepare/execute model, so you might have to check your ODBC settings before running. --Robert Dim cn As New ADODB.Connection Dim cmdPrep1 As New ADODB.Command Dim prm1 As New ADODB.Parameter Dim prm2 As New ADODB.Parameter Dim strCn As String strCn = Server=MyServerName;Database=pubs;Trusted_Connection=yes cn.Provider = sqloledb cn.Open strCn Set cmdPrep1.ActiveConnection = cn cmdPrep1.CommandText = UPDATE titles SET type=? WHERE title_id =? cmdPrep1.CommandType = adCmdText cmdPrep1.Prepared = True Set prm1 = cmdPrep1.CreateParameter(Type, adChar, adParamInput, 12, New Bus) cmdPrep1.Parameters.Append prm1 Set prm2 = cmdPrep1.CreateParameter(ProductID, adInteger, adParamInput, 4, 3) cmdPrep1.Parameters.Append prm2 cmdPrep1.Execute cmdPrep1(Type) = New Cook cmdPrep1(title_id) = TC cmdPrep1.Execute cn.Close -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Laurent Gautier Sent: Monday, February 27, 2006 9:38 AM To: r-help@stat.math.ethz.ch Subject: [R] prepared query with RODBC ? Dear List, Would anyone know how to perform prepared queries with ROBC ? I had a shot with some of the internal (non-exported) functions of the package but ended up with a segfault, so I prefer asking around before experimenting further... Thanks, Laurent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
Re: [R] Class Method, S3 / S4
You could also define a replacement function and methods for it, when test(testObj) - 22 would change testObj itself. This is done via setReplaceMethod, but you will need to look at Chambers (1998) to understand that, as ?setReplaceMethod leads to a page that does not describe it apart from the call sequence (nor is it in the index of the book, but see pp 340-2). On Thu, 2 Mar 2006, Martin Morgan wrote: Again, R has a different paradigm from what you're used to. R is a 'pass by value' language. So 'obj' inside the method is a *copy* of testObj, and your assignment changes the 'value' slot of the copy. An R way of doing this might be setMethod(test, signature=c(connect), function( obj ) { [EMAIL PROTECTED] - [EMAIL PROTECTED] / 2 ## and other manipulations... obj }) testObj - test( testObj ) I 'know' these things by reading Chambers' Programming with Data, and by looking at exsiting code (ok, and maybe some other ways, too ;). There are some example packages suggested in this thread https://stat.ethz.ch/pipermail/r-devel/2005-November/035370.html If you have an R source distribution, look in, for instance, PATH-TO-R-SRC/src/library/stats4/R At the R command prompt, do something like library(stats4) library(help=stats4) ?update-methods getMethods(update) A warning, I guess, is that looking at complicated code (and the help pages for the methods package) can be confusing without the kind of foundation that Chambers' book provides. Maybe others on the list will provide some hints for introductory documentation on S4 classes and methods. Hope that's enough to get you going! Martin Dominik Locher [EMAIL PROTECTED] writes: Hi Martin Thanks a lot for your short example. If you input test(testObj) it will return 22 However, how is it possible that the value will be saved in the object i.e. (does not work currently!!??) setMethod(test, signature=c(connect), function( obj ) { [EMAIL PROTECTED][EMAIL PROTECTED] / 2 }) so that test(testObj) will save a new value to [EMAIL PROTECTED] or [EMAIL PROTECTED] will return 22. Thanks. Nik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Graphics question
Hi I am trying to plot two points (with confidence intervals) on a graph to illustrate the value of a particular quantity after 1 and 2 iterations respectively. I'm doing this by plot(cycle,alpha[2,],main=,ylim=c(-8,-3),cex=2,col=red,pch=19,ylab=e xpression(alpha),xlab=cycle) Etc.. Where cycle [1] 1 2 alpha [,1] [,2] [1,] -6.227266 -5.762146 [2,] -5.200972 -5.010401 [3,] -4.174677 -4.258655 When I plot this I get the x-axis scale reading 1.0,1.1,1.2,...,2.0 I want to get it to read simply 12 Is there an easy way to do this? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Graphics question
try the following: plot(..., xaxt = n) axis(1, at = 1:2) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Bowden, J.M. [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, March 02, 2006 4:41 PM Subject: [R] Graphics question Hi I am trying to plot two points (with confidence intervals) on a graph to illustrate the value of a particular quantity after 1 and 2 iterations respectively. I'm doing this by plot(cycle,alpha[2,],main=,ylim=c(-8,-3),cex=2,col=red,pch=19,ylab=e xpression(alpha),xlab=cycle) Etc.. Where cycle [1] 1 2 alpha [,1] [,2] [1,] -6.227266 -5.762146 [2,] -5.200972 -5.010401 [3,] -4.174677 -4.258655 When I plot this I get the x-axis scale reading 1.0,1.1,1.2,...,2.0 I want to get it to read simply 12 Is there an easy way to do this? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] predict.glm - how to?
Hi I have a little R problem. I have created a GLM model in R and now I want to predict some values outside the values I have in the model (extrapolate). I have this code: fitted.model4 - glm(Yval ~ time, family=gaussian, data=Fuel) The question is - How do I predict a value of Yval ie with a value of time = 340 and also get confidence/prediction intervals for Yvar? I have tried the predict.glm but cannot make it work - any suggestions how to do this using predict.glm? Yval are 312 fuel prices ranging from 60 to 140 and time is a sequence from 1 to 312. The GLM summary output is as follows: Deviance Residuals: Min 1Q Median 3Q Max -24.978 -4.033 -0.3914.747 15.323 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 79.698229 0.871830 91.42 2e-16 *** seq(1:312) 0.180127 0.004828 37.31 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for gaussian family taken to be 59.00219) Null deviance: 100408 on 311 degrees of freedom Residual deviance: 18291 on 310 degrees of freedom AIC: 2161.6 Number of Fisher Scoring iterations: 2 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Skip last NA's?
Robert Lundqvist wrote: I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply take x[1:6]? I have several vectors a couple of thousand observations long with varying numbers of NA's in the end. I'd prefer not to search through all of these one at a time.) Robert __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html x[1:max(which(!is.na(x)))] or, to allow for cases in which x may consist entirely of NAs or have length 0, x[0:max(0,which(!is.na(x)))] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library file for R's nmath routines
On 02/03/06, Globe Trotter wrote: Dear Professor Ripley, These are FC4 RPMs. So, there is a separate RPM called libRmath? I was not aware of that. Btw, it is not in libR.so. yum install libRmath libRmath-devel should give both the library and the header files. Sorry, I did not realize that the installation was important to post. It is. :-) Best, GT -- José Matos __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] predict.glm - how to?
On 3/2/06, Laurits Søgaard Nielsen [EMAIL PROTECTED] wrote: Hi I have a little R problem. I have created a GLM model in R and now I want to predict some values outside the values I have in the model (extrapolate). myglm - glm( some stuff here) whatever - some-new-hypothetical-data-you-create predict (myglm, newdata=whatever, type=response) I have hints on this in Rtips http://pj.freefaculty.org/R/Rtips.html#7.5 -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library file for R's nmath routines
Thanks! I will not give my e-mail address (hence the real name and affiliation), until the R-newsgroup moderators stop saving e-mail addresses to the archive, for spiders to pick up easily. Yes, I did not know how to get them, and I am sorry for not knowing, but part of being a professor is to tell people how to go about learning. Many thanks for all your help! I have downloaded the libRmath RPM but (as you point out), it is not necessary. So, thank you again!! Best wishes. --- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Thu, 2 Mar 2006, Globe Trotter wrote: Dear Profesor Ripley, It is a FC4 installation. So, there is an RPM which is called libRmath? The functions are not there in libR.so. They are in libR.so, you just don't know how to get them. Please do your own homework as you were asked to (and give your real name and affiliation)! I said there were `separate RPMs for libRmath', and there are. Thanks and best wishes, GT --- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 1 Mar 2006, someone claiming to be `Globe Trotter' wrote: Hi, I am wondering where the library file for R's nmath routines are? Doing a search on libR gave me the following: /usr/lib/libRKC16.so.1.2.0 /usr/lib/libRKC.so.1.2.0 /usr/lib/R/lib/libRlapack.so /usr/lib/R/lib/libR.so /usr/lib/libRKC.so.1 /usr/lib/libRKC16.so.1 None of these have the functions in nmath. libR.so must have if this is a functional build of R. But you have missed so much it is hard to help you. You have not followed the posting guide and told us anything about your R installation. If you installed from sources, you missed src/nmath/standalone/README. If this were a RedHat RPM, you missed separate RPMs for libRmath. And so on. Any help? Many thanks and best wishes! GT PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 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 __ Do You Yahoo!? http://mail.yahoo.com -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Deparsing '...'
Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tcltk error when calling a dialog
Hello; I've got several radiobuttons in tcltk with the following sintaxis: tk2.rd - /tkradiobutton(/frame4,command=plotDialog1,text=New Q plot, value=2, variable=OUTPLOTtclVar/)/ All the buttons call the same function plotDialog1. With the objective of call a dialog to select some plotting options. When I select one of the radiobuttons and the windows with the plotting options appears. It appears blank, and I obtain this message of error in R: Error in structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) : [tcl] grab failed: window not viewable. All radio buttons are within a frame in a window named dlg. I've removed nearly everything in this function and I still obtain the same error when clicking on a radiobutton. Even with this very simple remaining code: plotDialog1 - function/()/ { mddlg2 - /tktoplevel()/ tkwm./deiconify(/mddlg2/)/ tkgrab./set(/mddlg2/)/ tkwm./title(/mddlg2,Plot options/)/ onNO - function/()/ { tkgrab./release(/mddlg2/)/ /tkdestroy(/mddlg2/)/ /tkfocus(/dlg/)/ } // NO.but - /tkbutton(/mddlg2,text= Cancel ,command=onNO/)/ /tkgrid(/NO.but,pady=2/)/ /tkfocus(/mddlg2/)/ tkwait./window(/mddlg2/)/ } Please for those who are used to utilize the tcltk library: ¿Can you see a clear error in this? I'm new to this library and tcltk and I'm unable to find out the error. Thanks and best regards, Javier [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] prepared query with RODBC ?
Perhaps this thread should be continued in the r-sig-db list? Laurent Gautier wrote: Dear List, Would anyone know how to perform prepared queries with ROBC ? I had a shot with some of the internal (non-exported) functions of the package but ended up with a segfault, so I prefer asking around before experimenting further... Thanks, Laurent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html R applications that require a tighter interface to DBMSs could greatly benefit from such a facility, but prepared statements have not been used much from R, AFAIK. In a nutshell, a prepared statement is an SQL statement that is parsed, optimized, cached in the server, and then repeatedly executed with new data (using what is called data binding). Some of its benefits are significant improved performance, breaking big tasks into smaller, more manageable tasks, etc. A trivial example: ## prepare an SQL statement for repeated insertions, and bind ## output data.frame columns 1, 2, 3, and 4 to the SQL statement ps - dbPrepareStatement(conn, INSERT into SCORING (id, x1, x2, score) VALUES (:1,:2,:3,:4), bind = c(char, char, numeric, numeric)) ## compute new scores while(condition){ ... new_scores - predict(model, newdata) dbExecStatement(ps, data = new_scores) } dbCommit(con) dbClearResult(ps) I believe most DBMSs provide means to do this (PostgreSQL, MySQL, Sybase, Oracle, SQLite, ODBC 3.0, ...), but I think only the R-Oracle interface currently implements them (and only in an experimental basis). Regards, -- David __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Restricting Access to Function Codes
I am writing some educational simulation functions (R funcns) for undergrad students. The functions will be publicly placed in one of the university labs so that students can go and do their exploration and also will be required to do some simulations based on certain parameters they receive. Problem is how I can restrict access to function codes so that students do not change or mess up with them. Any ideas? Thanks! Gamal Note: functions are progressively added to as the course progresses so there is no complete package to install beforehand. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoregressive Model with Independent Variable
On Mar 1, 2006, at 8:35 PM, Dirk Eddelbuettel wrote: On 1 March 2006 at 20:06, Jarrett Byrnes wrote: | Hey, all, I may just be missing something, but I'm trying to construct | a temporal autoregression with an independant variable other than just | what is happened at a previous point in time. So, the model structure | would be something like | | y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a*x(t) | Yes: arima(), see in particular the xreg argument. Thanks so much! arima() seems to mostly fit the bill. I have data from multiple sites to use, as well. e.g. Timey1 x1 y2 x2 1 4 6 7 10 2 5 10 5 20 3 10 1 7 15 etc. I would like to use all of the sites in creating a model - I realize that the structure of the model would now be along the lines of: y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a1*x(t)+a2*x(t-1)...+c Where c is the site effect - I know this can get all wrapped up in the intercept, but, how does one pass this data to arima() to make it work? I know that arima() takes a vector of y values - can it take a matrix of y values and a corresponding matrix of x values, or is there some other function that does this? -Jarrett __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Simultaneous horizontal and vertical CIs in xyplot
I have xyplots (small number of observed points). The model estimates a mean value for both x and y, not usually identical with an observed data pair. The model also estimates simultaneous horizontal and vertical CIs on the mean values of x and y. I wish to add the mean point with both CIs to the xyplot. Can anyone give any tips for using xYplot (Hmisc) to do so? Can plotCI (plotrix) be used for that purpose? Running R 2.2.1 on Mac OS 10.4.5 via R Cocoa GUI 1.13 . Thanks, Nathan Nathan Leon Pace, MD, MStat University of Utah Salt Lake City, UT 84132 Office: 801.581.6393 Fax: 801.581.4367 Cell: 801.205.1019 Pager: 801.291.9019 Home: 801.467.2925 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
Matthew Dowle [EMAIL PROTECTED] writes: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d f - function(x,...)as.character(match.call(expand.dots=FALSE)$...) f(x,a,b,c*d) [1] a b c * d or maybe f - function(x,...) sapply(match.call(expand.dots=FALSE)$..., deparse, backtick=TRUE) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
That's much neater, thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: 02 March 2006 16:59 To: Matthew Dowle Cc: 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' Matthew Dowle [EMAIL PROTECTED] writes: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d f - function(x,...)as.character(match.call(expand.dots=FALSE)$...) f(x,a,b,c*d) [1] a b c * d or maybe f - function(x,...) sapply(match.call(expand.dots=FALSE)$..., deparse, backtick=TRUE) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
f - function(...) as.character(match.call())[-1] f(x,a,b,c*d) [1] x a b c * d On Thu, 2 Mar 2006, Matthew Dowle wrote: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
That's even neater. But when its called from within another function, this happens, see below. I was planning to call f something like 'getdots' and use it in several functions that need to do this. f - function(...) as.character(match.call())[-1] f(a,b,c) [1] a b c g = function(x,...) f(...) g(x,a,b,c) [1] ..1 ..2 ..3 -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 02 March 2006 17:18 To: Matthew Dowle Cc: 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' f - function(...) as.character(match.call())[-1] f(x,a,b,c*d) [1] x a b c * d On Thu, 2 Mar 2006, Matthew Dowle wrote: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Drop1 and weights
On Thu, 2 Mar 2006, Yan Wong wrote: On 2 Mar 2006, at 13:25, Prof Brian Ripley wrote: It looks like at some point weighted.residuals() was changed, and broke this. The models are fitted correctly, but AIC is wrong. However, note that it does work correctly for a glm() fit which gives you a workaround. Thank you. You example is not reproducible, so I was unable to test the workaround nor the correction which will shortly be in R-patched. Indeed, I realised this, but assumed that the problem could be understood even without my dataset. I'll test my data on the patched version when it becomes available, and re-post then. Now I have tried a similar example, I think that the workaround is correct but potentially confusing due to another error elsewhere. Using drop1 on a gaussian glm fit with weights gives the correct deviance and the correct AICs up to an additive constant. However, AIC() on such a fit gives the wrong AIC, since gaussian()$aic is incorrect (or at least it treats the weights as case weights, which is not the interpretation everything else uses). (I've changed that in R-devel.) So in 2.2.1 patched library(MASS) hills.lm - lm(time ~ dist + climb, data=hills, weights=1/dist^2) drop1(hills.lm) Single term deletions Model: time ~ dist + climb Df Sum of SqRSSAIC none 437.64 94.41 dist1164.05 601.68 103.55 climb 1 8.66 446.29 93.10 hills.glm - glm(time ~ dist + climb, data=hills, weights=1/dist^2) drop1(hills.glm) Single term deletions Model: time ~ dist + climb Df DevianceAIC none 437.64 21.30 dist1 601.68 30.44 climb 1 446.29 19.98 and in R-devel hills.glm - glm(time ~ dist + climb, data=hills, weights=1/dist^2) drop1(hills.glm) Single term deletions Model: time ~ dist + climb Df DevianceAIC none 437.64 323.87 dist1 601.68 333.01 climb 1 446.29 322.55 (These differ only in which additive constants are included, with that in drop1.glm in 2.2.1 patched being based on an incorrect calculation, which for this purpose does not matter.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
Matthew Dowle [EMAIL PROTECTED] writes: That's even neater. But when its called from within another function, this happens, see below. I was planning to call f something like 'getdots' and use it in several functions that need to do this. f - function(...) as.character(match.call())[-1] f(a,b,c) [1] a b c g = function(x,...) f(...) g(x,a,b,c) [1] ..1 ..2 ..3 Yes, that will (and must) happen. If you really want to go that route, you need something in the veins of f - function() match.call(sys.function(-1), call=sys.call(-1)) g = function(x,...) f() g(x,a,b,c) g(x = x, a, b, c) -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 02 March 2006 17:18 To: Matthew Dowle Cc: 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' f - function(...) as.character(match.call())[-1] f(x,a,b,c*d) [1] x a b c * d On Thu, 2 Mar 2006, Matthew Dowle wrote: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] heckit with a probit
To compute heckit model I have micEcon package .Use it. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
That works well. So the final version is: getdots = function() as.character(match.call(sys.function(-1), call=sys.call(-1), expand.dots=FALSE)$...) Thank you both for your help. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: 02 March 2006 18:07 To: Matthew Dowle Cc: 'Prof Brian Ripley'; 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' Matthew Dowle [EMAIL PROTECTED] writes: That's even neater. But when its called from within another function, this happens, see below. I was planning to call f something like 'getdots' and use it in several functions that need to do this. f - function(...) as.character(match.call())[-1] f(a,b,c) [1] a b c g = function(x,...) f(...) g(x,a,b,c) [1] ..1 ..2 ..3 Yes, that will (and must) happen. If you really want to go that route, you need something in the veins of f - function() match.call(sys.function(-1), call=sys.call(-1)) g = function(x,...) f() g(x,a,b,c) g(x = x, a, b, c) -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 02 March 2006 17:18 To: Matthew Dowle Cc: 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' f - function(...) as.character(match.call())[-1] f(x,a,b,c*d) [1] x a b c * d On Thu, 2 Mar 2006, Matthew Dowle wrote: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] extendable arrays in R
In an R program I am working on, I progressively build up several vectors of integers. I never know how long the vectors will eventually be, so I can't preallocate them with vector(). If I preallocate all of the vectors to their maximum size, I will run out of memory. I tried using c() or append() to build up the vectors, as in the following (tried on R 2.1.0 on Linux and R 2.2.1 on MacOS 10): li - vector() # also tried list() and pairlist() for (i in 0:4) { li - c(li, i) # also tried with i and li swapped if (i %% 1 == 0) system('date') } The problem is that based on the times this outputs, it is O(n^2), matching the straightforward implementation of c() where everything passed to c() is copied. I tried extending the vector by assigning to length(li) instead of using c(), but that also runs in O(n) (so the loop runs in O(n^2)) and appears to copy the elements. What I am looking for is an array that can dynamically resized in amortized constant or log time (like python's list or C++'s std::vector). I could build up a data structure inside R (the same way std::vector is built on top of C arrays), but I was hoping someone might have some advice on a better way to do this. Does R have a resizeable array type that I'm missing? What do others generally do in this case? Thank you, Brad __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Deparsing '...'
Note that this still has the restriction that getdots must be used directly in the function which is to be deparsed so one could not, for example, put it in another utility function which deparses the function and extracts the first component. To do that you need to pass the frame: f - function(n = sys.parent()) match.call(sys.function(n), call=sys.call(n)) # test - note that g calls first which calls f so f is not directly called by g first - function(n = sys.parent()) f(n)[1:2] g - function(x,...) first() g(x,a,b,c) g(x = x, a, b, c) On 3/2/06, Matthew Dowle [EMAIL PROTECTED] wrote: That works well. So the final version is: getdots = function() as.character(match.call(sys.function(-1), call=sys.call(-1), expand.dots=FALSE)$...) Thank you both for your help. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Dalgaard Sent: 02 March 2006 18:07 To: Matthew Dowle Cc: 'Prof Brian Ripley'; 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' Matthew Dowle [EMAIL PROTECTED] writes: That's even neater. But when its called from within another function, this happens, see below. I was planning to call f something like 'getdots' and use it in several functions that need to do this. f - function(...) as.character(match.call())[-1] f(a,b,c) [1] a b c g = function(x,...) f(...) g(x,a,b,c) [1] ..1 ..2 ..3 Yes, that will (and must) happen. If you really want to go that route, you need something in the veins of f - function() match.call(sys.function(-1), call=sys.call(-1)) g = function(x,...) f() g(x,a,b,c) g(x = x, a, b, c) -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 02 March 2006 17:18 To: Matthew Dowle Cc: 'r-help@stat.math.ethz.ch' Subject: Re: [R] Deparsing '...' f - function(...) as.character(match.call())[-1] f(x,a,b,c*d) [1] x a b c * d On Thu, 2 Mar 2006, Matthew Dowle wrote: Hi, The following function works, but is there a neater way to write it? f = function(x,...) { # return a character vector of the arguments passed in after 'x' gsub( ,,unlist(strsplit(deparse(substitute(list(...))),[(,)])))[-1] } f(x,a,b,c*d) [1] a b c*d Thanks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] CCF and Lag questions
I am new to R and new to time series modeling. I have a set of variables (var1, var2, var3, var4, var5) for which I have historical yearly data. I am trying to use this data to produce a prediction of var1, 3 years into the future. I have a few basic questions: 1) I am able to read in my data, and convert it to a time series format using 'ts.' data_ts - ts(data, start = 1988, end = 2005, frequency = 1, deltat = 1) However, I am not able to refer to the individual columns or variables of my new time series object. For example, I am able to reference 'var1' by typing, data$var1, but I can not do the same by using data_ts$var1. I don't see how I can use data_ts without being able to reference the individual columns in my dataset. 2) Since I'm trying to build a multivariate time series model, I want to find the correlations of var1 with my other variables (var1, var2, ...etc.) and their lagged values. But since I'm trying to produce a forecast for 3 years into the future, I want to find the ccf between var1 and my other variables lagged 3 years. I tried doing: ccf(var1, lag(var2, 3)) but I get the following error: Error in na.fail.default(ts.union(as.ts(x), as.ts(y))) : missing values in object Does anyone know how to use the lag funciton and ccf together? 3) Suppose var1 and var2 are both of length 20. I would expect the correlation of the fourth lag of ccf(var1, var2) to be the same as lag zero of: ccf(var1[1:17], var2[4:20]), but they are not. Can someone explain why not? 4) How do I interpret the negative lags produced from the ccf function? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] No Subject
Hello all, I try use effects package. I have linear model: fit=lm(y~x*z) Then I need plot such as: y axis is y x axis is x plot lines for each level z. I use code: plot(effect(x*z,fit,xlevels=list(x=levels(x),z=levels(z))),multiline=TRUE) (The idea comes from Effect Displays in R for Generalised Linear Models by John Fox) The code, according the paper, would produce all levels of effect to one graph instead producing too many panels in the graph. I try to use it but I have problem: x has 5 levels and z has 12. I just get plot with y on vertical axis, z on horizontal axis and lines for each level x. I think that happened because x has less levels than z. Please, give me advise, what option I should change or add to get right plot. I modified this code: plot(effect(neuroticism*extraversion,mod.cowles,xlevels=list(neuroticism=0:24,extraversion=seq(0,24,6))),multiline=TRUE,ylab=Prabability(Volunteer)) Thank you in advance. Natalia. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Autoregressive Model with Independent Variable
On Mar 1, 2006, at 8:35 PM, Dirk Eddelbuettel wrote: On 1 March 2006 at 20:06, Jarrett Byrnes wrote: | Hey, all, I may just be missing something, but I'm trying to construct | a temporal autoregression with an independant variable other than just | what is happened at a previous point in time. So, the model structure | would be something like | | y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a*x(t) | Yes: arima(), see in particular the xreg argument. Thanks so much! arima() seems to mostly fit the bill. I have data from multiple sites to use, as well. e.g. Timey1 x1 y2 x2 1 4 6 7 10 2 5 10 5 20 3 10 1 7 15 etc. I would like to use all of the sites in creating a model - I realize that the structure of the model would now be along the lines of: y(t)=b0+b1*y(t-1)+b2*y(t-2)...+a1*x(t)+a2*x(t-1)...+c Where c is the site effect - I know this can get all wrapped up in the intercept, but, how does one pass this data to arima() to make it work? I know that arima() takes a vector of y values - can it take a matrix of y values and a corresponding matrix of x values, or is there some other function that does this? -Jarrett __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] CCF and Lag questions
Pallavi Naresh wrote: I am new to R and new to time series modeling. I have a set of variables (var1, var2, var3, var4, var5) for which I have historical yearly data. I am trying to use this data to produce a prediction of var1, 3 years into the future. I have a few basic questions: 1) I am able to read in my data, and convert it to a time series format using 'ts.' data_ts - ts(data, start = 1988, end = 2005, frequency = 1, deltat = 1) However, I am not able to refer to the individual columns or variables of my new time series object. For example, I am able to reference 'var1' by typing, data$var1, but I can not do the same by using data_ts$var1. I don't see how I can use data_ts without being able to reference the individual columns in my dataset. So you have a multiple time series. Type class(data_ts) to see. This is a matrix, not a data.frame so you need: data_ts[,var1] in place of data_ts$var1 2) Since I'm trying to build a multivariate time series model, I want to find the correlations of var1 with my other variables (var1, var2, ...etc.) and their lagged values. But since I'm trying to produce a forecast for 3 years into the future, I want to find the ccf between var1 and my other variables lagged 3 years. I tried doing: ccf(var1, lag(var2, 3)) Try ccf( data_ts[,var1], data_ts[,var2]) but I get the following error: Error in na.fail.default(ts.union(as.ts(x), as.ts(y))) : missing values in object So if you have missing values in the object try: ccf( data_ts[,var1], data_ts[,var2], na.action=na.pass) Does anyone know how to use the lag funciton and ccf together? Is it necessary? Kjetil 3) Suppose var1 and var2 are both of length 20. I would expect the correlation of the fourth lag of ccf(var1, var2) to be the same as lag zero of: ccf(var1[1:17], var2[4:20]), but they are not. Can someone explain why not? 4) How do I interpret the negative lags produced from the ccf function? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] extendable arrays in R
Brad Thompson wrote: In an R program I am working on, I progressively build up several vectors of integers. I never know how long the vectors will eventually be, so I can't preallocate them with vector(). If I preallocate all of the vectors to their maximum size, I will run out of memory. I tried using c() or append() to build up the vectors, as in the following (tried on R 2.1.0 on Linux and R 2.2.1 on MacOS 10): li - vector() # also tried list() and pairlist() for (i in 0:4) { li - c(li, i) # also tried with i and li swapped if (i %% 1 == 0) system('date') } The problem is that based on the times this outputs, it is O(n^2), matching the straightforward implementation of c() where everything passed to c() is copied. I tried extending the vector by assigning to length(li) instead of using c(), but that also runs in O(n) (so the loop runs in O(n^2)) and appears to copy the elements. What I am looking for is an array that can dynamically resized in amortized constant or log time (like python's list or C++'s std::vector). I could build up a data structure inside R (the same way std::vector is built on top of C arrays), but I was hoping someone might have some advice on a better way to do this. Does R have a resizeable array type that I'm missing? What do others generally do in this case? Thank you, Brad Hi, Brad, You can add length as needed as in: ## create a buffer li - vector(numeric, 1000) t1 - proc.time()[3] for (i in 1:99) { ## add more space if needed if(i length(li)) length(li) - length(li) + 1000 li[i] - i if(i %% 1 == 0) { t2 - proc.time()[3] cat(sprintf(n = %6d; time = %4.2f\n, i, t2 - t1)) ## flush.console() ## Windows only, I think t1 - t2 } } ## resize 'li' length(li) - i HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] extracting RGB values from a colorspace class object
Greetings, After pouring over the documentation for the 'colorspace' package, I have not been able to figure out how the plot() method converts colorspace coordinates to RGB values for display on the screen. I am convert between colorspaces with the various as() methods... but cannot seem to find a way to extract RGB (i.e. for displaying on a computer screen) triplets from color space coordinates. Here is a sample of the data that I am working with: H V C x y Y 2.5Y0.2 2 1.43 0.97 0.237 2.5Y0.4 2 0.729 0.588 0.467 2.5Y0.6 2 0.563 0.491 0.699 2.5Y0.6 4 0.995 0.734 0.699 2.5Y0.8 2 0.479 0.439 0.943 2.5Y0.8 4 0.82 0.64 0.943 2.5Y 1 20.43620.4177 1.21 I have converted xyY coordinates to XYZ coordinates, based on the equations presented here: http://www.brucelindbloom.com/index.html?ColorCalcHelp.html #read in the soil colors: munsell + xyY soil - read.table(soil_colors, header=F, col.names=c(H,V,C,x,y,Y)) #convert to XYZ X - (soil$x * soil$Y ) / soil$y Y - soil$Y Z - ( (1- soil$x - soil$y) * soil$Y ) / soil$y #make an XYZ colorspace object: require(colorspace) soil_XYZ - XYZ(X,Y,Z) #visualize the new XYZ colorspace object in the L*U*V colorspace: plot(as(soil_XYZ, LUV), cex=2) here is an example of the output: http://169.237.35.250/~dylan/temp/soil_colors-LUV_space.png Somehow the plot() method in the colorspace package is converting color space coordinates to their RGB values... Does anyone have an idea as to how to access these RGB triplets? Thanks in advance! -- Dylan Beaudette Soils and Biogeochemistry Graduate Group University of California at Davis 530.754.7341 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Combining plaintext and plotmath expressions
I searched the archives and did not find a solution, so I pose this question to those well-versed in the use of plotmath and expressions. I have a list of strings in an external CSV file which I wish to use sometimes as plot axis labels and sometimes as plot titles. These strings combine plaintext and a few mathematical expressions (Greek letters, subscripts). Moreover, I sometimes need to concatenate other plaintext with these strings. Thus far I have written my string list to look like this: X translation (*mu*m) Rotation (*degree*) Mean (*mu*m) Vb1-Vb2 *(Omega) H[2]O Used Max P # Defects I read in the strings, and use one at a time in the variable parmlabel. I have another variable called testlabel which I also need to concatenate, and can be things like distance or E-test. Sometimes I also concatenate another variable oplabel when the variable op is not zero-length. I have kludged a solution using this function: expr.label-function(title=){ ## single quote the character # so that it is not interpreted as a comment parmlabel-gsub(#,'#',cfg$parmlabel[icfg]) ## make sure that a string like Vb1-Vb2 is not interpreted as subtraction text1-gsub(-,*'-'*,testlabel) ## if need to prepend title test, do that, and make multiple spaces single if(nchar(title)) text1-paste(gsub( , ,title), ,testlabel,sep=) ## substitute to avoid interpretation of for text1-gsub(for,f*or,text1,fixed=TRUE) ## substitute ~ for spaces to avoid errors in parsing text1-gsub( ,~,text1,fixed=TRUE) ## see if we have a parsable expression text2-try(parse(text=parmlabel),silent=TRUE) ## if not parsable then concatenate another way if(class(text2)==try-error | length(text2)==0){ text2-gsub( ,~,parmlabel) exprtitle-paste(text1,text2,sep=~) } else{ exprtitle-paste('',text1,'~*',text2,sep='') } exprtitle-paste(text1,text2,sep=~) ## if the variable op is not zero-length, then use oplabel if(nchar(op)1) exprtitle=paste(exprtitle,'~',gsub(' ','~',oplabel),sep=) return(exprtitle) } As an example: parmlabel-'Vb1-Vb2 *(Omega)' testlabel-'E-test' op-'dev lab' oplabel-'Development Lab' expr.label(SPC Chart for) I then use exprtitle in: plot(1:10,title= if(plotnum==1) parse(text=exprtitle) else NULL) However: this code seems convoluted and ungainly I don't always get the results I want Any suggestions? Leif Kirschenbaum Senior Yield Engineer Reflectivity, Inc. (408) 737-8100 x307 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Curious subsetting behavior
I have a simple vector, called tmp that I want to subset based on another vector called vec. Everything works as expected except for below where the subsetting returns something other than the original data. Any ideas? vec - c(1,2,3,4,5,59,60,27,32,21) tmp [1] 1.0 1.1 2.0 2.1 2.2 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 [16] 9.1 9.2 10.0 10.1 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 18.1 19.0 20.0 [31] 20.1 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 28.1 29.0 29.1 30.0 31.0 32.0 [46] 34.0 35.0 37.0 37.1 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 45.1 46.0 48.0 [61] 50.0 tmp[-vec] [1] 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 9.1 9.2 10.0 10.1 11.0 [16] 13.0 14.0 15.0 16.0 17.0 18.1 19.0 20.0 20.1 22.0 23.0 24.0 25.0 26.0 27.0 [31] 28.0 28.1 29.0 29.1 30.0 31.0 32.0 34.0 35.0 37.0 37.1 38.0 39.0 40.0 41.0 [46] 42.0 43.0 44.0 45.0 45.1 50.0 vec - which(!is.na(MA.exp$targets$Grade)) vec [1] 1 3 8 9 11 12 13 15 18 21 22 23 24 25 26 27 29 30 32 33 34 35 36 37 38 [26] 39 41 43 44 45 46 47 48 51 52 53 54 55 56 57 59 60 61 str(vec) int [1:43] 1 3 8 9 11 12 13 15 18 21 ... tmp[1:20] [1] 1.0 1.1 2.0 2.1 2.2 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 [16] 9.1 9.2 10.0 10.1 11.0 Everything above is as expected. However, look at the output of tmp[vec] below. Why are the values of tmp incorrect? What am I missing? tmp[vec] [1] 1 2 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [26] 28 29 30 31 32 34 35 37 39 40 41 42 43 44 45 46 48 50 sessionInfo() Version 2.3.0 Under development (unstable) (2006-01-04 r36984) powerpc-apple-darwin8.3.0 attached base packages: [1] tools methods stats graphics grDevices utils [7] datasets base other attached packages: geneplotterannotate Biobase gplots gdata gtools 1.9.5 1.9.2 1.9.4 2.0.0 2.0.0 2.0.0 RdbiPgSQL RdbiPgSQLRdbi seanlib limma 1.0.9 1.0.9 1.0.4 1.0 2.4.9 Thanks, Sean [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] linear lists, creation, insertion, deletion , traversal *someone?*
Christian Hoffmann christian.hoffmann at wsl.ch writes: Hi, In a second try I will ask this list to give me some useful pointers. Linear lists, as described e.g. by N.Wirth in Algorithms and Data Structures, seem not to be implemented in S/R, although in lisp we have cons, car, cdr. [snip description of ops on linked list] Mapping this list management to R's list() is possible, but may not be so transparent. Insertions and deletions from a list may be more convoluted. If the linked list you are using will be large and involve lots of manipulation, you might want to store and implement it in C. But if you do it in native R ... You might use new.env(hash=TRUE) to create an environment() as the linked-list. It would contain one object that contains the name of (serving as the pointer to) the first node. (or it would contain NULL or FALSE if the linked-list was of length zero.) Each node would be a list() with two components: the value and the name of (i.e. the pointer to) the next element. To add a node you would create a name that is unique (within the environment at least), use assign() once to place the new node in the environment and once more to rewrite the preceeding nodes pointer to contain the name of the new node. Initialize and add data to a linked list: linklist - new.env(hash=TRUE) assign('start',FALSE,envir=linklist) for (i in 1:1 ){ + assign(as.character(i), list( ptr=get('start',linklist), value=rnorm(1) ), + envir=linklist) + assign('start',as.character(i), envir=linklist ) + } get(501,linklist) # example of one node $ptr [1] 500 $value [1] -0.7022237 Of course, you would write a function to do those two assignments. To delete a node you would use assign() to reset the pointer from the previous to the succeeding node, then rm() to delete the defunct node. to.delete - get(501, linklist)$ptr assign( 501, list(ptr = get( to.delete, linklist )$ptr, + val = get(501, linklist)$val ), linklist ) rm( list=to.delete, envir=linklist ) get(501,linklist) $ptr [1] 499 $val [1] -0.7022237 Does anybody have experience in this? I could not find any reference in R resources, also the Blue Book is mute here. Thank you Christian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Curious subsetting behavior
Just because R doesn't print the extraneous .0 you think the result is wrong? Andy From: Sean Davis I have a simple vector, called tmp that I want to subset based on another vector called vec. Everything works as expected except for below where the subsetting returns something other than the original data. Any ideas? vec - c(1,2,3,4,5,59,60,27,32,21) tmp [1] 1.0 1.1 2.0 2.1 2.2 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 [16] 9.1 9.2 10.0 10.1 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 18.1 19.0 20.0 [31] 20.1 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 28.1 29.0 29.1 30.0 31.0 32.0 [46] 34.0 35.0 37.0 37.1 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 45.1 46.0 48.0 [61] 50.0 tmp[-vec] [1] 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 9.1 9.2 10.0 10.1 11.0 [16] 13.0 14.0 15.0 16.0 17.0 18.1 19.0 20.0 20.1 22.0 23.0 24.0 25.0 26.0 27.0 [31] 28.0 28.1 29.0 29.1 30.0 31.0 32.0 34.0 35.0 37.0 37.1 38.0 39.0 40.0 41.0 [46] 42.0 43.0 44.0 45.0 45.1 50.0 vec - which(!is.na(MA.exp$targets$Grade)) vec [1] 1 3 8 9 11 12 13 15 18 21 22 23 24 25 26 27 29 30 32 33 34 35 36 37 38 [26] 39 41 43 44 45 46 47 48 51 52 53 54 55 56 57 59 60 61 str(vec) int [1:43] 1 3 8 9 11 12 13 15 18 21 ... tmp[1:20] [1] 1.0 1.1 2.0 2.1 2.2 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 [16] 9.1 9.2 10.0 10.1 11.0 Everything above is as expected. However, look at the output of tmp[vec] below. Why are the values of tmp incorrect? What am I missing? tmp[vec] [1] 1 2 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [26] 28 29 30 31 32 34 35 37 39 40 41 42 43 44 45 46 48 50 sessionInfo() Version 2.3.0 Under development (unstable) (2006-01-04 r36984) powerpc-apple-darwin8.3.0 attached base packages: [1] tools methods stats graphics grDevices utils [7] datasets base other attached packages: geneplotterannotate Biobase gplots gdata gtools 1.9.5 1.9.2 1.9.4 2.0.0 2.0.0 2.0.0 RdbiPgSQL RdbiPgSQLRdbi seanlib limma 1.0.9 1.0.9 1.0.4 1.0 2.4.9 Thanks, Sean [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Curious subsetting behavior
On 3/2/06 3:25 PM, Liaw, Andy [EMAIL PROTECTED] wrote: Just because R doesn't print the extraneous .0 you think the result is wrong? Time to go home Thanks Andy. Sean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] do.call help
Hello all: I have a character variable (foo) that contains the names of some numeric variables. For my application, I'd like to cbind the numeric variables and calculate the row mean using the character variable. I think I do this using do.call but the function to call using do.call is eluding me! Example below and help appreciated. TIA, -Andy x1-x2-x3-x4-rnorm(10) foo - c(x1,x2,x3,x4) # what I want... rowMeans(cbind(x1,x2,x3,x4)) bar - function(aCharVaraible) { cbind(stuff goes here) rowMeans(stuff goes here) } # how I want to get it... do.call(bar,foo) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] do.call help
Andy Bunn wrote: Hello all: I have a character variable (foo) that contains the names of some numeric variables. For my application, I'd like to cbind the numeric variables and calculate the row mean using the character variable. I think I do this using do.call but the function to call using do.call is eluding me! Example below and help appreciated. TIA, -Andy x1-x2-x3-x4-rnorm(10) foo - c(x1,x2,x3,x4) # what I want... rowMeans(cbind(x1,x2,x3,x4)) bar - function(aCharVaraible) { cbind(stuff goes here) rowMeans(stuff goes here) } # how I want to get it... do.call(bar,foo) How about: set.seed(42) x1 - x2 - x3 - x4 - rnorm(10) foo - c(x1,x2,x3,x4) bar - function(x) { y - do.call(cbind, lapply(x, get)) rowMeans(y) } do.call(bar, list(foo)) HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Summary()
Hi, I have a dataframe(FireDanger) that contains weather data (T, RH, WS, etc) measured at 27 stations. I want to do a quantile summary for each variable at each station. quantile(FireDanger$RH, probs=seq(0,1,0.1), na.rm=T) summary(FireDanger) are close, but not quite. Is there a single command to get this done? Thank you. Daniel Chan Meteorologist Georgia Forestry Commission P O Box 819 Macon, GA 31202 Tel: 478-751-3508 Fax: 478-751-3465 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Summary()
Probably something like this: x - as.data.frame(matrix(rnorm(27 * 5), 27, 5)) sapply(x, quantile, seq(0, 1, .1)) V1 V2 V3 V4 V5 0% -3.18125816 -2.3857797 -1.0564583 -2.5085757 -2.142863890 10% -1.63832807 -1.3854193 -0.7863538 -2.0054480 -1.308758065 20% -0.55663305 -0.9820594 -0.5997770 -0.8506803 -0.855000253 30% -0.24216894 -0.6497351 -0.4301487 -0.5292818 -0.685654756 40% -0.18417030 -0.3367184 -0.3249491 -0.2804804 -0.552243583 50% -0.01245975 -0.1686330 -0.2490444 -0.1474143 -0.374655382 60% 0.10358080 0.1360502 0.1102148 0.2109845 -0.006060502 70% 0.52499224 0.3635301 0.3328593 0.4300751 0.186768725 80% 1.27043728 0.6718734 0.6026165 0.9356643 0.643105330 90% 1.77792321 1.3059572 0.8323459 1.3301074 1.398859959 100% 2.38227909 2.5356611 2.0936289 1.9094287 2.181349090 HTH, Andy From: Dan Chan Hi, I have a dataframe(FireDanger) that contains weather data (T, RH, WS, etc) measured at 27 stations. I want to do a quantile summary for each variable at each station. quantile(FireDanger$RH, probs=seq(0,1,0.1), na.rm=T) summary(FireDanger) are close, but not quite. Is there a single command to get this done? Thank you. Daniel Chan Meteorologist Georgia Forestry Commission P O Box 819 Macon, GA 31202 Tel: 478-751-3508 Fax: 478-751-3465 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] calling R's library using C
Hi, Thanks, everyone for all the help! So, here is my calling function in C (called test.c): #includestdio.h #includestdlib.h #includeRmath.h int main(void) { printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } I compile using: gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lm -lR However, running ./a.out gives me: 1.00 0.040160 The first is wrong, but the second non-central is correct, and matches the answer from R. Incidentally, pgamma (which is what pchisq calls, as per the C program inside R) is also wrong and not surprisingly, gives the same answer as above. Any suggestions? Many thanks! __ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Increase Decimal Accuracy?
Is there any way to increase the decimal accuracy for probability distributions. For example (in R): 1-pchisq(90,5) [1] 0 But in Maple, I find that the value is 0.67193x10-17. I need to compare some really small p-values...is there a way to increase the decimal place accuracy beyond 1x10-16 (which seems to be the limit)? Any help would be appreciated. Ann __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Increase Decimal Accuracy?
Ann Hess wrote: Is there any way to increase the decimal accuracy for probability distributions. For example (in R): 1-pchisq(90,5) [1] 0 But in Maple, I find that the value is 0.67193x10-17. Look at this: 1-pchisq(90,5) [1] 0 pchisq(90,5, lower=FALSE) [1] 6.71932e-18 Kjetil I need to compare some really small p-values...is there a way to increase the decimal place accuracy beyond 1x10-16 (which seems to be the limit)? Any help would be appreciated. Ann __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Increase Decimal Accuracy?
Ann Hess wrote: Is there any way to increase the decimal accuracy for probability distributions. For example (in R): 1-pchisq(90,5) [1] 0 But in Maple, I find that the value is 0.67193x10-17. I need to compare some really small p-values...is there a way to increase the decimal place accuracy beyond 1x10-16 (which seems to be the limit)? Any help would be appreciated. Ann Try pchisq(90, 5, lower.tail = FALSE) Also read FAQ 7.31. http://cran.r-project.org/faqs.html HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library file for R's nmath routines
I guess that you intended to send this message to the list. :-) On 02/03/06, Globe Trotter [EMAIL PROTECTED] wrote: Hi, Thanks, everyone for all the help! So, here is my calling function in C (called test.c): #includestdio.h #includestdlib.h #includeRmath.h int main(void) { printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } I compile using: gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lm -lR Why do you link against libm? Shouldn't it be gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lRmath -lR ? However, running ./a.out gives me: 1.00 0.040160 The first is wrong, but the second non-central is correct, and matches the answer from R. Incidentally, pgamma (which is what pchisq calls, as per the C program inside R) is also wrong and not surprisingly, gives the same answer as above. Any suggestions? Many thanks! -- José Matos __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] library file for R's nmath routines
Hi, Thanks! --- Jos� Matos [EMAIL PROTECTED] wrote: I guess that you intended to send this message to the list. :-) On 02/03/06, Globe Trotter [EMAIL PROTECTED] wrote: Hi, Thanks, everyone for all the help! So, here is my calling function in C (called test.c): #includestdio.h #includestdlib.h #includeRmath.h int main(void) { printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } I compile using: gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lm -lR Why do you link against libm? Shouldn't it be gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lRmath -lR ? I linked against libm because Rmath.h includes math.h so I thought that maybe those links are needed. But even linking this does not give the correct answer (for pchisq). Something else is going on. I could not also get the runif to work. Thanks! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] calling R's library using C
(whitespace trimmed) On 2 March 2006 at 13:42, Globe Trotter wrote: | Thanks, everyone for all the help! So, here is my calling function in C | (called | test.c): | | #includestdio.h | #includestdlib.h | #includeRmath.h | | int main(void) { |printf(%f \n,pchisq(2.,7., 1, 0)); |printf(%f \n,pnchisq(2.,7.,0., 1, 0)); |return EXIT_SUCCESS; | } | | I compile using: | | gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lm -lR | | However, running | ./a.out | | gives me: | | 1.00 | 0.040160 | | The first is wrong, but the second non-central is correct, and matches the | answer from R. | | Incidentally, pgamma (which is what pchisq calls, as per the C program inside | R) is also wrong and not surprisingly, gives the same answer as above. | | Any suggestions? As Brian Ripley already told you, you are so wrong that it is unclear why we bother helping you for matters clearly stated in manuals you continue to ignore. Anyway -- on my Debian system, your file compiles, builds and runs fine: [EMAIL PROTECTED]:/tmp gcc -o globetrotter -I/usr/share/R/include globetrotter.c -lm -lRmath -L/usr/lib/R/lib -lR [EMAIL PROTECTED]:/tmp LD_LIBRARY_PATH=/usr/lib/R/lib ./globetrotter 0.040160 0.040160 That said, I put fine in quotes as you shouldn't need either -lR nor the include directive. Witness: [EMAIL PROTECTED]:/tmp cp /usr/share/doc/r-mathlib/examples/test.c nmtest.c [EMAIL PROTECTED]:/tmp gcc -o nmtest nmtest.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./nmtest [EMAIL PROTECTED]:/tmp tail -6 nmtest.c main() { /* something to force the library to be included */ qnorm(0.7, 0.0, 1.0, 0, 0); return 0; } [EMAIL PROTECTED]:/tmp The key is the #define MATHLIB_STANDALONE 1 in the R example. Once you add that before the #include for Rmath.h, you're fine: [EMAIL PROTECTED]:/tmp gcc -o globetrotter globetrotter.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./globetrotter 0.040160 0.040160 [EMAIL PROTECTED]:/tmp cat globetrotter.c #includestdio.h #includestdlib.h #define MATHLIB_STANDALONE 1 #include Rmath.h int main(void) { printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } As they say, if all else fails you could consider reading the manual that discusses this example. Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Command-line editing history
Hi all, Are there any plans to add more functionality to command-line editing and history editing on the command line? In MATLAB (I know, comparisons are odious ...), you can type p and up-arrow on the command line and scroll through the recently entered commands beginning with p. This is a very useful feature and something that I believe is not replicated in R. Please correct me if I'm wrong; currently I use history(Inf) in R, search for what I want and cut and paste if I find what I'm looking for. Also in MATLAB, tab completion is available for directory listings and also for function name completion. Again, I'm unaware of how to do this in R. The added MATLAB functionality makes finding files easy on the command line and it also saves the fingers on long function names. Thanks, Jack. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Collinearity in nls problem
Trying different parameterizations is often a wise with nonlinear regression. However, I know of no general rule for finding a good one other than to try several and try to fit a paraboloid to the sums of squares surface in a region of the least squares solution: The best parameterization will be fairly close to parabolic. To do this, I've used expand.grid to get the points, then chop of all points with sums of squares exceeding the minimum plus some number that should represent, say, a joint 99% confidence region. I also supplement this with contour or perspective plots: Parameterizations with the better R^2's usually also have a more elliptical appearance in contour plots. I've done this successfully to find a parameterization that will both speed up estimation AND provide reasonable accuracy with Wald approximate confidence intervals. Even without that, however, we can still get good, joint confidence regions in the form of contour plots of the sums of squares surface: The validity of these confidence regions is only affected by the intrinsic curvature of the problem, and is not affected by the parameterization. Of course, if we select a strange parameterization, our confidence regions will not look very elliptical (and our univariate confidence intervals may be far from symmetric). My favorite reference for this kind of thing is Bates and Watts (1988) Nonlinear Regression Analysis and Its Applications (Wiley). hope this helps. spencer graves Simon Frost wrote: Dear R-Help list, I have a nonlinear least squares problem, which involves a changepoint; at the beginning, the outcome y is constant, and after a delay, t0, y follows a biexponential decay. I log-transform the data, to stabilize the error variance. At time t t0, my model is log(y_i)=log(exp(a0)+exp(b0)) at time t = t0, the model is log(y_i)=log(exp(a0-a1*(t_i - t0))+exp(b0=b1*(t_i - t0))) I thought that I would have identifiability issues, but this model seems to work fine except that the parameters t0 (the delay) is highly correlated with the initial decay slope a0 (which makes sense, as the longer the delay, the more rapid the drop has to be, conditional on the data). To get over this problem, I could reparameterize the problem, but it isn't clear to me how to do this for the above model. I also thought about using a penalized least square approach, to shrink t0 and a1 towards 0. I haven't seen much on penalized least squares in a nonlinear least squares setting; is this a good way to go? Can I justifiably penalize only a0 and a1, or should I also penalize the other parameters? Thanks for any help! Simon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to show the intermediate tick marks without the values in a different color
Is there a way to show also the intermediate tick marks without the values? Example: plot(cars) What would one do to show the tick marks in, say, gray color at the increment of 1 without showing the actual values in-between the default x values: 5, 10, 15, 20, 25? platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R Thanks, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Command-line editing history
Unless I'm mistaken, all those features (and more) are available if you run R within ESS/(X)Emacs. Andy From: John McHenry Hi all, Are there any plans to add more functionality to command-line editing and history editing on the command line? In MATLAB (I know, comparisons are odious ...), you can type p and up-arrow on the command line and scroll through the recently entered commands beginning with p. This is a very useful feature and something that I believe is not replicated in R. Please correct me if I'm wrong; currently I use history(Inf) in R, search for what I want and cut and paste if I find what I'm looking for. Also in MATLAB, tab completion is available for directory listings and also for function name completion. Again, I'm unaware of how to do this in R. The added MATLAB functionality makes finding files easy on the command line and it also saves the fingers on long function names. Thanks, Jack. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to show the intermediate tick marks without the values in a different color
On Thu, 2006-03-02 at 20:06 -0600, xpRt.wannabe wrote: Is there a way to show also the intermediate tick marks without the values? Example: plot(cars) What would one do to show the tick marks in, say, gray color at the increment of 1 without showing the actual values in-between the default x values: 5, 10, 15, 20, 25? Try this: # Do the plot without the x axis plot(cars, xlim = c(0, 25), xaxt = n) # Do the x axis in grey with tick marks at 0:25 # without labels axis(1, at = 0:25, labels = NA, col = grey) # Now do the default tick marks in black with labels axis(1) See ?plot.default, ?par (for 'xaxt') and ?axis for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Command-line editing history
And JGR has that features as well. 2006/3/3, Liaw, Andy [EMAIL PROTECTED]: Unless I'm mistaken, all those features (and more) are available if you run R within ESS/(X)Emacs. Andy From: John McHenry Hi all, Are there any plans to add more functionality to command-line editing and history editing on the command line? In MATLAB (I know, comparisons are odious ...), you can type p and up-arrow on the command line and scroll through the recently entered commands beginning with p. This is a very useful feature and something that I believe is not replicated in R. Please correct me if I'm wrong; currently I use history(Inf) in R, search for what I want and cut and paste if I find what I'm looking for. Also in MATLAB, tab completion is available for directory listings and also for function name completion. Again, I'm unaware of how to do this in R. The added MATLAB functionality makes finding files easy on the command line and it also saves the fingers on long function names. Thanks, Jack. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R for Windows GUI front-end has encountered a problem
Hi, I try to run my model using Quantile Regression (quantreg) package. However, when I run the script, it has an error message in a pop-up window: R for Windows GUI front-end has encountered a problem and needs to close. We are sorry for the inconvenience. The error has error information as follows: Error signature AppName: rgui.exeAppVer: 2.21.51220.0ModName: r.dll ModVer: 2.21.51220.0 Offset: 00065e50 I am not sure what causes this problem since sometime the model is run through and give the result. Sometime it has an error during the way. If the model itself is wrong, it should not give any result but in my case, it gives the result but just sometime. If you know what causes this problem and know how to solve it, please let me know. Thank you very much for your help. Sincerely yours, Nantachai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Fwd: Re: calling R's library using C
Sorry, forgot to switch the header to the R group --- Globe Trotter [EMAIL PROTECTED] wrote: Date: Thu, 2 Mar 2006 19:35:21 -0800 (PST) From: Globe Trotter [EMAIL PROTECTED] Subject: Re: [R] calling R's library using C To: Dirk Eddelbuettel [EMAIL PROTECTED] Hi, Dirk: Thanks for all the help. I thought I would clarify certain things. First, I did not read that section of the manual (no one provided the pertinent link), but I did try out that example that you suggested. It is also in R.2.2.1/src/nmath/standalone. However, and this is where I got misled, Professor Ripley's caustic statement that I should have had the functions in libR.so (but I did not know where to look) led me astray. I am sure it is all my fault. Anyway, the fact of the matter is that because if I include that library (and define that MATH_STANDALONE), I get errors: in particular, it would not recognize set_seed (which is a function which should work only if that is included). So, something was clearly long. After spending all of Thursday on this, I decided to post back. Thanks again for your missive. While I would appreciate the pertinent manual (English is not my strong suit, but I can follow there, I am sure): btw, I do not have the /usr/share/doc/r-mathlib/ directory, nor is it anywhere on my system (as per the output to locate), I really thank you for all your help! I am sure Professor Ripley would also appreciate your support. --- Dirk Eddelbuettel [EMAIL PROTECTED] wrote: (whitespace trimmed) On 2 March 2006 at 13:42, Globe Trotter wrote: | Thanks, everyone for all the help! So, here is my calling function in C | (called | test.c): | | #includestdio.h | #includestdlib.h | #includeRmath.h | | int main(void) { |printf(%f \n,pchisq(2.,7., 1, 0)); |printf(%f \n,pnchisq(2.,7.,0., 1, 0)); |return EXIT_SUCCESS; | } | | I compile using: | | gcc test.c -I/usr/lib/R/include -L/usr/lib/R/lib -lm -lR | | However, running | ./a.out | | gives me: | | 1.00 | 0.040160 | | The first is wrong, but the second non-central is correct, and matches the | answer from R. | | Incidentally, pgamma (which is what pchisq calls, as per the C program inside | R) is also wrong and not surprisingly, gives the same answer as above. | | Any suggestions? As Brian Ripley already told you, you are so wrong that it is unclear why we bother helping you for matters clearly stated in manuals you continue to ignore. Anyway -- on my Debian system, your file compiles, builds and runs fine: [EMAIL PROTECTED]:/tmp gcc -o globetrotter -I/usr/share/R/include globetrotter.c -lm -lRmath -L/usr/lib/R/lib -lR [EMAIL PROTECTED]:/tmp LD_LIBRARY_PATH=/usr/lib/R/lib ./globetrotter 0.040160 0.040160 That said, I put fine in quotes as you shouldn't need either -lR nor the include directive. Witness: [EMAIL PROTECTED]:/tmp cp /usr/share/doc/r-mathlib/examples/test.c nmtest.c [EMAIL PROTECTED]:/tmp gcc -o nmtest nmtest.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./nmtest [EMAIL PROTECTED]:/tmp tail -6 nmtest.c main() { /* something to force the library to be included */ qnorm(0.7, 0.0, 1.0, 0, 0); return 0; } [EMAIL PROTECTED]:/tmp The key is the #define MATHLIB_STANDALONE 1 in the R example. Once you add that before the #include for Rmath.h, you're fine: [EMAIL PROTECTED]:/tmp gcc -o globetrotter globetrotter.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./globetrotter 0.040160 0.040160 [EMAIL PROTECTED]:/tmp cat globetrotter.c #includestdio.h #includestdlib.h #define MATHLIB_STANDALONE 1 #include Rmath.h int main(void) { printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } As they say, if all else fails you could consider reading the manual that discusses this example. Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ Do You Yahoo!? http://mail.yahoo.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Fwd: Re: calling R's library using C
On 2 March 2006 at 19:37, Globe Trotter wrote: | Thanks for all the help. I thought I would clarify certain things. First, I | did | not read that section of the manual (no one provided the pertinent link), I'd do it now. Really. Not later. *Now*. Like the Posting Guide recommends. You may have heard of the sites www.r-project.org and cran.r-project.org. If you look closely, you will discover a link 'Manuals' on the left. You'd be surprised. All that you are griping about here is in Section 5.15 of the 'Writing R Extension' manual. | library (and define that MATH_STANDALONE), I get errors: in particular, it | would not recognize set_seed (which is a function which should work only if No problem here -- see below for you altered program and output. | (English is not my strong suit, but I can follow there, I am sure): btw, I do | not have the /usr/share/doc/r-mathlib/ directory, nor is it anywhere on | my Because you're on Red Hat, and I am on Debian. | system (as per the output to locate), I really thank you for all your help! I | am sure Professor Ripley would also appreciate your support. He really doesn't need my help, but I am flattered by the suggestion. Hope this helps, Dirk [EMAIL PROTECTED]:/tmp cat globetrotter.c #includestdio.h #includestdlib.h #define MATHLIB_STANDALONE 1 #include Rmath.h int main(void) { set_seed(42, 43); printf(Random with fixed seed: %f\n, unif_rand()); printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } [EMAIL PROTECTED]:/tmp gcc -o globetrotter globetrotter.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./globetrotter Random with fixed seed: 0.692304 0.040160 0.040160 [EMAIL PROTECTED]:/tmp ./globetrotter Random with fixed seed: 0.692304 0.040160 0.040160 [EMAIL PROTECTED]:/tmp -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Fwd: Re: calling R's library using C
I'd do it now. Really. Not later. *Now*. Like the Posting Guide recommends. You may have heard of the sites www.r-project.org and cran.r-project.org. If you look closely, you will discover a link 'Manuals' on the left. You'd be surprised. All that you are griping about here is in Section 5.15 of the 'Writing R Extension' manual. Of course! Thanks! I did look at this some years ago: there were no examples then (that I could decipher, at least) and so it is time to look again! No problem here -- see below for you altered program and output. Thanks; I did figure it out, before I sent the e-mail. (I was just relating my Thursday experiences.) But thanks! It validates exactly, what I did (except that I used runif, which actually calls unif_rand(). Fabulous!! Thanks a lot again, Dirk! This has, really really helped!! Best wishes! | (English is not my strong suit, but I can follow there, I am sure): btw, I do | not have the /usr/share/doc/r-mathlib/ directory, nor is it anywhere on | my Because you're on Red Hat, and I am on Debian. | system (as per the output to locate), I really thank you for all your help! I | am sure Professor Ripley would also appreciate your support. He really doesn't need my help, but I am flattered by the suggestion. Hope this helps, Dirk [EMAIL PROTECTED]:/tmp cat globetrotter.c #includestdio.h #includestdlib.h #define MATHLIB_STANDALONE 1 #include Rmath.h int main(void) { set_seed(42, 43); printf(Random with fixed seed: %f\n, unif_rand()); printf(%f \n,pchisq(2.,7., 1, 0)); printf(%f \n,pnchisq(2.,7.,0., 1, 0)); return EXIT_SUCCESS; } [EMAIL PROTECTED]:/tmp gcc -o globetrotter globetrotter.c -lm -lRmath [EMAIL PROTECTED]:/tmp ./globetrotter Random with fixed seed: 0.692304 0.040160 0.040160 [EMAIL PROTECTED]:/tmp ./globetrotter Random with fixed seed: 0.692304 0.040160 0.040160 [EMAIL PROTECTED]:/tmp -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Plot graph with different symbol size
Dear All, This is regarding symbols function. I'm preparing a graph for different species in a plot (based on the coordinate x y). I used inches in symbol function to indicate the different symbols size based on the size class (in diameter of tree trunk). The problem is that the symbol size is arrange in descending order. So the symbol for two species with different number of size class will have the same symbol size for the largest of each species diameter class (descending order). If the species A has 3 size class (e.g 10,20,30); and another species B has 5 size class (10,20,30,40,50), the symbols size display is the same for species A is the same as symbol size for species B for size class 30,40,50. How can I solve the problem? Example of my program code: dbhcat=cut(spdata$dbh,breaks=c(10,50,100,300,600,10),labels=c(1,2,3,4,5)) symbols(spdata$gx,spdata$gy,dbhcat,inches=c(0.05,0.1,1.5,2.0,2.5,3.0),add=TRUE) Abd. Rahman Kassim, PhD Forest Management Ecology Program Forestry Conservation Division Forest Research Institute Malaysia Kepong 52109 Selangor Malaysia Fax: 603-62729852 Tel: 603-62797179 * * [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R for Windows GUI front-end has encountered a problem
Nantachai Kantanantha wrote: Hi, I try to run my model using Quantile Regression (quantreg) package. However, when I run the script, it has an error message in a pop-up window: R for Windows GUI front-end has encountered a problem and needs to close. We are sorry for the inconvenience. The error has error information as follows: Error signature AppName: rgui.exe AppVer: 2.21.51220.0ModName: r.dll ModVer: 2.21.51220.0 Offset: 00065e50 I am not sure what causes this problem since sometime the model is run through and give the result. Sometime it has an error during the way. If the model itself is wrong, it should not give any result but in my case, it gives the result but just sometime. If you know what causes this problem and know how to solve it, please let me know. Thank you very much for your help. Sincerely yours, Nantachai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Please report your problem together with a small but reproducible example to the package maintainer (hence CC: Roger Koenker). Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Two quick questions
Hi all, 1. How to construct a date from three variables year, month, and day, where all three are integers? 2. I have a dataframe by date and sector. I would like to add-up all entries for all variable with identical date and sector, replacing the original entries, i.e. emulate the STATA command collapse (sum) var1 var2 var3, by(date sector). Thank you, Serguei Kaniovski __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Memory problem
Hi list, I am analysing a large dataset using random coefficient (using nlme) and fixed effects (using lm function) models. I have problem with my R version 2. 2. 1 due to memory allocation difficulties. When I try to expand the memory I get the following error message. R --min-vsize=1000 --max-vsize=10 --min-nsize=500 --max-nsize=1000 Error: target of assignment expands to non-language object R --min-vsize=1000 --max-vsize=5 --min-nsize=500 --max-nsize=1000 Error: target of assignment expands to non-language object I am working on Mac OS X Power PC G5 platform. I was wondering if anybody could give me a hint on how to solve this problem. Thanks in advance for your help Regards Mahdi -- --- Mahdi Osman (PhD) E-mail: [EMAIL PROTECTED] --- Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer! Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Two quick questions
On Fri, 3 Mar 2006, Serguei Kaniovski wrote: Hi all, 1. How to construct a date from three variables year, month, and day, where all three are integers? ?ISOdate (and perhaps use as.Date on the result) 2. I have a dataframe by date and sector. I would like to add-up all entries for all variable with identical date and sector, replacing the original entries, i.e. emulate the STATA command collapse (sum) var1 var2 var3, by(date sector). ?by (I am not sure how you replace the original entries, as the result is far shorter. If you mean that you want to replace each of the entries for date/sector by the sum for that date/sector use indexing, but this is much more commonly done for the mean. As ever, an example would have helped clarify your intentions.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html