[R] please help me
dear list I am student M.S. statistics in department statistics . I am working in the function nls in the [R 2.3.1] with 246 data and want to fit a model to vectors( v and u ) but I have a problem to use it u 5.00e-13 2.179057e+03 6.537171e+03 1.089529e+04 1.525340e+04 1.961151e+04 2.396963e+04 2.832774e+04 3.268586e+04 3.704397e+04 4.140209e+04 4.576020e+04 5.011831e+04 5.447643e+04 v 8.382562e-01 4.090868e+02 1.311053e+03 2.124143e+03 3.365494e+03 2.138903e+03 7.687774e+03 1.028396e+04 1.004186e+04 2.059798e+04 1.438464e+04 2.861373e+04 2.294919e+04 2.807701e+04 nls(v~c0+.5(a^2)*(u^2),start=list(c0=0,a=.3)) Error in eval(expr, envir, enclos) : attempt to apply non-function ... nls(v~c0+a*(u^s),start=list(c0=0,a=1,s=5000)) Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model i dont know how to solve it, please help me . best regards Sadeghian. __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] please help me
dear list I am student M.S. statistics in department statistics . I am working in the function nls in the [R 2.3.1] with 246 data and want to fit a model to vectors( v and u ) but I have a problem to use it u 5.00e-13 2.179057e+03 6.537171e+03 1.089529e+04 1.525340e+04 1.961151e+04 2.396963e+04 2.832774e+04 3.268586e+04 3.704397e+04 4.140209e+04 4.576020e+04 5.011831e+04 5.447643e+04 v 8.382562e-01 4.090868e+02 1.311053e+03 2.124143e+03 3.365494e+03 2.138903e+03 7.687774e+03 1.028396e+04 1.004186e+04 2.059798e+04 1.438464e+04 2.861373e+04 2.294919e+04 2.807701e+04 nls(v~c0+.5(a^2)*(u^2),start=list(c0=0,a=.3)) Error in eval(expr, envir, enclos) : attempt to apply non-function ... nls(v~c0+a*(u^s),start=list(c0=0,a=1,s=5000)) Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an infinity produced when evaluating the model i dont know how to solve it, please help me . best regards Sadeghian. __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extending zoo (or ts) objects
list(...) I would like to extend zoo objects for use in a hydrological application. By that I mean I want to attach various attributes, such as id numbers, coordinates of the observation location, a units specification, etc. I might also want to add to the class attribute (inheriting from zoo) and define some custom methods. I can add attributes() to a zoo object, but the problem is that when I do operations on the object, such as window, `[`, lag etc, the attributes are lost. That makes it awkward to manage. E.g. foo - zoo(1:5, order.by=as.Date(1:5)) attr(foo, location) - c(150, -35) The functions below all return a modified zoo object; test which ones keep the user-specified attributes: attr(foo[1:4], location) NULL attr(window(foo), location) NULL attr(lag(foo), location) NULL attr(na.approx(foo), location) ## this one keeps attributes [1] 150 -35 attr(rollmean(foo, 1), location) NULL attr(aggregate(foo, months, mean), location) NULL I notice that many operations on ts objects have the same behaviour (dropping user-specified attributes). In contrast, subsetting (indexing) a data.frame keeps them, as I had expected. Any ideas for how to manage this? Felix -- Felix Andrews / 安福立 PhD candidate Integrated Catchment Assessment and Management Centre The Fenner School of Environment and Society The Australian National University (Building 48A), ACT 0200 Beijing Bag, Locked Bag 40, Kingston ACT 2604 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] please help me
azadeh sadeghian wrote: dear list I am student M.S. statistics in department statistics . I am working in the function nls in the [R 2.3.1] with 246 data and want to fit a model to vectors( v and u ) but I have a problem to use it Thanks for providing a reproducible example. Your version of R is _really_ old: you should probably update (or ask you administrator to update) to make sure that all possible bugs etc. are fixed. u=c(5.00e-13,2.179057e+03,6.537171e+03,1.089529e+04,1.525340e+04, 1.91151e+04,2.396963e+04,2.832774e+04,3.268586e+04,3.704397e+04, 4.140209e+04,4.576020e+04,5.011831e+04,5.447643e+04) v=c(8.382562e-01,4.090868e+02,1.311053e+03,2.124143e+03,3.365494e+03, 2.138903e+03,7.687774e+03,1.028396e+04,1.004186e+04,2.059798e+04, 1.438464e+04,2.861373e+04,2.294919e+04,2.807701e+04) ## always a good idea to look at the data plot(v~u) ## your code: error nls(v~c0+.5(a^2)*(u^2),start=list(c0=0,a=.3)) ## you need a * between .5 and (a^2) m2 = nls(v~c0+.5*(a^2)*(u^2),start=list(c0=0,a=.3)) coef(n2) ## you can also fit this (quadratic regression) with lm m3 = lm(v~I(u^2)) ## converting the coefficient sqrt(2*coef(m3)[2]) ## you need to use sensible starting conditions! ## one way to get is to look at the plot and ##take a guess. Another would be to assume ## c0=0 and fit a linear model to log(v) as a function ## of log(u) nls(v~c0+a*(u^s),start=list(c0=0,a=1,s=2)) -- View this message in context: http://www.nabble.com/please-help-me-tf4657131.html#a13309307 Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] please help me
azadeh sadeghian wrote: dear list I am student M.S. statistics in department statistics . I am working in the function nls in the [R 2.3.1] with 246 data and want to fit a model to vectors( v and u ) but I have a problem to use it u PS -- I just looked back at the list and noticed that you have posted several messages, all with the title please help me (or help me), and all about the same kinds of problems with nls (and the previous respondents also suggested that you think more carefully about what you're doing and what your starting conditions are). Please use more informative subject lines, and please help yourself ... Ben Bolker -- View this message in context: http://www.nabble.com/please-help-me-tf4657131.html#a13309309 Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Getting at what a named object represents in a function...
Hi, I'm pretty new to R. I have an object (say a list) and I I have a function that I call on various columns in that list (excuse terminology if it's wrong/ambiguous). Imagine its like this (actual values are unimportant) and called mylist: mylist AB 15 25 36 48 50 I have a function: foo = function(param){ #modify list A or B values depending on whether A or B's passsd in (via 'param') param[someindex]=another_value #doesn't change value in lits$A or list$B (whichever's been passed in as 'param') #I want something like: #if 'param' is list$A then list$A[someindex]=another_value #else if 'param' is list$B then list$B[some_index] = another_value } I then call this function on mylist$A (i.e. foo(mylist$A) and then on mylist$B (i.e. foo(mylist$B)) so 'param' in function foo is either mylist$A or mylist$B - can I tell which it is so that when param[someindex] is changed, it's actually mylist$A or mylist$B that's changed? If I modify param values in foo(), they're not modified in list...so is there a way to tell whether param represents list$A or list$B and hence allow to me to modify those actual values rather than 'param'? Thanks for help, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] r achives
I think that should be https://stat.ethz.ch/pipermail/r-help/ (note https prefix) From: (Ted Harding) [EMAIL PROTECTED] Subject: Re: [R] r achives On 19-Oct-07 09:36:52, raymond chiruka wrote: sorry but how do i accsess r archives If you mean the archive of postings to the R-help list, then: http://stat.ethz.ch/pipermail/r-help/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] r achives
Might I suggest that the Email deamon include the URL of the archives to the footer it attaches to Email messages. Johh John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) [EMAIL PROTECTED] Alan Zaslavsky [EMAIL PROTECTED] 10/20/07 9:53 AM I think that should be https://stat.ethz.ch/pipermail/r-help/ (note https prefix) From: (Ted Harding) [EMAIL PROTECTED] Subject: Re: [R] r achives On 19-Oct-07 09:36:52, raymond chiruka wrote: sorry but how do i accsess r archives If you mean the archive of postings to the R-help list, then: http://stat.ethz.ch/pipermail/r-help/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] r achives
On 20-Oct-07 13:53:11, Alan Zaslavsky wrote: I think that should be https://stat.ethz.ch/pipermail/r-help/ (note https prefix) Well, I thought so too: My bookmark has https. But, in replying to Raymond Chiruka, I wondered whether the https was necessary. So I tried http, and it worked. But now it does not work, but https does work; so: Yes, you are right, and it should be as you say! Ted. From: (Ted Harding) [EMAIL PROTECTED] Subject: Re: [R] r achives On 19-Oct-07 09:36:52, raymond chiruka wrote: sorry but how do i accsess r archives If you mean the archive of postings to the R-help list, then: http://stat.ethz.ch/pipermail/r-help/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Oct-07 Time: 15:36:12 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] r achives [follow-up]
On 20-Oct-07 15:23:25, Ted Harding wrote: On 20-Oct-07 13:53:11, Alan Zaslavsky wrote: I think that should be https://stat.ethz.ch/pipermail/r-help/ (note https prefix) Well, I thought so too: My bookmark has https. But, in replying to Raymond Chiruka, I wondered whether the https was necessary. So I tried http, and it worked. But now it does not work, but https does work; so: Yes, you are right, and it should be as you say! Ted. Follow-up: Having tried the http as above, and failing to connect, I then tried https, and was connected. But now I have I tried http again, and it connected. Probably what happened in the first place was that I was carrying a cookie from a previous connection, so http worked at that time (and I mis-interpreted the outcome). But, as a matter of interest, why is https needed for that site? Ted. From: (Ted Harding) [EMAIL PROTECTED] Subject: Re: [R] r achives On 19-Oct-07 09:36:52, raymond chiruka wrote: sorry but how do i accsess r archives If you mean the archive of postings to the R-help list, then: http://stat.ethz.ch/pipermail/r-help/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Oct-07 Time: 15:36:12 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Oct-07 Time: 16:29:05 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] modeling large data
Hi, Dear Listers, Several days ago, I posted a question regarding modeling large dataset in R. Could anyone with such experience shed some light on it? I truly appreciate it. wensui On 10/17/07, Wensui Liu [EMAIL PROTECTED] wrote: Hi, Dear Listers, I am just curious if R is able to model a logistic regression with 2-3000 variables and 30-40 million records. I know R is good but just want to know how good is to use it in a business envirnment such as database marketing. Thank you so much for you insight! -- === WenSui Liu Statistical Project Manager ChoicePoint Precision Marketing (http://spaces.msn.com/statcompute/blog) === -- === WenSui Liu Statistical Project Manager ChoicePoint Precision Marketing (http://spaces.msn.com/statcompute/blog) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pairs, par(plt)
I'm having some confusion over the coordinate system after using pairs. I'm not interested in the content of the actual pairs plot, although the number of pairs seems to matter a bit. I'm purely interested in knowing where my points will be plotted on the device. However, after using pairs, the par information (omd, fig, plt, and usr) don't reflect what points does. For example: pairs(iris[1:5]) par(xpd = NA) points(0 - 0.01 * 1:100, 0 - 0.01 * 1:100) points(0 - 0.01 * 1:100, 1 + 0.01 * 1:100) points(1 + 0.01 * 1:100, 0 - 0.01 * 1:100) points(1 + 0.01 * 1:100, 1 + 0.01 * 1:100) par(c(omd, fig, plt, usr)) The resulting plot shows that the corners of the are approximately 0.05 user coordinate units from the boundaries of the plot region. According to par, though, there is a margin around the plotting region that is clearly not symmetric and does not correspond to around 0.05 units. If we use pairs(iris[1:2]) and repeat the rest, the corners are now 0.02 user coordinate units. par provides the same information as before. So: 1. How do I figure out where coordinates I give to points will display on the figure? 2. More generally (for my own understanding), why does the par information not do what I expect? Do I have some fundamental misunderstanding of the arrangement of plotting, figure, display, and margin regions within the device? I'm using R 2.5.1, and this behavior occurs on a fresh R console. Thanks! Oliver -- Oliver Soong Donald Bren School of Environmental Science Management University of California, Santa Barbara Santa Barbara, CA 93106-5131 805-893-7044 (office) 610-291-9706 (cell) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] r achives
John Sorkin wrote: Might I suggest that the Email deamon include the URL of the archives to the footer it attaches to Email messages. Johh Er, it is one click from what is in there already. Is it really not possible for people to guess that the archives for a mailing list might be found via the link to the list itself? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unable to interactively label curves on a plot
Quin Wills wrote: Hello all Simple question for the gurus. I'm trying to interactively label curves on a single plot. The labcurve() function from Hmisc seems like the way to do this (?). I just can't seem to get it to work. Toy example: x - 1:10 y1 - x^2 y2 - 2*x plot(x,y1) lines(x,y2) labcurve(labels=c(curve1, curve2), method=locator) From the help file, this is how I would understand it should be done, but have tried many other combinations, with no luck. Running up-to-date R, R packages and Fedora. Many thanks, Quin Please take time to read the help file for labcurve which makes it clear that you need to give it the data as well as the curve labels. Also specify pl=TRUE. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] modeling large data
And I suggested to use the 'biglm' package. Didn't it work? It has examples that I found useful. B On Oct 20, 2007, at 11:41 AM, Wensui Liu [EMAIL PROTECTED] wrote: Hi, Dear Listers, Several days ago, I posted a question regarding modeling large dataset in R. Could anyone with such experience shed some light on it? I truly appreciate it. wensui On 10/17/07, Wensui Liu [EMAIL PROTECTED] wrote: Hi, Dear Listers, I am just curious if R is able to model a logistic regression with 2-3000 variables and 30-40 million records. I know R is good but just want to know how good is to use it in a business envirnment such as database marketing. Thank you so much for you insight! -- === WenSui Liu Statistical Project Manager ChoicePoint Precision Marketing (http://spaces.msn.com/statcompute/blog) === -- === WenSui Liu Statistical Project Manager ChoicePoint Precision Marketing (http://spaces.msn.com/statcompute/blog) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot.Design
John Smith wrote: Dear R-users: I am trying to use the following code to reproduce the figures on page 140 of Prof. Frank Harrell's book 'Regression Modeling Strategies': rm(list=ls()) options(width=128) library(Hmisc) library(Design) getHdata(counties) counties$older - counties$age6574 + counties$age75 label(counties$older) - '% age = 65, 1990' counties$pdensity - log10(counties$pop.density+1) label(counties$pdensity) - 'log 10 of 1992 pop per 1990 miles^2' dd - datadist(counties) options(datadist='dd') f - ols(democrat ~ rcs(pdensity,4) + rcs(pop.change,3) + rcs(older,3) + crime + rcs(college,5) + rcs(income,4) + rcs(college,5) %ia% rcs(income,4) + rcs(farm,3) + rcs(white,5) + rcs(turnout,3), data=counties) f r - resid(f) windows(width=10.67, height=6.60) par(mfrow=c(3,3)) par(mar=c(4, 4, 2, 2)) plot(f, ylim=c(20,70)) But I have following problems: 1): the last two subfigures are different with those from the book; 2): I have a error reads: Error in if (units == ) g(label) else if (label == ) g(units) else if (plotmath : missing value where TRUE/FALSE needed 3): I think there should be another subfigure on variable turnout, but is missing in book also I am using most current version of R, Design and Hmisc. Thanks John, I could reproduce the problem and this indicates a significant bug in plot.Design in some past version. I am almost certain the current version is correct because it now produces output that is consistent with the odds ratio chart. On the bottom row of the figure on p. 140 the voter turnout variable was missing, and as you mentioned the plot for % white is off. The plot for farm population shows a line that is too high. I have fixed the units error and will send you a corrected plot.Design in a separate e-mail. Thanks for reporting these problems. Frank [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Secondary Y axis title
I was curious about the exact same question that John Theal posed - how to get a second y-axis label for a plot of two data series against a common x (in my case, time). I tried two different methods - one in lattice and one in plot. Both times the y-axis on the right side appears but the label does not. Similar to John's comment, it appears that there is not enough room for the label. Gabor mentioned that the plot.zoo examples give a plot like this. When I run that series of examples, #7 appears to be what Gabor was referring to, but even there the label for the right-hand y-axis is missing. Help? Dave Hewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] beginner's tutorial, books, etc re: time-series analysis, ARMA/ARIMA models...
Can anyone point me towards a beginner's tutorial, books, etc for someone that on time-series analysis, ARMA/ARIMA models, etc? keywords: time-series, autoregression, autoregressive, tutorial, beginner, ARMA, ARIMA __ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Secondary Y axis title
That's strange. When I run example(plot.zoo) its also cut off but if I run the very same code by copying and pasting it into my session then its not cut off: packageDescription(zoo)$Version [1] 1.4-0 R.version.string [1] R version 2.6.0 Patched (2007-10-08 r43124) library(zoo) example(plot.zoo) opar - par(mai = c(.8, .8, .2, .8)) plot(z[,1], type = l, xlab = X axis label, ylab = colnames(z)[1]) Waiting to confirm page change... par(new = TRUE) plot(z[,2], type = l, ann = FALSE, yaxt = n, col = blue) axis(4) legend(x = topleft, bty = n, lty = c(1,1), col = c(black, blue), legend = paste(colnames(z), c((left scale), (right scale usr - par(usr) # mtext line should replace text line if y labels are to have same orientation # mtext(colnames(z)[2], 4, 2, col = blue) text(usr[2] + .1 * diff(usr[1:2]), mean(usr[3:4]), colnames(z)[2], srt = -90, xpd = TRUE, col = blue) par(opar) On 10/20/07, Dave Hewitt [EMAIL PROTECTED] wrote: I was curious about the exact same question that John Theal posed - how to get a second y-axis label for a plot of two data series against a common x (in my case, time). I tried two different methods - one in lattice and one in plot. Both times the y-axis on the right side appears but the label does not. Similar to John's comment, it appears that there is not enough room for the label. Gabor mentioned that the plot.zoo examples give a plot like this. When I run that series of examples, #7 appears to be what Gabor was referring to, but even there the label for the right-hand y-axis is missing. Help? Dave Hewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mussy data
On Sat, 2007-10-20 at 18:15 +0700, Sandra Stattman wrote: Hi, I am writing my B.SC thesis and I have to do something in R, my data are iindexidx 1110.2 2210.4 3310.3 4120.5 5220.3 6320.1 7130.2 8230.1 9330.4 and for the analysis they have to be as iindexidx 1110.2 4120.5 7130.2 2210.4 5220.3 8230.1 3310.3 6320.1 9330.4 Thank you for your help! ?order dat i index id x 1 1 1 1 0.2 2 2 2 1 0.4 3 3 3 1 0.3 4 4 1 2 0.5 5 5 2 2 0.3 6 6 3 2 0.1 7 7 1 3 0.2 8 8 2 3 0.1 9 9 3 3 0.4 ord - order(dat$index, dat$id) dat[ord, ] i index id x 1 1 1 1 0.2 4 4 1 2 0.5 7 7 1 3 0.2 2 2 2 1 0.4 5 5 2 2 0.3 8 8 2 3 0.1 3 3 3 1 0.3 6 6 3 2 0.1 9 9 3 3 0.4 HTH G Sandra -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] formatting a list
On Sat, 20 Oct 2007, Tomas Vaisar wrote: Hi, I am new to R and need to read in a file with 19 columns and 7000 rows and make it into a list of 7000 lists with 19 items each. For a simpler case of 10 by 10 table I used x -scan(file, list(0,0,0,0,0,0,0,0,0,0)), perhaps clumsy, but it did the job. However with the large 19x7000 (which needs to be transposed) I am not sure how to go about it. Coudl somebody suggest a way? dat - as.data.frame( matrix( scan('tmp.txt'), nr=19) ) returns a data.frame which is a list with some added attributes. or dat - lapply( readLines('tmp.txt'), function(x) scan(textConnection(x) ) ) Or char.dat - strsplit( readLines('tmp.txt'), split='[[:blank:]]+') numeric.dat - lapply( char.dat, as.numeric ) HTH, Chuck Thanks, Tomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Secondary Y axis title
In the zoo example you can control how far it lies from the axis by adjusting the text() command and you can alter the margins using the values for the mai parameter in the par() command. On 10/20/07, John Theal [EMAIL PROTECTED] wrote: I still haven't resolved this problem. However, when I run the plot.zoo example the label appears, it also appears if I enter the commands manually. The problem that persists is that the label has to lie so close to the secondary y axis, that (in my case) it becomes almost indistinguishable from the axis scale labels. If the label is long, then it over-writes some of the scale labeling. I thought it might be do to the way the Quartz window manager handles the figure margins (under Mac OS X), but it looks as though maybe this is not the case. I'm running the same versions of R (2.6.0, unpatched) and zoo (1.4-0) as Gabor. I am using R under Mac OS X. Dave Hewitt wrote: I was curious about the exact same question that John Theal posed - how to get a second y-axis label for a plot of two data series against a common x (in my case, time). I tried two different methods - one in lattice and one in plot. Both times the y-axis on the right side appears but the label does not. Similar to John's comment, it appears that there is not enough room for the label. Gabor mentioned that the plot.zoo examples give a plot like this. When I run that series of examples, #7 appears to be what Gabor was referring to, but even there the label for the right-hand y-axis is missing. Help? Dave Hewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Secondary Y axis title
The controls for the margin sizes, which set the amount of space allocated for the labels, are the 'mai' numbers in the first 'par' call. The fourth number changed to 0.9 or greater should give you more room like you're looking for. You can use the alternative 'mtext' way of adding the label (it's simpler), which I have used below to make the right label appear the same distance from the axis as the left label (option line = 3). I don't see how to adjust the reading direction of the label to be top-to-bottom with 'mtext', so I guess you'll need the 'text' way of doing it if you want that orientation (although I don't understand the 'usr' positions that define the location). Gabor, do you know how to change the reading direction with 'mtext'? I tried 'srt' and that did not work. library(zoo) set.seed(1) z - zoo(cbind(A = cumsum(rnorm(100)), B = cumsum(rnorm(100, mean = 0.2 par(mai = c(.8, .8, .2, .9)) # Or change '.9' to a larger number for even more room (the units are inches) plot(z[,1], type = l, xlab = X axis label, ylab = colnames(z)[1], lty = 1, lwd = 2) par(new = TRUE) plot(z[,2], type = l, ann = FALSE, yaxt = n, col = blue, lty = 2, lwd = 2) axis(4) legend(x = topleft, bty = n, lty = c(1,2), lwd = c(2,2), col = c(black, blue), legend = paste(colnames(z), c((left y-axis), (right y-axis mtext(colnames(z)[2], 4, line = 3, col = blue) --Dave At 11:42 PM 10/20/2007 +0200, John Theal wrote: I still haven't resolved this problem. However, when I run the plot.zoo example the label appears, it also appears if I enter the commands manually. The problem that persists is that the label has to lie so close to the secondary y axis, that (in my case) it becomes almost indistinguishable from the axis scale labels. If the label is long, then it over-writes some of the scale labeling. I thought it might be do to the way the Quartz window manager handles the figure margins (under Mac OS X), but it looks as though maybe this is not the case. I'm running the same versions of R (2.6.0, unpatched) and zoo (1.4-0) as Gabor. I am using R under Mac OS X. Dave Hewitt wrote: I was curious about the exact same question that John Theal posed - how to get a second y-axis label for a plot of two data series against a common x (in my case, time). I tried two different methods - one in lattice and one in plot. Both times the y-axis on the right side appears but the label does not. Similar to John's comment, it appears that there is not enough room for the label. Gabor mentioned that the plot.zoo examples give a plot like this. When I run that series of examples, #7 appears to be what Gabor was referring to, but even there the label for the right-hand y-axis is missing. Help? Dave Hewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Secondary Y axis title
mtext does not support srt -- use text instead. There is a comment about that in the example although perhaps the wording could be clearer. On 10/20/07, Dave Hewitt [EMAIL PROTECTED] wrote: The controls for the margin sizes, which set the amount of space allocated for the labels, are the 'mai' numbers in the first 'par' call. The fourth number changed to 0.9 or greater should give you more room like you're looking for. You can use the alternative 'mtext' way of adding the label (it's simpler), which I have used below to make the right label appear the same distance from the axis as the left label (option line = 3). I don't see how to adjust the reading direction of the label to be top-to-bottom with 'mtext', so I guess you'll need the 'text' way of doing it if you want that orientation (although I don't understand the 'usr' positions that define the location). Gabor, do you know how to change the reading direction with 'mtext'? I tried 'srt' and that did not work. library(zoo) set.seed(1) z - zoo(cbind(A = cumsum(rnorm(100)), B = cumsum(rnorm(100, mean = 0.2 par(mai = c(.8, .8, .2, .9)) # Or change '.9' to a larger number for even more room (the units are inches) plot(z[,1], type = l, xlab = X axis label, ylab = colnames(z)[1], lty = 1, lwd = 2) par(new = TRUE) plot(z[,2], type = l, ann = FALSE, yaxt = n, col = blue, lty = 2, lwd = 2) axis(4) legend(x = topleft, bty = n, lty = c(1,2), lwd = c(2,2), col = c(black, blue), legend = paste(colnames(z), c((left y-axis), (right y-axis mtext(colnames(z)[2], 4, line = 3, col = blue) --Dave At 11:42 PM 10/20/2007 +0200, John Theal wrote: I still haven't resolved this problem. However, when I run the plot.zoo example the label appears, it also appears if I enter the commands manually. The problem that persists is that the label has to lie so close to the secondary y axis, that (in my case) it becomes almost indistinguishable from the axis scale labels. If the label is long, then it over-writes some of the scale labeling. I thought it might be do to the way the Quartz window manager handles the figure margins (under Mac OS X), but it looks as though maybe this is not the case. I'm running the same versions of R (2.6.0, unpatched) and zoo (1.4-0) as Gabor. I am using R under Mac OS X. Dave Hewitt wrote: I was curious about the exact same question that John Theal posed - how to get a second y-axis label for a plot of two data series against a common x (in my case, time). I tried two different methods - one in lattice and one in plot. Both times the y-axis on the right side appears but the label does not. Similar to John's comment, it appears that there is not enough room for the label. Gabor mentioned that the plot.zoo examples give a plot like this. When I run that series of examples, #7 appears to be what Gabor was referring to, but even there the label for the right-hand y-axis is missing. Help? Dave Hewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.