Re: [R] sum specific rows in a data frame

2010-04-15 Thread hadley wickham
to release that version? On Thu, Apr 15, 2010 at 9:09 AM, hadley wickham h.wick...@gmail.com wrote: On Thu, Apr 15, 2010 at 1:16 AM, Chuck vijay.n...@gmail.com wrote: Depending on the size of the dataframe and the operations you are trying to perform, aggregate or ddply may be better

Re: [R] Combining ggplot2 objects and/or extracting layers

2010-04-09 Thread hadley wickham
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 trying

Re: [R] error bars on barplot

2010-04-09 Thread hadley wickham
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 University

Re: [R] Using read.table to read file created with read.table and qmethod = escape

2010-04-08 Thread Hadley Wickham
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.table and read.table

Re: [R] Using read.table to read file created with read.table and qmethod = escape

2010-04-08 Thread Hadley Wickham
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.

Re: [R] Using read.table to read file created with read.table and qmethod = escape

2010-04-08 Thread Hadley Wickham
On Thu, Apr 8, 2010 at 8:20 AM, jim holtman jholt...@gmail.com 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,

Re: [R] Strange csv parsing problem

2010-04-08 Thread Hadley Wickham
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

Re: [R] ggplot2, density barplot and geom_point layer

2010-04-07 Thread hadley wickham
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 johannes_graum...@web.de wrote: Hi, Please consider the example below. How can I

[R] Using read.table to read file created with read.table and qmethod = escape

2010-04-07 Thread Hadley Wickham
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 final line found

[R] Strange csv parsing problem

2010-04-07 Thread Hadley Wickham
url - http://dl.dropbox.com/u/41902/22240.csv; read.csv(url)[, 1] [1] oppose NAoppose 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]

Re: [R] SAS and R on multiple operating systems

2010-04-06 Thread hadley wickham
 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

Re: [R] Sharing levels across multiple factor vectors

2010-04-01 Thread hadley wickham
On Thu, Apr 1, 2010 at 3:05 AM, Peter Dalgaard pda...@gmail.com 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

Re: [R] sample size 20K? Was: fitness of regression tree: how to measure???

2010-04-01 Thread hadley wickham
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 infer

Re: [R] regular expression help to extract specific strings from text

2010-03-31 Thread hadley wickham
On Wed, Mar 31, 2010 at 8:20 AM, Tony B tony.bre...@googlemail.com 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!

Re: [R] Competing with SPSS and SAS: improving code that loops through rows (data manipulation)

2010-03-27 Thread hadley wickham
# 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', sep =

Re: [R] Competing with SPSS and SAS: improving code that loops throughrows (data manipulation)

2010-03-27 Thread hadley wickham
 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/

Re: [R] flexible alternative to subsetting dataframe inside nested loops

2010-03-24 Thread hadley wickham
On Wed, Mar 24, 2010 at 8:52 AM, mgierdal mgier...@gmail.com 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

Re: [R] GGPLOT2: Reverse order of legend to match order of x-axis

2010-03-24 Thread hadley wickham
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 ryan.steven.gar...@gmail.com wrote: How do I reverse the order of the legend in a bar plot to match order of the

[R] Encrypt/decrypt in R

2010-03-19 Thread Hadley Wickham
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

Re: [R] Encrypt/decrypt in R

2010-03-19 Thread Hadley Wickham
On Fri, Mar 19, 2010 at 12:35 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Fri, Mar 19, 2010 at 5:10 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Fri, Mar 19, 2010 at 5:00 PM, Hadley Wickham had...@rice.edu wrote: Hi all, Does any one know of any encryption

Re: [R] Retrieving latitude and longitude via Google Maps API

2010-03-16 Thread hadley wickham
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 google

Re: [R] likelihood ratio test between glmer and glm

2010-03-14 Thread hadley wickham
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, df) -

[R] [R-pkgs] ggplot2: version 0.8.7

2010-03-13 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

Re: [R] ggplot2: varwidth-equivalent for geom_boxplot?

2010-03-11 Thread hadley wickham
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: What is varwidth? Hadley On Wed, Mar 10, 2010 at 1:55 PM

Re: [R] ggplot2 rose diagram

2010-03-10 Thread hadley wickham
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 tghow...@gw.dec.state.ny.us wrote: To answer two of my own questions to get them into the archives (I am slowly getting the hang of ggplot):

