Re: [R] Accessing list names in lapply

2009-11-20 Thread SIES 73
Yet another possibility is to iterate on both values and names simultaneously using mapply(): df1 <- split( x=rnorm(n=100, sd=seq(from=1, to=10, each=10)), f=letters[seq(from=1, to=10, each=10)] ) mapply(function(x, y) plot(x, ylab=y), df1, names(df1)) Enrique -Original Message---

Re: [R] array slice notation?

2009-08-06 Thread SIES 73
Hi, The do.call() version is likely slower than the vector version. To select multiple rows, just replace the 1 by the vector with the rows. The TRUEs in the list fail if the array happens to have 0 length in the corresponding dimension. You can build the list passed to do.call() first setting

Re: [R] Application logging in R

2009-07-22 Thread SIES 73
Hi Brian, In general, R lacks many utilities for "applications". I'd say it's more focused on "one-shot" analysis, what is logic given its origin in statistics/academics. Few packages deal with these types of "application automation". Logging is already addressed in some packages: you should ha

Re: [R] R-help Digest, Vol 77, Issue 9

2009-07-09 Thread SIES 73
Hi, This may be due to several reasons. That I can think about: 1) Ensure you close *all* possibly open workbooks: nBooks <- xl[["Workbooks"]]$Count(); for (i in seq_len(nBooks)) xl[["Workbooks"]]$item(i)$Close(SaveChanges=FALSE); 2) The excel application referen

Re: [R] Dump plots to powerpoint?

2009-07-08 Thread SIES 73
Hi, On windows, you can use a COM client (with packages like rcom or RDCOMClient) to control powerpoint from R and insert the generated image using powerpoint's object model. You can either use the clipboard or an intermediate image file saved to disk. Not hard to do, but this seems to be alre

Re: [R] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-25 Thread SIES 73
mapply(function(x, class) match.fun(paste("as", class, > sep="."))(x), x, colClasses("Dif"), SIMPLIFY=FALSE), stringsAsFactors=FALSE) Enrique -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: jueves, 25 de junio d

Re: [R] Apply as.factor (or as.numeric etc) to multiple columns

2009-06-25 Thread SIES 73
Hi Mark, I frequently need to do that when importing data. This one-liner works: > data.frame(mapply(as, x, c("integer", "character", "factor"), > SIMPLIFY=FALSE), stringsAsFactors=FALSE); but it has two problems: 1) as() is an S4 method that does not always work 2) writting the vector of cla

Re: [R] How to get legend outside of plot?

2009-01-14 Thread SIES 73
> How can I create a legend that is fully outside of the plot, similar to > what excel does by default, for example? The common solution with traditional plots (pre-modifying the margin) works well for a one-shot plot, where you calculate the legend size by trial-and-error. The problem arises w

[R] Lattice equivalent of axis(..., hadj=0)?

2008-11-05 Thread SIES 73
Hi, I'm trying to show categories labels on the y-axis of a lattice barchart left-aligned instead of the default right-aligned. That is, in the following example code: x <- c(14.16, 9.98, 14.59, 15.24) names(x) <- c("Banks & Finance", "Technology", "Non-Cyclicals", "Communications")