Re: [R] R forum for only Statistics

2011-04-28 Thread Jeremy Hetzel
Vincy, In addition to the R-help mailing list, other forums for R and statistics that I go to include: Stackoverflow's R tagged questions http://stackoverflow.com/questions/tagged/r StackExchange's Stats site: http://stats.stackexchange.com/ A Google search for R statistics forum shows a few

Re: [R] Speed up code with for() loop

2011-04-28 Thread Jeremy Hetzel
Hans, You could parallelize it with the multicore package. The only other thing I can think of is to use calls to .Internal(). But be vigilant, as this might not be good advice. ?.Internal warns that only true R wizards should even consider using the function. First, an example with

Re: [R] calculations with vectors of unequal length

2011-04-27 Thread Jeremy Hetzel
See ?merge. df.1 - data.frame(year=factor(rep(1:3,3)), level=rep(letters[1:3],3), number=c(11:19)) df.2 - data.frame(year=factor(c(1:5)), number=c(21:25)) df.3 - merge(df.1, df.2, by = year) df.3$new - with(df.3, number.x + number.y) Jeremy On Wednesday, April 27, 2011 7:30:13 AM UTC-4, E

Re: [R] setting options only inside functions

2011-04-27 Thread Jeremy Hetzel
See ?on.exit Jeremy On Wednesday, April 27, 2011 9:16:13 AM UTC-4, Jannis wrote: Dear list members, is it possible to set some options only inside a function so that the original options are restored once the function is finished or aborted due to an error? Until now I do something

Re: [R] Random Relabelling

2011-04-20 Thread Jeremy Hetzel
Kevin, The following follows John's suggestion, but without the loop. It's quick for me. Jeremy Jeremy T. Hetzel Boston University ## Generate sample data n - 4000 rep - 1000 rate - rnorm(n, mean = 15, sd = 2) / 10 # Mortality rates around 15/100k ## Create an empty matrix with

Re: [R] R plots pdf() does not allow spotcolors?

2011-04-13 Thread Jeremy Hetzel
Scribus claims to be able to convert RGB/CMYK colors to spot colors: http://documentation.scribus.net/index.php/Spot_Colors I've never used Scribus, but it's floss. Jeremy __ R-help@r-project.org mailing list

Re: [R] R plots pdf() does not allow spotcolors?

2011-04-13 Thread Jeremy Hetzel
By the way, I had trouble importing PDFs into Scribus 1.3.3. However, Scribus 1.4.0rc3 had no problem opening multi-page PDFs, assuming the appropriate Ghostscript was also installed (I'm on Windows 7 at the moment). So Matthieu might be able to combine all of his figures into a single PDF,

Re: [R] Converting a categorical variable to multiple dichotemousvariables

2011-04-12 Thread Jeremy Hetzel
$eth, unique(simtest$eth), ==) + 0 # Combine simtest.combined - cbind(simtest, simtest.dichotomous) head(simtest.combined) Jeremy Jeremy Hetzel Boston University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Multinomial Logit Model with lots of Dummy Variables

2011-04-10 Thread Jeremy Hetzel
If you are just looking to collapse the dummy variables into two factor variables, the following will work. ## Generate some example data set.seed(1234) n - 100 # Generate outcome outcome - rbinom(n, 3, 0.5) colnames(exposures) - paste(V, seq(1:10), sep = ) #Generate dummy variables for A and B

Re: [R] xyplot, groups and colors

2011-04-08 Thread Jeremy Hetzel
and geom_line colour aesthetics as group g1 + geom_point(aes(colour = group)) + geom_line(aes(colour = group)) Is this what you are after? Jeremy Jeremy Hetzel Boston University [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] Removing not duplicated rows

2011-04-08 Thread Jeremy Hetzel
As I understand it, you are trying to subset the data frame to include only rows with a non-unique id. Try this: x - data.frame(cbind(id=c(1,2,2,2,3,3,4,5,6,6), value=1:10)) id.table - table(x$id) x_new - subset(x, id %in% id.table[id.table 1]) Jeremy

Re: [R] Removing not duplicated rows

2011-04-08 Thread Jeremy Hetzel
Sorry, I left out the names() function in the last step. Try this instead: x - data.frame(cbind(id=c(1,2,2,2,3,3,4,5,6,6), value=1:10)) id.table - table(x$id) x_new - subset(x, id %in% names(id.table[id.table 1])) Jeremy __ R-help@r-project.org