Re: [R] Opposite color in R

2015-07-27 Thread Steve Taylor
I wonder if the hcl colour space is useful? Varying hue while keeping chroma and luminosity constant should give varying colours of perceptually the same "colourness" and brightness. ?hcl pie(rep(1,12),col=hcl((1:12)*30,c=70),border=NA) -Original Message- From: R-help [mailto:r-help-b

[R] valid LRT between MASS::polr and nnet::multinom

2015-07-07 Thread Steve Taylor
Dear R-helpers, Does anyone know if the likelihoods calculated by these two packages are comparable in this way? That is, is this a valid likelihood ratio test? # Reproducable example: library(MASS) library(nnet) data(housing) polr1 = MASS::polr(Sat ~ Infl + Type + Cont, weights=Freq, data=ho

Re: [R] Subset() within function: logical error

2015-06-29 Thread Steve Taylor
Using return() within a for loop makes no sense: only the first one will be returned. How about: alldf.B = subset(alldf, stream=='B') # etc... Also, have a look at unique(alldf$stream) or levels(alldf$stream) if you want to use a for loop on each unique value. cheers, Steve -Original

Re: [R] Call to a function

2015-06-23 Thread Steve Taylor
Note that objects can have more than one class, in which case your == and %in% might not work as expected. Better to use inherits(). cheers, Steve -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Yen Sent: Wednesday, 24 June 2015 11:37a To:

Re: [R] Plotting Confidence Intervals

2015-05-03 Thread Steve Taylor
Have you tried: library(effects) plot(allEffects(ines),ylim=c(460,550)) -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andre Roldao Sent: Saturday, 2 May 2015 2:50p To: r-help@r-project.org Subject: [R] Plotting Confidence Intervals Hi Guys, It's the

Re: [R] cbind question, please

2015-04-24 Thread Steve Taylor
This works for me... get0 = function(x) get(x,pos=1) sapply(big.char, get0) The extra step seems necessary because without it, get() gets base::cat() instead of cat. cheers, Steve -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent:

Re: [R] regex find anything which is not a number

2015-03-12 Thread Steve Taylor
How about letting a standard function decide which are numbers: which(!is.na(suppressWarnings(as.numeric(myvector Also works with numbers in scientific notation and (presumably) different decimal characters, e.g. comma if that's what the locale uses. -Original Message- From: R-help

Re: [R] Using dates in R

2015-03-04 Thread Steve Taylor
> today <- as.Date("2015-03-04") # default format Better is: today <- Sys.Date() S -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Thursday, 5 March 2015 7:47a To: Brian Hamel Cc: r-help@r-project.org Subject: Re: [R] Using dates

Re: [R] the less-than-minus gotcha

2015-02-02 Thread Steve Taylor
= `<-` # this is going in my .Rprofile x := 1 -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Tuesday, 3 February 2015 3:54p To: Steve Taylor; r-h...@stat.math.ethz.ch Subject: Re: [R] the less-than-minus gotcha I did not start out liking <-, but I

Re: [R] the less-than-minus gotcha

2015-02-02 Thread Steve Taylor
I disagree. Assignments in my code are all lines that look like this: variable = expression They are easy to find and easy to read. -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, 3 February 2015 3:36p To: Steve Taylor Cc: r-h...@stat.math.ethz.ch Subject

Re: [R] the less-than-minus gotcha

2015-02-02 Thread Steve Taylor
Responding to several messages in this thread... > > All the more reason to use = instead of <- > Definitely not! Martin and Rolf are right, it's not a reason for that; I wrote that quickly without thinking it through. An "=" user might be more likely to fall for the gotcha, if not spacing the

Re: [R] the less-than-minus gotcha

2015-02-01 Thread Steve Taylor
All the more reason to use = instead of <- -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker Sent: Monday, 2 February 2015 2:07p To: r-h...@stat.math.ethz.ch Subject: Re: [R] the less-than-minus gotcha Mike Miller gmail.com> writes: > > I've

[R] Webdings font on pdf device

2014-11-03 Thread Steve Taylor
Dear R-helpers Has anyone successfully used the Webdings font on a pdf or postscript device? I'm tearing my hair out trying to figure out how to make it work. # It works on a png() device: windowsFonts(Webdings = windowsFont("Webdings")) png('Webdings.png', family = 'Webdings') plot(-3:3,-3:3,t

Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-16 Thread Steve Taylor
> From: Duncan Murdoch... > Don't use a bitmap format (png). I disagree. Each vector format comes with its own problems. > Don't produce your graph in one format (screen display), then convert to > another (png). Open the device in the format you want for the final file. Agreed. > Use a vect

Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-16 Thread Steve Taylor
Unfortunately the win.metafile() device does not support semi-transparent colours, which I like using. In my experience, the best way to get R graphics into Word is to use compressed high-resolution tiff, like this: word.tif = function(filename="Word_Figure_%03d.tif", zoom=4, width=17, height=

Re: [R] Matrix Multiplication using R.

2013-08-15 Thread Steve Taylor
The function crossprod() might be useful? crossprod(X) is a more efficient way of producing t(X) %*% X -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Praveen Surendran Sent: Thursday, 15 August 2013 10:30p To: r-help@r-project.

Re: [R] How can I create a data.table with 1000 variables (Var1:Var1000)

2013-08-15 Thread Steve Taylor
How about this: df1000cols = setNames(as.data.frame(matrix(numeric(0),ncol=1000)),paste0("V",1:1000)) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Pooya Lalehzari Sent: Friday, 16 August 2013 8:27a To: Bert Gunter Cc: r-help@r

Re: [R] Boundaries of consecutive integers

2013-05-26 Thread Steve Taylor
How's this: big.gap = diff(test) > 1 cbind(test[c(TRUE, big.gap)], test[c(big.gap, TRUE)]) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lizzy Wilbanks Sent: Tuesday, 14 May 2013 1:18p To: r-help@r-project.org Subject: [R] Bound

[R] using a personal template for new R scripts

2013-02-28 Thread Steve Taylor
Does anyone know if there's an easy facility to create and specify a template file to be used for new R scripts? I found myself creating this function which works well (in RStudio on Windows). newR = function(filename=tempfile(tmpdir='.',fileext='.R'), open=TRUE) { template = paste(Sys.getenv(

Re: [R] Any R package to do the harmonic analysis

2013-02-19 Thread Steve Taylor
Have a look thru the Time Series task view... http://cran.r-project.org/web/views/TimeSeries.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Janesh Devkota Sent: Wednesday, 20 February 2013 5:52a To: r-help@r-project.org Subj

Re: [R] sem package, suppress warnings

2013-01-20 Thread Steve Taylor
Have you tried suppressWarnings(sem(mod, S = as.matrix(dataset), N = 1000, maxiter = 1, warn = FALSE)) > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Dustin Fife > Sent: Saturday, 19 January 2013 5:32a > To: r-help > Su

Re: [R] how to use "..."

2013-01-20 Thread Steve Taylor
> On 13-01-20 2:28 PM, Steve Taylor wrote: > >> From: Duncan Murdoch > >> Maybe we just need a manual on how to use the existing help system. But > >> I suspect people who won't read the existing manuals won't read that > >> one, either. > >

Re: [R] how to use "..."

2013-01-20 Thread Steve Taylor
> From: Duncan Murdoch > Maybe we just need a manual on how to use the existing help system. But > I suspect people who won't read the existing manuals won't read that > one, either. Duncan, I assume you're being facetious. Every R user soon learns to use help() and help.search() or their equiv

Re: [R] how to use "..."

2013-01-17 Thread Steve Taylor
Here's a link (on my local CRAN)... http://cran.stat.auckland.ac.nz/doc/manuals/r-release/R-intro.html#The-three-dots-argument -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Friday, 18 January 2013 4:54a To: iva

Re: [R] how to use "..."

2013-01-17 Thread Steve Taylor
The ellipsis object is not listed in the base help pages! help(`+`) # this works - help on arithmetic operators help("+") # also works help(`...`) # fails with Error: '...' used in an incorrect context help("...") # fails also with No documentation for '...' in specified packages and libraries: y

Re: [R] Setting Number of Displayed Digits

2012-08-09 Thread Steve Taylor
Have you tried: options(digits=9) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rich Shepard Sent: Wednesday, 8 August 2012 5:51a To: r-help@r-project.org Subject: [R] Setting Number of Displayed Digits Some chemicals have co

Re: [R] Package 'nlme' linear mixed effects model error "unexpected symbol"

2012-07-26 Thread Steve Taylor
This will work: model2007 <- You can't start an identifier with a digit. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of msherwood Sent: Thursday, 26 July 2012 9:44a To: r-help@r-project.org Subject: [R] Package 'nlme' linear mixed

Re: [R] Boxplot with Log10 and base-exponent axis

2012-06-24 Thread Steve Taylor
This (and William's solution) is so good, I must ask: Is there a good reason why this is not the default functionality in the graphics package? The default displays the number 1 as 1+e00 which is hideous! -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-

Re: [R] glm(weights) and standard errors

2012-05-28 Thread Steve Taylor
him about the survey package. -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Friday, 25 May 2012 9:37p To: ilai Cc: Steve Taylor; r-help@r-project.org Subject: Re: [R] glm(weights) and standard errors Weighting can be confusing: There are three standard forms of

Re: [R] How to open a file with a name changed?

2012-05-24 Thread Steve Taylor
You probably want to use paste or paste0 instead of cat. paste0(cit,dia,extension) Also, this might work: tail(dir("C:/Bonos/",patt="csv$"),1) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Minerva Mora Sent: Friday, 25 May 2012

Re: [R] glm(weights) and standard errors

2012-05-23 Thread Steve Taylor
2 3:37p To: Steve Taylor Cc: r-help@r-project.org Subject: Re: [R] glm(weights) and standard errors On May 21, 2012, at 10:58 PM, Steve Taylor wrote: > Is there a way to tell glm() that rows in the data represent a certain > number of observations other than one? Perhaps even fractional >

[R] glm(weights) and standard errors

2012-05-21 Thread Steve Taylor
/sim.3177 Other suggestions would be most welcome. ___ Steve Taylor Biostatistician Pacific Islands Families Study Faculty of Health and Environmental Sciences AUT University __ R-help@r-project.org mailing list

Re: [R] Export a plot/figure to excel or word?

2012-03-14 Thread Steve Taylor
]ti[f]+$", filename,ignore.case=TRUE) filename = paste(filename,"tif",sep='.') tiff(filename=filename, res=96*zoom, width=width, height=height, units='cm', pointsize=pointsize, compression="lzw", ...) } Note the zoom, which creates high quality imag

Re: [R] Export a plot/figure to excel or word?

2012-03-14 Thread Steve Taylor
I have found the TIF format (with lossless compression) most suitable for inclusion in Word documents. Here's my function for producing a tif plot... word.tif <- function(filename="Word_Figure.tif", zoom=5, res=96*zoom, width=17, height=10, pointsize=10, bg='white') { if (!filename %like% "

Re: [R] Reading spss files into R - warnings

2012-02-26 Thread Steve Taylor
suppressWarnings() will get rid of them for you. Note that in R a factor cannot have duplicate levels. Compare the results with use.value.labels turned on or off, to see which you prefer. I also get the "unknown type" warnings, but I ignore them as my data seems to arrive into R intact. Hope

Re: [R] Why does length("") == 1?

2011-11-10 Thread Steve Taylor
"" is a character vector with one element in it. ?nchar ?length >>> From: Worik R To:r-help Date: 11/Nov/2011 1:21p Subject: [R] Why does length("") == 1? It seems obvious to me that the empty string "" is length 0. cheers Worik [[alternative HTML version deleted]] __

Re: [R] Urgent help needed for honours project - breaks between races in one year

2011-10-06 Thread Steve Taylor
This might help: if x is a vector of the race days then max(diff(sort(x))) finds the biggest gap between consecutive values. >>> From: "Jana.K" To: Date: 7/Oct/2011 4:47a Subject: [R] Urgent help needed for honours project - breaks between races in one year Hi to anyone who is willing to he

Re: [R] Storing and managing custom R functions for re-use

2011-07-12 Thread Steve Taylor
My solution to the clutter problem is this: at start-up time, create a list of functions, attach the list and then delete the list. I haven't delved into making packages yet. if (any(search()=="MyFunctions")) detach(MyFunctions) MyFunctions <- list() MyFunctions$ "%like%" <- function(x,y) { s

Re: [R] Export R dataframes to excel

2011-03-01 Thread Steve Taylor
You can copy it with the following function and then paste into Excel... copy = function (df, buffer.kb=256) { write.table(df, file=paste("clipboard-",buffer.kb,sep=""), sep="\t", na='', quote=FALSE, row.names=FALSE) } >>> From: maxsilva To: Date: 2/Mar/2011 8:50a Subject: [R] Export

Re: [R] Change a value in a matrix randomly

2010-11-09 Thread Steve Taylor
A=matrix(0,nr=3,nc=4) A[sample(prod(dim(A)),1)]=1 >>> From: "Barroso, Judit" To:"r-help@r-project.org" Date: 10/Nov/2010 11:12a Subject: [R] Change a value in a matrix randomly I have a matrix of ceros, for example: 0 0 0 0 0 0 0

Re: [R] Trouble accessing cov function from stats library

2010-10-11 Thread Steve Taylor
Note that R is case sensitive, so cov and Cov are different. >>> From: "Barth B. Riley" To:"r-help@r-project.org" Date: 12/Oct/2010 3:31a Subject: [R] Trouble accessing cov function from stats library Dear all I am trying to use the cov function in the stats library. I have no problem using t

Re: [R] Line Type Specification: lty="" but lty=""?

2010-10-10 Thread Steve Taylor
You might have to use segments() to place the line segments precisely. ?segments >>> From: Henrik Bengtsson To:Peter Alspach CC:r-help Date: 11/Oct/2010 1:23p Subject: Re: [R] Line Type Specification: lty="" but lty=""? Thanks both, but unfortunately not. Here is a better illustration on w

Re: [R] weird to me interaction between time() and %%, %/%

2010-08-31 Thread Steve Taylor
€” — — — — — — — — Steve Taylor Biostatistician Pacific Islands Families Study Faculty of Health and Environmental Sciences Auckland University of Technology — — — — — — — — — — — — — — — — — [[alternative HTML version deleted

Re: [R] logos and goodies

2010-08-01 Thread Steve Taylor
Would this be suitable? http://en.wikipedia.org/wiki/File:Rlogo.png [[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-projec

Re: [R] do the standard R analysis functions handle spatial "grid" data?

2010-07-12 Thread Steve Taylor
Have a look at the Task View for spatial data... http://cran.ms.unimelb.edu.au/web/views/Spatial.html >>> From: "chris howden" To:, Date: 13/Jul/2010 2:01p Subject: [R] do the standard R analysis functions handle spatial "grid" data? Hi everyone, I'm doing a resource function analysis with r

Re: [R] findInterval and data resolution

2010-07-12 Thread Steve Taylor
How about this: these = which(vec2 < x1[1] | vec2 > x1[2]) vec2[these] # Or using logical indexation directly: vec2[vec2 < x1[1] | vec2 > x1[2]] >>> From: Bryan Hanson To:R Help Date: 13/Jul/2010 9:28a Subject: [R] findInterval and data resolution Hello Wise Ones... I need a clever way aroun

Re: [R] how to efficiently compute set unique?

2010-06-21 Thread Steve Taylor
The original question was about a matrix, not a vector and this is much slower: x <- sample(10, size=13584763, replace=T) dim(x) <- c(13584763, 1) system.time(unique(x)) So the solution would be: unique(as.vector(x)) >>> From: Duncan Murdoch To:G FANG CC: Date: 22/Jun/2010 1:20p Subjec

Re: [R] unexpected result from format(x, digits)

2010-04-28 Thread Steve Taylor
Ted wrote: > In the second, 0.08953 rounds (to 2 significant digits) to 0.090, > which can be printed without further loss of precision as 0.09 > while giving the other numbers 2 significant digits. I guess I'm disagreeing with the idea of dropping the trailing zero. It should be retained, since

Re: [R] unexpected result from format(x, digits)

2010-04-28 Thread Steve Taylor
0.08953 to two significant figures is "0.090" not "0.09". Thanks, I'll sprintf instead. From: Duncan Murdoch To:Steve Taylor CC: Date: 29/Apr/2010 9:53a Subject: Re: [R] unexpected result from format(x, digits) On 28/04/2010 5:45 PM, Steve Taylor wrote: > >

[R] unexpected result from format(x, digits)

2010-04-28 Thread Steve Taylor
Is this a bug somewhere? The format function, using a specific number of digits, doesn't give sensible results: R> set.seed(2);print(x<-rexp(5)) [1] 1.86535 0.40475 0.14665 1.73071 0.08953 R> format(x,digits=1) [1] "1.87" "0.40" "0.15" "1.73" "0.09" R> format(x,digits=2) [1] "1.87" "0.40" "0.

Re: [R] Tinn-R

2010-04-25 Thread Steve Taylor
Thanks Ben. Putting that code into my .Rprofile file helped; then it gets executed whenever R starts up. >>> From: Ben Bolker To: Date: 20/Apr/2010 10:05a Subject: Re: [R] Tinn-R Robert Ruser gmail.com> writes: > I want to use the free distribution of R (R REvolution 3.2) [this is a littl

Re: [R] can I rotate a matrix

2010-03-18 Thread Steve Taylor
How about this for a more generalised matrix rotation function (works with 1-column and 1-row matrices too) ... rotate = function(mat) t(mat[nrow(mat):1,,drop=FALSE]) >>> From: To: Date: 19/Mar/2010 10:15a Subject: Re: [R] can I rotate a matrix > Now that *is* neat! Thanks! Unfortunately, i

Re: [R] Running script with double-click

2010-03-04 Thread Steve Taylor
You can create a right-mouse menu command to run an R program as follows (although the details may be different for different versions of Windows). In Windows Explorer: 1. Tools / Folder Options / File Types 2. find the extension for R files and push Advanced 3. add a new action called "Run" w

Re: [R] First. Last. Data row selection

2010-02-23 Thread Steve Taylor
Ah, those can be used to index the rows: # create a new column with TRUE for the first row of each Vin: ladata2$First <- !duplicated(ladata2$Vin) # view only those rows: ladata2[ladata2$First,] >>> From: wookie1976 To: Date: 24/Feb/2010 2:53 p.m. Subject: Re: [R] First. Last. Data row selec

Re: [R] First. Last. Data row selection

2010-02-23 Thread Steve Taylor
These tell you the first and last row for each plate: !duplicated(df$plate) !duplicated(df$plate, fromLast=TRUE) Hope that helps. Steve >>> From: wookie1976 To: Date: 24/Feb/2010 6:54 a.m. Subject: [R] First. Last. Data row selection I am in the process of switching from SAS over to R.

Re: [R] using step() with package geepack

2010-02-15 Thread Steve Taylor
Is anyone else using the 'geepack' package? >>> From: "Steve Taylor" To: Date: 11/Feb/2010 11:28 a.m. Subject: [R] using step() with package geepack I'm using the package geepack to fit GEE models. Does anyone know of methods for add1 and drop1 for a 'gee

Re: [R] Selective load of .First() function just for Rgui.exe

2010-02-15 Thread Steve Taylor
Here's another way to have different behaviour only for interactive sessions: if (interactive()) { winMenuAdd(menuname, NULL, NULL) # etc. } >>> From: Duncan Murdoch To: CC: Date: 13/Feb/2010 6:15 a.m. Subject: Re: [R] Selective load of .First() function just for Rgui.exe On 12/02/2010 11:

[R] using step() with package geepack

2010-02-10 Thread Steve Taylor
I'm using the package geepack to fit GEE models. Does anyone know of methods for add1 and drop1 for a 'geeglm' model object, or perhaps a method for extractAIC based on the QIC of Pan 2001? I see there has been some mention of this on R-help a few years ago (RSiteSearch("QIC")). The package

[R] Polygons in Windows metafile

2010-01-26 Thread Steve Taylor
Hi all, I'm producing some pie charts (Yes I know!) and plotting them into a Windows metafile. This is for insertion into a Word document. The circles come out rather jagged when you zoom in on them, the cause of which I have perhaps narrowed down to the way polygon() works in the metafile d

Re: [R] a question about deleting rows

2010-01-13 Thread Steve Taylor
yourdataframe = subset(yourdataframe, !(n2==0 & n3==0 & n4==0 & n5==0)) >>> From: karena To: Date: 14/Jan/2010 12:24 p.m. Subject: [R] a question about deleting rows I have a file like this: idn1n2 n3 n4 n5 n6 1 3 47 8 102 2 4 12 4

Re: [R] Drop last numeral

2010-01-12 Thread Steve Taylor
Try this: substr(Data,1,nchar(Data)-1) Steve >>> From: LCOG1 To: Date: 13/Jan/2010 9:15 a.m. Subject: [R] Drop last numeral Hello all, Frustrated and i know you can help I need to drop the last numeral of each of my values in my data set. So for the following i have tried the ?substri

Re: [R] how to import data from excel to R

2009-12-17 Thread Steve Taylor
Or copy a rectangle of data in Excel, then grab it from the clipboard in R as follows: my.data <- read.table("clipboard",head=TRUE,sep='\t') cheers, Steve [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https: