Re: [R] Ceiling to the nearest ten?
Perhaps not the most elegant but 10*ceiling(x/10) usually works for me... Cheers rob *** Want to know about Britain's birds? Try www.bto.org/birdfacts *** Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU Ph: +44 (0)1842 750050 E: [EMAIL PROTECTED] Fx: +44 (0)1842 750030 W: http://www.bto.org "How can anyone be enlightened, when truth is so poorly lit" = > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Lauri Nikkinen > Sent: 14 January 2008 17:18 > To: [EMAIL PROTECTED] > Subject: [R] Ceiling to the nearest ten? > > R-users, > > Is there a function for ceiling to the nearest ten? > > a <- 1:10*4 > a > [1] 4 8 12 16 20 24 28 32 36 40 > > The resulting vector should look like this ("ceiling to the > nearest ten") [1] 10 10 20 20 20 30 30 40 40 40 > > Thanks in advance > Lauri > > __ > 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] things that are difficult/impossible to do in SAS or SPSSbut simple in R
I wonder if those who complain about SAS as a programming environment have discovered SAS/IML which provides a programming environment akin to Matlab which is more than capable (at least for those problems which can be treated with a matrix like approach). As someone who uses both SAS and R - graphical output is so much easier in R, but for handling large 'messy' datasets SAS wins hands down... Cheers Rob *** Want to know about Britain's birds? Try www.bto.org/birdfacts *** Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU Ph: +44 (0)1842 750050 E: [EMAIL PROTECTED] Fx: +44 (0)1842 750030 W: http://www.bto.org "How can anyone be enlightened, when truth is so poorly lit" = > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jeffrey J. Hallman > Sent: 16 January 2008 22:38 > To: [EMAIL PROTECTED] > Subject: Re: [R] things that are difficult/impossible to do > in SAS or SPSSbut simple in R > > SAS has no facilities for date arithmetic and no easy way to > build it yourself. In fact, that's the biggest problem with > SAS: it stinks as a programming environment, so it's always > much more difficult than it should be to do something new. > As soon as you get away from the canned procs and have to > write something of your own, SAS falls down. > > I don't know enough about SPSS to comment. > -- > Jeff > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to plot image() without painting a map (the background)
I've used a similar three-stage approach. Depending on the format of your map (mine came from an ArcView shape file) you may be able to specify col="transparent" for the foreground (ie land) in plot as I did (tip, use border= to get colours for the country borders). This works where alpha channels don't, such as png. Not sure what image you have, but there may be alternatives, for example, I found .Internal(filledcontour()) extremely useful because then I could explicitly set some of the image to "transparent"... Hth rob *** Want to know about Britain's birds? Try www.bto.org/birdfacts *** Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU Ph: +44 (0)1842 750050 E: [EMAIL PROTECTED] Fx: +44 (0)1842 750030 W: http://www.bto.org "How can anyone be enlightened, when truth is so poorly lit" = > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Greg Snow > Sent: 19 February 2008 17:20 > To: Ptit_Bleu; r-help@r-project.org > Subject: Re: [R] how to plot image() without painting a map > (the background) > > The approach that I usually use for things like this is: > > Plot the map to get the aspect ratio and limits correct. > Add the image (obscuring the original map). > Add the map again on top of the image using a light grey color. > > This seems to work fine for me. Another aproach that you may > try (untested) is to use colors with an alpha channel > (transparency) in the call to image, then the background map > may show through. Not all graphics devices support alpha > channels, so test on one that does. > > Hope this helps, > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > [EMAIL PROTECTED] > (801) 408-8111 > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Ptit_Bleu > > Sent: Monday, February 18, 2008 8:59 AM > > To: r-help@r-project.org > > Subject: [R] how to plot image() without painting a map (the > > background) > > > > > > Hello, > > > > I'm trying to plot dayly evolution of the temperature over > France from > > Global Forecast System files ("I'm trying" is the right > > expression...). > > > > akilonlat03 is the temperature for different latitudes and > longitudes > > à 3 o'clock. > > akilonlat06 is the temperature for different latitudes and > longitudes > > à 6 o'clock. > > > > I would like to plot akilonlat03 and then akilonlat06 and > keep the map > > of France in background. > > My script (see below) doesn't work as image "paints" the > background as > > I read somewhere in this forum. > > > > So would have someone a solution to correct my script ? > > Thanks in advance, > > Ptit Bleu. > > > > > > > > > > akilonlat03<-interp(lonlat03$Longitude, lonlat03$Latitude, > > (5/9)*(lonlat03$TMP_200802150300-32)) > > akilonlat06<-interp(lonlat06$Longitude, lonlat06$Latitude, > > (5/9)*(lonlat06$TMP_200802150600-32)) > > > > map('france') > > > > image(akilonlat03, col=cm.colors(100), axes=FALSE, add=TRUE) > > #contour(akilonlat03, col="blue", add=TRUE) image(akilonlat06, > > col=cm.colors(100), axes=FALSE, add=TRUE) #contour(akilonlat06, > > col="blue", add=TRUE) > > > > -- > > View this message in context: > > http://www.nabble.com/how-to-plot-image%28%29-without-painting > > -a-map-%28the-background%29-tp15546906p15546906.html > > Sent from the R help mailing list archive at Nabble.com. > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with gamm errors
Dear All Hopefully someone out there can point out what I am missing! I have a (large, several hundred) dataset of gardens in which over two years the presence/absence of a particular bird species is noted each week. I have good reason to believe there is a difference between the two years in the weekly proportion of gardens and would like to assess this, before going on to look in more detail at particular weeks. There is nothing special about the particular gardens used (though they are not strictly a random sample) and the weekly 'counts' are obviously autocorrelated (with weeks closer together being more similar though the correlation may differ between gardens). Thus (I suspect) a gamm statement such as: > m1=gamm(present~s(week,bs="cc")+s(week,bs="cc",by=y1),random=list(garden=~1) , correlation=corAR1(form=~week|garden),family=binomial,data=count.data2) is required (y1 is year and the others are self explanatory, all variables are in count.data2). This yields the following output > Maximum number of PQL iterations: 20 > iteration 1 > Error in eval(expr, envir, enclos) : object "week" not found Presumably something is not getting passed internally to glmmPQL (see results of traceback()) [large data vector scrolls off screen] 6: eval(expr, envir, enclos) 5: eval(mcall) 4: glmmPQL(y ~ X - 1, random = rand, data = strip.offset(mf), family = family, correlation = correlation, control = control, weights = weights, niter = niterPQL, verbose = verbosePQL) 3: eval(expr, envir, enclos) 2: eval(parse(text = paste("ret$lme<-glmmPQL(", deparse(fixed.formula), ",random=rand,data=strip.offset(mf),family=family,correlation=correlation,co ntrol=control,", "weights=weights,niter=niterPQL,verbose=verbosePQL)", sep = ""))) 1: gamm(present ~ s(week, bs = "cc") + s(week, bs = "cc", by = y1), random = list(garden = ~1), correlation = corAR1(form = ~week | garden), family = binomial, data = count.data2) Question 1: I have followed the example in Simon Wood's excellent GAM book in specifying the form of the correlation term, but have I done this right or do I need extra information to get it to recognise the week variable? Leaving that aside, I altered to the form of correlation to > m1=gamm(present~s(week,bs="cc")+s(week,bs="cc",by=y1),random=list(garden=~1) , correlation=corAR1(form=~1|garden),family=binomial,data=count.data2) (ie removing the week term). This model proceeds - to a point... Maximum number of PQL iterations: 20 iteration 1 iteration 2 iteration 3 iteration 4 iteration 5 iteration 6 Error: attempt to select less than one element Traceback() suggests that the model fits, but that lme can't calculate something? 2: extract.lme.cov2(ret$lme, mf, n.sr + 1) 1: gamm(present ~ s(week, bs = "cc") + s(week, bs = "cc", by = y1), random = list(garden = ~1), correlation = corAR1(form = ~1 | garden), family = binomial, data = count.data2) Question 2: Any hints on what might be causing this? Am I fitting the wrong (or too complicated a model)? Btw if it is relevant I am using mgcv_1.3-19 and R 2.3.1. Many thanks for any hints on where I should start digging Cheers rob *** Want to know about Britain's birds? Try www.bto.org/birdfacts *** Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU Ph: +44 (0)1842 750050 E: [EMAIL PROTECTED] Fx: +44 (0)1842 750030 W: http://www.bto.org eSafe scanned this email for viruses, vandals and malicious content (!) "How can anyone be enlightened, when truth is so poorly lit" = __ 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.