Re: [R] ggplot2 rose diagram

2010-03-10 Thread hadley wickham
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 moving

Re: [R] Help with aggregate and cor

2010-03-10 Thread hadley wickham
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 Statistics

Re: [R] Why can't apply be used with as.factor on a data.frame ?

2010-03-07 Thread hadley wickham
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,

Re: [R] vectorizing ANOVA over a vectorized linear model

2010-03-07 Thread hadley wickham
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

Re: [R] vectorizing ANOVA over a vectorized linear model

2010-03-07 Thread hadley wickham
please On Sun, Mar 7, 2010 at 2:08 PM, hadley wickham h.wick...@gmail.com wrote: 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

Re: [R] two questions for R beginners

2010-03-01 Thread hadley wickham
One of the things about R which many (and that certainly includes me) have to find out the hard way is that you have to *learn* what to expect! You can't just import it from prior experience in other contexts. So, by the time you have learned that a matrix is such that all its elements must

Re: [R] two questions for R beginners

2010-03-01 Thread hadley wickham
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 one

Re: [R] ggplot2 : bug in coord_equal() ?

2010-02-26 Thread hadley wickham
Hi David, That's the behaviour I'd expect - the plot is 5 x 13000. What were you expecting? Hadley On Fri, Feb 26, 2010 at 8:06 AM, David Hajage dhajag...@gmail.com wrote: Hello, I think there is a bug in coord_equal when x s a factor : ggplot(diamonds, aes(clarity, fill=cut)) +

Re: [R] How to use a 'hidden' function directly?

