> Suppose X is a dataframe or a matrix. What would you expect to get from
> X[1]? What about as.vector(X), or as.numeric(X)?
>
> The point is that a dataframe is a list, and a matrix isn't. If users don't
> understand that, then they'll be confused somewhere. Making matrices more
> list-like in
The basic reason because apply works with matrices - it first turns
the input into a matrix, processes each column and then returns a
matrix. See colwise in the plyr package for a function that works
column wise on a data frame, returning a data frame.
Hadley
On Sun, Mar 7, 2010 at 11:07 AM, Tal
Hi Mark,
If efficiency is a concern you might want to read "Computing Thousands
of Test Statistics Simultaneously in R" by Holger Schwender and Tina
Müller, http://stat-computing.org/newsletter/issues/scgn-18-1.pdf.
If you just want to do it, see the examples in
http://had.co.nz/plyr/plyr-intro-0
> 15032 Hunter Court, Westfield, IN 46074
>
> (317) 490-5129 Work, & Mobile & VoiceMail
> (317) 399-1219 Skype No Voicemail please
>
>
> On Sun, Mar 7, 2010 at 2:08 PM, hadley wickham wrote:
>>
>> Hi Mark,
>>
>> If efficiency is a concern you m
For Q2 you can use opts(legend.position = c(0.9, 0.9)).
For Q3, you can also use scale_y_sqrt().
Hadley
On Wed, Mar 10, 2010 at 2:05 PM, Tim Howard wrote:
> To answer two of my own questions to get them into the archives (I am slowly
> getting the hang of ggplot):
>
> Q1. use "opts(axis.text.
What is varwidth?
Hadley
On Wed, Mar 10, 2010 at 1:55 PM, Johannes Graumann
wrote:
> Hi,
>
> Is there such a thing? If no: is it easily simulated?
>
> thanks, Joh
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> By Q2 I was trying to refer to the Y-axis labels. For the polar plot, the
> Y-axis labels reside left of the panel. I was looking for a way to get the
> Y-axis labels to radiate out from the center so it would be clear which line
> each label refers to. I still can't find any reference to movi
> Run that function hourly with plyr
>
> output.hourly <- dlply(df.i1,"tshour",cor.dat)
Why not
output.hourly <- ddply(df.i1,"tshour",cor.dat)
? Generally you want to work with data frames in R, if at all possible.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of St
oportional to the
> square-roots of the number of observations in the groups."
>
> I find this option often very useful.
>
> Thanks for any insight into how to achieve this with geom_boxplot.
>
> Joh
>
> On Wednesday 10 March 2010 16:12:49 hadley wickham wrote:
>
ggplot2
ggplot2 is a plotting system for R, based on the grammar of graphics,
which tries to take the good parts of base and lattice graphics and
avoid bad parts. It takes care of many of the fiddly details
that make plotting a hassle (l
> Based on a discussion found on the R mailing list but dating back to 2008, I
> have compared the log-likelihoods of the glm model and of the glmer model as
> follows:
>
> lrt <- function (obj1, obj2){
> L0 <- logLik(obj1)
> L1 <- logLik(obj2)
> L01 <- as.vector(- 2 * (L0 - L1))
> df <- attr(L1,
>>> Does anyone have any experience retrieving latitutde and longitude for
>>> an address from the Google Maps API?
>
> This thread from r-sig-geo may be of interest:
> https://stat.ethz.ch/pipermail/r-sig-geo/2010-March/thread.html#7788
In particularly, note that what you are doing is against the
Hi all,
Does any one know of any encryption/decryption algorithms in R? I'm
not looking for anything robust - I want some way of printing output
to the screen that the user can't read immediately, but can decrypt a
little later. The main thing I don't want to the user to see is a
number, so (e.g
On Fri, Mar 19, 2010 at 12:35 PM, Barry Rowlingson
wrote:
> On Fri, Mar 19, 2010 at 5:10 PM, Barry Rowlingson
> wrote:
>> On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham wrote:
>>> Hi all,
>>>
>>> Does any one know of any encryption/decryption algorithms
Have a look at ddply from the plyr package, http://had.co.nz/plyr.
It's made for exactly this type of operation.
Hadley
On Wed, Jun 24, 2009 at 10:34 PM, Stephan Lindner wrote:
> Dear all,
>
>
> I have a code where I subset a data frame to match entries within
> levels of an factor (actually, the
On Fri, Jun 26, 2009 at 10:27 PM, Osman Al-Radi wrote:
> Dear Richard and David,
>
> Thanks for this reference. I looked into vcd and mosaic plot, it is a nice
> plot for investigating associations between two or more variables. However,
> I just need to plot the frequency of a single variable as t
> Also consider ddply in the plyr package (although that's an over kill if
> your only having two loops)
Maybe, but it sure is much simpler:
library(plyr)
ddply(data, c("industry","year"), summarise, avg = mean(X1))
Hadley
--
http://had.co.nz/
__
R-
Hi Chris,
Try this:
qplot(reorder(model, delta), delta, data = growthm.bic)
Hadley
On Sun, Jun 28, 2009 at 9:53 AM, Christopher
Desjardins wrote:
> Hi,
> I have 45 models that I have named: 1, 2, 3, ... , 45 and I am trying to
> plot them in order of ascending BIC values. I am however unclear a
ackage. That code is giving me
> the following error:
>
>> qplot(reorder(model,delta),delta,data=growthm.bic)
> Error in UseMethod("reorder") : no applicable method for "reorder"
>
> Cheers,
> Chris
>
> On 6/28/09 8:21 PM, hadley wickham wrote:
>
>
On Tue, Jun 30, 2009 at 2:12 PM, Barry
Rowlingson wrote:
> On Tue, Jun 30, 2009 at 8:05 PM, Mark Knecht wrote:
>
>> You could wrap it in a function of your own making, right?
>>
>> AddNewDev = function() {dev.new();AddNewDev=dev.cur()}
>>
>> histPlot=AddNewDev()
>>
>> Seems to work.
>
> You leaRn
On Wed, Jul 1, 2009 at 2:10 PM, Sunil
Suchindran wrote:
> #Highlight the text below (without the header)
> # read the data in from clipboard
>
> df <- do.call(data.frame, scan("clipboard", what=list(id=0,
> date="",loctype=0 ,haptype=0)))
>
> # split the data by date, sample 1 observation from each
On Thu, Jul 2, 2009 at 8:15 AM, James Martin wrote:
> Hadley, Sunil, and list,
>
> This is not quite doing what I wanted it to do (as far as I can tell). I
> perhaps did not explain it thoroughly. It seems to be sampling one value
> for each day leaving ~200 observations. I need for it randomly ch
On Thu, Jun 18, 2009 at 12:08 PM, Dirk Eddelbuettel wrote:
>
> On 18 June 2009 at 09:36, Bert Gunter wrote:
> | -- or Chapter 4 in S PROGRAMMING? (you'll need to determine if it's "reader
> | friendly")
>
> +1
>
> It helped me a lot too back in the day. But I am wondering if there are good
> curre
On Thu, Jul 2, 2009 at 3:34 PM, Sebastien
Bihorel wrote:
> Dear R-users,
>
> I would like to know how expressions could be passed as arguments to do.call
> functions. As illustrated in the short example below, concatenating lists
> objects and an expression creates an expression object, which is no
On Sat, Jul 4, 2009 at 7:56 PM, Mark Kimpel wrote:
> I am using grep to locate colnames to automate a report build and have
> run into a problem when a colname is not found. The use of integer(0)
> in a conditional statement seems to be a no no as it has length 0.
> Below is a self-contained trivia
> 2) Related to the above, how do I tell what packages are currently
> loaded at any given time so that I don't waste time loading things
> that are already loaded? search() tells me what's available, but
> what's loaded? The best I can find so far goes like this:
Loading something a second time t
Also make sure to check roxygen (from roxygen.org) - it makes package
documentation much much easier. Ironically, the documentation for
roxygen currently leaves something to be desired but I think Peter and
Manuel are working on it.
Hadley
On Sat, Jul 4, 2009 at 3:59 PM, Jason Rupert wrote:
>
>
> I think the root cause of a number of my coding problems in R right
> now is my lack of skills in reading and grabbing portions of the data
> out of arrays. I'm new at this. (And not a programmer) I need to find
> some good examples to read and test on that subject. If I could locate
> which co
Hi Malcolm,
You need to tell geom_boxplot not to use stat_boxplot:
geom_boxplot(aes(lower=y_q1, upper=y_q3, middle=y_med, ymin=y_min,
ymax=y_max), stat = "identity")
Hadley
On Mon, Jul 6, 2009 at 6:55 AM, Malcolm Ryan wrote:
> Is there anyway in ggplot2 to set the aesthetics for a geom_boxplot
>
On Mon, Jul 6, 2009 at 12:12 AM, nyk wrote:
>
> Thanks for your reply! This is what I was looking for!
> I'm using
> nas1 <- apply(data_matrix,1,function(x)sum(is.na(x))/nrow(data_matrix))
> nas2 <- apply(data_matrix,2,function(x)sum(is.na(x))/ncol(data_matrix))
You can simplify this a little:
pe
On Mon, Jul 6, 2009 at 8:22 PM, Mark Knecht wrote:
> Hi,
> In the examples from the ReShape package there is a simple example
> of using melt followed by cast that produces a smallish amount of
> output about the chicks database. Here's the code:
>
> library(reshape)
>
> names(ChickWeight) <- tol
Hi Benoit,
What do you expect width to do? You are already setting the left and
right extents with xmin and xmax.
Hadley
On Thu, Jul 9, 2009 at 10:37 AM, Benoit
Boulinguiez wrote:
> Hi all,
>
> quick question: is the optional command "width" effective in the
> geom_errorbarh() layer of ggplot?
from a formula.
> I'm looking for the equivalent of curve() in ggplot2, Hadley Wickham
> mentions geom_curve, but as far as I've seen in the help it doesn't exist.
>
> My need is to plot a regular scatter plot of experimental data (easy to do
> actually) and then add the
Hi megh,
Unfortunately there's a known bug which prevents you from setting the
y axis title in this way. Instead you can do :
qplot(...) + scale_y_continuous("")
I think I've figured out a work around and it will be fixed in a future release.
Hadley
On Mon, Jul 13, 2009 at 2:15 AM, megh wrote
> In this simple example, it took less than half a second to generate the
> result. That is on a 2.93 Ghz MacBook Pro.
>
>
> So, for your data, the code would look something like this:
>
>
> system.time(DF.new <- do.call(rbind,
> lapply(split(patch_summary,
> patch_summ
On Mon, Jul 13, 2009 at 5:55 AM, Weiwei Shi wrote:
> Hi, there:
>
> Assume I have a dataframe with rownames like A with rownames like a to e,
>
>> A
> [,1] [,2]
> a 1 6
> b 2 7
> c 3 8
> d 4 9
> e 5 10
>
> when I use A[1,], I lost the rowname for it, like below. How co
t Boulinguiez
>
>
> -Message d'origine-
> De : hadley wickham [mailto:h.wick...@gmail.com]
> Envoyé : dimanche 12 juillet 2009 11:04
> À : Benoit Boulinguiez
> Cc : r-help@r-project.org
> Objet : Re: [R] ggplot2: geom_errorbarh()
>
> Hi Benoit,
>
> Wh
Could you please give a reproducible example?
Thanks,
Hadley
On Thu, Jul 16, 2009 at 5:41 PM, Alex Brown wrote:
> Hi there,
>
> I'm trying to find out the command to stop clipping to plot region in
> ggplot.
>
> I have a bar chart (axis flipped) with labels on the bars, but the
> lab
ely...
>
>
> Regards/Cordialement
>
>
> Benoit Boulinguiez
>
>
> -Message d'origine-
> De : hadley wickham [mailto:h.wick...@gmail.com]
> Envoyé : mercredi 15 juillet 2009 14:52
> À : Benoit Boulinguiez
> Cc : r-help@r-project.org
> Objet : Re: [R] g
On Fri, Jul 17, 2009 at 3:39 AM, Alex Brown wrote:
>
> Sure thing, an example.:
>
> ggplot
> (data.frame(name=letters[1:3],value=c(1,4,9),type=c("fun","fun","not
> fun")),aes(x=name,y=value,fill=type,label=paste("value is ",value))) +
> geom_bar() + coord_flip() + geom_text(hjust=0)
>
> I'd like th
> for educational purposes I wonder if it is possible to simulate
> different data sets (or specifically residuals) for a linear regression.
> I would like to show my students residuals with different means,
> variances and distributions (normal, but also not normal) in the plots
> created with the
> Ups, I just realized that we have the possibility of using
> grid.remove(..., redraw = FALSE) which is more or less what I was looking for.
>
> But I'm still wondering if its possible to remove a viewport from
> a viewport tree:
I've talked with Paul about this (for the general case of modifying
> Drawing grid graphics always takes long, I would write the images to png's
> and make the animation. If you use Linux I can suggest some nice tools to do
> this. This movie is also much more compatible with all kinds of machines. It
> might be that you can get your grid animation working on your
On Tue, Jul 21, 2009 at 7:39 PM, Gene Leynes wrote:
> # Just when I thought I had the basic stuff mastered
> # This has been quite perplexing, thanks for any help
>
>
> ## Here's the example:
>
> db1=data.frame(
> olditems=c('soup','','','','nuts'),
> prices=c(4.45, 3.25, 4.42, 2.25, 3.98
Hi Damien,
This is because of a small bug. You can work around it by explicitly
using the force function - dlply(d, "V1", force). The default will be
fixed in the next version.
Regards,
Hadley
On Tue, Jul 21, 2009 at 11:18 AM, Damien Moore wrote:
> I'm running R 2.9.1 on winXP, using the libr
Have a look at the meifly package, which also includes tools for
visualising the resulting models.
Hadley
On Wed, Jul 22, 2009 at 7:28 AM, Thomas A. Groen wrote:
> Hi,
>
> I would like to have a script/function (or write one) that can calculate the
> linear models for all possible combinations of
On Fri, Jul 24, 2009 at 9:08 AM, Steve
Lianoglou wrote:
> Hi,
>
> On Jul 24, 2009, at 8:49 AM,
> wrote:
>
>> Hi,
>> can anyone tell me what a "roclet" is exactly?
>> Is this terminology specific to R, or is it used in other languages
>> aswell?
>
> Never heard of it before and google isn't retu
Hi Benoit,
Unfortunately there's currently no way to do that - the legend
automatically corresponds to the geom in the plot.
Hadley
On Thu, Jul 23, 2009 at 11:30 AM, Benoit
Boulinguiez wrote:
> Hi all,
>
> I've this ggplot2 graph
> (http://www.4shared.com/file/120101043/f3e9350/isotherm.html).
>
On Mon, Aug 3, 2009 at 5:23 PM, wrote:
> I'm having trouble reshaping a data.frame from long to wide.
> (I think that's the right terminology; feel free to educate me.)
> I've looked at the reshape function and package and plyr package,
> but I can't quite figure out how to do this after a dozen v
Hi all,
On October 19, I'll be offering a one data ggplot2 course in
conjunction with the ISMI Manufacturing Week. The course is open to
all and you can attend in person (Austin TX) or over the web. More
information available from http://lookingatdata.com/ismi-2009/
Regards,
Hadley
--
http://
On Wed, Mar 24, 2010 at 8:52 AM, mgierdal wrote:
>
> I have a dataFrame variable:
>
> L1 L2 L3 ... v1 v2 ...
> 1
> 2
> 3
> 4
> ...
>
> I want to process subsets of it as defined by combinations of L1-L2-L3. I do
> it successfully using nested loops:
>
> for (i in valuesOfL1 {
> for (j
See here:
http://learnr.wordpress.com/2010/03/23/ggplot2-changing-the-default-order-of-legend-labels-and-stacking-of-data/
Hadley
On Wed, Mar 24, 2010 at 2:40 PM, Ryan Garner
wrote:
>
> How do I reverse the order of the legend in a bar plot to match order of the
> x-axis? In other words, I want
> # Set up the ratio variables
> system.time({
> temp <- cbind(data, do.call(cbind, lapply(names(data)[3:4], function(.x)
> {
> unlist(by(data, data$group, function(.y) .y[,.x] /
> max(.y[,.x])))
> })))
> colnames(temp)[5:6] <- paste(colnames(data)[3:4], 'ind.to.max',
> exp1^(a[case] * l * 10)
>
> would be better written out of the loop as
>
> b <- exp1^(a * l * 10)
And even better as
b <- exp(a * l * 10)
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
On Wed, Mar 31, 2010 at 8:20 AM, Tony B wrote:
> Dear all,
>
> Lets say I have the following:
>
>> x <- c("Eve: Going to try something new today...", "Adam: Hey @Eve, how are
>> you finding R? #rstats", "Eve: @Adam, It's awesome, so much better at
>> statistics that #Excel ever was! @Cain & @Abl
On Thu, Apr 1, 2010 at 3:05 AM, Peter Dalgaard wrote:
> Jeff Brown wrote:
>> Sorry for spamming. I swear I had worked on that problem a long time before
>> posting.
>>
>> But I just figured it out: I have to change the values, which are
>> represented as integers, not strings. So the following c
> Incidentally, there is nothing new or radical in this; indeed, John Tukey,
> Leo Breiman, George Box, and others wrote eloquently about this decades ago.
> And Breiman's random forest modeling procedure explicitly abandoned efforts
> to build simply interpretable models (from which one might infe
> Also I have seen 5,000 page listings in SAS.
Is this a pro or a con?
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
__
R-help@r-project.org mailing list
https://stat.ethz.c
Because of the way you've constructed the plot with qplot, you need to use:
myPlot + geom_point(
data=medians,
aes(x=med,shape=cut, y=0),
size=2.5,
)
Hadley
On Wed, Apr 7, 2010 at 5:11 AM, Johannes Graumann
wrote:
> Hi,
>
> Please consider the example below. How can I manage to overlay the p
df <- data.frame(a = "a\"b")
write.table(df, "test.csv", sep = ",", row = F)
Is there any to load test.csv into R correctly? I've tried the following:
> read.table("test.csv", sep = ",")
[1] V1
<0 rows> (or 0-length row.names)
Warning message:
In read.table("test.csv", sep = ",") :
incomplete
> url <- "http://dl.dropbox.com/u/41902/22240.csv";
>
> read.csv(url)[, 1]
[1] "oppose" NA"oppose" "support"
> read.csv(url, header = F)[, 1]
[1] "url"
[2] "http://maplight.org/us-congress/bill/109-hr-5825/387248";
[3] "http://maplight.org/us-congress/bill/110-hr-3546/378743";
[4] "http:/
> df <- data.frame(a = "a\"b", v = 4, z = "this is Z")
> write.csv(df, "test.csv", row.names = FALSE, quote = FALSE)
> read.csv("test.csv", quote = "")
Unfortunately my real example is more like:
df <- data.frame(a = "a\"b", v = 4, z = "this is: A, B, C")
so quote = F won't work.
Can write.tabl
>> Can write.table and read.table really be so asymmetric?
>
> write() is a wrapper for cat() and read() is a wrapper for scan() so the
> question should really be can cat() and scan() be so asymmetric. Looking at
> their help pages, I would say that at least some degree of asymmetry is
> plausible
On Thu, Apr 8, 2010 at 8:20 AM, jim holtman wrote:
> You were using read.csv and not read.table. The following seems to work
> with using a separator that will probably not appear in the text:
>
>> df <- data.frame(a = "a\"b", v = 4, z = "this is: A, B, C")
>> write.table(df, "test.csv", row.name
> Remove the comma and count.fields gives 11 for all rows.
> From your other post(s) on escaped quotes, I assume that
> this won't solve your problem with the existing files. (:
Right - but assuming I'm not crazy, that should cause an error in
read.csv, right? It shouldn't just parse the file reg
> Other then rebuilding the plots, is there any way either (1) to combine
> existing ggplot2 plots or (2) to extract a layer from an existing plot
> so that it can be added to another?
Not really, although you can always pull apart the plot components.
Can you give an example of what you are tryin
> bar.err (agricolae)
> plotCI (gplots)
> xYplot (Hmisc)
> error.bars (psych)
> dispersion (plotrix)
> plotCI (plotrix)
>
Not to mention: http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice Univers
On Thu, Apr 15, 2010 at 1:16 AM, Chuck wrote:
> Depending on the size of the dataframe and the operations you are
> trying to perform, aggregate or ddply may be better. In the function
> below, df has the same structure as your dataframe.
Current version of plyr:
agg ddply
X100.00
addition of key columns that don't affect the
> number of groups. For example, grouping by Year and Month, if I add
> MonthBegin, a POSIXct column from which the Year and Month columns were
> derived, I run out of memory.
>
> hadley wickham wrote:
>
>>On Th
hat
> version?
>
> On Thu, Apr 15, 2010 at 9:09 AM, hadley wickham wrote:
>>
>> On Thu, Apr 15, 2010 at 1:16 AM, Chuck wrote:
>> > Depending on the size of the dataframe and the operations you are
>> > trying to perform, aggregate or ddply may be better. I
> corr.V2.V3 = function(x) {
> out = cor(x$V2, x$V3)
> names(out) = "CORR"
> return(out)
> }
A litte more concisely:
corr.V2.V3 = function(x) {
c(CORR = cor(x$V2, x$V3))
}
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
__
On Mon, Apr 19, 2010 at 5:13 AM, Paul Rigor (ucla) wrote:
> Hi all,
> I'm an R novice.
>
> I have data that's already formatted as "molten" that reshape should be able
> to work with. For example, the following was read in with
> read.csv(filename,sep=" ", header=FALSE)
>
> V1 V
Hi Liam,
Unfortunately this currently isn't supported. It's on my to do list:
http://github.com/hadley/ggplot2/issues/issue/94
Hadley
On Tue, Apr 20, 2010 at 7:59 PM, Liam Blanckenberg
wrote:
> Hi all,
>
> I have a question about setting arbitrary breaks/labels when using GGPLOT
> and date/tim
Use geom_segment and calculate the end points yourself.
Hadley
On Fri, Apr 23, 2010 at 8:38 AM, arnaud chozo wrote:
> Hi all,
>
> I'd want to plot a segment from a line specified by slope and intercept.
> I want to plot this line between two limits, x1 and x2, without imposing
> these limits to t
>> rm(list=ls())
>
> PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but
> don't post it. It's not fair to a person who may not read your code line by
> line before pasting it into their workspace and having it wiped out. Do you
> expect us to completely clear out our workspace
>> If clearing out your workspace destroys *any* work, then something is
>> seriously wrong with your workflow.
>>
>
> Yes, of course. Lets all post viruses to run on each others'
> machines. That will teach those users who don't run antivirus and
> backup software between each posting to r-help.
> Perhaps, true in some respects. I am still chiseling out work using
> primitive editing tools. But it still takes several minutes to load the
> objects I am working on into memory and then several minutes each to build
> new models. The models still reside in memory, since I do not know any
> met
On Sat, Apr 24, 2010 at 12:54 PM, Peter Ehlers wrote:
> Well, this has seriously gotten off the original topic.
>
> While Hadley makes some sense, it is nevertheless
> sometimes the case (surely so for David, I would surmise)
> that one is putting together a response to an R-help
> query when a ne
> Many people seem to be reluctant to define functions,
> even thought I think it is a pretty small step from
> writing scripts to writing functions.
I'm not so sure - I find most students struggle to grasp that next
level of abstraction. Generalising from a specific task to a general
function is
Yes.
Hadley
PS. If you provide a small reproducible example you are bound to get
more useful answers ;)
On Tue, Apr 27, 2010 at 8:45 AM, arnaud chozo wrote:
> Hi all,
>
> I'd want to plot a table of numbers such that the values are represented by
> gray level. Is there an easy way to do that u
> The problem is that I want HCount and HProbCount to use custom
> gradients. i.e. a colour for 0-10, next shade for 10-30, next for 30-70
> etc.
Use cut to create factor with those levels, and then scale_fill_manual
to match values to colours.
> Due to some magic done on the data, one uses inter
t with widths equal to the durations
> of the recessions. Once I create a free-standing plot, I'd like to be able
> to use it in various other contexts, including adding it to other existing
> plots. The alternative is to reconstruct the plot as a layer and add it to
> the other plots, but t
> wtf <- factor(x, levels(c(levels(wtf), NA), exclude=NULL)
> xtabs (~ wtf, exclude=NULL, na.action=na.pass)
Also see addNA.
Hadley
--
http://had.co.nz/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
On Fri, Sep 25, 2009 at 7:55 AM, baptiste auguie
wrote:
> Thank you Paul, I was convinced I tried this option but I obviously didn't!
>
> In ?packGrob, the user is warned that packing grobs can be slow. In
> order to quantify this, I made the following comparison of 3
> functions,
>
> - table1 use
> or with l_ply (plyr package)
> l_ply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x
The best way to do this is to supply both the object you want to
iterate over, and its names. Unfortunately it's slightly difficult to
create a data structure of the correct form to do thi
> many thanks for your answer and for the enormous work you put into plyr, a
> really powerful package.
> For now, I will solve my problem with a variable label attribute, I usually
> attach to columns in data frames. I asked the list, because I thought, I am
> overlooking something trivial, since
On Mon, Sep 28, 2009 at 9:01 AM, Gary Lewis wrote:
> Hi - Many organizations now make their data available as XML via a
> REST web service architecture. Is there any R package or facility to
> access this type of data directly (eg, to make the HTTP GET request
> and have the downloaded data put in
> Have you used persp or trans3d before? Here is a little piece of data that I
> am want to convert to 2d. I can plot (x,z) or (z,y). I know there is a better
> way to convert it to 2d. I did it long time back in my 3d geometry class.
http://en.wikipedia.org/wiki/3D_projection ?
Hadley
--
htt
On Tue, Sep 29, 2009 at 6:58 AM, wrote:
> Apologies for the misunderstanding. I can come up with a solution that might
> suit your needs:
>
> library(plyr)
> out <- ddply(test, .(nr), function(x) data.frame(date=x$date,
> index=rank(-as.integer(x$date
> out[is.na(out$nr) | is.na(out$date),
On Wed, Sep 30, 2009 at 2:32 PM, Ista Zahn wrote:
> An extremely verbose, but (in my view) easy to understand approach is:
>
>> data.f <- data; data.f[which(data <= 10)] <- levs[1]; data.f[which(data >
>> 10)] <- levs[2]; data.f <- factor(data.f)
>
All those which()s are unnecessary. And if you
On Fri, Oct 2, 2009 at 4:24 AM, jim holtman wrote:
> try this:
>
>> x <- read.table(textConnection("x1 x2 x3
> + A 1 1.5
> + B 2 0.9
> + B 3 2.7
> + C 7 1.8
> + D 7 1.3"), header=TRUE)
>> closeAllConnections()
>> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(
> The point Duncan was making was
>
> "What other value would you expect it to have after incrementing from 1 to
> 200 and stopping"?
Well, depending on the scoping rules of the language you are used to,
you might expect i at the top-level to remain undefined.
Hadley
--
http://had.co.nz/
_
> Whether or not what follows is to be recommended I don't know, but it
> seems to work,
>
> p <- ggplot(diamonds, aes(carat, ..density..)) +
> geom_histogram(binwidth = 0.2)
>
> x = quote(cut)
> facets = facet_grid(as.formula(bquote(.~.(x
> p + facets
That's what I'd recommend. You can also
> It is much easier to do you data preparation before plotting.
>
> Cummul <- ddply(subset(DF, precipitation!="NA"), "gauge_name",
> function(x){
> x$Cummul <- cumsum(x$precipitation)
> x
> })
With a little less typing:
Cummul <- ddply(subset(DF, precipitation!="NA"), "gauge_name",
Please provide a reproducible example. I've had problems with
multcompLetters in the past, because I was giving it slightly
incorrect input.
Hadley
On Tue, Oct 6, 2009 at 7:41 AM, goz wrote:
>
> hello,
>
> i try to use the multcomp letters, but i have problems with my results :
>
> here is my p
On Tue, Oct 13, 2009 at 6:57 AM, Ista Zahn wrote:
> I'm sure there's a really cool way to do this with plyr, although I
> don't know if my particular plyr version is much better. Anyway here
> it is:
>
> cmbine <- read.csv(textConnection('names, mass, classes
> apple,0.50,1
> tiger,100.00,2
> penc
>> Can I use (a) the logo and/or (b) the slogan for the KCL R workshops?
>> I think it is quite clear from "my" website that this is neither about
>> the Springer book series nor about an R user conference.
>
> No, sorry, the logo/name should be used exclusively for the Springer series
> and the R
> Neither a1 nor 2:100 are lists, so it would seem that sapply would be more
> appropriate.
The difference between lapply and sapply is the output, not the input.
Hadley
--
http://had.co.nz/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/m
> Is there a way to have some points solid and some points hollow? I have two
> classes of points and there are so many points, that it's hard to see just
> the difference in shapes. I'd like to have one of the classes be hollow in
> addition to being a different shape. Any help would be grand.
Yo
Just a note: this technique is called memoisation.
Hadley
On Wed, Oct 14, 2009 at 3:42 PM, Benilton Carvalho wrote:
> Thank you very much, Martin. :)
>
> b
>
> On Oct 14, 2009, at 5:23 PM, Martin Morgan wrote:
>
>> Steve Lianoglou wrote:
>>>
>>> Very clever, that looks to do the trick!
>>
>> I th
201 - 300 of 1521 matches
Mail list logo