Re: [R] new article on R at oreillynet.com
Le 19.11.2005 16:47, Kevin Farnham a écrit : An article I wrote that provides a basic introduction to R has been published on Oreillynet.com. The article is titled Analyzing Statistics with GNU/R. Here is the link: http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html Please feel free to post comments or interesting basic R scripts at the end of the article. Kevin Farnham Hi Kevin, I think you forgot to use dev.off() when producing output graphic files. For example i don't think the last example before the conclusion works. Regards, Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques +---+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---+ __ R-help@stat.math.ethz.ch 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] force apply() to return a list
Hi I have a function f() that I want to apply() to a matrix. I want the answer to be a list. However, sometimes all the vectors returned by f() are the same length and apply() returns a matrix. I do not want this. Hi How do I force apply() to consistently return a list? Toy example follows. R f - function(x){1:max(x[1],4)} R a1 - cbind(1:5,5:1) R apply(a1,1,f) [[1]] [1] 1 2 3 4 [[2]] [1] 1 2 3 4 [[3]] [1] 1 2 3 4 [[4]] [1] 1 2 3 4 [[5]] [1] 1 2 3 4 5 list returned: desired behaviour. Now try the same but with a different matrix from a1: R a2 - cbind(1:3,3:1) R apply(a2,1,f) [,1] [,2] [,3] [1,]111 [2,]222 [3,]333 [4,]444 matrix returned: this is undesired behaviour (in my application, I pass the list to do.call()). How do I force apply() to behave consistently and return a list, irrespectively of the length of vectors returned by f()? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] new article on R at oreillynet.com
Le 21.11.2005 09:12, Romain Francois a écrit : Le 19.11.2005 16:47, Kevin Farnham a écrit : An article I wrote that provides a basic introduction to R has been published on Oreillynet.com. The article is titled Analyzing Statistics with GNU/R. Here is the link: http://www.onlamp.com/pub/a/onlamp/2005/11/17/r_for_statistics.html Please feel free to post comments or interesting basic R scripts at the end of the article. Kevin Farnham Hi Kevin, I think you forgot to use dev.off() when producing output graphic files. For example i don't think the last example before the conclusion works. Regards, Romain Hi again, I shouldn't post anything before the third coffea. That do work (maybe q() close the device) but I would still advise to call dev.off(). Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques +---+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---+ __ R-help@stat.math.ethz.ch 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] force apply() to return a list
a solution is the following f - function(x){list(1:max(x[1], 4))} a2 - cbind(1:3, 3:1) out - lapply(apply(a2, 1, f), [[, 1) 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: Robin Hankin [EMAIL PROTECTED] To: RHelp r-help@stat.math.ethz.ch Sent: Monday, November 21, 2005 9:16 AM Subject: [R] force apply() to return a list Hi I have a function f() that I want to apply() to a matrix. I want the answer to be a list. However, sometimes all the vectors returned by f() are the same length and apply() returns a matrix. I do not want this. Hi How do I force apply() to consistently return a list? Toy example follows. R f - function(x){1:max(x[1],4)} R a1 - cbind(1:5,5:1) R apply(a1,1,f) [[1]] [1] 1 2 3 4 [[2]] [1] 1 2 3 4 [[3]] [1] 1 2 3 4 [[4]] [1] 1 2 3 4 [[5]] [1] 1 2 3 4 5 list returned: desired behaviour. Now try the same but with a different matrix from a1: R a2 - cbind(1:3,3:1) R apply(a2,1,f) [,1] [,2] [,3] [1,]111 [2,]222 [3,]333 [4,]444 matrix returned: this is undesired behaviour (in my application, I pass the list to do.call()). How do I force apply() to behave consistently and return a list, irrespectively of the length of vectors returned by f()? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html 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] force apply() to return a list
Hi Dimitris On 21 Nov 2005, at 08:37, Dimitris Rizopoulos wrote: out - lapply(apply(a2, 1, f), [[, 1) thanks for this, but it doesn't quite do what I want: f - function(x){1:max(x[1],4)} lapply(apply(cbind(1:5,5:1), 1, f), [[, 1) [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 1 [[5]] [1] 1 I want [[1]] [1] 1 2 3 4 [[2]] [1] 1 2 3 4 [[3]] [1] 1 2 3 4 [[4]] [1] 1 2 3 4 [[5]] [1] 1 2 3 4 5 best wishes Robin -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] force apply() to return a list
I've also changed the f() function, i.e., f - function(x){list(1:max(x[1], 4))} I hope it'll work now. 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: Robin Hankin [EMAIL PROTECTED] To: Dimitris Rizopoulos [EMAIL PROTECTED] Cc: Robin Hankin [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Monday, November 21, 2005 9:40 AM Subject: Re: [R] force apply() to return a list Hi Dimitris On 21 Nov 2005, at 08:37, Dimitris Rizopoulos wrote: out - lapply(apply(a2, 1, f), [[, 1) thanks for this, but it doesn't quite do what I want: f - function(x){1:max(x[1],4)} lapply(apply(cbind(1:5,5:1), 1, f), [[, 1) [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 1 [[5]] [1] 1 I want [[1]] [1] 1 2 3 4 [[2]] [1] 1 2 3 4 [[3]] [1] 1 2 3 4 [[4]] [1] 1 2 3 4 [[5]] [1] 1 2 3 4 5 best wishes Robin -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 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] repeated values, nlme, correlation structures
You are concerned that, using the mean of each age category as variable leads to a loss of information regarding the variance on the weight at each age and nestbox. What information do you think you lose? In particular, have you studied the residuals from your fit? I would guess that the you probably have heterscedasticity with the variance of the residuals probably increasing with the age. Plots of the absolute residuals might help identify this. Also, is the number of blue tits in each age constant, or does it change, e.g., as some of the chicks die? To try to assess how much information I lost (especially if some of the chicks died), I might plot the weights in each nest box and connect the dots manually, attempting to assign chick identity to the individual numbers. I might do it two different ways, one best fit, and another worst plausible. Then I might try to fit models to these two augmented data sets as if I had the true chick identity. Then comparing these fits with the one you already have should help you evaluate what information you lost by using the averages AND give you a reasonable shot at recovering that information. If the results were promising, I might generate more than two sets of assignments, involving other people in that task. Bon Chance Spencer Graves Patrick Giraudoux wrote: Dear listers, My request of last week seems not to have drawn someone's attention. Suppose it was not clear enough. I am coping with an observational study where people's aim was to fit growth curve for a population of young blue tits. For logistic reasons, people have not been capable to number each individual, but they have a method to assess their age. Thus, nestboxes were visited occasionnally, youngs aged and weighted. This makes a multilevel data set, with two classification factors: - the nestbox (youngs shared the same parents and general feeding conditions) - age in each nestbox (animals from the same nestbox have been weighed along time, which likely leads to time correlation) Life would have been heaven if individuals were numbered, and thus nlme correlation structure implemented in the package be used easy. As mentioned above, this could not be the case. In a first approach, I actually used the mean weight of the youngs weighed at each age in nest boxes for the variable age, and could get a nice fit with nestbox as random variable and corCAR1(form=~age|nestbox) as covariation structure. modm0c-nlme(pds~Asym/(1+exp((xmid-age)/scal)), fixed=list(Asym~1,xmid~1,scal~1), random=Asym+xmid~1|nestbox,data=croispulm, start=list(fixed=c(10,5,2.2)), method=ML, corr=corCAR1(form=~age|nestbox) ) Assuming that I did not commited some error in setting model parameters (?), this way of doing is not fully satisfying, since using the mean of each age category as variable leads to a loss of information regarding the variance on the weight at each age and nestbox. My question is: is there a way to handle repeated values per group (here several youngs in an age category in each nestbox) in such a case? I would really appreciate an answer, even negative... Kind regards, Patrick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch 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] force apply() to return a list
Hi again Dimitris On 21 Nov 2005, at 08:52, Dimitris Rizopoulos wrote: I've also changed the f() function, i.e., f - function(x){list(1:max(x[1], 4))} lapply(apply(cbind(1:5,5:1), 1, f), [[, 1) oops, I missed that. Works fine now, with both cases, and I can use this. Thanks! Still, it's a little disconcerting that apply() as generally used can return a list 99.9% of the time and a matrix the other 0.1%. It took me a long time to track this down when debugging my code the other night. Does anyone else agree? Would it be possible to add an argument such as force.list (with default FALSE) to apply() that makes apply() return a list under all circumstances? Also, adding Dimitris's excellent workaround to apply()'s manpage would be helpful. best wishes rksh I hope it'll work now. Best, Dimitris -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to run R in batch mode
system(R CMD BATCH test.R,intern=TRUE) command works! thanks to everybody thank you kindly Duncan Murdoch wrote: On 11/18/2005 11:25 AM, Beatriz wrote: I write R CMD BATCH test.R in my R console I have send you an image (RunBatch.jpg) of my console and the test.R file I don't think the jpg made it to R-help, but I saw it. You tried to run R CMD BATCH test.R from within R. That's meant to be a system command. Since you're running in Windows, you should open a command shell. One way to do that is to choose Run... from the Start Menu, and enter cmd. You'll get a black command shell window. If your path is set properly so that you can run R from there, then R CMD BATCH test.R should work. There is a way to do this from within R: run system(R CMD BATCH test.R,intern=TRUE) This still depends on your path being set correctly to find R. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cointegration rank
Dear R - helpers, I am using the urca package to estimate cointegration relations, and I would be really grateful if somebody could help me with this questions: After estimating the unrestriced VAR with ca.jo I would like to impose the rank restriction (for example rank = 1) and then obtain the restricted estimate of PI to be utilized to estimate the VECM model. Is it possible? It seems to me that the function cajools estimates the VECM without the restrictions. Did I miss something? How is it possible to impose them? Thanks a lot in advance! Carlo Hello Carlo, you can achieve this, by calculating your desired PI-matrix by hand, given the slots 'V' and 'W' of your ca.jo object and then execute a restricted OLS-estimation, if I understand your goal correctly. Please, bear in mind the non-uniqueness of the factorization of the PI-matrix by doing so. HTH, Bernhard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html* Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * __ R-help@stat.math.ethz.ch 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] PNG-import into R
Hi there I'm looking for a function to read PNG-bitmap-images from a file into R. I only found: - the pixmap-package which cannot import png or similar formats - the rimage-package which can only import lossy jpeg-images (the convertion from png to jpeg modifies the data!) Is there any possibility to read PNG-files? Thanks for any help Dominic Sydler __ R-help@stat.math.ethz.ch 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] Is there anything like a write.fwf() or possibility to print a data.frame without rownames?
Dear R users, R has read.fwf() function, however I would need write.fwf. I know other write.* functions, but I need fixed width format of data, which I would like to export from R. I tried to use: - write.table, but I can not control alignment of columns - write.matrix from MASS, but columns are to wide I came to this option, which is very neat: # tmp is data.frame sink(file = file) print(tmp) sink() This works very nice, but I would like to get rid of rownames, which are always printed. Another not so important issue is width of printed columns. I presume this is determined by max(length column name, max(length of values in a column)) but sometimes it would be usefull to control width of columns also. Can someone help me with this issue? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch 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] cointegration rank
Thanks a lot! I have another question on cointegration, so I will go on this post. Is it possible to estimate a cointegration with some exogenous explanatory variables? Since, after testing for exogeneity, I would like to re-estimate the relation keeping some of the previous endogenous as exogenous. Many thanks! Carlo On Nov 21, 2005 11:21 AM, Pfaff, Bernhard Dr. [EMAIL PROTECTED] wrote: Dear R - helpers, I am using the urca package to estimate cointegration relations, and I would be really grateful if somebody could help me with this questions: After estimating the unrestriced VAR with ca.jo I would like to impose the rank restriction (for example rank = 1) and then obtain the restricted estimate of PI to be utilized to estimate the VECM model. Is it possible? It seems to me that the function cajools estimates the VECM without the restrictions. Did I miss something? How is it possible to impose them? Thanks a lot in advance! Carlo Hello Carlo, you can achieve this, by calculating your desired PI-matrix by hand, given the slots 'V' and 'W' of your ca.jo object and then execute a restricted OLS-estimation, if I understand your goal correctly. Please, bear in mind the non-uniqueness of the factorization of the PI-matrix by doing so. HTH, Bernhard __ R-help@stat.math.ethz.ch 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] Howto? plot legend with no line behind the points
Hi R-help, We are using R 2.2 on Win XP and have a detail question on how the legend can be optimised. We use the following; - plot(,type=b,...) The lines in the plot do not cross the points. How can we obtain the same effect in the legend? (points without a line through them..) We tried setting the pt.bg to white but this did not help. See script below. thanks, Jan par(mar=c(5,5,2,4) +.1) # dit om extra text in Y-as te plaatsen plot(ts.X, type=b, col=1, pch=19,ylim=c(-0.4,0.2),ylab=c(X)) legend.txt - c(X,Y) # Define how the legend looks like, place it on the right location legend(topright, legend.txt,col=1,lty=1, pch=c(19,1),bty=n, pt.bg=1) par(new=T) plot(ts.Y, type=b, lty=1, col=1, pch=1, ylab=, xlab=,yaxt=n,ylim=c(0.1,0.7)) axis(4) mtext(side=4, line=3, Y, cex=1) -- Ir. Jan Verbesselt Research Associate Lab of Geomatics, K.U.Leuven Vital Decosterstraat 102, 3000 Leuven, Belgium Tel:+32-16-329750 Fax:+32-16-329760 http://gloveg.kuleuven.ac.be/ 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] singular convergence with lmer function i lme4
Dear R users, I am trying to fit a GLMM to the following dataset; tab a bc 1 1 0.6 199320100313 2 1 0.8 199427100412 3 1 0.8 199427202112 4 1 0.2 199428100611 5 1 1.0 199428101011 6 1 0.8 19942810 7 0 0.8 199527103011 8 1 0.6 199527200711 9 0 0.8 199527202411 10 0 0.6 199529100412 11 1 0.2 19962620 12 2 0.8 199627200612 13 1 0.4 199628100111 14 1 0.8 199628101511 15 1 0.4 199726200212 16 1 0.2 199726202111 17 1 0.6 199727101411 18 2 0.6 199727106911 19 2 0.6 199728100212 20 0 0.4 199820100811 21 1 0.8 199826200611 22 2 0.6 199827203811 23 2 1.0 200038109911 24 0 0.6 200126202511 25 0 0.4 200226100311 26 1 0.6 200226100411 27 1 0.4 200226100611 28 1 0.4 200226126011 29 1 0.4 200226203712 30 2 0.6 200227220313 With the following model; lmer(a~b + (1|c), family=poisson, data=tab), What I want to do is to see if number of recruits (a) is dependent on the brood sex ratio (b) including brood identity (c) as random factor. However, I get the following error message; lmer(a~b + (1|c), family=poisson, data=tab) Error in devAGQ(PQLpars, 1) : Unable to invert singular factor of downdated X'X In addition: Warning messages: 1: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 2: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 3: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 4: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 5: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 6: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 7: IRLS iterations for PQL did not converge I do not understand what causes this error message, all help is highly appreciated! I am running R version 2.20 on win XPP. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R lme4 package version: 0.98-1 Matrix version: 0.98-7 lattice version: 0.12-11 Best regards, Arild __ R-help@stat.math.ethz.ch 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] singular convergence with lmer function i lme4
Arild Husby wrote: Dear R users, I am trying to fit a GLMM to the following dataset; tab a bc 1 1 0.6 199320100313 2 1 0.8 199427100412 3 1 0.8 199427202112 4 1 0.2 199428100611 5 1 1.0 199428101011 6 1 0.8 19942810 7 0 0.8 199527103011 8 1 0.6 199527200711 9 0 0.8 199527202411 10 0 0.6 199529100412 11 1 0.2 19962620 12 2 0.8 199627200612 13 1 0.4 199628100111 14 1 0.8 199628101511 15 1 0.4 199726200212 16 1 0.2 199726202111 17 1 0.6 199727101411 18 2 0.6 199727106911 19 2 0.6 199728100212 20 0 0.4 199820100811 21 1 0.8 199826200611 22 2 0.6 199827203811 23 2 1.0 200038109911 24 0 0.6 200126202511 25 0 0.4 200226100311 26 1 0.6 200226100411 27 1 0.4 200226100611 28 1 0.4 200226126011 29 1 0.4 200226203712 30 2 0.6 200227220313 With the following model; lmer(a~b + (1|c), family=poisson, data=tab), What I want to do is to see if number of recruits (a) is dependent on the brood sex ratio (b) including brood identity (c) as random factor. However, I get the following error message; lmer(a~b + (1|c), family=poisson, data=tab) Error in devAGQ(PQLpars, 1) : Unable to invert singular factor of downdated X'X In addition: Warning messages: 1: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 2: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 3: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 4: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 5: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 6: optim or nlminb returned message singular convergence (7) in: LMEopt(x = mer, value = cv) 7: IRLS iterations for PQL did not converge I do not understand what causes this error message, all help is highly appreciated! I am running R version 2.20 on win XPP. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.0 year 2005 month10 day 06 svn rev 35749 language R lme4 package version: 0.98-1 Matrix version: 0.98-7 lattice version: 0.12-11 Is this the entire dataset or just a portion. If the former, then you have thirty groups with one observation per group. This is not reasonable for fitting GLMM. I would suggest either making the grouping variable more broad or collecting more data. Since tab$c looks like dates, maybe try: tab$c2 - factor(substr(as.character(tab$c), 1, 4)) table(tab$c2) fit - lmer(a ~ b + (1 | c2), tab, poisson) This works, but you still have only one observation for 1993, 2000, and 2001. 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] question on RPART
Dera all, a simple question on rpart: when I run rpart on some data sets, I do not always get the surrogate splits at the root node. This does not depend on the presence of missing data because none of my data sets contains any, nevertheless sometimes i get them sometimes no, I wonder why! Can anybody help me? thanks a lot, melina Carmela Cappelli Department of Statistics School of Political Science University of Naples Federico II Via Rodinò n. 22 80138 Naples, Italy tel: +39-081-2537553 fax:+39-081-2537466 [[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] SPSS and R do they like each other?
Hi, I wonder how well SPSS and R communicate, because I need SPSS but would like to do some data manipulations in R. However I am very afraid of never ending import-export-complications especially with all those labels and extra information my SPSS files contain. My data come from SPSS and have to be exported to SPSS again (because I need to produce special output tables, which would be hard to generate in R). Have you done that kind of stuff? Thanks for sharing your experience! Michael __ R-help@stat.math.ethz.ch 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] cointegration rank
Thanks a lot! I have another question on cointegration, so I will go on this post. Is it possible to estimate a cointegration with some exogenous explanatory variables? Since, after testing for exogeneity, I would like to re-estimate the relation keeping some of the previous endogenous as exogenous. Many thanks! Carlo Hello Carlo, you can use the 'dumvar' argument for his purpose, and exclude the relevant variables from your data matrix 'x'. HTH, Bernhard On Nov 21, 2005 11:21 AM, Pfaff, Bernhard Dr. [EMAIL PROTECTED] wrote: Dear R - helpers, I am using the urca package to estimate cointegration relations, and I would be really grateful if somebody could help me with this questions: After estimating the unrestriced VAR with ca.jo I would like to impose the rank restriction (for example rank = 1) and then obtain the restricted estimate of PI to be utilized to estimate the VECM model. Is it possible? It seems to me that the function cajools estimates the VECM without the restrictions. Did I miss something? How is it possible to impose them? Thanks a lot in advance! Carlo Hello Carlo, you can achieve this, by calculating your desired PI-matrix by hand, given the slots 'V' and 'W' of your ca.jo object and then execute a restricted OLS-estimation, if I understand your goal correctly. Please, bear in mind the non-uniqueness of the factorization of the PI-matrix by doing so. HTH, Bernhard __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html* Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * __ R-help@stat.math.ethz.ch 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] SPSS and R – do they like each other?
Hello Micael, 2005/11/21, [EMAIL PROTECTED] [EMAIL PROTECTED]: Hi, I wonder how well SPSS and R communicate, because I need SPSS but would like to do some data manipulations in R. However I am very afraid of never ending import-export-complications – especially with all those labels and extra information my SPSS files contain. My data come from SPSS and have to be exported to SPSS again (because I need to produce special output tables, which would be hard to generate in R). I've experiencing no big problems when choosing a simple text format for your data files! Since I don't know what data specifics characterize your files it is hard to assure everything will go well. But if you do choose the appropriate file format there shouldn't be too much problem moving files to and fro R. regards Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames?
Hi did you tried something like write.table( tab, file.txt, sep=\t, row.names=F) which writes to tab separated file? Petr On 21 Nov 2005 at 11:56, Gregor Gorjanc wrote: Date sent: Mon, 21 Nov 2005 11:56:48 +0100 From: Gregor Gorjanc [EMAIL PROTECTED] Organization: University of Ljubljana To: [EMAIL PROTECTED] Subject:[R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Dear R users, R has read.fwf() function, however I would need write.fwf. I know other write.* functions, but I need fixed width format of data, which I would like to export from R. I tried to use: - write.table, but I can not control alignment of columns - write.matrix from MASS, but columns are to wide I came to this option, which is very neat: # tmp is data.frame sink(file = file) print(tmp) sink() This works very nice, but I would like to get rid of rownames, which are always printed. Another not so important issue is width of printed columns. I presume this is determined by max(length column name, max(length of values in a column)) but sometimes it would be usefull to control width of columns also. Can someone help me with this issue? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch 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] SPSS and R ? do they like each other?
Hi, from SPSS you can save in export format and then use read.spss in R. But you don't retain the labelling (AFAIK). Nevertheless, let me ask you what kind of table spss gives you that R can't? Ciao, Stefano On Mon, Nov 21, 2005 at 01:33:39PM +0100, Thomas Schönhoff wrote: ThomasHello Micael, Thomas Thomas2005/11/21, [EMAIL PROTECTED] [EMAIL PROTECTED]: Thomas Hi, Thomas Thomas I wonder how well SPSS and R communicate, because I Thomas need SPSS but would like to do some data manipulations Thomas in R. However I am very afraid of never ending Thomas import-export-complications ? especially with all Thomas those labels and extra information my SPSS files Thomas contain. My data come from SPSS and have to be Thomas exported to SPSS again (because I need to produce Thomas special output tables, which would be hard to generate Thomas in R). Thomas ThomasI've experiencing no big problems when choosing a simple text format Thomasfor your data files! ThomasSince I don't know what data specifics characterize your files it is Thomashard to assure everything will go well. But if you do choose the Thomasappropriate file format there shouldn't be too much problem moving Thomasfiles to and fro R. Thomas Thomas Thomasregards Thomas ThomasThomas Thomas Thomas__ ThomasR-help@stat.math.ethz.ch mailing list Thomashttps://stat.ethz.ch/mailman/listinfo/r-help ThomasPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames?
Petr Pikal wrote: Hi did you tried something like write.table( tab, file.txt, sep=\t, row.names=F) which writes to tab separated file? Petr thanks, but I do not want a tab delimited file. I need spaces between columns. On 21 Nov 2005 at 11:56, Gregor Gorjanc wrote: Date sent:Mon, 21 Nov 2005 11:56:48 +0100 From: Gregor Gorjanc [EMAIL PROTECTED] Organization: University of Ljubljana To: [EMAIL PROTECTED] Subject: [R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames? Send reply to:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Dear R users, R has read.fwf() function, however I would need write.fwf. I know other write.* functions, but I need fixed width format of data, which I would like to export from R. I tried to use: - write.table, but I can not control alignment of columns - write.matrix from MASS, but columns are to wide I came to this option, which is very neat: # tmp is data.frame sink(file = file) print(tmp) sink() This works very nice, but I would like to get rid of rownames, which are always printed. Another not so important issue is width of printed columns. I presume this is determined by max(length column name, max(length of values in a column)) but sometimes it would be usefull to control width of columns also. Can someone help me with this issue? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch 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] negative x y in ppp.object
Dear all, I am using the spatstat package, but my field data was a mirror image of the data plotted by plot.ppp(X). Therefore I changed it using -x and -y coordinates. However, I guess (I saw debug) that I get some error messages because of that. So, could anyone please tell me if I really can not use negative values for x and y coordinates in a ppp.object (and relates analysis)? Best regards, Sara Mouro [[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] Fw: Re: Is there anything like a write.fwf() or possibility to print adata.frame without rownames?
Petr Pikal wrote: Hi did you tried something like write.table( tab, file.txt, sep=\t, row.names=F) which writes to tab separated file? Petr thanks, but I do not want a tab delimited file. I need spaces between columns. write.table( tab, file.txt, sep=, row.names=F) Can it do what you want? On 21 Nov 2005 at 11:56, Gregor Gorjanc wrote: Date sent: Mon, 21 Nov 2005 11:56:48 +0100 From:Gregor Gorjanc [EMAIL PROTECTED] Organization:University of Ljubljana To: [EMAIL PROTECTED] Subject: [R] Is there anything like a write.fwf() or possibility to print a data.frame without rownames? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Dear R users, R has read.fwf() function, however I would need write.fwf. I know other write.* functions, but I need fixed width format of data, which I would like to export from R. I tried to use: - write.table, but I can not control alignment of columns - write.matrix from MASS, but columns are to wide I came to this option, which is very neat: # tmp is data.frame sink(file = file) print(tmp) sink() This works very nice, but I would like to get rid of rownames, which are always printed. Another not so important issue is width of printed columns. I presume this is determined by max(length column name, max(length of values in a column)) but sometimes it would be usefull to control width of columns also. Can someone help me with this issue? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html = = = = = = = = = = = = = = = = = = = = 2005-11-21 -- Deparment of Sociology Fudan University My new mail addres is [EMAIL PROTECTED] Blog:http://sociology.yculblog.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] singular convergence with lmer function i lme4
Dear Sundar, Thank you for your reply. The posted dataset is just a subset from the entire dataset. I found that it is clutch size 5 that causes the model to fail, since whenever I try to include it the model fails to converge.. Hence, I only included this subset into the mail. However, my original dataset is the following (only needed variables extracted); tab2 - cbind(numbrec,sexratio,fclutsize,LNRREIR) tab2 numbrec sexratio fclutsize LNRREIR [1,] 1 0.600 2 199320100313 [2,] 1 0.750 1 199327102511 [3,] 1 0.250 1 199327202911 [4,] 1 0.667 3 199327203011 [5,] 3 1.000 1 199328100411 [6,] 1 0.250 1 199329100511 [7,] 2 0.250 1 199329100711 [8,] 1 0.750 1 199329101211 [9,] 1 0.500 1 199420100411 [10,] 1 0.800 2 199427100412 [11,] 1 0.667 3 199427100511 [12,] 1 0.800 2 199427202112 [13,] 2 0.500 1 199427206011 [14,] 1 0.200 2 199428100611 [15,] 1 1.000 2 199428101011 [16,] 1 0.800 2 19942810 [17,] 2 0.500 3 199428101211 [18,] 0 0.500 1 199526200811 [19,] 0 1.000 1 19952620 [20,] 0 0.250 1 199527100211 [21,] 0 0.800 2 199527103011 [22,] 2 0.500 1 199527200212 [23,] 1 0.600 2 199527200711 [24,] 0 0.250 1 19952720 [25,] 0 0.800 2 199527202411 [26,] 0 0.600 2 199529100412 [27,] 1 0.500 1 199529100712 [28,] 0 0.750 1 199626200911 [29,] 1 0.200 2 19962620 [30,] 1 0.250 1 199626201211 [31,] 2 0.800 2 199627200612 [32,] 1 0.400 2 199628100111 [33,] 4 0.750 1 199628100911 [34,] 0 0.833 3 199628101011 [35,] 1 0.750 1 199628101411 [36,] 1 0.800 2 199628101511 [37,] 3 0.333 3 199628101711 [38,] 1 0.400 2 199726200212 [39,] 1 0.200 2 199726202111 [40,] 1 0.600 2 199727101411 [41,] 2 0.600 2 199727106911 [42,] 2 0.750 1 199727209811 [43,] 2 0.600 2 199728100212 [44,] 0 0.500 3 199728100612 [45,] 1 0.500 1 199729100611 [46,] 0 0.400 2 199820100811 [47,] 3 0.000 1 199826102111 [48,] 1 0.800 2 199826200611 [49,] 1 0.000 1 199826200711 [50,] 3 0.250 1 199826203111 [51,] 1 0.250 1 199826203412 [52,] 1 0.500 1 199827103011 [53,] 2 0.600 2 199827203811 [54,] 1 0.500 1 199828100512 [55,] 0 0.500 1 199828100612 [56,] 0 0.750 1 199928101611 [57,] 1 0.333 3 199928102511 [58,] 0 0.500 1 200028101211 [59,] 1 0.750 1 200028101212 [60,] 2 0.250 1 200038100111 [61,] 2 1.000 2 200038109911 [62,] 3 0.750 1 200126101211 [63,] 0 0.600 2 200126202511 [64,] 0 0.400 2 200226100311 [65,] 1 0.600 2 200226100411 [66,] 1 0.400 2 200226100611 [67,] 1 0.400 2 200226126011 [68,] 0 0.750 1 200226202111 [69,] 1 0.400 2 200226203712 [70,] 0 0.500 3 200227120711 [71,] 1 0.500 1 200227120713 [72,] 3 0.750 1 200227170311 [73,] 1 0.667 3 200227220111 [74,] 0 0.500 1 200227220311 [75,] 0 0.500 1 200227220312 [76,] 2 0.600 2 200227220313 [77,] 0 0.750 1 200228101511 [78,] 1 0.250 1 200228102511 [79,] 1 0.250 1 200238103111 tab2 - data.frame(tab2) #convert to data frame. Where numbrec is number of recruits, ant fclutsize is the clutch size (factor from 4 to 6) and LNRREIR which is a unique number given to a brood (consisting of year, island number etc..) So each LNRREIR is a unique number, however we want to include this as a random factor to account for non independence among nestlings within brood (Krackow Tcladek 2001). Furthermore, a mother might have more than one brood per year or might have broods between years that we want to control for. What we want to check is to see if number of recruits is dependent on the sex ratio or if there is any interaction with clutch size. And my model is; obj1 - lmer(numbrec~sexratio*fclutsize + (1|LNRREIR), family=poisson, data=tab2) summary(obj1) Which gives me the same error
Re: [R] force apply() to return a list
Try this: tapply(a, row(a), f, simplify = FALSE) tapply(a, row(a), max, simplify = FALSE) # still returns list On 11/21/05, Robin Hankin [EMAIL PROTECTED] wrote: Hi Dimitris On 21 Nov 2005, at 08:37, Dimitris Rizopoulos wrote: out - lapply(apply(a2, 1, f), [[, 1) thanks for this, but it doesn't quite do what I want: f - function(x){1:max(x[1],4)} lapply(apply(cbind(1:5,5:1), 1, f), [[, 1) [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 1 [[5]] [1] 1 I want [[1]] [1] 1 2 3 4 [[2]] [1] 1 2 3 4 [[3]] [1] 1 2 3 4 [[4]] [1] 1 2 3 4 [[5]] [1] 1 2 3 4 5 best wishes Robin -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] cointegration rank
Thanks a million! Carlo On Nov 21, 2005 01:23 PM, Pfaff, Bernhard Dr. [EMAIL PROTECTED] wrote: Thanks a lot! I have another question on cointegration, so I will go on this post. Is it possible to estimate a cointegration with some exogenous explanatory variables? Since, after testing for exogeneity, I would like to re-estimate the relation keeping some of the previous endogenous as exogenous. Many thanks! Carlo Hello Carlo, you can use the 'dumvar' argument for his purpose, and exclude the relevant variables from your data matrix 'x'. HTH, Bernhard On Nov 21, 2005 11:21 AM, Pfaff, Bernhard Dr. [EMAIL PROTECTED] wrote: Dear R - helpers, I am using the urca package to estimate cointegration relations, and I would be really grateful if somebody could help me with this questions: After estimating the unrestriced VAR with ca.jo I would like to impose the rank restriction (for example rank = 1) and then obtain the restricted estimate of PI to be utilized to estimate the VECM model. Is it possible? It seems to me that the function cajools estimates the VECM without the restrictions. Did I miss something? How is it possible to impose them? Thanks a lot in advance! Carlo Hello Carlo, you can achieve this, by calculating your desired PI-matrix by hand, given the slots 'V' and 'W' of your ca.jo object and then execute a restricted OLS-estimation, if I understand your goal correctly. Please, bear in mind the non-uniqueness of the factorization of the PI-matrix by doing so. HTH, Bernhard __ R-help@stat.math.ethz.ch 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] modify boxplot
Hi everybody, I'm trying to modify the boxplot just to set the upper whisker to the 90 percentile value, but I still couldn't find the solution. Can anyone help me? Thanks Alessandro Carletti __ R-help@stat.math.ethz.ch 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] force apply() to return a list
Hi Gabor thanks for this. On 21 Nov 2005, at 13:26, Gabor Grothendieck wrote: Try this: tapply(a, row(a), f, simplify = FALSE) [ here a - cbind(1:5 , 5:1) f - function(x){list(1:max(x[1],4))} ] This also works. I actually need unlist(... , recursive=FALSE) to pass the list to do.call() but that 's fine. But, my question here is: how does one arrive at such a solution from the manpage? The manpage seems to indicate that the first argument to tapply() is a ragged array, or a vector. I can't reconcile Gabor's use of tapply() with the manpage. How to understand Gabor's suggestion better? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] force apply() to return a list
On 11/21/05, Robin Hankin [EMAIL PROTECTED] wrote: Hi Gabor thanks for this. On 21 Nov 2005, at 13:26, Gabor Grothendieck wrote: Try this: tapply(a, row(a), f, simplify = FALSE) [ here a - cbind(1:5 , 5:1) f - function(x){list(1:max(x[1],4))} ] This also works. I actually need unlist(... , recursive=FALSE) to pass the list to do.call() but that 's fine. But, my question here is: how does one arrive at such a solution from the manpage? The manpage seems to indicate that the first argument to tapply() is a ragged array, or a vector. I can't reconcile Gabor's use of tapply() with the manpage. How to understand Gabor's suggestion better? A matrix is just a vector with a dim attribute. x - 1:4 attr(x, dim) - c(2,2) # or dim(x) - c(2,2) class(x) [1] matrix __ R-help@stat.math.ethz.ch 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] force apply() to return a list
G'day Robin, RH == Robin Hankin [EMAIL PROTECTED] writes: RH Still, it's a little disconcerting that apply() as generally RH used can return a list 99.9% of the time and a matrix the RH other 0.1%. It probably depends on how it is used. :-) I usually use apply in situations where I know that the lengths of the result is always the same and want a matrix returned. Thus, in my applications in 99.99% of the time a matrix is returned and the other 0.01% a list (and I forget that apply could return a list). (BTW, 67.8% of all statistics are made up on the spot, just as the last three presumably. :) ) RH It took me a long time to track this down when debugging my RH code the other night. It is called defensive programming (and it is great if it works). :-) If your code expects a list, make sure that it gets a list and spits a dummy if not, then these kind of problems are easy to find. RH Does anyone else agree? Would it be possible to add an RH argument such as force.list (with default FALSE) to apply() RH that makes apply() return a list under all circumstances? RH Also, adding Dimitris's excellent workaround to apply()'s RH manpage would be helpful. If you supply appropriate patches against the SVN source, I am sure that R core will consider it. And although Dimitris solution is quite nice, I find that it obfuscate the code a bit. What is wrong with checking whether the result returned by apply is a matrix, and if so turn the matrix into a list. Probably the easiest way to turn a matrix into a list is to use as.data.frame(), if you want that the printed version of the object looks like a list, then use as.list() too: a2 - cbind(1:3,3:1) f - function(x){1:max(x[1],4)} apply(a2,1,f) [,1] [,2] [,3] [1,]111 [2,]222 [3,]333 [4,]444 res - apply(a2,1,f) if(is.matrix(res)) res - as.list(as.data.frame(res)) res $V1 [1] 1 2 3 4 $V2 [1] 1 2 3 4 $V3 [1] 1 2 3 4 Cheers, Berwin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PNG-import into R
I was looking once for all supported image formats, here is what I found: Format | read file to matrix | write matrix to file | write plot to file ---|-|--|--- PNG| | | png, bitmap, GDD JPEG | read.jpeg | | jpeg, bitmap, GDD GIF| read.gif| write.gif| GDD TIFF | read.picture| write.picture| savetiff, bitmap PDF| | | pdf, bitmap ENVI | read.ENVI | write.ENVI | ? | read.pnm| write.pnm| I have not played with every one of those functions and I think that every read/write returns matrix in some other internal format. Also, last 2 formats are rather exotic and of limited use. Use CRAN search to look up package of each function. So I think that in your case your best bet would be to convert your file to GIF (if you can live with only 256 colors) or TIFF. Also does anybody know how hard would it be to tap into C code needed for 'read.jpeg', 'png' and 'jpeg' functions to write 'read.png' , 'write.png', and 'write.jpeg' functions? Jarek Tuszynski -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sydler, Dominik Sent: Monday, November 21, 2005 5:36 AM To: r-help@stat.math.ethz.ch Subject: [R] PNG-import into R Hi there I'm looking for a function to read PNG-bitmap-images from a file into R. I only found: - the pixmap-package which cannot import png or similar formats - the rimage-package which can only import lossy jpeg-images (the convertion from png to jpeg modifies the data!) Is there any possibility to read PNG-files? Thanks for any help Dominic Sydler __ R-help@stat.math.ethz.ch 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] nlme question
Deepayan, Yes, thanks for confirming my suspicions. I know mixed models are different but, I did not think they were so different as to preclude estimating the var-cov matrix (via the Hessian in Maximum likelihood, as you point out). Thanks for prompting me to think about MCMC. Your suggestion to consider MCMC makes me realize that using BUGS, I could directly sample from the posterior of the linear combination of parameters - to get its variance and eliminate the extra step using the var-cov matrix. As you say, with results better than the asymptotic approximation. (Maybe I can do the same thing with mcmcsamp?, but I'm not familiar with this and will have to take a look at it.) -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: Thursday, November 17, 2005 2:22 PM To: Doran, Harold Cc: Wassell, James T., Ph.D.; r-help@stat.math.ethz.ch Subject: Re: nlme question On 11/17/05, Doran, Harold [EMAIL PROTECTED] wrote: I think the authors are mistaken. Sigma is random error, and due to its randomness it cannot be systematically related to anything. It is this ind. assumption that allows for the likelihood to be expressed as described in Pinhiero and Bates p.62. I think not. The issue is dependence between the _estimates_ of sigma, tao, etc, and that may well be present. Presumably, if one can compute the likelihood surface as a function of the 3 parameters, the hessian at the MLE's would give the estimated covariance. However, I don't think nlme does this. A different approach you might want to consider is using mcmcsamp in the lme4 package (or more precisely, the Matrix package) to get samples from the joint posterior distribution. This is likely to be better than the asymptotic normal approximation in any case. Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PNG-import into R
Tuszynski, Jaroslaw W. wrote: Also does anybody know how hard would it be to tap into C code needed for 'read.jpeg', 'png' and 'jpeg' functions to write 'read.png' , 'write.png', and 'write.jpeg' functions? Much, much harder than using ImageMagick to convert to one of the formats that R can read. system(convert foo.png foo.pnm) foo = read.pnm(foo.pnm) ImageMagick is here: http://www.imagemagick.org/script/index.php And is normally already installed on modern Linux distributions. But yes, native reading without conversion is sometimes preferable. Baz __ R-help@stat.math.ethz.ch 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] PNG-import into R
Hi, I dont think you can import PNG images into R directly (although I may be wrong). I use ImageMagick (available for most operating systems) and the system() function to do my image conversions. convertImage-function(dirname,srcname,targetname){ strSrcName-shQuote(paste(dirname,srcname,sep='/')) strTrgName-shQuote(paste(dirname,targetname,sep='/')) filelist-system(paste('ls',strSrcName,sep=' '),TRUE,TRUE) if(length(filelist)1){ stop(Source Image Not Found) } filelist-system(paste('ls',strTrgName,sep=' '),TRUE,TRUE) if(length(filelist)1){ strcmd-paste('convert',strSrcName,strTrgName,sep=' ') system(strcmd) } } On Mon, 2005-21-11 at 11:36 +0100, Sydler, Dominik wrote: Hi there I'm looking for a function to read PNG-bitmap-images from a file into R. I only found: - the pixmap-package which cannot import png or similar formats - the rimage-package which can only import lossy jpeg-images (the convertion from png to jpeg modifies the data!) Is there any possibility to read PNG-files? Thanks for any help Dominic Sydler __ R-help@stat.math.ethz.ch 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] binary kmeans tree
Dear R-Users, does anyone know if there exists a package for a kmeans variant which creates a binary tree by stepwise splitting of the data? If you do not understand what I mean then have a look at the following link (there it is called KD-trees): http://www.cs.cmu.edu/~dpelleg/kmeans.html Thanks in advance, Timo __ R-help@stat.math.ethz.ch 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] Howto? plot legend with no line behind the points
Jan == Jan Verbesselt [EMAIL PROTECTED] on Mon, 21 Nov 2005 12:28:35 +0100 writes: Jan Hi R-help, Jan We are using R 2.2 on Win XP and have a detail question on how the Jan legend can be optimised. Jan We use the following; - plot(,type=b,...) Jan The lines in the plot do not cross the points. How can we obtain the Jan same effect in the legend? (points without a line through them..) not directly, however you can trick it, see below Jan We tried setting the pt.bg to white but this did not help. I think it does help some.. read on Jan See script below. par(mar=c(5,5,2,4) +.1) # dit om extra text in Y-as te plaatsen plot(ts.X, type=b, col=1, pch=19,ylim=c(-0.4,0.2),ylab=c(X)) legend.txt - c(X,Y) # Define how the legend looks like, place it on the right location legend(topright, legend.txt,col=1,lty=1, pch=c(19,1),bty=n, pt.bg=1) par(new=T) plot(ts.Y, type=b, lty=1, col=1, pch=1, ylab=, xlab=,yaxt=n,ylim=c(0.1,0.7)) axis(4) mtext(side=4, line=3, Y, cex=1) Unfortunately you don't give a reproducible example {we don't have your ts.X and ts.Y}, so I make up a simpler version of the above: ## A bivariate time-series set.seed(1) xy - cbind(x = ts(cumsum(rnorm(47))), y = ts(cumsum(rt(47, df=3 plot(xy, plot.type = single, type = b, pch = 21, col=1:2, bg = light blue) legend(topright, c(x,y), col=1:2, lty=47, pch = 21, bty=n, pt.bg=light blue) I'm using pch=21 and I've used pt.bg just to show it's effect here; of course you can play with these as well. And the real trick was to play with 'lty' using the nice on/off convention (47: a dash of length 4; a break of length 7). Now of course, we also might accept patches for improving legend (source at https://svn.R-project.org/R/trunk/src/library/graphics/R/legend.R ). Naturally, I think it's the argument 'merge' that could be extended to allow something analogous to plot type = b. Hoping this helps: Martin Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] odesolve with banded Jacobian [was no subject]
Dear Karline Soetaert, I've just returned from a week of travel, so have not had a great deal of time to look at your request. From a brief rereading of the original lsoda documentation, it looks as if all I need to do is set a flag to a different value (jt to 4), and leave it up to the user to construct the function that calculates the jacobian properly. If you'd contact me directly, ideally with a test model, I will see if the modification is really that simple; if so, I'll make the change and release an updated odesolve to CRAN. Woody PS: Thanks, Martin R. Woodrow Setzer, Jr. National Center for Computational Toxicology US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 Martin Maechler [EMAIL PROTECTED] ath.ethz.chTo Soetaert, Karline 11/14/2005 09:46 [EMAIL PROTECTED] AM cc R-help@stat.math.ethz.ch, Woodrow Setzer/RTP/USEPA/[EMAIL PROTECTED] Please respondSubject toRe: [R] odesolve with banded Martin Maechler Jacobian [was no subject] [EMAIL PROTECTED] ath.ethz.ch KSoet == Soetaert, Karline [EMAIL PROTECTED] on Mon, 14 Nov 2005 13:20:24 +0100 writes: KSoet Hi, I am trying to solve a model that consists of KSoet rather stiff ODEs in R. KSoet I use the package ODEsolve (lsoda) to solve these KSoet ODEs. KSoet To speed up the integration, the jacobian is also KSoet specified. KSoet Basically, the model is a one-dimensional KSoet advection-diffusion problem, and thus the jacobian is KSoet a tridiagonal matrix. KSoet The size of this jacobian is 100*100. KSoet In the original package LSODA it is possible to KSoet specify that the jacobian is banded, which makes its KSoet inversion very efficient. KSoet However, this feature seems to have been removed in KSoet the R version. KSoet Is there a way to overcome this limitation? Yes. But probably not a very easy one; maybe even a very cumbersome one... ;-) Note however that questions like these should typically be addressed at the package author - which you can always quickly find out via packageDescription(odesolve) Package: odesolve Version: 0.5-12 Date: 2004/10/25 Title: Solvers for Ordinary Differential Equations Author: R. Woodrow Setzer [EMAIL PROTECTED] Maintainer: R. Woodrow Setzer [EMAIL PROTECTED] Depends: R (= 1.4.0) Description: This package provides an interface for the ODE solver lsoda. ODEs are expressed as R functions or as compiled code. ... I've CC'ed this e-mail to Woodrow to help you for once .. KSoet [[alternative HTML version deleted]] KSoet __ KSoet . KSoet PLEASE do read the posting guide! KSoet http://www.R-project.org/posting-guide.html if you do read that guide, it will tell you - why you should always use a 'Subject' for your e-mails - why HTML-ified e-mails are not much liked and what you can do about it. Regards, Martin Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] garch function in R
I'm using R 2.1.1 and just successfully installed packages tseries, fseries. I try to run example http://www.maths.lth.se/help/R/.R/library/tseries/html/garch.html But it shows x.arch - garch(x, order = c(0,2)) # Fit ARCH(2) Error: couldn't find function garch Then I run command help.search(garch) it shows the R information. Which package(s) do I really need to run garch models? Thanks, Shelton - [[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] Warning message help
I am trying to great a new column of effort data from an existing vector of gears used. It is a simple code where effort[Gear==300]=(DIST_TOW*7412) effort[Gear==301]=(DIST_TOW*7412) The code appears to work for some of the data but fails for others and inserts a NA value I also get this warning message Warning message: number of items to replace is not a multiple of replacement length Can anybody tell me what this means. thanks Cameron Guenther Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [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] predicted values from cv.glm
Hi folks, Is there a way to get the predicted values from leave-one-out cross validation using cv.glm? More generally, is there a way to see what output is available with any function that may not show up using the help() function? Below is the code that I've been using: SRCOUNT - read.table(file.choose(),header=T) library(boot) library(MASS) q_u2 - glm.nb(res_est ~ U2 + I(U2^2), SRCOUNT, link = log) cv.qu2- cv.glm(SRCOUNT,qu2) Many thanks, Jeff Jeffrey A. Stratford, Ph.D. Postdoctoral Associate 331 Funchess Hall Department of Biological Sciences Auburn University Auburn, AL 36849 334-329-9198 FAX 334-844-9234 http://www.auburn.edu/~stratja __ R-help@stat.math.ethz.ch 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] Comparing rows of matrices with different dimensions
Hi there, I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly? Here it is: I have two matrices: a [,1] [,2] [,3] [1,]149 [2,]26 10 [3,]36 11 [4,]48 12 b [,1] [,2] [1,]14 [2,]25 [3,]36 Now I want to find out which rows of b can also be found in a (without its last column). So the solution must be something like either TRUE FALSE TRUE or the rows where their is a match (rows 1 and 3) Till now I have tried things like b %in% a[,1:2] or so but that doesn't work because I want to compare the WHOLE row of b with the whole row of a without column 3. Thank you very much for any help. Regards, Antje [[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] modify boxplot
Without modifying the code, you can take the output from 'boxplot(...plot=F)', change the values in the 'stats' object within the value returned, and then pass it to 'bxp'; x - boxplot(yourdata,...,plot=F) x$stats[5,] - quantile(yourdata, .9) bxp(x) On 11/21/05, alessandro carletti [EMAIL PROTECTED] wrote: Hi everybody, I'm trying to modify the boxplot just to set the upper whisker to the 90 percentile value, but I still couldn't find the solution. Can anyone help me? Thanks Alessandro Carletti __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Howto? plot legend with no line behind the points
On 11/21/2005 10:33 AM, Martin Maechler wrote: Jan == Jan Verbesselt [EMAIL PROTECTED] on Mon, 21 Nov 2005 12:28:35 +0100 writes: Jan Hi R-help, Jan We are using R 2.2 on Win XP and have a detail question on how the Jan legend can be optimised. Jan We use the following; - plot(,type=b,...) Jan The lines in the plot do not cross the points. How can we obtain the Jan same effect in the legend? (points without a line through them..) not directly, however you can trick it, see below Jan We tried setting the pt.bg to white but this did not help. I think it does help some.. read on Jan See script below. par(mar=c(5,5,2,4) +.1) # dit om extra text in Y-as te plaatsen plot(ts.X, type=b, col=1, pch=19,ylim=c(-0.4,0.2),ylab=c(X)) legend.txt - c(X,Y) # Define how the legend looks like, place it on the right location legend(topright, legend.txt,col=1,lty=1, pch=c(19,1),bty=n, pt.bg=1) par(new=T) plot(ts.Y, type=b, lty=1, col=1, pch=1, ylab=, xlab=,yaxt=n,ylim=c(0.1,0.7)) axis(4) mtext(side=4, line=3, Y, cex=1) Unfortunately you don't give a reproducible example {we don't have your ts.X and ts.Y}, so I make up a simpler version of the above: ## A bivariate time-series set.seed(1) xy - cbind(x = ts(cumsum(rnorm(47))), y = ts(cumsum(rt(47, df=3 plot(xy, plot.type = single, type = b, pch = 21, col=1:2, bg = light blue) legend(topright, c(x,y), col=1:2, lty=47, pch = 21, bty=n, pt.bg=light blue) I'm using pch=21 and I've used pt.bg just to show it's effect here; of course you can play with these as well. And the real trick was to play with 'lty' using the nice on/off convention (47: a dash of length 4; a break of length 7). Now of course, we also might accept patches for improving legend (source at https://svn.R-project.org/R/trunk/src/library/graphics/R/legend.R ). Naturally, I think it's the argument 'merge' that could be extended to allow something analogous to plot type = b. Are there any examples with merge = FALSE that look good? It seems to me that it would be a cleaner change to add a new parameter type that did what it does in plot(), and then eventually drop merge. If there really are examples with merge = FALSE that people want to keep, then we could keep it, but I still think adding type would be better than fiddling with merge. Of course, this suggestion isn't trivial to implement for type = 'b', where we'd want -- * -- in the legend, but I think it could be done with some sort of trickery involving 3 points with type = 'c' overlaid with one point with type = 'p'. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PNG-import into R
On Mon, 2005-11-21 at 09:38 -0500, Tuszynski, Jaroslaw W. wrote: Also does anybody know how hard would it be to tap into C code needed for 'read.jpeg', 'png' and 'jpeg' functions to write 'read.png' , 'write.png', and 'write.jpeg' functions? Not too difficult (at least with libpng). I was fiddling with adding a read.png method to the rimage package for my own use, but have not really finished it. The code is based on the example code from the libpng docs and and an O'Reilly article The C code and R wrapper can be found at http://blue.chem.psu.edu/~rajarshi/code/R/pngio.c http://blue.chem.psu.edu/~rajarshi/code/R/png.R Right now it segfaults, so its not really useful yet. --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- All theoretical chemistry is really physics; and all theoretical chemists know it. -- Richard P. Feynman __ R-help@stat.math.ethz.ch 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] Comparing rows of matrices with different dimensions
how about: a - cbind(1:4, c(4, 6, 6, 8), 9:12) b - cbind(1:3, 4:6) # apply(b, 1, paste, collapse = ) %in% apply(a[, -3], 1, paste, collapse = ) 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: Antje Döring [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, November 21, 2005 4:57 PM Subject: [R] Comparing rows of matrices with different dimensions Hi there, I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly? Here it is: I have two matrices: a [,1] [,2] [,3] [1,]149 [2,]26 10 [3,]36 11 [4,]48 12 b [,1] [,2] [1,]14 [2,]25 [3,]36 Now I want to find out which rows of b can also be found in a (without its last column). So the solution must be something like either TRUE FALSE TRUE or the rows where their is a match (rows 1 and 3) Till now I have tried things like b %in% a[,1:2] or so but that doesn't work because I want to compare the WHOLE row of b with the whole row of a without column 3. Thank you very much for any help. Regards, Antje [[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] Warning message help
Shouldnt that be effort[Gear==300]-(DIST_TOW*7412) I think we're going to need to see some sample datasets to tell you any more. On Mon, 2005-21-11 at 10:44 -0500, Guenther, Cameron wrote: I am trying to great a new column of effort data from an existing vector of gears used. It is a simple code where effort[Gear==300]=(DIST_TOW*7412) effort[Gear==301]=(DIST_TOW*7412) The code appears to work for some of the data but fails for others and inserts a NA value I also get this warning message Warning message: number of items to replace is not a multiple of replacement length Can anybody tell me what this means. thanks Cameron Guenther Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [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-help@stat.math.ethz.ch 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] garch function in R
On Mon, 2005-11-21 at 07:44 -0800, Xiaodong Jin wrote: I'm using R 2.1.1 and just successfully installed packages tseries, fseries. I try to run example http://www.maths.lth.se/help/R/.R/library/tseries/html/garch.html But it shows x.arch - garch(x, order = c(0,2)) # Fit ARCH(2) Error: couldn't find function garch Then I run command help.search(garch) it shows the R information. Did you load the package before trying to use it? E.g.: library(tseries) From a fresh R session this is what I get: ?garch #error as I haven't loaded the package No documentation for 'garch' in specified packages and libraries: you could try 'help.search(garch)' library(tseries) Loading required package: quadprog Loading required package: zoo ?garch #displays help file as expected Which package(s) do I really need to run garch models? Looks like you need quadprog and zoo to be installed and available as well. Thanks, Shelton HTH, Gav -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch 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] conversion from RData to R file
I would highly appreciate some hints regarding this issue. Regards, Dejan _ From: Loncar, Dejan Sent: 15 November 2005 10:32 To: 'r-help@stat.math.ethz.ch' Subject: conversion from RData to R file Dear all I am beginner in R coding and have a problem to figure out how to convert RData format into R format. After I converted csv file using read.csv I got RData file but to run some R code need R format Many Thanks Dejan [[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] Comparing rows of matrices with different dimensions
If I understand you correctly, ## not tested apply(cbind(a[,-3],b),1,function(x)isTRUE(all.equal(x[1:2],x[3:4]))) or something similar. The basic idea is just to drop the last column of a and check to see whether rows are the same (possible within numeric fuzz). This assumes order counts. If the rows must just contain the same values (possibly replicated different numbers of times, then add calls to unique (or maybe use setdiff if numeric fuzz is not an issue). HTH Cheers, Bert -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Antje Döring Sent: Monday, November 21, 2005 7:57 AM To: r-help@stat.math.ethz.ch Subject: [R] Comparing rows of matrices with different dimensions Hi there, I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly? Here it is: I have two matrices: a [,1] [,2] [,3] [1,]149 [2,]26 10 [3,]36 11 [4,]48 12 b [,1] [,2] [1,]14 [2,]25 [3,]36 Now I want to find out which rows of b can also be found in a (without its last column). So the solution must be something like either TRUE FALSE TRUE or the rows where their is a match (rows 1 and 3) Till now I have tried things like b %in% a[,1:2] or so but that doesn't work because I want to compare the WHOLE row of b with the whole row of a without column 3. Thank you very much for any help. Regards, Antje [[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] Comparing rows of matrices with different dimensions
On Mon, 2005-11-21 at 16:57 +0100, Antje Döring wrote: Hi there, I have a question, which I thought is very easy to solve, but somehow I can't find a solution. Probably someone could help me quickly? Here it is: I have two matrices: a [,1] [,2] [,3] [1,]149 [2,]26 10 [3,]36 11 [4,]48 12 b [,1] [,2] [1,]14 [2,]25 [3,]36 Now I want to find out which rows of b can also be found in a (without its last column). So the solution must be something like either TRUE FALSE TRUE or the rows where their is a match (rows 1 and 3) Till now I have tried things like b %in% a[,1:2] or so but that doesn't work because I want to compare the WHOLE row of b with the whole row of a without column 3. Thank you very much for any help. Regards, Antje Here is one possible approach, though not tested beyond this example: which(apply(matrix(b %in% a, dim(b)), 1, all)) [1] 1 3 The steps are: # which elements of b are in a b %in% a [1] TRUE TRUE TRUE TRUE FALSE TRUE # Turn that into a matrix the same shape as b matrix(b %in% a, dim(b)) [,1] [,2] [1,] TRUE TRUE [2,] TRUE FALSE [3,] TRUE TRUE # get T/F for which rows are all TRUE apply(matrix(b %in% a, dim(b)), 1, all) [1] TRUE FALSE TRUE # Now get the indices which(apply(matrix(b %in% a, dim(b)), 1, all)) [1] 1 3 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] conversion from RData to R file
Please read the docs! -- especially An Introduction to R. There is no need whatever to have your **data** in text format (other than, perhaps, to read into into R), which is generally what R format (a .R suffix in teh filename, I presume) indicates. See ?attach, perhaps? -- or maybe ?load . Also please read the posting guide and provide a reproducible example as it suggests to clearly communicate what you wish to do. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Loncar, Dejan Sent: Monday, November 21, 2005 8:22 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] conversion from RData to R file I would highly appreciate some hints regarding this issue. Regards, Dejan _ From: Loncar, Dejan Sent: 15 November 2005 10:32 To: 'r-help@stat.math.ethz.ch' Subject:conversion from RData to R file Dear all I am beginner in R coding and have a problem to figure out how to convert RData format into R format. After I converted csv file using read.csv I got RData file but to run some R code need R format Many Thanks Dejan [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] ./configure: /bin/sh: bad interpreter: Permission denied
I am trying to install R1.8. When I use make to build R, it gives me following error, * Installing *source* package 'foreign' ... /usr/local/bin/R-1.8.1/bin/INSTALL: ./configure: /bin/sh: bad interpreter: Permission denied ERROR: configuration failed for package 'foreign' ** Removing '/usr/local/bin/R-1.8.1/library/foreign' make[2]: *** [foreign.ts] Error 1 make[2]: Leaving directory `/usr/local/bin/R-1.8.1/src/library/Recommended' make[1]: *** [recommended-packages] Error 2 make[1]: Leaving directory `/usr/local/bin/R-1.8.1/src/library/Recommended' make: *** [stamp-recommended] Error 2 Am I doing something wrong here? I am installing as root. Thanks, Denna - [[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] Largest allowable matrix
What do you want to do with these large matrices? Both scan and read.table allow you to skip a certain number of lines at the beginning of a file and process however many lines you want from that point. I recently had large files that were too big for S-Plus 6. I moved to R, and processed them as submatrices without a problem. I typically use readLines to check the format of the first few records and count.fields to determine if all records have the same numbers of fields. In one case recently, I had a file that was almost but not quite regular. I processed the file in pieces, carefully examining records right before and after each change in the number of records, and recovered basically everything without going back to my client (through several layers of bureaucracy) to ask for their help in parsing that file. I frequently use a construct like the following: File. - .filename readLines(File., 9) # to check the format including the sep character quantile(nFlds - count.fields(File., sep=\t)) #or sep=, for csv # If the file honestly has a fixed number of fields, # this will show that. # If not, either the sep character is wrong or the file has problems. # In either case, this helps me plan what to do next. hope this helps. spencer graves Prof Brian Ripley wrote: On Mon, 21 Nov 2005, Uwe Ligges wrote: Barry Baker wrote: Hello, I am a new R user and have two datasets that I would like to analyze. The first is (2409222 x 17) and the other is (21682998 x 17). Is this possible in R? If not then what is the maximum number of rows and columns or number of elements that R can handle? The number of columns and rows is not a problem here, but you will need 21682998 * 17 * 4 bytes to store the latter matrix (assuming floats) in memory, that is 1406.139 Mb. R does not use floats internally. So unless these are integers/logicals you are going to need twice that, In order to do something sensible with the data, you need *at least* twice the amount of RAM, hence at least 3Gb. Here I think the issue is rather virtual memory and address space. You will need a 64-bit OS to do anything with this object. -- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA [EMAIL PROTECTED] www.pdf.com http://www.pdf.com Tel: 408-938-4420 Fax: 408-280-7915 __ R-help@stat.math.ethz.ch 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 Reference Card (especially useful for Newbies)
Newbies (and others!) may find useful the R Reference Card made available by Tom Short and Rpad at http://www.rpad.org/Rpad/Rpad-refcard.pdf or through the Contributed link on CRAN (where some other reference cards are also linked). It categorizes and organizes a bunch of R's basic, most used functions so that they can be easily found. For example, paste() is under the Strings heading and expand.grid() is under Data Creation. For newbies struggling to find the right R function as well as veterans who can't quite remember the function name, it's very handy. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help with xtable
Hello, How do you change the size of the caracters (tiny, small) using xtable? It works out for print.xtable when typing print.xtable(xtable(mydata),size=small) but I do not see any results when doing xtable(mydata,size=small) Anyone could help ? Thanks Matthieu [[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] Multinomial Nested Logit package in R?
Dear R-Help, I'm hoping to find a Multinomial Nested Logit package in R. It would be great to find something analogous to PROC MDC in SAS: The MDC (Multinomial Discrete Choice) procedure analyzes models where the choice set consists of multiple alternatives. This procedure supports conditional logit, mixed logit, heteroscedastic extreme value, nested logit, and multinomial probit mod- els. The MDC procedure uses the maximum likelihood (ML) or simulated maximum likelihood method for model estimation. Since the term multinomial logit is often used instead of conditional logit in econometrics literature, the term simple multino- mial logit is used here to denote the model used by Schmidt and Strauss (1975), while multinomial logit is used as a synonym of conditional logit. I found this web site useful in comparing various categorical dependent variable models, but it only addresses SAS, STATA, LIMDEP, and SPSS: http://www.indiana.edu/~statmath/stat/all/cdvm/cdvm1.html I have searched using: 1. Google site:r-project multinomial nested logit 2. Google site:r-project.org multinomial discrete choice 3. R help.search(multinomial nested logit) No help files found matching ‘multinomial nested logit’ using fuzzy matching 4. R help.search(multinomial discrete choice) No help files found matching ‘multinomial discrete choice’ using fuzzy matching Possibilities that seem unclear and/or not very promising: 1. It is my understanding that the multinom function in the nnet package does NOT do nested models. 2. The MNP (multinomial probit) package is close, but I want a logit, not probit, model. 3. http://www.r-project.org/nocvs/mail/r-help/2002/4394.html On Wed, 29 May 2002, Vumani Dlamini wrote: Has anyone implemented the conditional logit and/or the nested logit model in R? Conditional logistic regression is clogit() in the survival package. But the survival package didn't seem to have what I needed. Am I overlooking anything? Are there any synonyms that I should be using for the search? I would appreciate any pointers or suggestions. Thanks, -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] Monte Carlo EM for GLMM
Dear All, I have to programme a Monte Carlo EM for an Generalized Linear Mixed Model, Binomial Response and Normal Random Effect, Could anyone give me a hand sending some R code? TIA Francisco ___ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar __ R-help@stat.math.ethz.ch 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] Plotting one or more series on the same graphs
Hi, I'm from Italy (sorry for my english...). I've two questions about the plot function. I've to create a simple graph for the data set n_species: species=sqlQuery(dati, select count(distinct species), season from captures_complete_r group by species, season) n_species=tapply(species$count, species$season, sum) n_species=data.frame(n_species) n_species n_species autumn10 spring 7 summer 7 winter 7 The problem is that, if I use plot(n_species), I can't put the seasons on the x-axis, and so the values on that axes appear as numbers. I've tried to remove the axis and then I've add with the script: plot(n_species, type=l, main=Species trend, xlab=Season, ylab=Number of species,ylim=c(3,10), col=1, axes=FALSE) legend(topright, c(Species captured), col = c(1), lty=c(1)) axis(1, 1:4, c(autumn, spring, summer, winter) ) axis(2, 1:11) and it seems to work, but when I have decimal value on the y-axis, the script plot(k$simp_seas, ylim=c(min(k), max(k)), type=l,main=Index trend, xlab=Season, ylab=Index value, axes=FALSE) points(k$shan_seas, col=red, type=l) leg.txt=c(Simpson's index, Shannon's index) legend(topleft, leg.txt, col=c(1,2), lty=c(1,1)) axis(1, 1:4, c(autumn, spring, summer, winter) ) axis(2, 1:11) doesn't put decimal value, but jut a 1 in the middle of the vertical axis. How can make a correct graphs? Thanks, Gianpaolo. __ R-help@stat.math.ethz.ch 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] Multinomial Nested Logit package in R?
Peter Rossi has a package bayesm for various flavors of choice models. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David C. James Sent: Monday, November 21, 2005 12:18 PM To: r-help@stat.math.ethz.ch Subject: [R] Multinomial Nested Logit package in R? Dear R-Help, I'm hoping to find a Multinomial Nested Logit package in R. It would be great to find something analogous to PROC MDC in SAS: The MDC (Multinomial Discrete Choice) procedure analyzes models where the choice set consists of multiple alternatives. This procedure supports conditional logit, mixed logit, heteroscedastic extreme value, nested logit, and multinomial probit mod- els. The MDC procedure uses the maximum likelihood (ML) or simulated maximum likelihood method for model estimation. Since the term multinomial logit is often used instead of conditional logit in econometrics literature, the term simple multino- mial logit is used here to denote the model used by Schmidt and Strauss (1975), while multinomial logit is used as a synonym of conditional logit. I found this web site useful in comparing various categorical dependent variable models, but it only addresses SAS, STATA, LIMDEP, and SPSS: http://www.indiana.edu/~statmath/stat/all/cdvm/cdvm1.html I have searched using: 1. Google site:r-project multinomial nested logit 2. Google site:r-project.org multinomial discrete choice 3. R help.search(multinomial nested logit) No help files found matching 'multinomial nested logit' using fuzzy matching 4. R help.search(multinomial discrete choice) No help files found matching 'multinomial discrete choice' using fuzzy matching Possibilities that seem unclear and/or not very promising: 1. It is my understanding that the multinom function in the nnet package does NOT do nested models. 2. The MNP (multinomial probit) package is close, but I want a logit, not probit, model. 3. http://www.r-project.org/nocvs/mail/r-help/2002/4394.html On Wed, 29 May 2002, Vumani Dlamini wrote: Has anyone implemented the conditional logit and/or the nested logit model in R? Conditional logistic regression is clogit() in the survival package. But the survival package didn't seem to have what I needed. Am I overlooking anything? Are there any synonyms that I should be using for the search? I would appreciate any pointers or suggestions. Thanks, -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 -- -- This e-mail and any attachments may be confidential or\ ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] conversion from RData to R file
On 21-Nov-05 Berton Gunter wrote: Please read the docs! -- especially An Introduction to R. There is no need whatever to have your **data** in text format (other than, perhaps, to read into into R), which is generally what R format (a .R suffix in the filename, I presume) indicates. I would qualify this (very slightly). One of the good reasons for having data in a text file is that it is easy to edit it, along with the fact that a frequent format for primary data is textual -- e.g. CSV. In my experience, one can often encounter errors in data that need correction quite some time after they have first been used in R. (I'm talking mainly about non-obvious errors: plausible values that are in fact wrong, missing values in the wrong place or extra ones introduced, etc.) Once one has saved out data as R-data, there is a psychological prejudice that they don't need looking at again (this is one of those psycho-logical inferences, which follows from the practical fact that data in R-Data format are for just loading). Just a thought ... Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 21-Nov-05 Time: 18:14:28 -- XFMail -- __ R-help@stat.math.ethz.ch 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] Warning message help
Cameron Assuming DIST_TOW is a vector of the same length as effort and Gear, is this what you mean? effort[Gear==300] = DIST_TOW[Gear==300]*7412 MHP on 11/21/2005 10:44 AM Guenther, Cameron said the following: I am trying to great a new column of effort data from an existing vector of gears used. It is a simple code where effort[Gear==300]=(DIST_TOW*7412) effort[Gear==301]=(DIST_TOW*7412) [...] -- Michael Prager, Ph.D. Population Dynamics Team, NMFS SE Fisheries Science Center NOAA Center for Coastal Fisheries and Habitat Research Beaufort, North Carolina 28516 http://shrimp.ccfhrb.noaa.gov/~mprager/ Opinions expressed are personal, not official. No government endorsement of any product is made or implied. __ R-help@stat.math.ethz.ch 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] ./configure: /bin/sh: bad interpreter: Permission denied
On Mon, 2005-11-21 at 09:01 -0800, Dhruti Ramani wrote: I am trying to install R1.8. When I use make to build R, it gives me following error, * Installing *source* package 'foreign' ... /usr/local/bin/R-1.8.1/bin/INSTALL: ./configure: /bin/sh: bad interpreter: Permission denied ERROR: configuration failed for package 'foreign' ** Removing '/usr/local/bin/R-1.8.1/library/foreign' make[2]: *** [foreign.ts] Error 1 make[2]: Leaving directory `/usr/local/bin/R-1.8.1/src/library/Recommended' make[1]: *** [recommended-packages] Error 2 make[1]: Leaving directory `/usr/local/bin/R-1.8.1/src/library/Recommended' make: *** [stamp-recommended] Error 2 Am I doing something wrong here? I am installing as root. Thanks, Denna First, you are trying to install a version of R (1.8.1) that is two years old today. I would suggest getting either the current release version tarball for 2.2.0, or better would be the R 2.2.0 patched version. The former is available from your local CRAN mirror, the latter is available at: ftp://ftp.stat.math.ethz.ch/Software/R/R-patched.tar.gz I would try to install using a current version of R first to see if the error is still present. If it is, then you may have an access/permission issue with /tmp. Review sections 2.1 and 5.1 in the R Admin Manual regarding /tmp and the TMPDIR environment variable 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] nlme question
On 11/21/05, Wassell, James T., Ph.D. [EMAIL PROTECTED] wrote: Deepayan, Yes, thanks for confirming my suspicions. I know mixed models are different but, I did not think they were so different as to preclude estimating the var-cov matrix (via the Hessian in Maximum likelihood, as you point out). Thanks for prompting me to think about MCMC. Your suggestion to consider MCMC makes me realize that using BUGS, I could directly sample from the posterior of the linear combination of parameters - to get its variance and eliminate the extra step using the var-cov matrix. As you say, with results better than the asymptotic approximation. (Maybe I can do the same thing with mcmcsamp?, but I'm not familiar with this and will have to take a look at it.) That should be easy. mcmcsamp produces mcmc objects, which are essentially matrices, with each row containing one set of parameter values. Getting a sample of a linear combination is one call to %*% away. Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem in compilation from source in./configure R.2.2
Hello useRs! I'm REALLY having trouble with readline when compiling R. 2.2 from source during ./configure. Here are the last lines of the configure log: checking readline/history.h usability... yes checking readline/history.h presence... yes checking for readline/history.h... yes checking readline/readline.h usability... yes checking readline/readline.h presence... yes checking for readline/readline.h... yes checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... no checking for main in -ltermcap... no checking for main in -ltermlib... no checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available I'm on a ASUS W2V laptop (Chipset 915PM), on Mandriva 2005LE distro, libreadline5 and readline5-devel installed. I managed to get it compiled and installed using option --with-readline=no. However, as I use R dayly, I'd like to get a functional terminal again Can I do something to fix this, is it a configure script error or should I just change distro? :)) The R.2.0 rpm for mandrake installs ok. here the location of my libreadline files /usr/lib/libreadline.a /usr/lib/libreadline.so /lib/libreadline.so.5 /lib/libreadline.so.5.0 /lib/libreadline.so CheeRs! Pedro Pedro Cordeiro Estrela PhD. student UMR 2695: Origine structure et évolution de la biodiversité Département de systématique et évolution Muséum National d'Histoire Naturelle 55, rue Buffon 75005 Paris - FRANCE tel: (33) [0]1 40 79 30 86 fax: (33) [0]1 40 79 30 63 [0] : from france only _ - [[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] Plotting one or more series on the same graphs
On Mon, 2005-11-21 at 11:12 +0100, [EMAIL PROTECTED] wrote: Hi, I'm from Italy (sorry for my english...). I've two questions about the plot function. I've to create a simple graph for the data set n_species: species=sqlQuery(dati, select count(distinct species), season from captures_complete_r group by species, season) n_species=tapply(species$count, species$season, sum) n_species=data.frame(n_species) n_species n_species autumn10 spring 7 summer 7 winter 7 The problem is that, if I use plot(n_species), I can't put the seasons on the x-axis, and so the values on that axes appear as numbers. The problem here is that by default, plot() is using the result of: axTicks(1) as the x labels and tick mark locations, which yields: axTicks(1) [1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 with four data points. Actually, R is using a C coded equivalent of axTicks() internally, but the result is the same. See ?axTicks for more information. I've tried to remove the axis and then I've add with the script: plot(n_species, type=l, main=Species trend, xlab=Season, ylab=Number of species,ylim=c(3,10), col=1, axes=FALSE) legend(topright, c(Species captured), col = c(1), lty=c(1)) axis(1, 1:4, c(autumn, spring, summer, winter) ) axis(2, 1:11) This is better and gives you finer control over the axis labels and tick mark locations. However, using axis(2, 1:11) will cause problems as the 'y' ranges of your values change, as you see below. and it seems to work, but when I have decimal value on the y-axis, the script plot(k$simp_seas, ylim=c(min(k), max(k)), type=l,main=Index trend, xlab=Season, ylab=Index value, axes=FALSE) points(k$shan_seas, col=red, type=l) leg.txt=c(Simpson's index, Shannon's index) legend(topleft, leg.txt, col=c(1,2), lty=c(1,1)) axis(1, 1:4, c(autumn, spring, summer, winter) ) axis(2, 1:11) doesn't put decimal value, but jut a 1 in the middle of the vertical axis. How can make a correct graphs? Thanks, Gianpaolo. Since we don't have your actual data, I can provide some guidance, but not a specific solution. In your examples above, you need to exclude the x axis from being drawn, but not the y axis. Using 'axes = FALSE' will preclude both axes from being drawn. Thus: Instead of using 'axes = FALSE', use 'xaxt = n', which will preclude the x axis only from being drawn. You will then end up with the default y axis tick marks and labels. See ?par for more information. If you want more control over the y axis values as well, you can continue to use 'axes = FALSE', but will need to consider how you want the tick marks and labels to look and then use those values as the arguments to axis(2, ...) as appropriate, rather than hard coding the values and expecting them to work in all cases. In addition, you might want to take a look at ?matplot, which will enable you to plot multiple series in a single plot. 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] Help with xtable
On Mon, 2005-11-21 at 18:16 +0100, Matthieu Cornec wrote: Hello, How do you change the size of the caracters (tiny, small) using xtable? It works out for print.xtable when typing print.xtable(xtable(mydata),size=small) but I do not see any results when doing xtable(mydata,size=small) Anyone could help ? Thanks Matthieu As documented, xtable() ignores any ... arguments specified. Thus passing 'size' as part of the call here has no effect, since 'size' is not an enumerated argument for xtable(). print.xtable() has a 'size' argument enumerated, so it is respected there. BTW, print.xtable(..) is not required. print(xtable(mydata), size = small) will work and is preferred over calling the method directly. 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
[R] how to plot a list in graphs
hi all, I have a matrix and named each row and column as like below... a-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) col-c(peter,david,richrd,vincent,selva) rows-c(julius,caeser,anja,maya) dimnames(a)-list(rows,col) a peter david richrd vincent selva julius 315 27 39 9 caeser 618 30 42 8 anja 921 33 45 7 maya 1224 36 10 6 How I can plot this in graphs like julius Vs peter and so on.. whether it could ne done with image function?.. please give me some suggestions... best regards, eric. Research student, Fraunhofer IPT, Germany. - [[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] attributes of a data.frame
Dear all, I noticed that a data.frame has four attributes: - names - row.names - class - variable.labels While one can use the first three (i.e. names(foo) or class(foo)), the fourth one can only be used via: attributes(foo)$variable.labels (which is kind of a tedious thing to type) Is it or would be possible to simply use: variable.labels(foo) like the first three attributes? I tried: varlab - function(x) attributes(x)$variable.labels but then I cannot use this to assign a specific label: varlab(foo)[1] - some string Error: couldn't find function varlab- Thank you, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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] attributes of a data.frame
?assign -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian DUSA Sent: Monday, November 21, 2005 11:19 AM To: r-help@stat.math.ethz.ch Subject: [R] attributes of a data.frame Dear all, I noticed that a data.frame has four attributes: - names - row.names - class - variable.labels While one can use the first three (i.e. names(foo) or class(foo)), the fourth one can only be used via: attributes(foo)$variable.labels (which is kind of a tedious thing to type) Is it or would be possible to simply use: variable.labels(foo) like the first three attributes? I tried: varlab - function(x) attributes(x)$variable.labels but then I cannot use this to assign a specific label: varlab(foo)[1] - some string Error: couldn't find function varlab- Thank you, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Adding points to wireframe
On 11/18/05, Pierre-Luc Brunelle [EMAIL PROTECTED] wrote: Hi, I am using function wireframe from package lattice to draw a 3D surface. I would like to add a few points on the surface. I read in a post from Deepayan Sarkar that To do this in a wireframe plot you would probably use the panel function panel.3dscatter. Does someone have an example? Here goes. Let's say the surface you want is: surf - expand.grid(x = seq(-pi, pi, length = 50), y = seq(-pi, pi, length = 50)) surf$z - with(surf, { d - 3 * sqrt(x^2 + y^2) exp(-0.02 * d^2) * sin(d) }) To draw just the surface, you can of course do library(lattice) wireframe(z ~ x * y, g, aspect = c(1, .5), scales = list(arrows = FALSE)) To modify the display, you will want to write your own panel.3d.wireframe function (as suggested in ?panel.cloud), which defaults to 'panel.3dwire'. The first thing to realise is that lots of funny things go on inside panel functions that you don't really want to know about. The trick is to make liberal use of the ... argument, only naming arguments that you need to work with or override. So our first try might be to write an explicit but minimal panel.3d.wireframe function that does nothing new: wireframe(z ~ x * y, g, aspect = c(1, .5), scales = list(arrows = FALSE), panel.3d.wireframe = function(...) { panel.3dwire(...) }) Now, you want to add points using 3dscatter, and that's obviously going to use different data. However, most of the rest of the arguments will be the same for the panel.3dwire and panel.3dscatter calls (giving details of the 3-D to 2-D projection, mostly), so you need to capture the data passed in to panel.3d.wireframe, without worrying about the exact form of the rest of the arguments. This can be done by: wireframe(z ~ x * y, g, aspect = c(1, .5), scales = list(arrows = FALSE), panel.3d.wireframe = function(x, y, z, ...) { panel.3dwire(x = x, y = y, z = z, ...) }) which is of course the same as before. Now let's add a few points using panel.3dscatter: wireframe(z ~ x * y, g, aspect = c(1, .5), scales = list(arrows = FALSE), panel.3d.wireframe = function(x, y, z, ...) { panel.3dwire(x = x, y = y, z = z, ...) panel.3dscatter(x = runif(10, -0.5, 0.5), y = runif(10, -0.5, 0.5), z = runif(10, -0.25, 0.25), ...) }) Note that the ... arguments have been passed on to panel.3dscatter. Without it, you would have the error that you reported. Now, presumably the points that you want to add are in the original data scale, whereas panel.3dwire wants data in a different (linearly shifted and scaled) scale suitable for 3-D transformations. I happened to know what that transformed scale is (usually [-0.5, 0.5]), and the call above makes use of that knowledge. In practice, you would have to make the conversion from data scale to transformed scale yourself, and that's where the *lim and *lim.scaled arguments come in. They contain the range of the data cube in the original and transformed scales respectively. So let's say the points you want to add (in the original scale) are: pts - data.frame(x = runif(10, -pi, pi), y = runif(10, -pi, pi), z = runif(10, -1, 1)) Then the suitable transformation can be done as follows: wireframe(z ~ x * y, g, aspect = c(1, .5), scales = list(arrows = FALSE), pts = pts, panel.3d.wireframe = function(x, y, z, xlim, ylim, zlim, xlim.scaled, ylim.scaled, zlim.scaled, pts, ...) { panel.3dwire(x = x, y = y, z = z, xlim = xlim, ylim = ylim, zlim = zlim, xlim.scaled = xlim.scaled, ylim.scaled = ylim.scaled, zlim.scaled = zlim.scaled, ...) xx - xlim.scaled[1] + diff(xlim.scaled) * (pts$x - xlim[1]) / diff(xlim) yy - ylim.scaled[1] + diff(ylim.scaled) * (pts$y - ylim[1]) / diff(ylim) zz - zlim.scaled[1] + diff(zlim.scaled) * (pts$z - zlim[1]) / diff(zlim) panel.3dscatter(x = xx, y = yy, z = zz, xlim = xlim, ylim = ylim, zlim = zlim, xlim.scaled = xlim.scaled, ylim.scaled = ylim.scaled, zlim.scaled = zlim.scaled,
Re: [R] Adding points to wireframe
On 11/21/05, Deepayan Sarkar [EMAIL PROTECTED] wrote: On 11/18/05, Pierre-Luc Brunelle [EMAIL PROTECTED] wrote: Hi, I am using function wireframe from package lattice to draw a 3D surface. I would like to add a few points on the surface. I read in a post from Deepayan Sarkar that To do this in a wireframe plot you would probably use the panel function panel.3dscatter. Does someone have an example? Here goes. Let's say the surface you want is: surf - expand.grid(x = seq(-pi, pi, length = 50), y = seq(-pi, pi, length = 50)) surf$z - with(surf, { d - 3 * sqrt(x^2 + y^2) exp(-0.02 * d^2) * sin(d) }) Add g - surf here if you want the rest to work. Sorry about that. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] attributes of a data.frame
No! Ignore my previous advice . To assign attrributes of anything, see ?attributes. Shame on me! -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian DUSA Sent: Monday, November 21, 2005 11:19 AM To: r-help@stat.math.ethz.ch Subject: [R] attributes of a data.frame Dear all, I noticed that a data.frame has four attributes: - names - row.names - class - variable.labels While one can use the first three (i.e. names(foo) or class(foo)), the fourth one can only be used via: attributes(foo)$variable.labels (which is kind of a tedious thing to type) Is it or would be possible to simply use: variable.labels(foo) like the first three attributes? I tried: varlab - function(x) attributes(x)$variable.labels but then I cannot use this to assign a specific label: varlab(foo)[1] - some string Error: couldn't find function varlab- Thank you, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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] Removing Rows
I have a data frame with the following dimensions 217 x 5 I want to create two data frames from the original. 1) One containing every tenth row of the original data frame 2) Other containing the rest of the rows. How do I do this? I've tried subset() and calling the index. thank you in advance, [[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] arima prediction
x-c(-1.873,-0.121) # 23 numerics; x.arma12 - armaFit(x ~ arma(1,2)) #estimates y[t]= -0.11465 - 0.23767 y[t-1] - 0.14230 e[t-1] -0.85770 e[t-2] + e[t]; # ? how to predict 46 steps ahead based on 23 data points? # the following doesn't work since n is in armaSim rather than armaFit; predict(x.arima12, n.ahead=46) # 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] How to assign the p value from anova to a variable ?
Hi , If I need to assign the p-value from anova(lm(y~x1*x2)) to a variable temp. How can I do that? In other words, I need to let temp-1.228e-07. I ever tried to use temp-anova(lm(y~x1*x2))$Respone[x1:x2,Pr(F)], but it doesn't work. The result is like: anova(lm(y~x1*x2)) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F valuePr(F) x1 1 0.1009 0.1009 8.7183 0.01835 * x2 1 0.5983 0.5983 51.6845 9.343e-05 *** x1:x2 1 3.4940 3.4940 301.8363 1.228e-07 *** Residuals 8 0.0926 0.0116 Any idea is appreiciated, thanks a lot! Fay __ R-help@stat.math.ethz.ch 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] attributes of a data.frame
On 11/21/2005 2:18 PM, Adrian DUSA wrote: Dear all, I noticed that a data.frame has four attributes: - names - row.names - class - variable.labels While one can use the first three (i.e. names(foo) or class(foo)), the fourth one can only be used via: attributes(foo)$variable.labels (which is kind of a tedious thing to type) Is it or would be possible to simply use: variable.labels(foo) like the first three attributes? I tried: varlab - function(x) attributes(x)$variable.labels but then I cannot use this to assign a specific label: varlab(foo)[1] - some string Error: couldn't find function varlab- Not all dataframes have the variable.labels attribute. I'm guessing you've installed some contributed package to add them, or are importing an SPSS datafile using read.spss. So don't expect varlab() or variable.labels() function to be a standard R function. If you want to define it, definitions like this should work (but I can't test them): varlab - function(foo) attr(foo, variable.labels) varlab- - function(foo, label, value) { attr(foo, variable.labels)[label] - value foo } Use them like this: varlab(x) # to see the labels varlab(x, varname) - label # to set one Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to plot a list in graphs
On 11/21/05, peter eric [EMAIL PROTECTED] wrote: hi all, I have a matrix and named each row and column as like below... a-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) col-c(peter,david,richrd,vincent,selva) rows-c(julius,caeser,anja,maya) dimnames(a)-list(rows,col) a peter david richrd vincent selva julius 315 27 39 9 caeser 618 30 42 8 anja 921 33 45 7 maya 1224 36 10 6 How I can plot this in graphs like julius Vs peter and so on.. whether it could ne done with image function?.. Sure, how about image(a) If you want the axes to be labelled appropriately, it might be easier with library(lattice) levelplot(a) or perhaps levelplot(a, scales = list(x = list(rot = 90))) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Method for $
Ulrike Groemping [EMAIL PROTECTED] wrote: I have defined a class myclass and would like the slots to be extractable not only by @ but also by $. I now try to write a method for $ that simply executes the request [EMAIL PROTECTED], whenever someone calls object$slotname for any object of class myclass. I don't manage to find out how I can provide this function with slotname, so that one and the same function works for any arbitrary slotname a user might choose. ... I would caution against defining methods for $. In addition to Martin Maechler and Duncan Temple Lange's warnings about the danger of this, I would note that it could make R run much slower. I once tried defining a method for it in S-PLUS; that converted $ into a generic function, which slowed down every call to $, of which there are many. Even if it wouldn't slow down R, as we work to make R and S-PLUS more compatible you or someone else might try your code in S-PLUS, and cause a big speed hit. Maybe I could (and should?) have defined the class with just one slot that contains the list, which would make it behave like I want it immediately. Why not make it a list with an S3 class, rather than an S4 class? Tim Hesterberg | Tim Hesterberg Research Scientist | | [EMAIL PROTECTED] Insightful Corp.| | (206)802-23191700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3012, U.S.A. | | www.insightful.com/Hesterberg | Download the S+Resample library from www.insightful.com/downloads/libraries Two Research Scientist positions: data mining frailty/mixed effects http://www.insightful.com/company/jobs.asp Speak out about biased science in Washington D.C. http://home.comcast.net/~timhesterberg/ScientificIntegrity.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] attributes of a data.frame
On Monday 21 November 2005 22:41, Duncan Murdoch wrote: [...snip...] Not all dataframes have the variable.labels attribute. I'm guessing you've installed some contributed package to add them, or are importing an SPSS datafile using read.spss. So don't expect varlab() or variable.labels() function to be a standard R function. Aa-haa... of course you are right: I read them via read.spss. I understand. Now, just to the sake of it, would it be wrong to make it standard? Is there a special reason not to? If you want to define it, definitions like this should work (but I can't test them): varlab - function(foo) attr(foo, variable.labels) varlab- - function(foo, label, value) { attr(foo, variable.labels)[label] - value foo } Use them like this: varlab(x) # to see the labels varlab(x, varname) - label # to set one Duncan Murdoch Thank you for the tip; I'll certainly use it. Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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] PNG-import into R
Rajarshi Guha wrote: Right now it segfaults, so its not really useful yet. Can I use that as a tag line? __ R-help@stat.math.ethz.ch 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] PNG-import into R
On Mon, 21 Nov 2005, Sydler, Dominik wrote: Hi there I'm looking for a function to read PNG-bitmap-images from a file into R. I only found: - the pixmap-package which cannot import png or similar formats - the rimage-package which can only import lossy jpeg-images (the convertion from png to jpeg modifies the data!) Is there any possibility to read PNG-files? Under Linux, install GDAL directly then package rgdal from source, I guess some variant of this under OSX. Under Windows, install the rgdal binary package from Prof. Ripley's repository - for me: options(repos) $repos CRANCRANextra @CRAN@ http://www.stats.ox.ac.uk/pub/RWin; or download from: http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.2/ directly. Then: x.png - GDAL.open(file.choose()) getDriverLongName(getDriver(x.png)) [1] Portable Network Graphics From there you use getRasterData() on the bands and subscenes you want, GDAL.open() just returns a file handle, letting you choose the parts you need. That is probably the least resistance path. Thanks for any help Dominic Sydler __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] attributes of a data.frame
On 11/21/2005 2:51 PM, Adrian DUSA wrote: On Monday 21 November 2005 22:41, Duncan Murdoch wrote: [...snip...] Not all dataframes have the variable.labels attribute. I'm guessing you've installed some contributed package to add them, or are importing an SPSS datafile using read.spss. So don't expect varlab() or variable.labels() function to be a standard R function. Aa-haa... of course you are right: I read them via read.spss. I understand. Now, just to the sake of it, would it be wrong to make it standard? Is there a special reason not to? I think it's just that the R core developers don't see the need for them. If something is worth documenting, then you should write an .Rd file or a vignette about it, and that gives you more flexibility than a one line label. I think there are definitely developers out there who disagree with this point of view, and I'm pretty sure I've seen a contributed package that offered support for this, but I can't remember which one right now. So that's another reason why it's not in the base: it doesn't need to be, you can just go find and install that contributed package! Duncan Murdoch If you want to define it, definitions like this should work (but I can't test them): varlab - function(foo) attr(foo, variable.labels) varlab- - function(foo, label, value) { attr(foo, variable.labels)[label] - value foo } Use them like this: varlab(x) # to see the labels varlab(x, varname) - label # to set one Duncan Murdoch Thank you for the tip; I'll certainly use it. Adrian __ R-help@stat.math.ethz.ch 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] attributes of a data.frame
On Monday 21 November 2005 23:00, Duncan Murdoch wrote: [...snip...] I think it's just that the R core developers don't see the need for them. If something is worth documenting, then you should write an .Rd file or a vignette about it, and that gives you more flexibility than a one line label. I think there are definitely developers out there who disagree with this point of view, and I'm pretty sure I've seen a contributed package that offered support for this, but I can't remember which one right now. So that's another reason why it's not in the base: it doesn't need to be, you can just go find and install that contributed package! Duncan Murdoch I got it, it's logic. Well, one could always use Hmisc which does very well these things. Thank you again, Adrian -- Adrian DUSA Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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 plot a list in graphs
Really your (Mr.deepayan´s)answer is what I expected..thanks a lot...and I like to ask you one more thing.. Is it possible to do boolean operations in this matrix and plot that also in graphs? for example 1. a[anja,maya] Vs a[vincent,selva] means things common between the rows anjamaya and columns vincent selva 2.a[anja,maya] Vs a[peter,david] and so on... So in that case whether it is possible to plot in the same graph(since I´m doing different...more than one.. comparisions) or I´ve to plot in a multiple graph.. kindly help me... thanks a lot with regards, eric Deepayan Sarkar [EMAIL PROTECTED] wrote: On 11/21/05, peter eric wrote: hi all, I have a matrix and named each row and column as like below... a-matrix(c(seq(3,45,3),seq(10,6,-1)),4,5,byrow=F) col-c(peter,david,richrd,vincent,selva) rows-c(julius,caeser,anja,maya) dimnames(a)-list(rows,col) a peter david richrd vincent selva julius 3 15 27 39 9 caeser 6 18 30 42 8 anja 9 21 33 45 7 maya 12 24 36 10 6 How I can plot this in graphs like julius Vs peter and so on.. whether it could ne done with image function?.. Sure, how about image(a) If you want the axes to be labelled appropriately, it might be easier with library(lattice) levelplot(a) or perhaps levelplot(a, scales = list(x = list(rot = 90))) -Deepayan __ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem in compilation from source in./configure R.2.2
Pedro Cordeiro Estrela [EMAIL PROTECTED] writes: Hello useRs! I'm REALLY having trouble with readline when compiling R. 2.2 from source during ./configure. Here are the last lines of the configure log: checking readline/history.h usability... yes checking readline/history.h presence... yes checking for readline/history.h... yes checking readline/readline.h usability... yes checking readline/readline.h presence... yes checking for readline/readline.h... yes checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... no checking for main in -ltermcap... no checking for main in -ltermlib... no checking for rl_callback_read_char in -lreadline... no twice? This check is in there to check for some really old readline versions that didn't allow the style of readline interface that R used. Do you happen to have such an older version that could get picked up by the linker? What's inside config.log corresponding to the messages? These tests generally work by compiling and linking a small test program, and if that fails, you get the no part. However, sometimes the program fails for some other reason and the message becomes misleading. checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available I'm on a ASUS W2V laptop (Chipset 915PM), on Mandriva 2005LE distro, libreadline5 and readline5-devel installed. I managed to get it compiled and installed using option --with-readline=no. However, as I use R dayly, I'd like to get a functional terminal again Can I do something to fix this, is it a configure script error or should I just change distro? :)) The R.2.0 rpm for mandrake installs ok. here the location of my libreadline files /usr/lib/libreadline.a /usr/lib/libreadline.so /lib/libreadline.so.5 /lib/libreadline.so.5.0 /lib/libreadline.so CheeRs! Pedro Pedro Cordeiro Estrela PhD. student UMR 2695: Origine structure et évolution de la biodiversité Département de systématique et évolution Muséum National d'Histoire Naturelle 55, rue Buffon 75005 Paris - FRANCE tel: (33) [0]1 40 79 30 86 fax: (33) [0]1 40 79 30 63 [0] : from france only _ - [[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 -- 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] How to assign the p value from anova to a variable ?
On Mon, 21 Nov 2005, Gao Fay wrote: If I need to assign the p-value from anova(lm(y~x1*x2)) to a variable temp. How can I do that? Maybe this is what you want: anova(...)$Pr[3] Claus __ R-help@stat.math.ethz.ch 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] arima prediction
Jin, I think you are using ARIMA in a wrong situation because ARIMA is a short-momery model. Plus, 23 data points is also problematic. On 11/21/05, Xiaodong Jin [EMAIL PROTECTED] wrote: x-c(-1.873,-0.121) # 23 numerics; x.arma12 - armaFit(x ~ arma(1,2)) #estimates y[t]= -0.11465 - 0.23767 y[t-1] - 0.14230 e[t-1] -0.85770e[t-2] + e[t]; # ? how to predict 46 steps ahead based on 23 data points? # the following doesn't work since n is in armaSim rather than armaFit; predict(x.arima12, n.ahead=46) # 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 -- WenSui Liu (http://statcompute.blogspot.com) Senior Decision Support Analyst Cincinnati Children Hospital Medical Center [[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)
Hi, I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ # check for monotonicity in time-stamp data for cortisol collection ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? ( I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Can't figure out warning message
Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? (I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] -- [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can't figure out warning message
Works fine for me with no warning messages. R for Windows 2.2.0. Try upgrading (but I don't see why you get the warning either). Try changing to though, as you don't need to vectorize the conjunction. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Monday, November 21, 2005 3:17 PM To: 'RHelp' Subject: [R] Can't figure out warning message Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? (I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: mailto:[EMAIL PROTECTED] [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 __ R-help@stat.math.ethz.ch 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] Can't figure out warning message
Ravi Varadhan wrote: Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE Try to double the : in place of Kjetil I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? (I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: mailto:[EMAIL PROTECTED] [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 __ R-help@stat.math.ethz.ch 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] Can't figure out warning message
Hi, I apologize for my hasty posting. The function works perfectly, after I realized that I had a matrix named T sitting in my workspace, so when I set my default option for increase to T, it created a problem. Changing my default to TRUE solved my problem. Thanks, Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Monday, November 21, 2005 6:17 PM To: 'RHelp' Subject: [R] Can't figure out warning message Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? (I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: mailto:[EMAIL PROTECTED] [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 __ R-help@stat.math.ethz.ch 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] Function comparable to cutpt.coxph from Survival Analysis using S
The title says it all really; I am looking for a function along the lines of cutpt.coxph as described in Survival Analysis Using S (Tableman and Kim), Chapter 6. As may be guessed, the function optimises the cutpoint of a continuous variable for cox proportional hazard modelling. I can't find it, or any similar function, on CRAN. Alternatively, perhaps there is a way of extracting the likelihoods from the output of coxph. Rachel __ R-help@stat.math.ethz.ch 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 plot a list in graphs
On 11/21/05, peter eric [EMAIL PROTECTED] wrote: Really your (Mr.deepayan´s)answer is what I expected..thanks a lot...and I like to ask you one more thing.. Is it possible to do boolean operations in this matrix and plot that also in graphs? for example 1. a[anja,maya] Vs a[vincent,selva] means things common between the rows anjamaya and columns vincent selva You mean levelplot(a[c(anja, maya), c(vincent, selva)]) ? This is standard matrix indexing in R. 2.a[anja,maya] Vs a[peter,david] and so on... So in that case whether it is possible to plot in the same graph(since I´m doing different...more than one.. comparisions) or I´ve to plot in a multiple graph.. It depends on what you want to do. If the different comparisons are based on some systematic rule then levelplot may take you further. [Note that for this you may need to work with a data.frame instead of a matrix. E.g., mat2df - function(x) { rx - row(x) cx - col(x) data.frame(row = rownames(x)[rx], column = colnames(x)[cx], z = as.vector(x)) } b - mat2df(a) b is now a data frame: b row column z 1 julius peter 3 2 caeser peter 6 3anja peter 9 ... ] __ R-help@stat.math.ethz.ch 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] (no subject)
Ravi Varadhan [EMAIL PROTECTED] writes: Hi, I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ # check for monotonicity in time-stamp data for cortisol collection ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? ( I am using version 2.1.1 on Windows). Would you happen to have a variable called T around? -- 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] Can't figure out warning message
My guess is that you have an object 'T' hanging around. Like Berton, I get no error until I define: T - 0:1 and then run your test case, resulting in the warnings. Peter Ravi Varadhan wrote: Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: I have written the following function to check whether a vector has elements satisfying monotonicity. is.monotone - function(vec, increase=T){ ans - TRUE vec.nomis - vec[!is.na(vec)] if (increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE if (!increase any(diff(vec.nomis,1) 0, na.rm=T)) ans - FALSE ans } This works correctly, but I get this error message as below. x - 2:10 is.monotone(x) [1] TRUE Warning messages: 1: the condition has length 1 and only the first element will be used in: if (increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE 2: the condition has length 1 and only the first element will be used in: if (!increase any(diff(vec.nomis, 1) 0, na.rm = T)) ans - FALSE I am unable to see why the condition should have a length greater than 1, since any should give me a single logical value. Can any one tell me what is going on here? (I am using version 2.1.1 on Windows). Thanks very much, Ravi. -- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: mailto:[EMAIL PROTECTED] [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 -- Peter Ehlers Department of Mathematics and Statistics University of Calgary, 2500 University Dr. NW ph: 403-220-3936 __ R-help@stat.math.ethz.ch 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] Can't figure out warning message
P Ehlers (that's me) wrote: My guess is that you have an object 'T' hanging around. Like Berton, I get no error until I define: T - 0:1 and then run your test case, resulting in the warnings. Peter Ravi Varadhan wrote: Hi, I apologize for the previous posting, where the message was not formatted properly. Here is a better version: [snip] As the posting guide says: When responding to a very simple question, use the following algorithm: 2. type 4*runif(1) at the R prompt, and wait this many hours 4*runif(1) [1] 3.141592 Obviously, I acted much too hastily. My apologies. Peter -- Peter Ehlers Department of Mathematics and Statistics University of Calgary, 2500 University Dr. NW ph: 403-220-3936 __ R-help@stat.math.ethz.ch 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] Removing Rows
try this: (if d is the data.frame) 1) d[ (1:217)[1:217 %% 10 == 0], ] 2) d[ (1:217)[1:217 %% 10 != 0], ] 2005/11/21, mark salsburg [EMAIL PROTECTED]: I have a data frame with the following dimensions 217 x 5 I want to create two data frames from the original. 1) One containing every tenth row of the original data frame 2) Other containing the rest of the rows. How do I do this? I've tried subset() and calling the index. thank you in advance, [[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