Re: [R] ggplot2: histogram with proportions (or %)

2008-10-30 Thread hadley wickham
On Thu, Oct 30, 2008 at 3:49 AM, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote: > Dear Bernd, > > AFAIK you can only get counts, densitys, counts scale to a maximum of 1 > and likewise densitys. But you can alter the labels on the scales > manually. Well, a proportion is just the count divided by th

Re: [R] Subsetting data in a loop

2008-10-29 Thread hadley wickham
?split. Hadley On Wed, Oct 29, 2008 at 3:22 PM, t c <[EMAIL PROTECTED]> wrote: > I need some help with sub-setting my data. I am trying to divide a data > frame into multiple data frames based on the year collected, and stored in a > list with each new data frame labeled with "year X" where X

Re: [R] does qplot works with Sweave?

2008-10-28 Thread hadley wickham
t; execute. It works when using 'plot' though. Is this a normal behaviour? > > > \documentclass[9pt]{article} > \title{ggplot2 example} > > \begin{document} > > \maketitle > \section*{Examples of using ggplot2} > The goal is to be able to import ggplot2 graphics

Re: [R] ggplot2: how to combine position=stack and position=dodge in a single graph?

2008-10-28 Thread hadley wickham
On Fri, Oct 24, 2008 at 5:18 PM, Elena Schulz <[EMAIL PROTECTED]> wrote: > Hi Hadley, > > thanks a lot for your quick answer. >> You should be able to replicate any dodging layout with facetting > You mean instead of facetting by years, facetting by months? I will try this > an see how the plot loo

Re: [R] Process dataframes from list

2008-10-26 Thread hadley wickham
You might want to have a look at the plyr package - http://had.co.nz/plyr. The intro pdf describes a couple of problems that are similar to yours. Hadley On Sun, Oct 26, 2008 at 3:10 PM, Wade Wall <[EMAIL PROTECTED]> wrote: > Hi all, > > I have roughly fifty dataframes and a dataframe with the n

Re: [R] getting the "name" of an object

2008-10-22 Thread hadley wickham
On Wed, Oct 22, 2008 at 9:34 AM, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 10/22/2008 10:02 AM, francois Guilhaumon wrote: >> >> Hello, >> >> I'm looking for a way to get the "name" of an object when it is used >> within an "sapply". >> >> More precisely, with a simple example : >> >> I have a

Re: [R] ggplot scale limit and stat_smooth

2008-10-21 Thread hadley wickham
Hi Eric, > In the change log of ggplot2, version 0.7, I find this: > > "* scales: any point outside of limits is dropped (this was previously the > behaviour for discrete scales, but not continuous scales)" > > and that makes sense for some applications. But what about if I > want to summarize th

Re: [R] GGPLOT/QPLOT Boxplot with summary

2008-10-21 Thread hadley wickham
Here's two quick thoughts: qplot(1, mpg, data=mtcars, geom="boxplot") + facet_grid(. ~ cyl, margins =T) qplot(factor(cyl), mpg, data=mtcars, geom="boxplot") + geom_boxplot(aes(x = "all"), width = 0.9) Hadley On Tue, Oct 21, 2008 at 12:41 PM, SalishSea <[EMAIL PROTECTED]> wrote: > > I'd like to g

Re: [R] Multi matrix row-wise mapply?

