[R] Preparing data for display

2008-11-10 Thread Stavros Macrakis
I have a dataset of about 10^6 rows, each consisting of a timestamp, several factors, a string, some integers, and some floats. I'd like to graph this data in various ways, including straightforward ones (how many events per week over the past year for each of 4 values of some factor), some less s

Re: [R] Preparing data for display

2008-11-11 Thread Stavros Macrakis
On Mon, Nov 10, 2008 at 9:32 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Have you tried 'do.call(rbind,)'? Thanks for the suggestion! This works nicely. Another member of the list also suggested this approach (in private mail). Another useful suggestion was matplot. I'm still working on mas

Re: [R] Make one vector from matrix comparison

2008-11-12 Thread Stavros Macrakis
You can just call `c` on your result to flatten the matrix into a vector. You could also eliminate the for-loops by using the `apply` function: pairwise_setequal <- function(a,b) c(apply(a, 1, function(r){ apply(b, 1, setequal, r ) } )) But are you sure that is what you want to do? In the ca

[R] Outer, kronecker, etc.

2008-11-12 Thread Stavros Macrakis
`outer` (and related functions like kronecker) require that their functional argument operate elementwise on arrays. This means for example that outer( 1:2, 3:4, list) or outer(1:2,3:4,function(a,b){1}) gives an error. Is there a version of `outer`/`kronecker`/etc. that takes arbitr

[R] R run under Emacs fatal errors halt execution

2008-11-13 Thread Stavros Macrakis
I am running R.exe/Rterm.exe 2.7.1 under Emacs 22.1 under the DOS shell under Windows XP. (My Cygwin installation is broken!) I am not currently using ESS: > R.exe --vanilla R version 2.7.1 ... ... > 1+1 2 This works fine until I hit an R error -- pretty much any error -- when th

Re: [R] R run under Emacs fatal errors halt execution

2008-11-14 Thread Stavros Macrakis
On Fri, Nov 14, 2008 at 3:37 AM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > Why make life difficult for yourself by not using ESS? ... Frankly because I was intimidated by the 79-page (!!) manual. But you have shamed me into trying it. Installation was painless, and it seems to work as expe

[R] Superimposing y-variables in Lattice formulas

2008-11-14 Thread Stavros Macrakis
Given a data frame of a categorical variable and two continuous variables, I would like to display one continuous variable against the other for each value of the categorical variable, all superimposed on the same plot. For example: data(Indometh); str(Indometh) Classes 'nfnGroupedData', 'nfGroup

Re: [R] Superimposing y-variables in Lattice formulas

2008-11-15 Thread Stavros Macrakis
On Fri, Nov 14, 2008 at 6:55 PM, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: >> ...But how do I specify that I want to display all the Subjects on a... >> single graph, superimposing them all? > > Have you tried > xyplot ( conc ~ time , Indometh, groups = Subject ) ? Thanks very much for your help

Re: [R] Superimposing y-variables in Lattice formulas

2008-11-16 Thread Stavros Macrakis
Deepayan, Thanks again for your explanations. I must admit I am still struggling with some of these concepts (though I have in fact read more than just help pages!), and I would be delighted to find a holistic introduction to the concepts of formulae and of the lattice system -- in fact I have or

Re: [R] Superimposing y-variables in Lattice formulas

2008-11-16 Thread Stavros Macrakis
Thank you for the pointer to your paper "Getting Started with Lattice Graphics" -- it looks very useful. I think we're talking past each other on the question of the semantics of formula operators, and it's probably not productive to continue. I would guess that the underlying issue is that we co

Re: [R] Question on creating list object

2008-11-17 Thread Stavros Macrakis
On Mon, Nov 17, 2008 at 5:00 AM, megh <[EMAIL PROTECTED]> wrote: >> lapply(1:5, function(i) c(1,2,3)^i) > [[1]] > [1] 1 2 3 ... > This is fine. However my goal is : each element of this list should depend > on previous element like : > > lis # List name > then, > > lis[[i]] = lis[[i-1]] + c(1,2,3)^