2010-02-24 Thread hadley wickham
Try: stats:::R_pansari Hadley On Wed, Feb 24, 2010 at 7:55 PM, Dale Steele dale.w.ste...@gmail.com wrote: Thanks, when I modify the function as I think you suggest, I get the following error: qansari  - function(p, m, n) {                .C(R_qansari, as.integer(length(p)), q =

[R] [R-pkgs] ggplot2: version 0.8.6

2010-02-19 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

Re: [R] Need help on boxplot panel chart

2010-02-15 Thread hadley wickham
Hi Doug, Could you please provide a reproducible example? It's difficult to diagnose the problem without one. Hadley On Fri, Feb 12, 2010 at 2:46 PM, DougNiu d...@umn.edu wrote: Hi there: I am new to R and creating a boxplot panel chart to show a test result. I have four output variables

Re: [R] argh .. if/else .. why?

2010-02-15 Thread hadley wickham
I, personally, utilize the ifelse(test,statement,statement) function when possible over the methodology outlined. if + else and ifelse perform quite different tasks, and in general can not (and should not) be exchanged. In particular, note that for ifelse, the class attribute of the result is

Re: [R] Problems with boxplot in ggplot2:qplot

2010-02-15 Thread hadley wickham
Hi Dimitri, Have you looked at the examples for scale_x_date - http://had.co.nz/ggplot2/scale_date.html? They show you how to both set the limits and control the labels. Hadley On Sun, Feb 14, 2010 at 1:34 PM, Dimitri Shvorob dimitri.shvo...@gmail.com wrote: ... Unfortunately, a problem

Re: [R] Problems with boxplot in ggplot2:qplot

2010-02-15 Thread hadley wickham
Without a reproducible example, it's impossible to give you any more suggestions. Hadley On Mon, Feb 15, 2010 at 2:16 PM, Dimitri Shvorob dimitri.shvo...@gmail.com wrote: Trying + scale_x_date(format = %b) produces a peculiar result: Apr and Dec facets are labeled Jan, remaining labels

Re: [R] R ggplot2 legend text left justify

2010-02-09 Thread hadley wickham
Hi Paul, That's a bug in the current version of ggplot. I'm working on update for later this week. Hadley On Mon, Feb 8, 2010 at 5:56 PM, Paul Sutcliffe psutc...@it.uts.edu.au wrote: In ggplot2 how do you justify the legend text ? In the example below the opts(legend.text = theme_text(size

Re: [R] Fast way to determine number of lines in a file

2010-02-09 Thread hadley wickham
I was looking for a fast line counter as well a while ago and ended up writing a small function in R:  countLines() in the R.utils package At least at the time, it was faster than readLines() [for unknown reasons].  It is also more memory efficient.  It supports connections.  I don't think

Re: [R] ggplot2 stacked line plot

2010-02-09 Thread hadley wickham
Hi Liam, Your syntax is a little off. You want: p - ggplot2(~, aes(x = ~, y = ~, colour = Type)) + geom_area(aes(fill = Type), position = 'stack') Position isn't an aesthetic. Hadley On Sun, Feb 7, 2010 at 10:40 PM, Liam Blanckenberg liam.blanckenb...@gmail.com wrote: Hi all, I have

Re: [R] ggplot2 stacked line plot

2010-02-09 Thread hadley wickham
only a line for each (stacked) Type's value... I hope this is somewhat clear! Many thanks, Liam On Wed, Feb 10, 2010 at 1:53 AM, hadley wickham h.wick...@gmail.com wrote: Hi Liam, Your syntax is a little off.  You want: p - ggplot2(~, aes(x = ~, y = ~, colour = Type

[R] Fast way to determine number of lines in a file

2010-02-08 Thread Hadley Wickham
Hi all, Is there a fast way to determine the number of lines in a file? I'm looking for something like count.lines analogous to count.fields. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list

Re: [R] Fast way to determine number of lines in a file

2010-02-08 Thread Hadley Wickham
parser::nlines does it in C. Looks promising, but I need something that uses connections because I'm working with big bzipped files. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Fast way to determine number of lines in a file

2010-02-08 Thread hadley wickham
Hi Ken, How about something like length(readLines(fname)) I'm trying to avoid the overhead of reading the file in twice. (I'm trying to preallocate a data structure for a chunked read) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing

Re: [R] conditioned xyplot, many y variables

2010-02-07 Thread hadley wickham
On Sun, Feb 7, 2010 at 11:32 AM, Jacob Wegelin jacobwege...@fastmail.fm wrote: The example below creates parallel time-series plots of three different y variables conditioned by a dichotomous factor. In the graphical layout,        •       Each y variable inhabits its own row and is plotted

Re: [R] melt on OSX ignores na.rm=T

2010-02-06 Thread hadley wickham
Hi Titus, The latest version of reshape is 0.8.3 - perhaps upgrading will fix your problem. Hadley On Sat, Feb 6, 2010 at 4:51 AM, Titus von der Malsburg malsb...@gmail.com wrote: Hi list, I run R on Linux and OSX.  On both systems I use R version 2.9.2 (2009-08-24) and reshape version:

Re: [R] String Manipulation- Extract numerical and alphanumerical segment

2010-02-05 Thread hadley wickham
On Fri, Feb 5, 2010 at 9:29 AM, jim holtman jholt...@gmail.com wrote: Does this help: x - c(1234567.z3.abcdef-gh.12,1234567.z3.abcdef-gh.12,1234567.z3.abcdef-gh.12) y - strsplit(x, '[.]') Here's another way with the stringr package: library(stringr) x -

Re: [R] typo in contrast package's vignettes

2010-02-03 Thread hadley wickham
Really? Where exactly is the loophole in 'If the question relates to a contributed package ... try contacting the package maintainer first.'? How about the general R philosophy that if you dare to mistakenly submit a bug report that turns out to be a feature, not a bug, you shall be well and

Re: [R] tapply for function taking of 1 argument?

2010-02-03 Thread hadley wickham
On Wed, Feb 3, 2010 at 11:06 AM, David Freedman 3.14da...@gmail.com wrote: also, library(plyr) ddply(d,~grp,function(df) weighted.mean(df$x,df$w)) Or ddply(d, grp, summarise, mean = weighted.mean(x, w)) which is convenient if you want more than one output Hadley -- http://had.co.nz/

Re: [R] tapply for function taking of 1 argument?

2010-02-03 Thread hadley wickham
It will of necessity be slower (because there's more machinery underlying the sqldf package); but I doubt whether it would be noticeably slower than the native R solution in most practical situations. The same would be true for plyR's implementation (it relies on the proto package, which slows

Re: [R] ggplot2/qplot question regarding reducing the no. of x-axis labels

2010-02-03 Thread hadley wickham
Hi Thomas, Please provide a reproducible example. The most likely explanation is that after loading your data you haven't converted your date variable from a factor into a real date. Hadley On Wed, Feb 3, 2010 at 1:15 PM, Thomas Adams thomas.ad...@noaa.gov wrote: All: I am using the

Re: [R] Calculating subsets on the fly with ddply

2010-02-03 Thread hadley wickham
The ddply invocation would look like so: R my - ddply(iris, .(w=Sepal.Length 5.5, Species), transform, grmean=mean(Petal.Width)) R head(my)      w Sepal.Length Sepal.Width Petal.Length Petal.Width    Species grmean 1 FALSE          5.8         4.0          1.2         0.2     setosa

Re: [R] Using apply function on duplicates in a data.frame

2010-01-31 Thread hadley wickham
On Sun, Jan 31, 2010 at 5:05 PM, Sunny Srivastava research.b...@gmail.com wrote: Dear R-Helpers, I have a data.frame (df) and the head of data.frame looks like     ProbeUID ControlType     ProbeName GeneName SystematicName 1665     1577           0 pSysX_50_22_1 pSysX_50       pSysX_50 5422  

Re: [R] SemiPar/spm question

2010-01-30 Thread hadley wickham
Hi Chuck, It looks like a scoping bug in spmx to me: f - function() { x - data[data$id==111,] print(spm(x$value ~ f(1:nrow(x } f() I'd suggest you contact the package maintainer directly. Hadley On Fri, Jan 29, 2010 at 1:34 PM, Chuck White chuckwhi...@charter.net wrote: Hello -- I

Re: [R] Strange tick in ggplot geom_area; and ordering, again

2010-01-26 Thread hadley wickham
Hi Dieter, It looks like a bug: Order works fine with bars: qplot(factor(dur),weight=p,data=cf1, fill=score, geom = bar, order = rev(score)) but not with areas: qplot(dur, p, data=cf1, fill=score, geom = area, order = rev(score)) I'll add it to my to do list. Hadley On Tue, Jan 26, 2010 at

Re: [R] Strange tick in ggplot geom_area; and ordering, again

2010-01-26 Thread hadley wickham
can you also reproduce the “triangles” problem? Is it just a trivial corollary of the order-bug? The triangles are there because you have a layer of points (from the qplot default) and layer of areas. Setting geom = area in qplot fixes that. Hadley -- http://had.co.nz/

Re: [R] Strange tick in ggplot geom_area; and ordering, again

2010-01-26 Thread hadley wickham
In case you have a temporary workaround, it would be nice to have it. It’s a show stopper for my report. Bars are not an option, because the curve looks too jaggy. I just remember that to work around the problem, you can just manually order the data frame: cf1 - cf1[with(cf1, order(dur,

Re: [R] read multiple large files into one dataframe

2010-01-25 Thread hadley wickham
On Mon, Jan 25, 2010 at 4:43 AM, Paul Hiemstra p.hiems...@geo.uu.nl wrote: Brad Patrick Schneid wrote: ###  The following is very helpful # listOfFiles - list.files(pattern= .txt) d - do.call(rbind, lapply(listOfFiles, read.table)) ### but what if each

Re: [R] standardizing one variable by dividing each value by the mean - but within levels of a factor

2010-01-21 Thread hadley wickham
On Wed, Jan 20, 2010 at 4:37 PM, Dimitri Liakhovitski ld7...@gmail.com wrote: Hello! I have a data frame with a factor and a numeric variable: x-data.frame(factor=c(b,b,d,d,e,e),values=c(1,2,10,20,100,200)) For each level of factor - I would like to divide each value of values by the mean

Re: [R] problem of data manipulation

2010-01-20 Thread hadley wickham
Note that in the documentaton ?[.data.table where I say that 'by' is slow, I mean relative to how fast it could be.  Its seems, in this specific example anyway, and with the code posted so far, to be significantly faster than sqldf and plyr. Of course the best of both worlds would be to use

Re: [R] problem of data manipulation

2010-01-20 Thread hadley wickham
On Wed, Jan 20, 2010 at 8:43 AM, Matthew Dowle mdo...@mdowle.plus.com wrote: Sounds like a good idea. Would it be possible to give an example of how to combine plyr with data.table, and why that is better than a data.table only solution ? Well, ideally, you'd do: adt - data.table(a) ans2 -

Re: [R] problem of data manipulation

2010-01-19 Thread hadley wickham
On Mon, Jan 18, 2010 at 1:54 PM, Bert Gunter gunter.ber...@gene.com wrote: One way to do it: 1. Convert your date column to the Date class using the as.Date() function. This allows you to do the necessary arithmetic on the dates below. dt - as.Date(a[,4],%d/%m/%Y) 2. Create a factor out of

Re: [R] Help using Cast (Text) Version

2010-01-18 Thread hadley wickham
If you can point me towards a doc that explains this in simple terms I would be obliged. Don't expect you to have to provide the answer. Any of the introductory texts should explain the various forms of indexing and the use of the apply family of functions. They are both central to effective

Re: [R] How to convert character matrix or data.frame to numeric?

2010-01-18 Thread hadley wickham
Ouch!   Hmmm.   From the Value section of the apply docs... If each call to FUN returns a vector of length n, then apply returns an array of dimension c(n, dim(X)[MARGIN]) if n 1.  Since I set MARGIN to 1, then I was operating on rows where n  is 3. c(n, dim(X)[MARGIN]) [1] 3 2 How about

Re: [R] Can an object reference itself?

2010-01-15 Thread hadley wickham
On Fri, Jan 15, 2010 at 5:30 PM, Janko Thyson janko.thy...@ku-eichstaett.de wrote: Dear List, I am not really familiar with any other language than R, but I’ve heard that in other languages there is something called “self referencing”. Here’s what I’m trying to get an answer for: Suppose

Re: [R] Building static HTML help pages in R 2.10.x on Windows

2010-01-08 Thread hadley wickham
I see. Well, I never lacked any of these capabilities... Please understand that people who use R to do their work may have different objectives than the developers - and they form the majority of R users. Well how about a documentation system that could look back over your history and notice

[R] Online R documentation

2010-01-08 Thread Hadley Wickham
Dear list, Many people seem unhappy with the new documentation server because you need to have R running to access it, and it's not immediately obvious how to bookmark references so they work long-term. One solution to this problem is to have a globally available website that provides access to

Re: [R] Online R documentation

2010-01-08 Thread Hadley Wickham
Many people seem unhappy with the new documentation server because you need to have R running to access it, and it's not immediately obvious how to bookmark references so they work long-term. One solution to this problem is to have a globally available website that provides access to all

Re: [R] Online R documentation

2010-01-08 Thread Hadley Wickham
http://pledgie.com/campaigns/7707 - here you can donate as much or as little as you like to support this project.  You won't pay until the total amount has been pledged. I misread the documentation - do you actually pay right away. If I don't reach the $1000, I'll pass on the money to a good

Re: [R] plyr: issue with column names when converting one element list to dataframe

2010-01-08 Thread hadley wickham
: dput(l) list(structure(c(0.182198327359618, 0.473715651135006, 0.29689366786141, 0.0471923536439665), .Dim = c(1L, 4L), .Dimnames = list(f5_9,    c((0.5,1.5], (1.5,2.5], (2.5,3.5], (3.5,4.5] Mark Am 06.01.2010 um 15:48 schrieb hadley wickham: Hi Mark, Could you send a the results

Re: [R] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread hadley wickham
What I'd really like is for someone who has good taste to redesign the look of the whole system.  I think one or two people are working on packages to do this, and I'd much rather spend time providing whatever low level support they need, rather than doing it myself. Have you looked at adding

Re: [R] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread hadley wickham
 I have to close all the tabs and call help to open them again.  Also, the R-supplied java tool for searching help is ancient and underwhelming. Then contribute a new one. And this would be pretty easy to, since you can program it in R. There are heaps of possibilities - you could use do

Re: [R] plyr: issue with column names when converting one element list to dataframe

2010-01-06 Thread hadley wickham
Hi Mark, Could you send a the results of dput(l)? It will make exploration easier. Hadley On Wed, Jan 6, 2010 at 8:07 AM, Mark Heckmann mark.heckm...@gmx.de wrote: Hi, I have an issue concerning plyr. I have a list l as output from dlply. l $`1`     (0.5,1.5] (1.5,2.5] (2.5,3.5]  

[R] [R-pkgs] ggplot2 version 0.8.5

2009-12-22 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

Re: [R] expand.grid game

2009-12-19 Thread hadley wickham
I hope I have missed a better way to do this in R. Otherwise, I believe what I'm after is some kind of C or C++ macro expansion, because the number of loops should not be hard coded. Why not generate the list of integers that sum to 17, and then mix with 0s as appropriate? Hadley --

Re: [R] Is there lazy copy in R?

2009-12-14 Thread hadley wickham
I don't understand what these addresses mean. Would you please help me understand it? Did you try reading the documentation? When an object is traced any copying of the object by the C function ‘duplicate’ or by arithmetic or mathematical operations produces a message to

Re: [R] Sources for open sourced homework questions for R?

2009-12-11 Thread hadley wickham
Hi Dave, I have a few drills available from http://had.co.nz/stat405 - see the right hand column, about half way down. They seem similar in spirit to what you're thinking of. You might want to look at the Little Schemer for a similar approach with a different programming language. However, I'm

Re: [R] Why a list of NULL's are reduced to NULL?

2009-12-11 Thread hadley wickham
A very common situation is that the users don't know all the possible return types of 'some_third_party_function()'. If the users don't know all the return types, he/she can not make sure the return type of function(x) {...} be always the same. How do you deal with this case? It's not that

Re: [R] ggplot: Problem with legend background

2009-12-11 Thread hadley wickham
Hi Luc, You want: legend.title=theme_text(size=20, hjust = 0) So the legend title is left aligned, not centred. Hadley On Fri, Dec 11, 2009 at 9:26 AM, MUHC_Research villa...@dms.umontreal.ca wrote: Dear R-users, I am preparing graphs for an upcoming article using the different functions

Re: [R] Fwd: Evaluating a function within a pre-defined environment?

2009-12-10 Thread hadley wickham
On Wed, Dec 9, 2009 at 4:48 PM, David Reiss dre...@systemsbiology.org wrote: Ideally I would like to be able to use the function f (in my example) as-is, without having to designate the environment as an argument, or to otherwise have to use e$x in the function body. e - new.env() e$x - 3 f -

Re: [R] About R memory management?

2009-12-10 Thread hadley wickham
For the case below, you don't need to know anything about how R manages memory, but you do need to understand basic concepts algorithmic complexity. You might find The Algorithm Design Manual, http://www.amazon.com/dp/1848000693, a good start. Hadley On Thu, Dec 10, 2009 at 10:26 AM, Peng Yu

Re: [R] barplot and cumulative curve using ggplot2 layers

2009-12-10 Thread hadley wickham
Hi Sunita, To get the bars, you want: ggplot(mydata, aes(x = factor(jobno), y = recruits)) + geom_bar() and to add the cumulative sum, first add it to the data: mydata$cum_ recruits - cumsum(mydata$recruits) and then add another layer: + geom_line(aes(y = cum_recruits, group = 1)) Hadley

[R] [R-pkgs] ggplot2: version 0.8.4

2009-12-10 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

Re: [R] How to get rid of NULL in the result of apply()?

2009-12-10 Thread hadley wickham
Is there a version of apply that returns a list without NULL's? I try to remove NULL elements in the following example, but neither for loops work. Would you please let me know what the correct way is? Try this function: compact - function(x) Filter(Negate(is.null), x) compact(x) Hadley

Re: [R] Assigning variables into an environment.

2009-12-09 Thread hadley wickham
On Wed, Dec 9, 2009 at 9:43 PM, Rolf Turner r.tur...@auckland.ac.nz wrote: I am working with a somewhat complicated structure in which I need to deal with a function that takes ``basic'' arguments and also depends on a number of parameters which change depending on circumstances. I thought

Re: [R] problem with split eating giga-bytes of memory

2009-12-08 Thread hadley wickham
Hi Mark, Why are you using factors? I think for this case you might find characters are faster and more space efficient. Alternatively, you can have a look at the plyr package which uses some tricks to keep memory usage down. Hadley On Tue, Dec 8, 2009 at 9:46 PM, Mark Kimpel

Re: [R] [ggplot2] Wind rose orientation

2009-12-07 Thread hadley wickham
The idea of plotting a wind rose must be fairly common.  I wonder if it would make sense to have a switch that would wrap data around the ends of a continuous scale? Probably - but it requires a lot of work, because ggplot2 doesn't currently support circular scales, which is what you really

Re: [R] [GGPLOT] Legends at different layers

2009-12-07 Thread hadley wickham
You mean: dat - data.frame(x = rnorm(100)) dat1 - data.frame( x = c(0,0), y = c(1,0), Label = c(Point1, Point2) ) ggplot(dat, aes(x)) + geom_histogram(aes(fill = ..count..)) + geom_point(aes(x, y, colour = Label), data = dat1, size = 4) + scale_fill_gradient(Count, low = green, high

Re: [R] [ggplot2] Wind rose orientation

2009-12-06 Thread hadley wickham
wind rose with another package and wait patiently until ggplot2 plots the full compass. Thanks again for a terrific software package. All the best, Tom Begin forwarded message: From: Thomas S. Dye t...@tsdye.com Date: December 3, 2009 9:42:27 PM HST To: hadley wickham h.wick...@gmail.com

Re: [R] Data Manipulation Question

2009-12-03 Thread hadley wickham
On Thu, Dec 3, 2009 at 3:52 PM, John Filben johnfil...@yahoo.com wrote: Can R support data manipulation programming that is available in the SAS datastep?  Specifically, can R support the following: -  Read multiple dataset one record at a time and compare values from each; then base

Re: [R] Scraping a web page

2009-12-03 Thread hadley wickham
If you're after text, then it's probably a matter of locating the element that encloses the data you want-- perhaps by using getNodeSet along with an XPath[1] that specifies the element you are interest with.  The text can then be recovered using the xmlValue() function. And rather than

Re: [R] [ggplot2] Wind rose orientation

2009-12-03 Thread hadley wickham
Hi Thomas, I suspect you want geom_bar(stat = identity, width = 1), but it's hard to be sure without a reproducible example. Hadley On Thu, Dec 3, 2009 at 8:18 PM, Thomas S. Dye t...@tsdye.com wrote: Aloha all, I love using ggplot.  It took a while to get used to the grammar of graphics,

Re: [R] How to get a matrix by sapply (with strsplit)?

2009-12-03 Thread hadley wickham
I'm not sure what the other lines(but the last) have to do anything, but are you looking for something like this: do.call(rbind, sapply(paste(1:10, 1:10), strsplit, split=' ')) strsplit is already vectorised wrt its first argument, so all you need is: do.call(rbind, strsplit(paste(1:10,

Re: [R] [ggplot2] Wind rose orientation

2009-12-03 Thread hadley wickham
the best, Tom On Dec 3, 2009, at 4:35 PM, hadley wickham wrote: Hi Thomas, I suspect you want  geom_bar(stat = identity, width = 1), but it's hard to be sure without a reproducible example. Hadley On Thu, Dec 3, 2009 at 8:18 PM, Thomas S. Dye t...@tsdye.com wrote: Aloha all, I love

Re: [R] ggplot legend for multiple time series

2009-12-01 Thread hadley wickham
Because of the combinatorial nature of ggplot2, it is simply not possible to provide an example that illustrates every single combination of options. There are already over 600 example graphics in the package - if you can't find one that exactly meets your need, you need to buy the book and learn

Re: [R] reshape question

2009-11-24 Thread hadley wickham
I don't really understand what you want and the example solution throws away quite a lot of data, so consider this alternative: data.out2 - read.table(textConnection(id   rater.1 n.1   rater.2 n.2 rater.3 n.3   rater.4 n.4 11   11 0.118  79        NA  NA        NA  NA        NA  NA 114

Re: [R] Check if string has all alphabets or numbers

2009-11-23 Thread hadley wickham
mywords- c(harry,met,sally,subway10,1800Movies,12345, not correct 123) all.letters - grep(^[[:alpha:]]*$, mywords) all.numbers - grep(^[[:digit:]]*$, mywords)  # numbers mixed - grep(^[[:digit:][:alpha:]]*$, mywords) mywords- c(harry,met,sally,subway10,1800Movies,12345, not correct 123, )

Re: [R] how to tell if its better to standardize your data matrix first when you do principal

2009-11-22 Thread hadley wickham
You've asked the same question on stackoverflow.com and received the same answer. This is rude because it duplicates effort. If you urgently need a response to a question, perhaps you should consider paying for it. Hadley On Sun, Nov 22, 2009 at 12:04 PM, masterinex xevilgan...@hotmail.com

<    1   2   3   4   5   6   7   8   9   10   >