2008-10-21 Thread hadley wickham
On Tue, Oct 21, 2008 at 1:58 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi group! > > Suppose I have 2 matrices A and B of equal dimensions. > I want to apply a function f to all corresponding pairs of rows from A > and B in an efficient manner. > Basically, I want > > mapply(f, data.frame(

Re: [R] Combining all possible values of variables into a new...

2008-10-20 Thread hadley wickham
On Mon, Oct 20, 2008 at 11:14 AM, jim holtman <[EMAIL PROTECTED]> wrote: > yet another way (as it always is in R): > >> x<-c(1,0,0,1,0,0,1,0,0,1) >> y<-c(1,3,2,3,2,1,2,3,2,3) >> z<-c(1,2,1,2,1,2,1,2,1,2) >> d<-as.data.frame(cbind(x,y,z)) >> d$myvar <- x*6 + (y-1)*2 + z >> >> d > x y z myvar > 1

Re: [R] The evaluation of optional function arguments

2008-10-19 Thread hadley wickham
Why don't you want to do this? timesDefineInside <- function(foo, bar...) { foo * bar } It seems like the obvious solution to your problem. Hadley On Sun, Oct 19, 2008 at 8:34 PM, Sietse Brouwer <[EMAIL PROTECTED]> wrote: > Dear R-helpers, > > I've got two functions; callTimes() calls times(

Re: [R] Date classes in ggplot2

2008-10-19 Thread hadley wickham
On Sun, Oct 19, 2008 at 10:49 AM, stephen sefick <[EMAIL PROTECTED]> wrote: > updn.gg <- (structure(list(date = structure(c(11808, 11869, 11961, 11992, > 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057, > 13149), class = "Date"), unrestored = c(1.13789418691602, 0.704948049842955, > 0

Re: [R] using ifelse with surprising results

2008-10-17 Thread hadley wickham
On Fri, Oct 17, 2008 at 3:50 PM, <[EMAIL PROTECTED]> wrote: > > Thanks for the gracious assistance in advance > > I'm working on a non-metric scaling problem and am calculating the distance > for input to isoMDS > > Here is the code > > library(MASS) > vegdata <- tapply(Percent, list(PRIMARY_VE, M

Re: [R] ggplot2 scale relation free

2008-10-17 Thread hadley wickham
s are done. thank you for the offer. > thanks agian > > On Fri, Oct 17, 2008 at 4:19 PM, hadley wickham <[EMAIL PROTECTED]> wrote: >> Hi Stephen, >> >> Thanks for the kind words about ggplot2 :) >> >> The next version of ggplot2 will implement the equival

Re: [R] ggplot2 scale relation free

2008-10-17 Thread hadley wickham
Hi Stephen, Thanks for the kind words about ggplot2 :) The next version of ggplot2 will implement the equivalent of scale relation free - I've just finished writing the bulk of the code and now I'm getting all the edge cases working. However, what you describe sounds like you want multiple scale

Re: [R] R plot

2008-10-17 Thread hadley wickham
On Fri, Oct 17, 2008 at 4:31 AM, Ted Harding <[EMAIL PROTECTED]> wrote: > On 17-Oct-08 09:01:08, Benoit Boulinguiez wrote: >> Hi, >> Personally I always use xlim and ylim with the plot or points >> function like that: >> >> plot( X,Y,pch=16,col=2,cex.axis=1.5,cex.lab=1.5, >> xlim=c(0,1.05*max

Re: [R] Grouped Histogram (colored)

2008-10-16 Thread hadley wickham
On Thu, Oct 16, 2008 at 11:42 AM, x0rr0x <[EMAIL PROTECTED]> wrote: > > Hi all, > > I'm trying to create a histogram which shows the frequency of variables > within a certain timeframe. > > I've been using SPSS before, but I didn't quite like it... > > To describe my problem further here are some e

Re: [R] correlation

2008-10-16 Thread hadley wickham
On Thu, Oct 16, 2008 at 8:05 AM, kdebusk <[EMAIL PROTECTED]> wrote: > What test do I use to determine if there is a correlation between a > discrete variable and a continuous variable? > > For example - I have water quality ratings for streams (excellent, > good, fair, poor) and a corresponding nit

Re: [R] combining same-day lab measurements with 'apply'

2008-10-15 Thread hadley wickham
Hi Dylan, You might want to have a look at the plyr package which is designed to make these sorts of tasks easier - http://had.co.nz/plyr. The site includes a ~20 page introductory pdf. Hadley On Wed, Oct 15, 2008 at 3:45 PM, dylan boyd <[EMAIL PROTECTED]> wrote: > Another request for help imp

Re: [R] comparing with lead function

2008-10-15 Thread hadley wickham
On Wed, Oct 15, 2008 at 5:59 AM, Michael Pearmain <[EMAIL PROTECTED]> wrote: > Hi All, > I've been trying to compare if the previous value in a variable is equal to > a binary value..(i.e i want to check if the last event was a yes or no) > > i've been trying to write some code for this, but it see

Re: [R] request: How can we ignore a component of list having no element

2008-10-15 Thread hadley wickham
An alternative approach would be to store 0 x 0 matrices instead of NULLs. This way every object in your list is a consistent type. Hadley On Wed, Oct 15, 2008 at 5:23 AM, Muhammad Azam <[EMAIL PROTECTED]> wrote: > Dear friends > There is a list of arrays comprising different no of rows and colu

Re: [R] A question about Heatmap for data with just 2 columns

2008-10-14 Thread hadley wickham
Why not use a scatterplot? That will be far far better for your purpose than a heatmap. Hadley On Tue, Oct 14, 2008 at 4:45 PM, feishi <[EMAIL PROTECTED]> wrote: > > Hi, I have a question about heatmap. I have a data with row as microRNA and > two columns are two cell expression values for these

Re: [R] Remove warnings.

2008-10-14 Thread hadley wickham
Why don't you just suppress the warning messages you are not interested in? ?suppressWarnings Hadley On Tue, Oct 14, 2008 at 7:59 AM, <[EMAIL PROTECTED]> wrote: > I have a function that could possibly generate warnings in a loop. What I > want is to report the warnings (warnings()) then clear

Re: [R] ggplot2 plot with symbols and then add line

2008-10-14 Thread hadley wickham
On Tue, Oct 14, 2008 at 6:46 AM, stephen sefick <[EMAIL PROTECTED]> wrote: > r <-(structure(list(TSS = c(2.8, 8.4, 11, 1.3, 4.2, 2, 3.4, 14, 8.2, > 3.1, 1.4, 0.9, 0.5, 6.1, 9.2, 0.6, 1, 11, 2.4, 1.2, 1.3, 1.3, > 0, 1.8, 8, 11, 11, 8.5, 8.5, 1.8, 13, 4.4, 1.4, 2.1, 0.5, 25, > 25, 9.3, 6.1, 1.6, 1.5,

Re: [R] ggplot faceting like lattice | variable

2008-10-13 Thread hadley wickham
Hi Stephen, It will definitely be in the next release because I just wrote the code last week. I'm aiming for another release early November. Hadley On Mon, Oct 13, 2008 at 2:07 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > I would like to be able to do the xyplot in ggplot below. I read in

Re: [R] Copyright Symbol

2008-10-11 Thread hadley wickham
Well, modulo your R set up, you should just be able to copy and paste that symbol into a text string: copy <- "(c)" and then place it wherever you like with text() or mtext(). Hadley On Sat, Oct 11, 2008 at 4:54 PM, Dr Eberhard W Lisse <[EMAIL PROTECTED]> wrote: > How do I put a copyright symbo

Re: [R] graphics

2008-10-11 Thread hadley wickham
On Sat, Oct 11, 2008 at 3:06 AM, Darja Poklukar <[EMAIL PROTECTED]> wrote: > > I just want to ask how to enlarge the resolution of my plots in R. For ex. > for publising I would like a picture of resolution minimal 500 dpi, all I > managed was picture of dim 5,28 X 5,83 with 118 pixels/cm. What

Re: [R] ggplot adding points

2008-10-10 Thread hadley wickham
On Fri, Oct 10, 2008 at 9:18 AM, stephen sefick <[EMAIL PROTECTED]> wrote: > I would like to do the following in ggplot: > what am I missing? > > River.Mile <-c(202, 198, 190, 185, 179, 148, 119, 61) > TSS <- c(1:8) > DOC <- seq(2, by= 0.6, length.out=8) > z <- data.frame(River.Mile, TSS, DOC) > xy

Re: [R] plot-parameter pch without influence when plotting a data-frame

2008-10-10 Thread hadley wickham
On Thu, Oct 9, 2008 at 8:19 AM, John Kane <[EMAIL PROTECTED]> wrote: > --- On Thu, 10/9/08, Oliver Bandel <[EMAIL PROTECTED]> wrote: > >> From: Oliver Bandel <[EMAIL PROTECTED]> >> Subject: Re: [R] plot-parameter pch without influence when plotting a >> data-frame >> To: "Gerhard Schön, UKE Hambur

Re: [R] Biplot connecting consecutive dates (ggplot?)

2008-10-09 Thread hadley wickham
On Thu, Oct 9, 2008 at 5:04 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > I would like to connect the dots based on when they occur in time. Is > there an easy way to do this? How exactly do you want to connect them? One approach is: qplot(V1, V2, data=f, colour=date) + geom_path() # or maybe

Re: [R] nls, lattice, and conversion over to ggplot

2008-10-09 Thread hadley wickham
On Thu, Oct 9, 2008 at 2:29 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > I am trying to figure out how to use ggplot2. I would like to do the below > with ggplot, but I can not figure out how. The data provided is a subset of > a much larger data set, but these data are the data necessary to m

Re: [R] Plot means with error bars - A novice needs help

2008-10-08 Thread hadley wickham
On Tue, Oct 7, 2008 at 11:31 PM, Michael Just <[EMAIL PROTECTED]> wrote: > Hello, > I'd appreciate a suggestion on how to construct plots (barplots?) that use > means on the Y axis instead of density/count. I'd also like to use groups > and plot error or confidence interval bars on these graphs. I

Re: [R] Histogram colours in lattice.

2008-10-07 Thread hadley wickham
On Tue, Oct 7, 2008 at 8:54 PM, Rolf Turner <[EMAIL PROTECTED]> wrote: > > I am trying to do a histogram lattice plot and I would like the > histogram to be filled with a different colour in each panel. > > Note: I want every bar in each histogram to be the same colour, > but that there should be

Re: [R] Stacked area chart and legends

2008-10-06 Thread hadley wickham
On Mon, Oct 6, 2008 at 10:54 AM, mbr <[EMAIL PROTECTED]> wrote: > > I have found lots of good advice on this forum about stacked area charts but > I've run into problems with the 2 recommended options: stackploy in plotrix > or qplot in ggplot2. I have a many page report that will be in a 2x2 page

Re: [R] [SOLVED] barchart for aggregated (sum) data in lattice?

2008-10-05 Thread hadley wickham
You can also do it with ggplot2: install.packages("ggplot2") library(ggplot2) qplot(month, weight = amount, fill = what, data=t1, geom="bar") You can find out more at http://had.co.nz/ggplot2 (And you probably want to set the levels of the months so they don't appear in alphabetical order) Had

[R] [R-pkgs] ggplot2 - version 0.7

2008-10-05 Thread hadley wickham
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

Re: [R] plyr package: passing further arguments fail

2008-10-05 Thread hadley wickham
On Sun, Oct 5, 2008 at 8:02 AM, Auguie, Baptiste <[EMAIL PROTECTED]> wrote: > Dear list and Hadley, > > The new plyr package seems to provide a clean and consistent way to apply a > function on several arguments. However, I don't understand why the following > example does not work like the stand

Re: [R] ggplot2: how to combine position=stack and position=dodge in a single graph?

2008-10-04 Thread hadley wickham
Hi Elena, Currently, there's no way to combine stacking and dodging in a single graphic. However, you can often use faceting to get a similar effect to dodging. Could you explain your problem in a little more detail? Thanks, Hadley On Sat, Oct 4, 2008 at 4:22 PM, Elena Schulz <[EMAIL PROTECTE

Re: [R] environment and scoping

2008-10-04 Thread hadley wickham
What's wrong with explicitly passing the variables as arguments to the function? aux.fun.one <- function(dat, x){ median(dat) - x } Hadley On Sat, Oct 4, 2008 at 11:50 AM, René Holst <[EMAIL PROTECTED]> wrote: > I haven't quite figured out how I can change the environment of a function. > I ha

Re: [R] color code from csv

2008-10-03 Thread hadley wickham
On Fri, Oct 3, 2008 at 2:10 PM, kerfuffle <[EMAIL PROTECTED]> wrote: > > hi folks, > > this is driving me up the wall. Apologies for posting twice in the same > week, I'm writing up a thesis. I wish to color-code some dots in an xy > plot. I've got a csv file with various elements, one of which

Re: [R] time segments intersection

2008-10-03 Thread hadley wickham
> Its as follows: > > chooseCRANmirror() > install.packages("zoo", dep = TRUE) > > or maybe: > > chooseCRANmirror() > install.packages("zoo", dep = TRUE, type = "mac.binary") > > If those do not work try installing some other packages, e.g. chron, > to see if you can install anything. If you still

Re: [R] question on xyplot

2008-10-03 Thread hadley wickham
On Fri, Oct 3, 2008 at 8:04 AM, eugen pircalabelu <[EMAIL PROTECTED]> wrote: > Hi List, > > > I have the following problem: I am using the multilevel package and make.univ > function for available in the package and then xyplot from lattice and I want > to know how could I be able to use the "coe

Re: [R] function in R

2008-10-02 Thread hadley wickham
On Thu, Oct 2, 2008 at 6:34 AM, Alphonse Monkamg <[EMAIL PROTECTED]> wrote: > > > > > Dear ALL, > > Does anyone know how to get the complete code program for any build-in > function > in R, e.g. when I tape mean in the R-console, I get the following: > > mean > > function (x, ...) > > UseMethod("

Re: [R] "group by" functionality in R

2008-10-01 Thread hadley wickham
On Wed, Oct 1, 2008 at 8:58 AM, Max Rausch <[EMAIL PROTECTED]> wrote: > I have a data frame with the following information > > day hourvolume > 1 2003-07-18 10 836700 > 2 2003-07-18 11 375000 > 3 2003-07-18 12 6 > 4 2003-07-188 102 > 5

Re: [R] "tapply versus by" in function with more than 1 arguments

2008-10-01 Thread hadley wickham
On Wed, Oct 1, 2008 at 7:21 AM, Cézar Freitas <[EMAIL PROTECTED]> wrote: > Hi. I searched the list and didn't found nothing similar to this. I > simplified my example like below: > > #I need calculate correlation (for example) between 2 columns classified by a > third one at a data.frame, like be

[R] [R-pkgs] New package: plyr

2008-09-30 Thread hadley wickham
plyr is a set of tools that solves a common set of problems: you need to break a big problem down into manageable pieces, operate on each pieces and then put all the pieces back together. It's already possible to do this with split and the apply functions, but plyr just makes it all a bit easier w

Re: [R] ggplot 2 - editing in the "panel_1_1" viewport

2008-09-30 Thread hadley wickham
> I want to divide up the text grobs for the key labels into two > different (text) grobs (each) and put them back into the space occupied > by the original text grob. I've worked with grobs enough to think this > should be easy, but I just cannot figure out how to identify the > specific text grob

Re: [R] ggplot, getting two scales and one stat.

2008-09-30 Thread hadley wickham
t(polls, aes(x =Date, y = Popular_Support, colour=Party)) + > + stat_smooth(span=0.5) + > + geom_point(aes(shape=Source)) > Error in `[.data.frame`(df, , var) : undefined columns selected > > if I move it back up into ggplot, then it works fine.... ?? > > > > 2008/9/27 ha

Re: [R] multiple plots - editing ggplot2 plot

2008-09-30 Thread hadley wickham
On Sat, Sep 27, 2008 at 10:20 AM, Pedro Barros <[EMAIL PROTECTED]> wrote: > > Hi All, > > I am trying to build a composite plot, with multiple categories, using > ggplot2. > > In principle, it could be done using facetting, but I do not seem to be able > to get past the defaults, so I try building

Re: [R] box-whisker plot from pre-summarized data?

2008-09-29 Thread hadley wickham
On Mon, Sep 29, 2008 at 4:27 PM, Avram Aelony <[EMAIL PROTECTED]> wrote: > Hello, > > Although my summary descriptives are generated outside of R (dataset is > huge), I would like to produce a box-whisker plot using bxp or perhaps a > function from the ggplot2 library using the precomputed summarie

Re: [R] reshape package does not recognize second id variable

2008-09-28 Thread hadley wickham
On Sun, Sep 28, 2008 at 6:45 PM, Keith Schnakenberg <[EMAIL PROTECTED]> wrote: > I am trying to use the reshape package for the first time. I have two waves > of a survey, so the id variables include a subject identification number and > a variable denoting the wave of the survey. > > I used the fo

Re: [R] ggplot, getting two scales and one stat.

2008-09-27 Thread hadley wickham
On Sat, Sep 27, 2008 at 1:08 AM, Tylere Couture <[EMAIL PROTECTED]> wrote: > I have a simple plot: > > ggplot(polls, aes(x =Date, y = Popular_Support, colour=Party, shape=Source)) > + > stat_smooth(span=0.5) + > geom_point() > > How can I get the smooth to only render along one of the scales? ie, I

Re: [R] Return a list

2008-09-26 Thread hadley wickham
> it depends on what the original author wanted. > > with constructs a new environment, and all assignments, if any, made in > the expression evaluated within with are invisible to the outside > (unless one plays with environments, again): > > x = 1:10 > a = 3 > with(test(), { x[1:3] = c(a,b,c); x

Re: [R] Newbie: Ranking a data frame, grouped by 2 or more columns

2008-09-26 Thread hadley wickham
On Fri, Sep 26, 2008 at 3:54 PM, Matthew Pettis <[EMAIL PROTECTED]> wrote: > Hi, > > I'd like to rank obs in a data frame as subset by 2 or more columns... > The example input would look like the following: > > ++++ > x y v > -- -- -- > a w 200 > a w 100 > b w 500

Re: [R] looking for a better way to code a bar graph

2008-09-26 Thread hadley wickham
Hi Norman, This is pretty easy in ggplot2 (if you adjust your data a little): install.packages("ggplot2") library(ggplot2) days <- seq(Sys.Date(), len=100, by="1 day") df <- data.frame( date = rep(days, each = 3), trt = rep(c("A", "B", "C"), 50), price = runif(150) ) qplot(date, price

Re: [R] Equivalent of 'first.var' or 'last.var' from SAS in R?

2008-09-25 Thread hadley wickham
On Thu, Sep 25, 2008 at 2:00 PM, Matthew Pettis <[EMAIL PROTECTED]> wrote: > Hi, > > I want to sort a data frame by multiple columns and then take the > first record in each unique level of the "by" group I used to sort the > data frame. Does someone have an example of how to do this? > > Thanks,

Re: [R] ggplot, qplot in loop

2008-09-25 Thread hadley wickham
On Thu, Sep 25, 2008 at 6:17 AM, Albin Blaschka <[EMAIL PROTECTED]> wrote: > > Dear List, > > yes, me again trying to work with qplot ;-) > > I would like to make several single plots within a loop, like this > (simplified and so on...): > > trials <- c("A","B","C") > mycolours <- ("wheat","darkoli

Re: [R] ggplot: adding layer using different data, groups and also controlling appearance

2008-09-24 Thread hadley wickham
On Wed, Sep 24, 2008 at 7:57 PM, <[EMAIL PROTECTED]> wrote: > > > I have a more complicated function I am trying to write, but I run in to a > problem when I want to > add something to the plot from more than one data set while simultaneously > controlling the > appearance of the additional laye

Re: [R] How to convert backslash to slash?

2008-09-24 Thread hadley wickham
> I agree that that some sort of facility would be convenient. Creating > latex output is > another situation where not having to escape backslashes would be convenient. And regular expressions, of course. Hadley -- http://had.co.nz/ __ R-help@r-pro

Re: [R] qplot, stacked area, own colourscheme

2008-09-24 Thread hadley wickham
On Wed, Sep 24, 2008 at 8:39 AM, Albin Blaschka <[EMAIL PROTECTED]> wrote: > > Dear list, > > I would like to apply my own colours to a stacked area plot, done with > qplot, but I have not succeeded... > > What do I have so far (I am dealing with the development of cover of > specific groups of pla

Re: [R] How to convert backslash to slash?

2008-09-23 Thread hadley wickham
Except it's a bit tricker because: s <- "C:\foo\bar" print(s) You'd need to work with encodeString( "C:\foo\bar") but that won't work in general: "c:\xjobs" "c:\" "c:\help" Hadley On Tue, Sep 23, 2008 at 3:00 PM, Shengqiao Li <[EMAIL PROTECTED]> wrote: > > How to use sub, gsub, etc. to repla

Re: [R] xyplot problem

2008-09-23 Thread hadley wickham
On Tue, Sep 23, 2008 at 8:27 AM, Pascal A. Niklaus <[EMAIL PROTECTED]> wrote: > Hi all, > > I am trying to produce some panels with dots in an X/Y plane where the > diameter of the dots indicates a Z value (like e.g. earthquake maps where dot > sizes indicate magnitudes and X/Y the location). > > T

Re: [R] Generating series of distributions with the same skewness and different kurtosis or with same kurtosis and different skewness?

2008-09-23 Thread hadley wickham
On Tue, Sep 23, 2008 at 9:59 AM, zhijie zhang <[EMAIL PROTECTED]> wrote: > Dear R users, > I hope to explain the concepts of skewness and kurtosis by generating > series of distributions with same skewness and different kurtosis or with > same kurtosis and different skewness, but it seems that i

Re: [R] sort a data matrix by all the values and keep the names

2008-09-22 Thread hadley wickham
gt; x1 x2 x3 > 1 1 4 8 > 2 7 6 2 >> melt(x, id = c()) > Error in if (!missing(id.var) && !(id.var %in% varnames)) { : > missing value where TRUE/FALSE needed >> > > > Steve McKinney > > > -Original Message- > From: [EMAIL PROTECTE

Re: [R] suppress legend in ggplot(data, aes(y=Y, x=X,fill=Z))?

2008-09-22 Thread hadley wickham
On Sun, Sep 21, 2008 at 5:25 PM, Tom Bonen <[EMAIL PROTECTED]> wrote: > hi, > > is there any way to suppress the legend in ggplot(data, aes(y=Y, > x=X,fill=Z)) ? i'd like the values to be displayed in different colors > as specified by fill= and this works just fine. but i do not want to > have the

Re: [R] sort a data matrix by all the values and keep the names

2008-09-22 Thread hadley wickham
On Mon, Sep 22, 2008 at 6:54 PM, zhihuali <[EMAIL PROTECTED]> wrote: > > Dear all, > > If I have a data frame x<-data.frame(x1=c(1,7),x2=c(4,6),x3=c(8,2)): > x1 x2 x3 > 1 4 8 > 7 6 2 > > I want to sort the whole data and get this: > x1 1 > x3 2 > x2 4 > x2 6 > x1 7 > x3 8

Re: [R] Warranty on Accuracy, Precision, Legality, ... of R in Research

2008-09-22 Thread hadley wickham
On Mon, Sep 22, 2008 at 4:07 PM, Marc Schwartz <[EMAIL PROTECTED]> wrote: > on 09/22/2008 11:26 AM Bert Chan wrote: >> Warranty on Accuracy, Precision, Legality, ... of R in Research >> >> (These questions may well have been raised.) >> >> What is the implied warranty of using R for research & publ

Re: [R] adding layers in ggplot2 (data and code included)

2008-09-22 Thread hadley wickham
Hi Juliet, On Sun, Sep 21, 2008 at 11:47 PM, Juliet Hannah <[EMAIL PROTECTED]> wrote: > Here is some sample data: > > mydata <- read.table(textConnection("Est GroupTri > 00 4.639644 > 10 4.579189 > 20 4.590714 > 01 4.443696 > 1

Re: [R] diff() for panel data

2008-09-20 Thread hadley wickham
Hi Gabriel, On Sat, Sep 20, 2008 at 7:54 PM, Gabriel Paul Mihalache <[EMAIL PROTECTED]> wrote: > I was suggested that more details with help re: my question on first > differences in panel data... > The data set in question is PWT6.2: > >> str(pwt6.2) > 'data.frame': 10340 obs. of 27 variables:

Re: [R] fast value replacement in (numeric) vector

2008-09-20 Thread hadley wickham
On Sat, Sep 20, 2008 at 4:41 PM, Ling, Gary (Electronic Trading) <[EMAIL PROTECTED]> wrote: > Hi R users, > What is the fastest way to replace a(some) value(s) in a (numeric) > vector? > I checked ?replace, but its output is another vector. > 1) I wonder if there's any function to perform in-place

Re: [R] [R-gui] Tinn-R/Latex output

2008-09-19 Thread hadley wickham
On Fri, Sep 19, 2008 at 4:05 PM, Frank E Harrell Jr <[EMAIL PROTECTED]> wrote: > Mike Prager wrote: >> >> "David Carslaw" <[EMAIL PROTECTED]> wrote: >> >>> I find Tinn-R to be an excellent editor for R, but I have one question I >>> have not been able to answer. >>> I wish to include some R code i

Re: [R] Plot availability

2008-09-19 Thread hadley wickham
I really would encourage you to look at ggplot2 before trying to create something of your own. Your example would convert to the following ggplot2 code: df <- data.frame(x = 0:3, y = 3:0) plot <- ggplot() + xlim(-3, 3) + ylim(-3, 3) + opts(main = "Hello World") plot + geom_line(aes(x=x, y=y), df

Re: [R] ggplot2 and lattice

2008-09-19 Thread hadley wickham
On Fri, Sep 19, 2008 at 3:27 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > I am in the process of learning lattice graphics and have looked at > ggplot2 a little. I would like to know if there is a "tutorial" that > shows how to convert lattice code into ggplot code and vise versa. I > am final

Re: [R] Plot availability

2008-09-19 Thread hadley wickham
On Fri, Sep 19, 2008 at 1:00 PM, john crepezzi <[EMAIL PROTECTED]> wrote: > I'm not so sure the original way I stated my issue was clear enough, > so I'll attempt to elaborate a little bit. > > I'd like to make a function that is passed the name of a plot object, > and a lines/point specification,

Re: [R] Coloring spaces between lines in xyplot

2008-09-19 Thread hadley wickham
On Thu, Sep 18, 2008 at 5:14 PM, Seth W Bigelow <[EMAIL PROTECTED]> wrote: > > Greetings: > I wish to create a stacked line graph in xyplot, adding color to the > spaces between the lines. For example, the code below creates a plot with > two lines extending across it, and I want to color the rhom

Re: [R] reproduce this graph in ggplot2 (code and data included)

2008-09-19 Thread hadley wickham
Here's one way: qplot(degreedays, therms, data=heating, colour = Location, shape = Location) + geom_smooth(method = "lm", fullrange = T, se = F) Hadley On Fri, Sep 19, 2008 at 12:45 PM, Juliet Hannah <[EMAIL PROTECTED]> wrote: > How can I reproduce this graph in ggplot2 (regression lines and da

Re: [R] Reporting with down and across variables

2008-09-18 Thread hadley wickham
the variable > has to be named 'value'? > > On Thu, Sep 18, 2008 at 10:08 AM, hadley wickham <[EMAIL PROTECTED]> wrote: >> On Thu, Sep 18, 2008 at 10:03 AM, Matthew Pettis >> <[EMAIL PROTECTED]> wrote: >>> [Reposting with changed example] >>

Re: [R] Suggestion: Re: Fatal error .RData

2008-09-18 Thread hadley wickham
And does it need to be a fatal error? load("test.txt") doesn't produce a fatal error even though the file clearly isn't in the correct format. Or is there the possibility that loading a malformed rdata file introduces memory corruption? On Thu, Sep 18, 2008 at 9:55 AM, Henrik Bengtsson <[EMAIL PR

Re: [R] Problem installing packages in newer versions of R

2008-09-18 Thread hadley wickham
Hi Miha, One tip for diagnosing build problems is to ignore all warnings and look for the first error. In your case it's: init.c:2:15: error: R.h: No such file or directory init.c:3:24: error: Rinternals.h: No such file or directory Which possibly suggests that you don't have the necessary head

Re: [R] Reporting with down and across variables

2008-09-18 Thread hadley wickham
On Thu, Sep 18, 2008 at 10:03 AM, Matthew Pettis <[EMAIL PROTECTED]> wrote: > [Reposting with changed example] > Hi, > > I want to take the dataframe df generated below and reshape the data with > column names being w, x, y, and the different levels of z. The values under > the different levels of

Re: [R] ggplot2 - deprecated guide= argument in

2008-09-18 Thread hadley wickham
> As for now, I have not yet delved deep enough into the new version to be > sure if I like it or not. It's just that I like the freedom to choose, and > the previous form was great. Any chance you may put it back as an optional > parameter? I doubt it, but you can override the defaults as follows

Re: [R] matrix to list

2008-09-17 Thread hadley wickham
On Wed, Sep 17, 2008 at 8:52 PM, Pinder, Adrian <[EMAIL PROTECTED]> wrote: > Hi, can someone please tell me how to convert a square matrix to a list in R? > > i.e. I want to convert from: > >a b c > a 1 1 1 > b 2 2 2 > c 3 3

Re: [R] creating rainbow gradients

2008-09-17 Thread hadley wickham
On Wed, Sep 17, 2008 at 3:58 PM, Gillian Silver <[EMAIL PROTECTED]> wrote: > Hi, how can I create a rainbow gradient in R? For example, let's say I have > a plot of y = x...and I want the plot to go from red -> orange -> yellow -> > green -> blue -> etc. Why would you want to? See http://epub.wu-

Re: [R] Stacked Area Plot

2008-09-17 Thread hadley wickham
On Wed, Sep 17, 2008 at 1:01 PM, Josip Dasovic <[EMAIL PROTECTED]> wrote: > Hi: > > I've searched the archives and the Internet for hours but have yet to find a > way to do stacked area plots (like the kind in Excel) in R. I think that > polygon may work but it would require a bit of manipulatio

Re: [R] ggplot2 - deprecated guide= argument in

2008-09-17 Thread hadley wickham
On Wed, Sep 17, 2008 at 5:34 AM, Pedro Barros <[EMAIL PROTECTED]> wrote: > > In the help for scale_fill_identity, it is written > ## Not run: > colour <- c("red","green","blue","yellow") > qplot(1:4, 1:4, fill=colour, geom="tile") > qplot(1:4, 1:4, fill=colour, geom="tile")

Re: [R] Scatterplot with data grouped by color

2008-09-12 Thread hadley wickham
On Fri, Sep 12, 2008 at 5:29 PM, Amanda Young <[EMAIL PROTECTED]> wrote: > Hi, > I am a complete R rookie so this question is probably really simple > but I haven't found an answer on the web that I can understand. > > My data frame has 3 columns, A, B and C. A and B have numbers (about > 8000 rows

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-12 Thread hadley wickham
On Fri, Sep 12, 2008 at 10:53 AM, Jeff Ryan <[EMAIL PROTECTED]> wrote: > > I'm still not entirely sure I follow the desired usage, as the original post > made no reference to ggplot2, but as Gabor mentioned the yearmon etc stuff > is quite useful. Well, I said "I need to be able to correct draw da

Re: [R] plotCI -- multiple plots on same graph

2008-09-12 Thread hadley wickham
> I have a bunch of lines I want to plot using plotCI() > > What Id like to know is, how can I connect the points with a line and how > can I print multiple lines on the same graph? You might want to have a look at ggplot2, e.g. http://had.co.nz/ggplot2/geom_errorbar.html, for an alternative way t

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
> The problem is trying to force everything into Date class. If you really > want a monthly series you probably want yearmon rather than Date > class Could you give a bit more detail about why you think this is the best way to proceed? To me, it seems like it's easiest to have one date class whi

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
>> I don't think that cut.Date helps because I want to make a new series, >> not divide up an existing one, similarly with to.period. as.yearmon, > > Use cut.Date like this (assuming the dates variable as in your post): > > r <- as.Date(cut(range(dates), "month")) > > > # every month > seq(r[1], r

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
> Hadley, > > What's wrong with: > > dates <- structure(c(8516, 8544, 8568, 8596, 8609, 8666, 8701, 8750, > 8754, 8798, 8811, 8817, 8860, 8873, 8918, 8931, > 8966, 9020, 9034, 9056), class = "Date") > > The problem is this: > as.Date(cut.Date(dates, "day"))

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
On Thu, Sep 11, 2008 at 2:26 PM, Jeffrey J. Hallman <[EMAIL PROTECTED]> wrote: > Look at the ti (Time Index) class in package tis. Here's some examples I > just did: >> x <- Sys.Date() >> x > [1] "2008-09-11" >> ti(x, "wsaturday") ## a ti for the week that x falls into > [1] 20080913 > clas

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
On Thu, Sep 11, 2008 at 11:00 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > See ?cut.Date > > In the zoo package see: > ?as.yearmon > ?as.yearqtr > ?aggregate.zoo > > and the many examples in: > ?plot.zoo > ?xyplot.zoo > as well as the three zoo vignettes. > > Also in the xts package look at

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
On Thu, Sep 11, 2008 at 12:04 PM, Whit Armstrong <[EMAIL PROTECTED]> wrote: > probably not pre-canned routines for that, but very easy to implement > with the tools provided in the library. > > Looks like most of what you want to do is fairly simple and not worth > the trouble of involving c++. > >

Re: [R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
> I'm wrapping boost date_time into an R package. I'll post it up to > cran shortly. > > http://www.boost.org/doc/libs/1_36_0/doc/html/date_time.html > > I'm not sure if that is what you are looking for, but there are a lot > of useful utilities in this library. Looks useful, but I didn't see any

[R] Truncating dates (and other date-time manipulations)

2008-09-11 Thread hadley wickham
Dear all, I've been struggling to perform common operations on dates that I need to be able to correct draw date-time scales - in particular I need to be able to round/truncate/ceiling dates to arbitrary precision - e.g. to weeks, months or years (or multiples thereof). I haven't been able to fin

Re: [R] All possible pairs of two variables

2008-09-11 Thread hadley wickham
On Wed, Sep 10, 2008 at 11:34 PM, Ron Michael <[EMAIL PROTECTED]> wrote: > I have two variables (x,y) : > > x : it takes all integer values from 0 to y and, > y : takes all values from 0, 10 > > I am looking for some R code to find all possible pairs of (x,y). Can anyone > please help me? ?expand

Re: [R] mixed model MANCOVA

2008-09-10 Thread hadley wickham
On Mon, Sep 8, 2008 at 1:06 PM, Erika Crispo <[EMAIL PROTECTED]> wrote: > Hello, > > I need to perform a mixed-model (with nesting) MANCOVA, using Type III sums > of squares. I know how to perform each of these types of tests individually, > but I am not sure if performing a mixed-model MANCOVA i

Re: [R] ggplot2: edge outlines on points

2008-09-10 Thread hadley wickham
Hi Adam, The next version of ggplot2 supports the build-in R plotting symbols that have different fills and borders, so you can do something like: geom_point(aes(colour=TRT), fill="red", colour="black", shape=21) Otherwise in the current version you can do: ggplot(data.frame(x = runif(20), y =

Re: [R] exporting tapply objects to csv-files

2008-09-09 Thread hadley wickham
On Tue, Sep 9, 2008 at 3:48 AM, Kunzler, Andreas <[EMAIL PROTECTED]> wrote: > Dear Everyone, > > I try to create a cvs-file with different results form the table function. > > Imagine a data-frame with two vectors a and b where b is of the class factor. > > I use the tapply function to count a for

<    6   7   8   9   10   11   12   13   14   15   >