Re: [R] looking for matches

2008-11-17 Thread Stavros Macrakis
I'm not sure I understand what you're looking for in the result. What exactly do you mean by a "match"? What do you want in the third table besides the class names? Do you just want a list (not a data frame) of those class names which table A and table B have in common? Then how about intersect

Re: [R] functional (?) programming in r

2008-11-17 Thread Stavros Macrakis
Wacek, I think when people say that R semantics are derived from Scheme, all they mean is that R supports lexical closures. But R has other features which are very un-Scheme-like, and when they interact with lexical closures, you get behavior you don't find in other functional languages. R passe

Re: [R] functional (?) programming in r

2008-11-17 Thread Stavros Macrakis
On Mon, Nov 17, 2008 at 7:33 PM, Wacek Kusnierczyk <[EMAIL PROTECTED]> wrote: > Gabor Grothendieck wrote: >> The R Language Definition manual that comes with R has a section on promises. Certainly. > on promises yes, but the question was whether the behaviour discussed > before is obvious and int

Re: [R] simplify this instruction

2008-11-19 Thread Stavros Macrakis
The previous solutions assume you are only interested in one small interval, but if your original example is just a simplified version, and the real problem is multiple, possibly large, intervals, you might want to try something like this: c(NA,"A","B")[1+findInterval( <>, c(0,9+1) ) ] which

[R] Dequantizing

2008-11-20 Thread Stavros Macrakis
I have some data measured with a coarsely-quantized clock. Let's say the real data are q<- sort(rexp(100,.5)) The quantized form is floor(q), so a simple quantile plot of one against the other can be calculated using: plot(q,type="l"); points(floor(q),col="red") which of course sho

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Stavros Macrakis
You can also do it from first principles: outer(1:100,1:100,`<`) * m which generalizes nicely to >, <=, >=, !=, etc. -s On 11/21/08, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > See ?upper.tri and ?lower.tri. __ R-help@r-project.o

[R] Bug in Kendall for n<4?

2008-11-21 Thread Stavros Macrakis
> library(Kendall) > Kendall(1:3,1:3) WARNING: Error exit, tauk2. IFAULT = 12 << tau = 1, 2-sided pvalue =1 I believe Kendall tau is well-defined for this case and the reported value is correct; isn't it a bug to give a warning? (And if, e.g., the pvalue is not well-defined in this

[R] Generalized "Outer"

2008-11-21 Thread Stavros Macrakis
Outer's arguments are restricted to atomic vectors or arrays built on atomic vectors (though the documentation is not explicit on this point). What is the equivalent for lists or arrays built on lists? My particular application was testing the Kendall tau function. I tried this > outer( permn(3)

Re: [R] Bug in Kendall for n<4?

2008-11-22 Thread Stavros Macrakis
On Sat, Nov 22, 2008 at 9:04 AM, Martin Maechler <[EMAIL PROTECTED]> wrote: >SM> I believe Kendall tau is well-defined for this case... > > The real question is *WHY* there needs to be a separate package 'Kendall' > when R itself does everything you want and does not show any problems? Than

Re: [R] Basic question on concatenating factors

