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
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,
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.
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
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
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
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
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),
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
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
__
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(...)
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
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
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
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
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)
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
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
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
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
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
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
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
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(.,
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
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
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
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.
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)
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
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
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
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
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),
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
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
__
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:
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
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
=
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
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
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
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,
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
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
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
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
# 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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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!
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
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
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
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
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
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
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
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
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!
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
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
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
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
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
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!
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
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
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
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
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
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
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
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()
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
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!
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
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
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
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
- 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
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
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 -
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 -
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
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
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
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
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 - 100 of 418 matches
Mail list logo