Re: [R] not understanding a do.call

2006-10-18 Thread Brahm, David
Mark Leeds [EMAIL PROTECTED] wrote: could someone explain the difference between do.call(cbind,list(a,b,c,d)) and cbind(a,b,c,d). do.call(cbind, list(a=a, b=b, c=c, d=d)) is indeed the same as cbind(a, b, c, d). But suppose you wanted a function to cbind any number of vectors in reverse order:

[R] Error: STRING_ELT() can only be applied to a 'character vector', not a 'builtin'

2006-10-17 Thread Brahm, David
I have a daily job that attaches hundreds of pseudo-packages containing data as promise objects (DDP's, ref: g.data package), and plots the results to a multi-page pdf device. Sometimes it fails. Under R-2.2.1 it just gave segfaults. Under R-2.3.1 it gave this error message: *** caught

[R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Brahm, David
After upgrading to R-2.3.1 on Linux Redhat, I was suprised by this: R x - c(721.077, 592.291, 372.208, 381.182) R sum(x) - 2066.758 [1] 4.547474e-13 Now I understand that floating point arithmetic is not precise, but 1) the result is exactly 0 in R-2.2.1 (patched) on the same machine, 2)

Re: [R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Brahm, David
I was concerned by this result (new in R-2.3.1): R x - c(721.077, 592.291, 372.208, 381.182) R sum(x) - 2066.758 [1] 4.547474e-13 But after Roger Peng's [EMAIL PROTECTED] insightful comment that the relative difference (sum(x)/2066.758 - 1) is exactly what is expected, I'm convinced that sum()

Re: [R] hello Excel... (native/Package/BETA)

2006-06-21 Thread Brahm, David
Hans-Peter, In my office, files are stored on an EMC shared server which is used by both our Windows PC's and our Linux machines. So it is common for us to process spreadsheet data using R on Linux. A Linux version of your package would be very welcome. Thanks! -- David Brahm ([EMAIL

[R] as.character.factor when the factor contains NA

2006-04-28 Thread Brahm, David
as.character.factor contains this line (where cx=levels(x)[x]): if (NA %in% levels(x)) cx[is.na(x)] - NA Is it possible that this is no longer the desired behavior? These two results don't seem very consistent: as.character(as.factor(c(AB, CD, NA))) [1] AB CD NA is.na(.Last.value)[3] [1]

Re: [R] data.frame to list

2006-04-05 Thread Brahm, David
Larry Howe [EMAIL PROTECTED] wants to: 1. read in a 2-column data file, e.g. status tab new db tab green title tab Most Significant Excursions 2. end up with an R list such that I can write e.g. lst$title and have R return Most Significant Excursions. I call this reading a hash table

Re: [R] rowVars

2006-04-04 Thread Brahm, David
I've written a rowVars function, but I don't think it throws the error you mention. You're welcome to use it if you like. rowVars - function(x, na.rm=FALSE, dims=1, unbiased=TRUE, SumSquares=FALSE, twopass=FALSE) { if (SumSquares) return(rowSums(x^2, na.rm, dims)) N -

Re: [R] [R-pkgs] sudoku

2006-01-31 Thread Brahm, David
sudoku_2.0 is now available on CRAN and mirrors. Thanks to some terrific contributions and suggestions, especially by new co-author Greg Snow, this version has a full GUI interface (native on Windows, or using tkrplot), a puzzle generator, and a function to fetch recently published puzzles. The

[R] [R-pkgs] sudoku

2006-01-06 Thread Brahm, David
Any doubts about R's big-league status should be put to rest, now that we have a Sudoku Puzzle Solver. Take that, SAS! See package sudoku on CRAN. The package could really use a puzzle generator -- contributors are welcome! -- David Brahm ([EMAIL PROTECTED]) [[alternative HTML

[R] Daylight Savings Time unknown in R-2.2.1

2006-01-06 Thread Brahm, David
Under R-2.2.1, a POSIXlt date created with strptime has an unknown Daylight Savings Time flag: strptime(20051208, %Y%m%d)$isdst [1] -1 This is true on both Linux (details below) and Windows. It did not occur under R-2.1.0. Any ideas? TIA! Sys.getenv(TZ) TZ Version: platform =

Re: [R] ess emacs 'shift+-' and '-'

2005-12-30 Thread Brahm, David
Albert Vilella [EMAIL PROTECTED] wrote: I would like to ask about how to disable the ess emacs shortcut that converts shift+- to '-' instead of _ symbols. Put this in your .emacs file (after ess is loaded): (ess-toggle-underscore nil) By the way, check out the ESS-help mailing list:

Re: [R] Age of an object?

2005-12-14 Thread Brahm, David
Trevor Hastie [EMAIL PROTECTED] wrote: It would be nice to have a date stamp on an object. In S/Splus this was always available, because objects were files. The g.data package on CRAN stores R objects in individual files, like the (old) S-Plus model. The timestamp on a file tells you the last

Re: [R] non-zero sequence of numbers

2005-10-11 Thread Brahm, David
Jason Horn [EMAIL PROTECTED] wrote: Can anyone think of a way to create a pretty() sequence that excludes zero? You could use except(pretty(x), 0), if you first defined the (quite useful) set-operation function: R except - function(a,b) unique(a[!match(a, b, 0)]) (Consider this a plug to

Re: [R] Help: x11 position in the Unix environment

2005-09-27 Thread Brahm, David
Shengzhe Wu [EMAIL PROTECTED] wrote: In the Unix environment, I open a window by x11(). May I specify the position of this window by specifying the position of the top left of the window as in Windows environment? I use xwit (version 3.4), a system command which manipulates existing X

[R] Superassignment (-) and indexing

2005-09-02 Thread Brahm, David
In a clean environment under R-2.1.0 on Linux: x - 1:5 x[3] - 9 Error: Object x not found Isn't that odd? (Note x - 9 works just fine.) Why am I doing this? Because I'm stepping through code that normally lives inside a function, where - is appropriate. -- David Brahm ([EMAIL PROTECTED])

Re: [R] small first graph of par(3,2), other 5 are correct

2005-07-11 Thread Brahm, David
Scot, Here is your toy example in more condensed form: x11() par(mar=c(0.5, 1, 5, 5)) par(mfrow=c(3,2)) plot(1:10) par(mex) # mex=1.0 here par(cex.axis=1.0, mex=0.5) # Now you change it for (i in 1:5) plot(1:10) When you build your first plot (effectively at the plot.new()

[R] Graphics: calling par(mar) after frame()

2005-07-06 Thread Brahm, David
The following code produces 6 plots on a page, but the first is distorted and different from the others: par(mfrow=c(3,2), las=2) for (i in 1:6) { frame() par(mar=c(7, 7, 1, 1)) axis(2); box(); abline(h=seq(0,1,.5), col=2:4) } The first plot's axes are mis-aligned with the plotting area

Re: [R] Graphics: calling par(mar) after frame()

2005-07-06 Thread Brahm, David
I wrote: par(mfrow=c(3,2), las=2) for (i in 1:6) { frame() par(mar=c(7, 7, 1, 1)) axis(2); box(); abline(h=seq(0,1,.5), col=2:4) } The first plot's axes are mis-aligned with the plotting area... Uwe Ligges [EMAIL PROTECTED] replied: Yes expected, at first you generate the plot, then

RE: [R] R annoyances

2005-05-23 Thread Brahm, David
Bogdan Romocea [EMAIL PROTECTED] wrote: Hypothetically, if whatever=T/F were forbidden and only whatever=TRUE/FALSE were allowed, all the code could be fixed with a simple sed script: [deleted] As Bogdan is lobbying hard for disallowing T/F, I wanted to speak up for the other side. Please

[R] Larger X11 fonts under R-2.1.0

2005-05-19 Thread Brahm, David
I view plots on my screen with X11(width=.455*11, height=.455*8.5), which creates a small window with the American standard aspect ratio. Under R-2.0.1 and earlier, the default fonts were a reasonable size, but under R-2.1.0 they are too big and fat. I now have to either set pointsize=10 in

RE: [R] Larger X11 fonts under R-2.1.0

2005-05-19 Thread Brahm, David
Thanks very much to Prof Brian Ripley [EMAIL PROTECTED] for the quick and illuminating reply: We have corrected a bug: you now get the size you ask for... DId you think to actually measure the sizes? Might be interesting (although you may need to measure the window too). Sticking a ruler up

RE: [R] string syntactic sugar in R? - long post

2005-05-11 Thread Brahm, David
charles loboz [EMAIL PROTECTED] wrote: A gstring is a string with variable names embedded and replaced by values(converted to strings, lazy eval) before use. I use the following function, which will take variables either from named arguments or from the environment. It also concatenates all

RE: [R] persp( ) Question

2005-05-06 Thread Brahm, David
Greg, Assign the output of persp to a variable pmat: R pmat - persp(X.grid, Y.grid, pred.loess1, theta=0, phi=12) Now you can add points to your plot with the usual points command. But you have to translate your 3D coordinates (x,y,z) into 2D coordinates for points to understand, and that's what

RE: [R] assign to an element of a vector

2005-04-29 Thread Brahm, David
Fernando Saldanha [EMAIL PROTECTED] wrote: I am trying to find a way to assign values to elements of a vector that will be defined by a user. a - c(1,2,3) get('a')[1] - 0 Error: Target of assignment expands to non-language object Try this function: g.assign - function(i, pos=1, ...,

[R] [R-pkgs] g.data version 1.6, upgrade in response to changes in R-2.1.0

2005-04-16 Thread Brahm, David
Version 1.6 of the g.data package is available on CRAN. The g.data package is used to create and maintain delayed-data packages (DDP's). Data stored in a DDP are available on demand, but do not take up memory until requested. You attach a DDP with g.data.attach(), then read from it and assign to

RE: [R] Search and convert string function

2005-03-07 Thread Brahm, David
peng shen [mailto:[EMAIL PROTECTED] wrote: R - 4 testString - I love $R So the final string I want to get is I love 4. How can I implement? I've written an interpolater function g.p with these additional features: - Loops through all occurences of the escape character ($) rather than all

RE: [R] passing command line arguments to 'R CMD BATCH myScript.R'

2005-02-25 Thread Brahm, David
I have never understood the difference between R CMD BATCH --vanilla --slave myScript.R outFile.txt and R --vanilla --slave myScript.R outFile.txt I use the latter method, and then the --args construction works great: R --vanilla --slave --args myArg1 myArg2 myScript.R outFile.txt In

RE: [R] Annual cumulative sums from time series

2005-02-10 Thread Brahm, David
Georg Hoermann [mailto:[EMAIL PROTECTED] wrote: www.hydrology.uni-kiel.de/~schorsch/statistik/erle_stat.csv ... contains a 10 year dataset. We often need cumulative *annual* sums (sunshine, precipitation), i.e. the sum must reset to 0 at the beginning of the year. I know of cumsum(), but I do

[R] outer(-x, x, pmin) cannot allocate

2004-12-22 Thread Brahm, David
R x - 0. + 1:8000 R y - outer(-x, x, pmin) Error: cannot allocate vector of size 100 Kb Why does R need to allocate a gigabyte to create an 8000 x 8000 matrix? It doesn't have any trouble with outer(-x, x, +). Thanks. -- David Brahm ([EMAIL PROTECTED]) Version: platform =

RE: [R] moving average method for time series objects

2004-09-24 Thread Brahm, David
Paul Schwarz [EMAIL PROTECTED] wrote: Is there an R function for calculating moving averages of time series objects? Others have replied, but here's the simple answer for a trailing 5-day moving average, no non-standard packages needed: R x - 1:20 R filter(x, rep(1/5,5), sides=1) -- David Brahm