2008-11-22 Thread Stavros Macrakis
On Sat, Nov 22, 2008 at 10:20 AM, jim holtman <[EMAIL PROTECTED]> wrote: > c.Factor <- > function (x, y) > { >newlevels = union(levels(x), levels(y)) >m = match(levels(y), newlevels) >ans = c(unclass(x), m[unclass(y)]) >levels(ans) = newlevels >class(ans) = "factor" >ans >

Re: [R] Basic question on concatenating factors

2008-11-23 Thread Stavros Macrakis
at a local university, and having written the "set" package for the Maxima computer algebra system, I am fairly well versed in the alternatives, thank you. > as well as how R actually does it How "R actually does it" today is not the issue. Do look up a basic computer s

Re: [R] how to test for the empty set

2008-11-24 Thread Stavros Macrakis
Doesn't length(x)=0 do the trick? In general, the cardinality of a set represented as a vector or list of elements is length(unique(x)). Unique uses `identical` as its equivalence relation, so length( unique( list( 1L, 1.0, 1+0i, as.logical(NA), as.character(NA), as.numeric(NA), NULL, logical(),

Re: [R] select a subset

2008-11-25 Thread Stavros Macrakis
How about something like: censor_choose <- function(fr) do.call(rbind, lapply( split( fr, fr$id), function(sub) sub[which.max( if (max(sub$censor)) sub$censor else sub$time) ,] ) ) Using your data, itc <- data.frame(id=c(1,1,1,2

Re: [R] memory limit

2008-11-26 Thread Stavros Macrakis
I routinely compute with a 2,500,000-row dataset with 16 columns, which takes 410MB of storage; my Windows box has 4GB, which avoids thrashing. As long as I'm careful not to compute and save multiple copies of the entire data frame (because 32-bit Windows R is limited to about 1.5GB address space

Re: [R] Examples of advanced data visualization

2008-11-29 Thread Stavros Macrakis
On Fri, Nov 28, 2008 at 4:13 PM, Tom Backer Johnsen <[EMAIL PROTECTED]>wrote: > Hans W. Borchers wrote: > ...The question is interesting, but what I have a somewhat negative reaction > to is the next passage: > >> Please answer to my e-mail address. In case enough interesting material >> comes up,

Re: [R] Using grep() to subset lines of text

2008-11-29 Thread Stavros Macrakis
Hmm, this brings up an interesting question. What if the string I'm looking for contains escape characters? For example, grep( paste( "^", "(ab)" ), c("ab","(ab)") ) => c(1), not c(2). I couldn't find an equivalent to Emacs's regexp-quote, which would let me write regexp.quote("(ab)") => "\\(ab\

Re: [R] Using grep() to subset lines of text

2008-11-29 Thread Stavros Macrakis
ll regexp's. > > On Sat, Nov 29, 2008 at 3:55 PM, Stavros Macrakis <[EMAIL PROTECTED]> > wrote: > > Hmm, this brings up an interesting question. What if the string I'm > looking > > for contains escape characters? For example, grep( paste( "^",

[R] XML-RPC

2008-12-02 Thread Stavros Macrakis
It looks like the xml and httpRequest libraries provide the necessary building blocks for writing an XML-RPC client. Has anyone done this? I'd like to benefit from your experience (or code!). Thanks, -s [[alternative HTML version deleted]] ___

[R] Approximate matching: agrep and TRE?

2008-12-04 Thread Stavros Macrakis
agrep{base} is very useful, but it would be very useful to also have the offset of the first match returned, e.g. agrepx("foo","sdxforzoo",max.distance=1) => 4 (there is room for quibbling over the definition of first match...). As far as I can tell, the only way to do that now is to do multiple ag

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Fri, Dec 5, 2008 at 8:18 AM, Wacek Kusnierczyk < [EMAIL PROTECTED]> wrote: > well, this answer the question only partially. this explains why a > system with finite precision arithmetic, such as r, will fail to be > logically correct in certain cases. it does not explain why r, a > language s

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk < [EMAIL PROTECTED]> wrote: > yepp, though (2/3)*3 not evaluating to 2 is again not a must, is it. Why is that less a must than .3-.2 == .1? On the contrary, the computing convention (and for that matter the usual scientific and engineering conv

Re: [R] Logical inconsistency

2008-12-06 Thread Stavros Macrakis
On Sat, Dec 6, 2008 at 4:32 PM, Wacek Kusnierczyk < [EMAIL PROTECTED]> wrote: > Stavros Macrakis wrote: > > On Sat, Dec 6, 2008 at 5:02 AM, Wacek Kusnierczyk < > > [EMAIL PROTECTED]> wrote: > >> yepp, though (2/3)*3 not evaluating to 2 is again not a must, is

Re: [R] Logical inconsistency

2008-12-07 Thread Stavros Macrakis
On Sun, Dec 7, 2008 at 3:51 AM, Wacek Kusnierczyk < [EMAIL PROTECTED]> wrote: > >> (* (/ 2.0 3.0) 3.0) is not exact either, as aren't (* (/ 2.0 2.0) > 2.0)... > > Actually, they *are* all exact in any system using IEEE floats. > not per definitionem of exactness as of r6rs, as of my understanding.

[R] R and Scheme

2008-12-08 Thread Stavros Macrakis
I've read in many places that R semantics are based on Scheme semantics. As a long-time Lisp user and implementor, I've tried to make this more precise, and this is what I've found so far. I've excluded trivial things that aren't basic semantic issues: support for arbitrary-precision integers; su

Re: [R] R and Scheme

2008-12-09 Thread Stavros Macrakis
Thanks for the various thoughtful replies to my post "R and Scheme", where I wondered what exactly people meant when they said that R semantics were based on Scheme semantics. R clearly has Scheme-like semantics for its function objects, which are first-class objects and correctly implement static

Re: [R] R and Scheme

2008-12-10 Thread Stavros Macrakis
On Wed, Dec 10, 2008 at 4:40 AM, Duncan Murdoch <[EMAIL PROTECTED]>wrote: > [deletions, including attribution, which I think were Stavros then Luke > then Peter:] >> >> In R, most data types (including numeric vectors) do not have a standard external representation which can be read back in w

Re: [R] Better way to find distances between points in a set?

2008-12-10 Thread Stavros Macrakis
On Tue, Dec 9, 2008 at 11:52 PM, Charles C. Berry <[EMAIL PROTECTED]>wrote: > The 'better way' to do almost anything starts with a reading of the > _posting guide_, which reminds you to >Do your homework before posting [Reasons whyfor deleted]]... > > Oh yes, if you are too lazy to look

Re: [R] Logical "in" test

2008-12-11 Thread Stavros Macrakis
i %in% c(7,10,30,50) On Thu, Dec 11, 2008 at 12:11 PM, David B. Thompson, Ph.D., P.E., D.WRE, CFM wrote: > OK, this should be trivial but I'm not finding it. I want to compress the > test, > > if (i==7 | i==10 | i==30 | i==50) {} > > into something like > > if (i in c(7,10,30,50)) {} > > so I ca

Re: [R] very long integers

2008-12-11 Thread Stavros Macrakis
If they are IDs, you presumably don't need to perform arithmetic on them, so why not store them as strings? If you're reading them with read.table, see the colClasses parameter. I am not sure how to do this in RODBC; as.isthere (as in read.table) does not affect columns that look like numbers --

Re: [R] repeated searching of no-missing values

2008-12-11 Thread Stavros Macrakis
On Wed, Dec 10, 2008 at 6:39 PM, Bert Gunter wrote: > ...?tapply says that the first argument is an **atomic** vector. A factor > is not an atomic vector. So tapply interprets it as such by looking only at > its representation, which is as integer values. > What is the rationale for this? If it

Re: [R] R imperfections? -- was: repeated searching of no-missing values

2008-12-11 Thread Stavros Macrakis
Bert, Thanks for your reply. I suspect we agree more than you might think Comments inline below. I've snipped out parts. -s On Thu, Dec 11, 2008 at 2:45 PM, Bert Gunter wrote: > Rationale? -- you'll have to ask the developers Hmm. It would be nice if this could be doc

Re: [R] R imperfections? -- was: repeated searching of no-missing values

2008-12-11 Thread Stavros Macrakis
Bert has pointed out to me that the R definition of "deprecated" is considerably more draconian than that in most other systems: ? Deprecated "These functions are provided for compatibility with older versions of *R* only, and may be defunct as soon as the next release." I would certain

Re: [R] sliding window over a large vector

2008-12-16 Thread Stavros Macrakis
For this particular proble (counting), doesn't cumsum solve it effectively and efficiently? vv <- cumsum(v) vv[n:length(vv)] - vv[1:(length(vv)-n+1] Of course, this doesn't work for the general case of an arbitrary sliding window function. -s On 12/15/08, Chris Oldmeadow wrote: >

<    1   2   3