[R] Help vectorising a function

2005-07-25 Thread hadley wickham
M - function(m, s, init = 0) { A - nrow(m); T - ncol(m) M - matrix(init, nrow = A, ncol = T) for(a in 1:(A-1)) { M[a+1, 2:T] - (s[a] * (M[a, ] + m[a, ]))[1:(T-1)] } M } This is from a mark-recapture study where M is an estimate of the

Re: [R] crosstab for n-way contingency tables

2005-08-30 Thread hadley wickham
Hi Isotta, You can do this with the reshape package (available from CRAN). eg install.packages(reshape) library(reshape) data(singer, package=lattice) singer$type - c(drammatic, spinto, lirico-spinto, lirico, leggero)[sample(1:5, 235, replace=T)] singer$school - c(german, italian, french,

[R] Displaying RProf output

2005-09-04 Thread hadley wickham
Hi, I've been experimenting with a new way of displaying the output from RProf, to make it easier to optimise your functions. I've included an example below. I'd love to get your feedback on how easy you think this graphic is to read, and on ways that it could be improved.

[R] Lists as a column in data.frame

2005-09-16 Thread hadley wickham
A data frame is a list of vectors of the same length. A list is a vector. So is it acceptable to use a list as a column of a data frame? I'd like to be able to take advantage of all the nice features of data frames (esp. subsetting) while storing more complicated objects. An example of this

Re: [R] xyplot and abline

2005-09-17 Thread hadley wickham
I wonderif there is a simple way to draw a regression line in the xyplot: Try: xyplot(y ~ x| age.cut, xlab=x, ylab=y, type=c(p,r)) Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Neat way of using R for pivoting?

2005-09-20 Thread hadley wickham
Hi Keith, You might want to check out my reshape package (http://had.co.nz/reshape/) which is very much pivot table inspired. I doesn't produce graphics yet, but the output is very amenable to being fed into existing R graphics function (especially lattice graphics). Hadley

[R] [R-pkgs] Reshape package: new version 0.5

2005-09-23 Thread hadley wickham
Reshape version 0.5 === Reshape is an R package for flexibly restructuring and aggregating data. It's very much pivot table inspired, and it (hopefully) makes it very easy to view your data the way you want. You can find out more at http://had.co.nz/reshape The big news in this

[R] Grid: constructing a gTree with grobs that use named viewports from a vpTree

2005-10-03 Thread hadley wickham
I'm trying to create a layout with named viewports that I can use for other functions. I create the viewport tree that I want, and a list of grobs with the viewports describing where they should go. library(grid) vp - vpTree( viewport(layout=grid.layout(2,2), name=layout),

Re: [R] Grid: constructing a gTree with grobs that use named viewports from a vpTree

2005-10-03 Thread hadley wickham
But I get: Error in downViewport.vpPath(vp, strict = TRUE, recording = FALSE) : Viewport 'tl' was not found presumably because no equivalent of the upViewport(1) command is used. What should I be doing here? I've solved my own problem - I need to use childrenvp instead and

Re: [R] The R Graph Gallery {was boxplot statistics}

2005-10-07 Thread hadley wickham
I also think there should be a on CRAN website a list of R websites. And in a perfect world one of the search engines scope would get extended to search them all. It's quite possible to set up your own: have a look at http://rollyo.com/ Hadley __

[R] Getting ... as an unevaluated list

2005-10-13 Thread hadley wickham
Hi, I'm trying to get ...as a list of unevaluated arguments, ie. substitute(list(...)) gives me an unevaluated list of the arguments, but I want a list of the unevaluated arguments. My attempts so far: (function(...) substitute(...))(a=1, b=a) # Only returns first (function(...)

Re: [R] Getting ... as an unevaluated list

2005-10-13 Thread hadley wickham
Perfect! Thanks Peter and Gabor. Hadley On 13 Oct 2005 19:59:49 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] writes: Try this: cl - as.list(match.call()) or match.call(expand.dots=FALSE)$... On 10/13/05, hadley wickham [EMAIL PROTECTED

Re: [R] Fitting a distribution to peaks in histogram

2006-07-19 Thread hadley wickham
I would like to fit a distribution to each of the peaks in a histogram, such as this: http://photos1.blogger.com/blogger/7029/2724/1600/DU145-Bax3-Bcl-xL.png As a first shot, I'd try fitting a mixture of gamma distributions (say 3), plus a constant term for the highest bin. You could do this

Re: [R] Fitting a distribution to peaks in histogram

2006-07-19 Thread hadley wickham
Can you be a bit more excact? I a biologist and relatively new to R In that case, I would _strongly_ advise that you get advice from a local statistician. I am measureing the amount of DNA in cells, and I need to know the percentage of cells in a part of the cell cycle; that the percentage

Re: [R] Fitting a distribution to peaks in histogram

2006-07-20 Thread hadley wickham
I am afraid that, by comparison, I am the local statistican. I am also the local R-guru, and neither is saying much - so please bear with me. Do you know of some functions (built in hopefully) that I can try? I'm a bit leery of offering advice without really sitting down and discussing your

Re: [R] dotchart with log scale?

2006-07-20 Thread hadley wickham
I would like to draw a dot chart on a log scale. What is the syntax for this? A barchart may use log=x, but trying this with dotchart() leads to an error message. You can do this easily with ggplot: install.packages(ggplot) library(ggplot) qplot(mpg, factor(cyl), data=mtcars, log=x)

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-26 Thread hadley wickham
And if lattice is ok then try this: library(lattice) xyplot(Consumption ~ Quarter, group = Year, data, type = o) Or you can use ggplot: install.packages(ggplot) library(ggplot) qplot(Quarter, Consumption, data=data,type=c(point,line), id=data$Year) Unfortunately this has uncovered a couple

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-26 Thread hadley wickham
I would like to make a question regarding the use of a grey background (by ggplot in this case, but also in other settings - I seem to remember a relevant lattice discussion). It seems that it is generally discouraged by journals. I guess one practical reason is that it makes photocopying

Re: [R] PCA with not non-negative definite covariance

2006-07-26 Thread hadley wickham
I suppose that another option could be just to use classical multi-dimensional scaling. By my understanding this is (if based on Euclidian measure) completely analogous to PCA, and because it's based explicitly on distances, I could easily exclude the variables with NA's on a pairwise basis

[R] Great R documentation

2006-07-31 Thread hadley wickham
Dear all, I'm trying to improve the documentation I provide my R packages, and to that end I'd like to find out what you think is great R documentation. I'm particularly interested in function documentation, but great vignettes, websites or book are also of interest. What is your favourite bit

Re: [R] Overlay Boxplot with scatter plot

2006-08-01 Thread hadley wickham
This is very easy to do with ggplot: # you need to get the development version from http://had.co.nz/ggplot: install.packages(ggplot, dep=TRUE, repos=http://www.ggobi.org/r/;) library(ggplot) qplot(a, factor(b), type=c(boxplot,point)) qplot(factor(b), a, type=c(boxplot,point)) Regards, Hadley

Re: [R] ggplot facet label font size

2006-08-03 Thread hadley wickham
Hi Sam, How do I change the font size in the facet labels along the edges of the plot? Unfortunately, you can't currently change the size of those fonts. However, it is on my todo list (as well as completely custom strip functions) and should be available in the near future. One thing you

[R] [R-pkgs] Reshape package: new version 0.7

2006-08-06 Thread hadley wickham
Reshape 0.7 === Reshape is an R package for flexibly restructuring and aggregating data. It is inspired by Excel's pivot tables, and it makes it very easy to view your data the way you want. The reshape package (along with ggplot) received the John Chambers Award for Statistical

Re: [R] Plotting logarithmic and semiloarithmic charts.

2006-08-07 Thread hadley wickham
Can anyone help me to find functions like LOGLOG and SEMILOG in Matlab. I am sure that they are out there. Thanks in advance plot(., log=y) plot(., log=x) plot(., log=xy) or install.packages(ggplot) library(ggplot) qplot(., log=y) qplot(., log=x) qplot(.,

Re: [R] More Plots

2006-08-08 Thread hadley wickham
How can we plot two graphs ex. lets say correlation ratio in the same window? I mean in the window I have : 1. Graph of correlation having X Y axes 2. Graph of ratio having A B axes one above the other. Why do you want to do this? It is not a good idea unless you are trying to

Re: [R] How to draw the decision boundaries for LDA and Rpart object

2006-08-09 Thread hadley wickham
Could you please tell me how to draw the decision boundaries in a scatterplot of the original data for a LDA or Rpart object. For example: library(rpart) fit.rpart - rpart(as.factor(group.id)~., data=data.frame(Data) ) You might want to have a look a classifly

Re: [R] proc standardize data frame x and y

2006-08-13 Thread hadley wickham
1) Can someone recommend an equivalent to SAS PROC Standardize in R? I am in need to frequently standardize a data frame, with z-scores, or squash to 0-1 scale - is there a slick function or package someone can recommend? You could try rescaler in the reshape package. It currently supports

Re: [R] split a y-axis to show data on different scales

2006-08-13 Thread hadley wickham
How do I split a y-axis to plot data on different scales? The short answer: you shouldn't. The whole point of plotting the data is so that you can compare them visually on the same scale. As soon as you split the scales you can no longer do this, and you effectively have two separate graphs.

Re: [R] Plots Without Displaying

2006-08-17 Thread hadley wickham
Yes, you can do that for lattice-based plots. The functions in the lattice package produce objects of class trellis which can be stored in a list and processed or updated at a later time: Or for ggplot based plots: install.packages(ggplot) library(ggplot) plotList - list(length=3)

Re: [R] split a y-axis to show data on different scales

2006-08-19 Thread hadley wickham
This is an interesting visual interpretation issue: it may be possible to shade the y-axis (which his thick like the top bars in Lattice plots), or shade the main graphing area from dark to light (or two shades, for two scales) to give a visual idea about the density or stretch of the

Re: [R] split a y-axis to show data on different scales

2006-08-19 Thread hadley wickham
Spencer Graves: but I believe there are times when scale breaks are appropriate, but the display should make this nonstandard transition very clear; ... in which case you are close to having two graphs sharing an x-axis and therefore saving on ink (yay!). If your main concern is saving

Re: [R] multivariate analysis by using lme

2006-08-21 Thread hadley wickham
Only after doing the best I could with univariate modeling would I then consider multivariate modeling. And then I'd want to think very carefully about whether the multivariate model(s) under consideration seemed consistent with the univariate results -- and what else they might tell me

Re: [R] Successive subsets from a vector?

2006-08-22 Thread hadley wickham
The loop method took 195 secs. Just assigning to an answer of the correct length reduced this to 5 secs. e.g. use ADDRESSES - character(length(VECTOR)-4) Moral: don't grow vectors repeatedly. Other languages (eg. Java) grow the size of the vector independently of the number of

Re: [R] lattice and several groups

2006-08-29 Thread hadley wickham
I would like to use the lattice library to show several groups on the same graph. Here's my example : ## the data f1 - factor(c(mod1,mod2,mod3),levels=c(mod1,mod2,mod3)) f1 - rep(f1,3) f2 - factor(rep(c(g1,g2,g3),each=3),levels=c(g1,g2,g3)) df - data.frame(val=c(4,3,2,5,4,3,6,5,4),

Re: [R] lattice and several groups

2006-08-30 Thread hadley wickham
In fact, my problem is to fit the data for every level of the f2 factor, showing the levels of the f1 factor and that for several surveys . Here's an example closer to my actual data : Then maybe you want: qplot(x, y, . ~ surveys, data=df, type=line, colour=f1, id=f2, size=f2) (which doesn't

[R] Weighed 2D kernel density estimator

2006-08-31 Thread hadley wickham
Is there a function/package that performs weighted 2D density estimates? I haven't found anything searching with those keywords, but perhaps there is a more general algorithm that I should be looking for. Any hints appreciated. Thanks, Hadley __

Re: [R] histograms

2006-09-01 Thread hadley wickham
Your data seems to have come through messed up but lets assume you have a data frame with one column per tumor. The convert your data to stacked form and call histogram: DF - data.frame(T1 = 1:10, T2 = 6:15) library(lattice) histogram(~ values | ind, stack(DF)) Or with ggplot and reshape:

Re: [R] Lattice plot with fitted curves

2006-09-01 Thread hadley wickham
I have some data which consists of time series for a number of sites. It appears that there is not much autocorrelation in the data and I have fitted a cubic for each site using lm. I would like to obtain a lattice plot with one panel for each site and showing the original data, and the

Re: [R] How can I fit the secondary y axis legend on my graph?

2006-09-03 Thread hadley wickham
Having a bit of trouble with plotting two y variables on the same graph. I cannot manage to get the secondary y axis label on to the right of the axis - it gets plotted beyond the graphic window I assume?! The way I constructed the graph is thus: Chris, I would strongly suggest you find a

Re: [R] Sweave and the [ function

2006-09-04 Thread hadley wickham
= str(women) women$height women[,1] [(women,1) @ to show the equivalence of three methods of extracting an element from a data.frame. However Sweave returns the last of these as women[1] in the S input chunk How can I force it not to do this and return [(women,1) I don't think

Re: [R] colorRamp

2006-09-05 Thread hadley wickham
I am using colorRamp in the following way. I am *sure* there is a better way to do this, so if you'd be so kind to show me the true R way: Another possibility is to use map_colour_gradient from ggplot, which takes care of most of that for you (although it doesn't use colorRamp, that could be

Re: [R] histogram in the background?

2006-09-06 Thread hadley wickham
I intend to draw a plot of y against x. In the background of this graph I wish to creat a histogram of the horizontal variable x. Does any expert know how to produce such a plot? When constructing such a plot, you need to be careful that you don't end up constructing a pretty picture instead

Re: [R] graphics - joining repeated measures with a line

2006-09-07 Thread hadley wickham
I would like to join repeated measures for patients across two visits using a line. The program below uses symbols to represent each patient. Basically, I would like to join each pair of symbols. This is easy in ggplot: install.packages(ggplot) library(ggplot) qplot(visit, var, id=patient,

Re: [R] rename cols

2006-09-12 Thread hadley wickham
For a newcomer who wants to rename variable fksm and klmk in a dataframe of with 439 variables there is not easy and intuitive solution. That person has to spend a lot of time listing columns and counting columns or doing string searches or using brackets within brackets within brackets to

Re: [R] Transformation of a data frame

2006-09-13 Thread hadley wickham
one approach is to use reshape(), e.g., # suppose that 'dat' is your data.frame, then res - reshape(dat, direction = wide, idvar = Q, timevar = S) res[is.na(res)] - 0 res You can also use the reshape package: library(reshape) datm - melt(dat, id=1:2) cast(datm, Q ~ S) See the introduction

Re: [R] using table in R

2006-09-17 Thread hadley wickham
This is the way to get the frequencies. But what I want is to store the elements in one vector and their frequencies in another vector. My problem is that when I call table to return the frequency table, I do not know how to extract these two vectors. I tried table(...)$dinnames and it did

Re: [R] Calculating mean together with split

2006-09-20 Thread hadley wickham
It contains about 19000 entries and the structure looks like this: NoPlants sim run year DensPlants 16 lng_cs99_renosterbos 140.00192 . . . it has 43 different entries for sim and year goes from 1 to 100, and run from 1 to 5. I would like to

Re: [R] Calculating mean together with split

2006-09-20 Thread hadley wickham
# Then try one of these: cast(dfm, year ~ sim) cast(dfm, year + sim ~ . ) cast(dfm, year ~ sim, margins=TRUE) Oops that should be: dfm - rename(df, c(DensPlants = value)) cast(dfm, year ~ sim, mean) cast(dfm, year + sim ~ . , mean) cast(dfm, year ~ sim, mean, margins=TRUE) (Thanks for

Re: [R] Compiling a contingency table of counts by case

2006-09-22 Thread hadley wickham
I have asked a similar question before but this time the problem is somewhat more involved. I have the following data: case;name;x 1;Joe;1 1;Mike;1 1;Zoe;1 2;Joe;1 2;Mike;0 2;Zoe;1 2;John;1 3;Mike;1 3;Zoe;0 3;Karl;0 I would like to count the number of case in which any two name

Re: [R] Compiling a contingency table of counts by case

2006-09-22 Thread hadley wickham
what's different from: with(dat, tapply(x, list(name,case), sum)) 1 2 3 Joe 1 1 NA John NA 1 NA Karl NA NA 0 Mike 1 0 1 and how to deal with this table ? Well, the syntax is easier (once you have the data in the correct, molten, form), and more flexible for other

Re: [R] Evaluation of defaults in functions

2006-09-28 Thread hadley wickham
And, to answer the specific question: Yes, R has lazy evaluation, everywhere. Arguments are always evaluated if and when they are needed. But doesn't R has a rather limited force of lazy evaluation? - you have no control over it, apart from that arguments are evaluated lazily. This rather

Re: [R] Evaluation of defaults in functions

2006-09-29 Thread hadley wickham
But doesn't R has a rather limited force of lazy evaluation? - you have no control over it, apart from that arguments are evaluated lazily. This rather limited compared to other languages (no lazy lists etc) You do have more control than that. You can't put a promise in a list, but

Re: [R] Evaluation of defaults in functions

2006-09-29 Thread hadley wickham
There are not all that many other languages that use lazy evaluation. Those that do are for the most part pure or nearly pure functional languages--Haskell is probably the main example. These go much further in their use of lazy evaluation than R. For analogs of the R expressions

[R] [R-pkgs] Reshape version 0.7.1

2006-09-30 Thread hadley wickham
Reshape version 0.7.1 = Reshape is an R package for flexibly restructuring and aggregating data. It's inspired by Excel's pivot tables, and it (hopefully) makes it very easy to get your data into the shape that you want. You can find out more at http://had.co.nz/reshape

Re: [R] Simple graphics

2006-10-01 Thread hadley wickham
Yes and no. This sort-of does what I want, except that it has no precision! After I edit the file.png with a graphic editor, I notice that the rectangle does not have 100 x 100 pixels in the sides, because the vertices are in weird points (instead of (50,50) to (150,150), they are from

Re: [R] Block comments in R?

2006-10-05 Thread hadley wickham
Still gives you problems with nested comments. *IF* we want to go down that route, we should have directional symbols like dsaldfysdfk What about heredocs? (http://en.wikipedia.org/wiki/Heredoc) Hadley __ R-help@stat.math.ethz.ch mailing list

Re: [R] Block comments in R?

2006-10-06 Thread hadley wickham
Commenting code out and providing documentation comments are easily done with a good editor, although R documentation comments really belong in files where help() can find them. R documentation comments belong in .Rd files at the moment, but how joyous would it be if they could be

Re: [R] is it possible to fill with a color or transparency gradient?

2006-10-06 Thread hadley wickham
I haven't been using R very long, so it's possible that I'm just missing something, but I haven't found anything like this in the help files. I've tried to poke around in graphics, grid, and ggplot, without any luck so far. I really like some of the functionality in ggplot, and it does some

Re: [R] Block comments in R?

2006-10-09 Thread hadley wickham
Current .Rd documentation has some obvious problems: - the parser strips comments out of examples when it runs them - there's no way to put images into the documentation - the keywords aren't much use - there's isn't a definition anywhere of what the format really is, so it's hard to know

Re: [R] combinatorics

2006-10-13 Thread hadley wickham
I've tried to think of an efficient and economical (and therefore clever) way of doing this for larger problems; but that will have to wait for another day! The ruby permutations library (http://permutation.rubyforge.org/doc/index.html) references The Algorithm Design Manual, Steven S.

[R] Installing packages on OS X

2004-09-08 Thread hadley wickham
On my computer, it seems that (binary?) packages installed through the GUI in RAqua are not used available to the command line version of R, while (source) packages installed with R CMD INSTALL are available to both. This is a problem when I run R CMD CHECK on a package that I am creating that

Re: [R] Installing packages on OS X

2004-09-09 Thread hadley wickham
Thanks to you both. Setting R_LIBS='~/Library/R/library/' in ~/.Renviron did the trick. Thanks, Hadley __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

[R] Confused about loading other packages from a package

2004-09-09 Thread hadley wickham
In my package, I create a new method for plot with the following signature: setMethod(plot, signature(x=marrayNorm, y=formula), plot.ma) where marrayNorm is a class defined in the marray package. After building and installing my package, I get the following warnings when I load my package

Re: [R] Confused about loading other packages from a package

2004-09-09 Thread hadley wickham
Unfortunately, marrayClasses doesn't seem to have a namespace: library(maVis) Error in loadNamespace(imp[[1]], c(lib.loc, .libPaths()), keep.source) : package 'marrayClasses' does not have a name space Error in library(maVis) : package/namespace load failed Any other ideas? Hadley

Re: [R] Confused about loading other packages from a package

2004-09-11 Thread hadley wickham
Roger's other one is the best one: use pre-2.0.0 and have Depends: marrayClasses in your DESCRIPTION file. Having require(marrayClasses) in install.R in your package may work, although you may need it in R_PROFILE.R as well. Adding require(marrayClasses) to install.R stops the error

[R] Raster images from sweave

2004-09-24 Thread hadley wickham
Is it possible to get sweave to produce raster (eg. png/jpg) plot images? I'm writing a vignette that contains plots with tens of thousands of points which results in very large pdf files (13 megs before compression). Thanks, Hadley __ [EMAIL

[R] Subset doesn't drop unused factor levels

2004-10-07 Thread hadley wickham
a - data.frame(b = rep(1:5, each=2), c=factor(rep(a,10), levels=c(a,b))) levels(subset(a, b=1, drop=T)$c) # [1] a b Is this a bug? Thanks,, Hadley __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Subset doesn't drop unused factor levels

2004-10-07 Thread hadley wickham
Ok. That makes sense. Thanks to you all for your help. Hadley __ [EMAIL PROTECTED] 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] R Cocoa won't load in Mac 10.3

2004-10-20 Thread hadley wickham
I installed R-cocoa 2.0.0 using the binary installer package on Mac OS 10.3. When I try to start the program from the GUI I get the following error message: Unable to start R: R_HOME is not set. Please set all required environment variables before running this program. I had the

Re: [R] Quick data-manipulation question

2004-10-28 Thread hadley wickham
How about do.call(rbind, j) ? Hadley On Thu, 28 Oct 2004 09:29:46 -0400, Sean Davis [EMAIL PROTECTED] wrote: I have a list of data frames and I want to concatenate them into a single data frame, basically appending all of the data frames to each other (they are all the same shape, in terms of

Re: [R] Running sum

2004-11-19 Thread hadley wickham
Perhaps I'm missing something, but isn't the maximum of the cumulative sum simply the last value, ie. sum(x)? Hadley __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

Re: [R] Running sum

2004-11-20 Thread hadley wickham
Perhaps I'm missing something, but isn't the maximum of the cumulative sum simply the last value, ie. sum(x)? As many have mentioned, I was forgetting the negative numbers. Thanks to those who pointed that out. Hadley __ [EMAIL PROTECTED] mailing

Re: [R] scatterplot of 100000 points and pdf file format

2004-11-24 Thread hadley wickham
Another possibility might be to use a 2d kernel density estimate (eg. kde2d from library(MASS). Then for the high density areas plot the density contours, for the low density areas plot the individual points. Hadley __ [EMAIL PROTECTED] mailing list

Re: [R] Searching for a string in RSQLite

2004-11-25 Thread hadley wickham
You may find dQuote() and sQuote() to be helpful, but a better Ooops, dQuote() and sQuote() won't be of much use as they escape quotes with quotes. A regular expression should do the trick: gsub(', ', Hi y'all). (Note that this looks like it has too many backslashes, but this is just the

Re: [R] adding regression curve to xyplot

2004-11-30 Thread hadley wickham
If you only want a simple linear regression, you might also want to try xyplot(t~s|factor(lonLabels[whichLon100])*factor(latLabels[whichLat100]), +   data=P100,pch=., type =c(p,r) - type r will automatically fit and plot the regression line for you. Hadley

Re: [R] New Year Wish List

2005-01-01 Thread hadley wickham
4. Sourceforge-like Support for Subprojects. This refers to groupware support for subproject development. The Lua and Ruby communities have done this with LuaForge.net and RubyForge.org. I think both are powered by http://gforge.org/ - it probably wouldn't be difficult to set up

Re: [R] Applying function to multiple input vectors

2005-03-27 Thread hadley wickham
Is there a method analogous to sapply() for this operation? Check out mapply. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

Re: [R] 4D Plot ??

2005-04-07 Thread hadley wickham
Hi Mike, I've done a bit of playing around with these kind of plots for visualising microarray data (to eventually go into a bioconductor package). I've attached my code for producing surfaceplots (my name for the type of plots that includes both image and contour plots) - it's all lattice

Re: [R] www.r-project.org

2006-04-25 Thread hadley wickham
Hi Romain, Generally a competition is a bad way of coming up with a new design. It generally emphasises looks over function and, of course, requires people to put in a lot of effort for a small chance of gain. I'd also agree with Friedrich that few people will enter. My opinion is if that

Re: [R] www.r-project.org

2006-04-25 Thread hadley wickham
The R Web site is working fine. Even if it is not relifted from a long time, it is functional. So, this is the point... and it should remain, at least, as functional as it is. As an experienced user of the R website, this probably is true for you. However, there are a number of confusing

Re: [R] www.r-project.org

2006-04-25 Thread hadley wickham
Isn't Other Contributed Documentation sufficient? Usability guidelines for websites suggest that you should have as few top-level menu items as possible, say 5-6 max... OK the R website is not like insert_company_name.com type website, but you wouldn't want to flood users with too many

Re: [R] New-user support package - suggestions?

2006-05-04 Thread hadley wickham
I started on such a project a while ago for my personal use when creating packages. Often I forget to use na.rm and never test my functions with code containing missing values, and then later on have to search back through my code and ensure I've used na.rm=TRUE everywhere. I didn't get very

Re: [R] Fast update of a lot of records in a database?

2006-05-19 Thread hadley wickham
put the updates into a temporary table called updates UPDATE bigtable AS a FROM updates AS b WHERE a.id = b.id SET a.col1 = b.col1 I don't think this will be any faster - why would creating a new table be faster than updating existing rows? I've never had a problem with using

[R] Function hints

2006-06-19 Thread hadley wickham
One of the recurring themes in the recent UserR conference was that many people find it difficult to find the functions they need for a particular task. Sandy Weisberg suggested a small idea he would like to see: a hints function that given an object, lists likely operations. I've done my best

Re: [R] Function hints

2006-06-20 Thread hadley wickham
what I really would love to see would be an improved help.search(): on r-devel I found a reference to the /concept tag in .Rd files and the fact that it is rarely used (again: I was not aware of this :-( ...), which might serve as keyword container suitable for improving help.search()

[R] [R-pkgs] ggplot: a new system for drawing graphics in R

2006-07-03 Thread hadley wickham
ggplot provides a new system for drawing graphics in R, based on the Grammar of Graphics. It combines the advantages of both base and lattice graphics: conditioning and shared axes are handled automatically, and you can still build up a plot step by step from multiple data sources. It also

[R] Weighted histograms

2006-07-10 Thread hadley wickham
Does anyone have any code for drawing weighted histograms (a la Manet/Mondrian) in R? Thanks, Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!

Re: [R] lm: Displaying 95% confidence and prediction intervals on scatterplots

2006-07-15 Thread hadley wickham
May I know how does one superimpose the 95% confidence and prediction intervals on the linear regression line of a scatterplot? You could use ggplot: install.packages(ggplot) library(ggplot) qplot(wt, mpg, data=mtcars, type=c(point,smooth), method=lm) (which gives the 95% confidence

Re: [R] Trailing on r-help messages

2006-07-16 Thread hadley wickham
Personally, I doubt anyone actually reads the bottom of the emails, and generally it is too late anyway, as they have already sent the message. Much like the opening text in R, details in footer tend to trigger legalese neurons and are largely ignored. I think it would be more useful to

Re: [R] Trailing on r-help messages

2006-07-16 Thread hadley wickham
They might read it when reading other people's messages since it would be at the bottom of every single one. Perhaps, it might also trigger same-blindness: seeing the same thing again and again makes it less and less likely to really percieve it. Hadley

Re: [R] Trailing on r-help messages

2006-07-17 Thread hadley wickham
I think that is likely true but it would at least mean that they had seen it repeatedly and there would really be no excuse for not following it (unlike the current situation where one needs to take action to follow the posting guide link and then read a lengthy page). Logically, that makes

Re: [R] Trailing on r-help messages

2006-07-17 Thread hadley wickham
- The inscription page is dynamically generated by mailman, i.e., typically python scripts. If any of you are interested in patching Mailman's sources in a reasonable way (i.e. easily reproducible for the next version of mailman), I'd consider a change there; otherwise not. The other

[R] Aligning ragged text columns

2006-07-19 Thread hadley wickham
Can anyone please suggest how I can print: a - matrix(c( Heading 1, This is some info\nabout heading 1, Heading 2, This is some info\nabout heading 2, ), byrow=T, nrow=2) to look like: Heading 1 This is some info about heading 1 Heading 2 This is some info

Re: [R] Aligning ragged text columns

2006-07-19 Thread hadley wickham
heading1 - Heading1 heading2 - Heading2 a - matrix(c( Heading 1, paste(This is some info\nabout, heading1, sep=), Heading 2, paste(This is some info\nabout, heading2, sep=), ), byrow=T, nrow=2) I wasn't so concerned about the redundancy in my example, but how it looks -

Re: [R] Aligning ragged text columns

2006-07-19 Thread hadley wickham
I find that things line up better in data.frames That's a good idea, although I was hoping there would be something in R to do it for me. I have ended up with: fwidth - max(nchar(x[,1])) descs - strwrap(x[,2], width=width - fwidth - 5, simplify=FALSE) output -

Re: [R] beginner Q: hashtable or dictionary?

2006-01-29 Thread hadley wickham
use a 'list': Is a list O(1) for setting and getting? Hadley __ 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] beginner Q: hashtable or dictionary?

2006-01-30 Thread hadley wickham
Is a list O(1) for setting and getting? Can you elaborate? R is a vector language, and normally you create a list in one pass, and you can retrieve multiple elements at once. When you use a hash table you expect it to be O(1) (on average) for getting and setting values (conditional on

Re: [R] beginner Q: hashtable or dictionary?

2006-01-30 Thread hadley wickham
I would think that when translating from another language, it is best to write it in R in the simplest way, which probably means using a list. Then if it turns out to be too slow, try doing something fancy. I suspect that speed improvements are seldom necessary -- I can't believe how fast

[R] [R-pkgs] Reshape version 0.6

2006-02-10 Thread hadley wickham
Reshape version 0.6 === Reshape is an R package for flexibly restructuring and aggregating data. It's inspired by Excel's pivot tables, and it (hopefully) makes it very easy to get your data into the shape that you want. You can find out more at http://had.co.nz/reshape What's

Re: [R] aggregate vs tapply; is there a middle ground?

2006-02-11 Thread hadley wickham
I faced a similar problem. Here's what I did tmp - data.frame(A=sample(LETTERS[1:5],10,replace=T),B=sample(letters[1:5],10,replace=T),C=rnorm(10)) tmp1 - with(tmp,aggregate(C,list(A=A,B=B),sum)) tmp2 - expand.grid(A=sort(unique(tmp$A)),B=sort(unique(tmp$B))) merge(tmp2,tmp1,all.x=T) At

  1   2   3   4   5   >