Re: [R] help converting for loop to vector operation

2009-04-29 Thread Avram Aelony
Dear List, Hadley offered the following solution: >library(plyr) >l_ply(2:6, draw_metric_by_date, df = economics, smooth = TRUE, BASEPATH = >basepath) Many thanks, Avram On Wednesday, April 29, 2009, at 12:59PM, "Avram Aelony" wrote: > >Dear List, > >I have a wrapper function that d

Re: [R] help converting for loop to vector operation

2009-04-29 Thread baptiste auguie
Hi, Here's one approach that I find perhaps more elegant than sweeping through the columns by their index, library(ggplot2) data(economics) str(economics) # library(reshape) d <- melt(economics, id="date") foo <- function(var="pop", d, smooth=FALSE, ... ) { p <- qplot( data=subs

[R] help converting for loop to vector operation

2009-04-29 Thread Avram Aelony
Dear List, I have a wrapper function that draws a graph that I'd like to use in a vector-like manner. The for-loop version I currently use is below. library(ggplot2) data(economics) h <- 600 w <- 800 #-- draw_metric_by_date <- functio