[Rd] Fetching email in R (IMAP)

2012-02-28 Thread Stavros Macrakis
Is there an R package for fetching email from an IMAP mail server? I found the CRAN package sendmailR (for sending mail via SMTP) and the CRAN package Imap (but that is actually Interactive Mapping, nothing to do with email). I also found a blog posting ( http://www.r-bloggers.com/sna-visualising

Re: [Rd] Efficiency of factor objects

2011-11-07 Thread Stavros Macrakis
Matthew, Yes, the case I am thinking of is a 1-column key; sorry for the overgeneralization. I haven't thought much about the multi-column key case. -s On Mon, Nov 7, 2011 at 12:48, Matthew Dowle wrote: > Stavros Macrakis alum.mit.edu> writes: > > > > data.t

[Rd] Efficiency of factor objects

2011-11-06 Thread Stavros Macrakis
Milan, Jeff, Patrick, Thank you for your comments and suggestions. Milan, This is far from a "completely theoretical problem". I am performing text analytics on a corpus of about 2m documents. There are tens of thousands of distinct words (lemmata). It seems to me that the natural representat

[Rd] Efficiency of factor objects

2011-11-04 Thread Stavros Macrakis
R factors are the natural way to represent factors -- and should be efficient since they use small integers. But in fact, for many (but not all) operations, R factors are considerably slower than integers, or even character strings. This appears to be because whenever a factor vector is subsetted

[Rd] Speed difference between df$a[1] and df[1,"a"]

2011-10-19 Thread Stavros Macrakis
I was surprised to find that df$a[1] is an order of magnitude faster than df[1,"a"]: > df <- data.frame(a=1:10) > system.time(replicate(10, df$a[3])) user system elapsed 0.360.000.36 > system.time(replicate(10, df[3,"a"])) user system elapsed 4.090.004.09

[Rd] Error checking in Sys.sleep

2010-12-22 Thread Stavros Macrakis
Sys.sleep returns immediately for arguments larger than 2.2e6 or so, including for Inf. This does conforms to the letter of the documention: "There is no guarantee that the process will sleep for the whole of the specified interval." but an error would be more helpful. Since Sys.sleep ignores cla

Re: [Rd] 0.5 != integrate(dnorm,0,20000) = 0

2010-12-13 Thread Stavros Macrakis
I'd suggest that the original sin here is calling some particular numerical integration routine 'integrate', which gives the user an illusory sense of power Functions have to be well-behaved in various ways for quadrature to work well, and you've got to expect things like > integrate(function(

[Rd] OWL ontologies in R?

2010-06-10 Thread Stavros Macrakis
Are there any R packages to import and use Web Ontology Language (OWL) ontologies (represented in OWL/RDF or other form)? Thanks, -s [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/m

[Rd] sample on data.frame

2010-02-19 Thread Stavros Macrakis
Currently, sample of a data.frame is a sample of the columns: e.g. sample(data.frame(a=1,b=2:3,c=4),2) => data.frame(b=2:3,c=c(4,4)) I'd have thought it would be much more common to want a sample of the rows. It's easy enough to define an appropriate function for this: sample.data.frame <- func

Re: [Rd] Inconsistency in as.data.frame.table for stringsAsFactors

2010-01-22 Thread Stavros Macrakis
aults are fixed or taken from global settings -- when there is no obvious reason for the default to vary by class. -s On Fri, Jan 22, 2010 at 3:17 AM, Martin Maechler wrote: > >>>>> "SM" == Stavros Macrakis > >>>>> on Thu, 21 Jan 2010

[Rd] Inconsistency in as.data.frame.table for stringsAsFactors

2010-01-21 Thread Stavros Macrakis
I noticed that in as.data.frame.table, the stringsAsFactors argument defaults to TRUE, whereas in the other as.data.frame methods, it defaults to default.stringsAsFactors(). The documentation and implementation agree on this, so this is not a bug. However, I was wondering if this disparity was in

Re: [Rd] how do I join two lists of the same type ?

2009-12-30 Thread Stavros Macrakis
rbind will work for data frames, but the type of your myData is not clear. Is it a list of data frames, in which case you probably want rbind(myData[[1]], myData[[2]])? I don't understand why you write NewData[1] for your desired result and not NewData. Do you perhaps want list(rbind(myData[[1]],

Re: [Rd] Rcpp: Clarifying the meaning of GPL?

2009-12-23 Thread Stavros Macrakis
you complain > I simply present the results (at conferences) as my own without mentioning > your name. > > Is this just a dispute between implementers? > > Stavros Macrakis wrote: > > On Wed, Dec 23, 2009 at 12:27 AM, Dominick Samperi < >> djsamp...@earthlink.net &

Re: [Rd] Rcpp: Clarifying the meaning of GPL?

2009-12-23 Thread Stavros Macrakis
On Wed, Dec 23, 2009 at 12:27 AM, Dominick Samperi wrote: > Stavros Macrakis wrote: > >> That said, as a matter of courtesy and clarity, I'd think that a fork >> should use a different name. >> > Yes, the point is that this is not a legal or technical matter,

Re: [Rd] Rcpp: Clarifying the meaning of GPL?

2009-12-22 Thread Stavros Macrakis
I am not sure what clause of the GPL you have in mind when you say that "it explicitly states that these changes should not leave misleading impressions about the original developer." Are you perhaps thinking of the passage in Section 7 which says: Notwithstanding any other provision of th

Re: [Rd] Vectorized switch

2009-12-18 Thread Stavros Macrakis
On Fri, Dec 18, 2009 at 2:39 PM, William Dunlap wrote: > > colchoose( data.frame(a=1:4,b=11:14), c('a','b','b','a')) > >=> c(1,11,11,1) > > I thought you would want c(1,12,13,4), not c(1,11,11,1), > out of this call. Perhaps I misunderstand your requirements. > Sorry, you're r

[Rd] Vectorized switch

2009-12-18 Thread Stavros Macrakis
What is the 'idiomatic' way of writing a vectorized switch statement? That is, I would like to write, e.g., vswitch( c('a','x','b','a'), a= 1:4, b=11:14, 100 ) => c(1, 100, 13, 4 ) equivalent to ifelse(

[Rd] Method dispatch for function

2009-11-23 Thread Stavros Macrakis
(I had sent this to r-help and got no responses -- perhaps r-devel is a better list for this question?) How can I determine what S3 method will be called for a particular first-argument class? I was imagining something like functionDispatch('str','numeric') => utils:::str.default , but I can't fi

Re: [Rd] Documentation for is.atomic and is.recursive

2009-09-03 Thread Stavros Macrakis
On Wed, Sep 2, 2009 at 5:30 PM, Duncan Murdoch wrote: > On 02/09/2009 4:10 PM, Stavros Macrakis wrote: ... >> I would nonetheless claim that the documentation as currently written >> is at best ambiguous and confusing, and would benefit from improved >> wording. > >

Re: [Rd] Documentation for is.atomic and is.recursive

2009-09-02 Thread Stavros Macrakis
gn decisions (wise or unwise) be revisited; only that they be documented more clearly. -s On Wed, Sep 2, 2009 at 3:37 PM, Duncan Murdoch wrote: > On 9/2/2009 2:39 PM, Stavros Macrakis wrote: >> >> The documentation for is.atomic and is.recursive is inconsi

Re: [Rd] Documentation for is.atomic and is.recursive

2009-09-02 Thread Stavros Macrakis
On Wed, Sep 2, 2009 at 2:39 PM, Stavros Macrakis wrote: > Most types of language objects are regarded as recursive: those > which are not are the atomic vector types, 'NULL' and symbols (as > given by 'as.name'). > > But is.recursive(as.nam

[Rd] Documentation for is.atomic and is.recursive

2009-09-02 Thread Stavros Macrakis
The documentation for is.atomic and is.recursive is inconsistent with their behavior in R 2.9.1 Windows. ? is.atomic 'is.atomic' returns 'TRUE' if 'x' is an atomic vector (or 'NULL') and 'FALSE' otherwise. ... 'is.atomic' is true for the atomic vector types ('"logical"',

Re: [Rd] nchar on factors

2009-08-24 Thread Stavros Macrakis
On Mon, Aug 24, 2009 at 5:36 PM, Peter Dalgaard wrote: > > The documentation has: > > >> > The internal equivalent of the default method of as.character is performed > on x (so there is no method dispatch). If you want to operate on non-vector > objects passing them through deparse first will be r

[Rd] nchar on factors

2009-08-24 Thread Stavros Macrakis
In R 2.9.1 Windows: > nchar(factor(paste('sdf',1:10))) [1] 1 1 1 1 1 1 1 1 2 1 so it appears that nchar is counting the number of characters in the numeric representation, just like: > nchar(as.numeric(factor(paste('sdf',1:10 [1] 1 1 1 1 1 1 1 1 2 1 but ?nchar says explicitly: x: ch

[Rd] Documentation of ties.method argument in `rank`

2009-08-20 Thread Stavros Macrakis
In R 2.9.1/Windows, ? rank says: Usage: rank(x, na.last = TRUE, ties.method = c("average", "first", "random", "max", "min")) Arguments: ... ties.method: a character string specifying how ties are treated, see 'Details'; can be abbreviated. This appears contradictory --

[Rd] BUG/FIX: View gives internal error with long argument (multiline deparse)

2009-07-29 Thread Stavros Macrakis
> View(as.data.frame(c("","yyy",1,1))) Error in dataviewer(x, title) : invalid argument The problem is that View linearizes its argument to generate a title using deparse(substitute(x)), which sometimes returns a vector of length > 1. A simple fix is to change this

Re: [Rd] S4 and connection slot [Sec=Unclassified]

2009-06-29 Thread Stavros Macrakis
On Mon, Jun 29, 2009 at 9:19 AM, Martin Morgan wrote: > ...I'm not sure that including a connection in a slot is going to be a good > idea, though -- a connection has reference-like semantics, so you can > end up with multiple objects pointing to the same connection, Also when > an object is garb

[Rd] Bugs in unique of data.frame and matrix

2009-06-26 Thread Stavros Macrakis
R version 2.8.1 (2008-12-22) / Windows XP There are several bugs in unique for data frames and matrices. Please find minimal reproducible examples below. -s -A- Unique of a vector uses numerical comparison: > nn <- ((1+2^-52)^(5:22)) > unique(nn) [1] 1 1 1 1 1 1 1 1 1 1 1 1

Re: [Rd] Documentation/software inconsistency in `:` and seq

2009-06-24 Thread Stavros Macrakis
On Wed, Jun 24, 2009 at 5:28 AM, Martin Maechler wrote: > >    SM> But of course 2.5 is not an integer or equal to one. > > Interestingly, because of an earlier posting on the topic, > two days ago (*), I have fixed the help page (and very slightly also > the code) of ":" Sorry for the redundant

[Rd] Documentation/software inconsistency in `:` and seq

2009-06-23 Thread Stavros Macrakis
In 2.8.1/Windows: According to ? : Details: For numeric arguments 'from:to' is equivalent to 'seq(from, to)' ... Value: For numeric arguments, a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer typ

Re: [Rd] Floating point precision / guard digits? (PR#13771)

2009-06-20 Thread Stavros Macrakis
a) this is not a bug, so this is the wrong list b) 'underflow' does not mean what you think it means. c) guard digits and sticky bits do improve rounding behavior, but floating point will always remain approximate. d) if it is important to your application to perform exact arithmetic on rational

[Rd] sort/partial NA handling

2009-06-05 Thread Stavros Macrakis
I am not sure if this is a documentation problem or an implementation problem: The 'partial' feature of sort works fine with all values of na.last for some values of 'partial': > sort(c(3,NA,1,2),na.last=FALSE,partial=1:2) # find minimum values [1] NA 1 2 3 > sort(c(3,NA,1,2),na.last=TRUE,

Re: [Rd] Print bug for matrix(list(NA_complex_, ...))

2009-06-03 Thread Stavros Macrakis
Quick action, thanks! Does this also fix the spacing problem (at the end of my bug report)? -s On Wed, Jun 3, 2009 at 2:49 PM, William Dunlap wrote: > Changing the uninitialized 'w' to 'R_print.na_width' for the complex NA > code fixes up the valgrind complaints on Linux and the ba

[Rd] Print bug for matrix(list(NA_complex_, ...))

2009-06-02 Thread Stavros Macrakis
In R 2.8.0 on Windows (tested both under ESS and under R Console in case there was an I/O issue) There is a bug in printing val <- matrix(list(NA_complex_,NA_complex_),1). > dput(val) structure(list(NA_complex_, NA_complex_), .Dim = 1:2) > print(val) [,1] [1,] [,2] [1,] Note that a large

[Rd] Vectorize fails for function with ... arglist

2009-06-02 Thread Stavros Macrakis
Vectorize is defined to return a function that acts as if 'mapply' was called. So we have: > mapply(dput,1:2)# mapply form 1L # calls dput on each element of 1:2 2L [1] 1 2 > Vectorize(dput)(1:2)# Vectorize form 1L

Re: [Rd] setdiff bizarre

2009-06-02 Thread Stavros Macrakis
On Tue, Jun 2, 2009 at 1:18 PM, William Dunlap wrote: > %in% is a thin wrapper on a call to match(). Yes, as I mentioned in my email, all this is clearly documented in ? match. > match() is not a generic function (and is not documented to be one), > so it treats data.frames as lists, as their

Re: [Rd] Recommendations for a quick UI.

2009-06-02 Thread Stavros Macrakis
On Mon, Jun 1, 2009 at 9:21 AM, Martin Maechler wrote: > > "AB" == Alex Bokov on Mon, 01 Jun 2009 00:24:58 > -0500 writes: > >AB> I'm trying to wrap my R package in a GUI such that when >AB> the user launches the app, they see my GUI window and >AB> never interact with the R cons

Re: [Rd] setdiff bizarre (was: odd behavior out of setdiff)

2009-06-02 Thread Stavros Macrakis
On Sat, May 30, 2009 at 11:59 AM, Stavros Macrakis wrote: > Since R is object-oriented, data frame set operations should be the natural > operations for their class. There are, I suppose, two natural ways: the > column-wise (variable-wise) and the row-wise (observation-wise) one. The &

[Rd] BUG: `lag` returns object of incorrect class

2009-06-01 Thread Stavros Macrakis
In R 2.8.0/Windows: > lag(1) [1] 1 attr(,"tsp") [1] 0 0 1 Though this has the 'tsp' attribute, it is of class "integer", and hence not a "time-series object" as defined by ? ts: "time-series objects... are vector [sic] or matrices with class of '"ts"' (and additional attributes)". ? lag further

Re: [Rd] setdiff bizarre (was: odd behavior out of setdiff)

2009-05-30 Thread Stavros Macrakis
ference of two sets of observations would seem to all be highly useful. -s On Sat, May 30, 2009 at 10:21 AM, G. Jay Kerns wrote: > On Sat, May 30, 2009 at 8:50 AM, Stavros Macrakis > wrote: > > It seems to me that, abstractly, a dataframe is just as > > straightf

Re: [Rd] setdiff bizarre (was: odd behavior out of setdiff)

2009-05-30 Thread Stavros Macrakis
It seems to me that, abstractly, a dataframe is just as straightforwardly a sequence of tuples/observations as a vector is a sequence of scalars. R's convention is that a 1-vector represents a scalar, and similarly, a 1-dataframe can represent a tuple (though it can also be represented as a list).

Re: [Rd] Why change data type when dropping to one-dimension?

2009-05-29 Thread Stavros Macrakis
This is another example of the general preference of the designers of R for convenience over consistency. In my opinion, this is a design flaw even for non-programmers, because I find that inconsistencies make the system harder to learn. Yes, the naive user may stumble over the difference between

Re: [Rd] [R] custom sort?

2009-05-29 Thread Stavros Macrakis
Thanks for the quick fix! -s On Fri, May 29, 2009 at 1:02 PM, Duncan Murdoch wrote: > On 5/29/2009 9:28 AM, Duncan Murdoch wrote: > >> I've moved this to R-devel... >> >> On 5/28/2009 8:17 PM, Stavros Macrakis wrote: >> >>>

Re: [Rd] Bug in base function sample ( ) (PR#13727)

2009-05-29 Thread Stavros Macrakis
> > ...I discovered that when R attempts to sample from an object with only one > number it does not > reproduce/report the number but instead chooses a random number between 1 > and that number. > This is the documented behavior. In my opinion, it is a design error, but changing it would no doub

Re: [Rd] Can we generate exe file using R? What is the maximum file size valid?

2009-05-13 Thread Stavros Macrakis
There are two distinct and orthogonal questions here: 1) Is it possible to package an R program/system in such a way that it can be distributed as a single executable file (including the R system, any necessary loaded packages, plus the application program) and run without an installation of R (wh

Re: [Rd] Can we generate exe file using R? What is the maximum file size valid?

2009-05-07 Thread Stavros Macrakis
On Wed, May 6, 2009 at 7:45 PM, Chessxm wrote: > First, I am wondering whether we are able to use R to generate an exe file, > or sth that can be executable outside R? > Emacs creates self-contained exe files using a library called 'unexec'; this allows all initialization, library loading, etc.

Re: [Rd] Some extensions to class inheritance and method selection

2009-04-29 Thread Stavros Macrakis
These look like important improvements. As a relative newcomer to the R community, I'm not sure I understand what the procedures are for such changes. In particular, does the fact that the changes were committed to R-devel mean that the changes have already been reviewed and approved by R Core?

Re: [Rd] Closed-source non-free ParallelR ?

2009-04-26 Thread Stavros Macrakis
On Sun, Apr 26, 2009 at 7:24 AM, Ted Harding wrote: > On 24-Apr-09 16:53:04, Stavros Macrakis wrote: >> On Thu, Apr 23, 2009 at 8:54 PM, Ted Harding >> wrote: >> [...] >>> ...inspires someone to incorporate the same language extension >>> into a GPL&#x

Re: [Rd] Closed-source non-free ParallelR ?

2009-04-24 Thread Stavros Macrakis
On Thu, Apr 23, 2009 at 8:54 PM, Ted Harding wrote: > ...However, if that commercial interpreter also had a 'compile' option, > and I compiled my progrtam using that, then equally I feel sure > that the compiled version would be subject to whatever restrictions > had been placed on distirbution fo

Re: [Rd] Closed-source non-free ParallelR ?

2009-04-23 Thread Stavros Macrakis
I said: >> ...The GPL FAQs are the FSF's interpretation.  The R Foundation is not >> obliged to have the same interpretation, and of course the FSF cannot >> enforce licenses given by the R Foundation On Thu, Apr 23, 2009 at 5:34 PM, Marc Schwartz wrote: > Underlying all of your comments seem

Re: [Rd] Closed-source non-free ParallelR ?

2009-04-23 Thread Stavros Macrakis
On Thu, Apr 23, 2009 at 1:25 PM, Marc Schwartz wrote: > On Apr 23, 2009, at 11:47 AM, Stavros Macrakis wrote: >> >> All that being said, the entity that must enforce these conditions is >> not the FSF, but the copyright owner, in this case the R Foundation... >> bundle

Re: [Rd] Closed-source non-free ParallelR ?

2009-04-23 Thread Stavros Macrakis
The FSF clearly promulgated the GPL with the intent of prohibiting the bundling of GPL code with proprietary code. The way the GPL does this is by putting conditions on distribution: if you "distribute" a program "based on" a GPL program, the whole program must be licensed under the GPL. Clearly,

Re: [Rd] 'is.integer' (PR#13671)

2009-04-22 Thread Stavros Macrakis
Dear R experts, You are being a bit harsh on this user. He simply doesn't understand the distinction between "object of type integer" and "integer-valued object", which is actually fairly subtle. On Wed, Apr 22, 2009 at 1:45 PM, wrote: > This is a very simple function that seems not to be worki

[Rd] Using trace

2009-04-16 Thread Stavros Macrakis
I posted the query below on r-help, but perhaps r-devel is more suitable... (I guess "r-devel" should be read as "those who develop (i.e. write) programs in R" rather than "those who develop R"?) -s I would like to trace functions, displaying their arguments and return value, but I h

Re: [Rd] Assignment to string

2009-04-01 Thread Stavros Macrakis
On Wed, Apr 1, 2009 at 5:11 PM, Wacek Kusnierczyk < waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > Stavros Macrakis wrote: > ... > i think this concords with the documentation in the sense that in an > assignment a string can work as a name. note that > >`foo ba

Re: [Rd] Assignment to string

2009-04-01 Thread Stavros Macrakis
On Wed, Apr 1, 2009 at 4:21 PM, Simon Urbanek wrote: > > On Apr 1, 2009, at 15:49 , Stavros Macrakis wrote: > > The documentation for assignment says: >> >>In all the assignment operator expressions, 'x' can be a name or >>an expression defining

[Rd] Assignment to string

2009-04-01 Thread Stavros Macrakis
The documentation for assignment says: In all the assignment operator expressions, 'x' can be a name or an expression defining a part of an object to be replaced (e.g., 'z[[1]]'). A syntactic name does not need to be quoted, though it can be (preferably by backticks). But the

Re: [Rd] what is the preferred method to create a package local variable?

2009-03-31 Thread Stavros Macrakis
On Tue, Mar 31, 2009 at 12:41 PM, Martin Morgan wrote: > I don't konw about preferred, but one method is > > pkgVars <- local({ >x <- NULL >list(getX=function() x, setX=function(value) x <<- value) > }) > > with use > > > pkgVars$getX() > ... > This introduces a different programming para

[Rd] as.data.frame peculiarities

2009-03-31 Thread Stavros Macrakis
The documentation of as.data.frame is not explicit about how it generates column names for the simple vector case, but it seems to use the character form of the quoted argument, e.g. names(as.data.frame(1:3)) [1] "1:3" But there is a strange case: names(as.data.frame(c("a"))) [1] "if (stringsAsF

[Rd] Error message for matrix(1)[[1,,]]

2009-03-26 Thread Stavros Macrakis
> matrix(1)[[1,]] Error in matrix(1)[[1, ]] : invalid subscript type 'symbol' This is of course an incorrect use of [[, but I think the error message could be more helpful. I will guess that it is interpreting the missing value indicator as a symbol, since I get the same error message for > matri

Re: [Rd] dput(as.list(function...)...) bug

2009-03-24 Thread Stavros Macrakis
Peter, Duncan, I understand that the missing value indicator is special and will not behave like an ordinary value in evaluation. I was only discussing its handling in the text representation functions dput and dump. Duncan, You are absolutely right that "list(x=)" is parseable (though not evalu

[Rd] dput(as.list(function...)...) bug

2009-03-23 Thread Stavros Macrakis
Tested in R 2.8.1 Windows > ff <- formals(function(x)1) > ff1 <- as.list(function(x)1)[1] # ff1 acts the same as ff in the examples below, but is a list rather than a pairlist > dput( ff , control=c("warnIncomplete")) list(x = ) This string is not parsable, but dput does not give a warning as sp

Re: [Rd] [R] which.na

2009-03-20 Thread Stavros Macrakis
There are many other useful extensions one might imagine along these lines. For instance, we could have an argument for stopping the 'which' calculation at the first result (or the first N results), which is often useful (cf. any). But I think it would be much cleaner for things like this to be d

Re: [Rd] Match .3 in a sequence

2009-03-17 Thread Stavros Macrakis
Petr, Thank you for the detailed diagnosis of the bizarre behavior I reported, which seems to indicate several distinct problems in the underlying code: 1) Factor allows repeated levels, e.g. factor(c(1),c(1,1,1)), with no warning or error. 2) Even from distinct inputs, factor of a numeric vecto

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Stavros Macrakis
> cvseqf <- as.factor(cvseq) >> match(.3,cvseq) > [1] 2 > which worked. > In general, would it be better to go the enumeration route via as.factor or > the approximation route? > Thanks for the help. > -Dan > > On Mon, Mar 16, 2009 at 8:24 AM, Stavros Macrakis > wro

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Stavros Macrakis
Well, first of all, seq(from=.2,to=.3) gives c(0.2), so I assume you really mean something like seq(from=.2,to=.3,by=.1), which gives c(0.2, 0.3). %in% tests for exact equality, which is almost never a good idea with floating-point numbers. You need to define what exactly you mean by "in" for flo

Re: [Rd] Definition of [[

2009-03-15 Thread Stavros Macrakis
Duncan, Thanks for the reply. On Sun, Mar 15, 2009 at 4:43 PM, Duncan Murdoch wrote: > On 15/03/2009 2:31 PM, Stavros Macrakis wrote: >> dput(ll[3]) >> list(NULL) >> ? i is positive and exceeds length(x); why isn't this list(NA)? > > Because the sentence yo

[Rd] Definition of [[

2009-03-15 Thread Stavros Macrakis
The semantics of [ and [[ don't seem to be fully specified in the Reference manual. In particular, I can't find where the following cases are covered: > cc <- c(1); ll <- list(1) > cc[3] [1] NA OK, RefMan says: If i is positive and exceeds length(x) then the corresponding selection is NA. > dpu

Re: [Rd] Conversion and rounding of POSIXct

2009-03-15 Thread Stavros Macrakis
On Sun, Mar 15, 2009 at 1:04 PM, Dirk Eddelbuettel wrote: Dirk, Thanks for your reply. > a) you need to enable sub-second print formats Yes, if I want to display sub-second printing. But I was just looking at the rounding behavior. > b) AFAIK pre-epoch times are second-class citizens In wha

[Rd] Conversion and rounding of POSIXct

2009-03-15 Thread Stavros Macrakis
POSIXct/lt supports fractional seconds (see Sub-second Accuracy section of man page), but there seem to be some inconsistencies in their handling. Converting to POSIXlt and back does not give back the same time for times before the origin: > t0 <- as.POSIXct('1934-01-05 23:59:59.1') > t0 [1]

[Rd] Assigning to factor[[i]]

2009-03-15 Thread Stavros Macrakis
I am a bit confused about the semantics of classes, [, and [[. For at least some important built-in classes (factors and dates), both the getter and the setter methods of [ operate on the class, but though the getter method of [[ operates on the class, the setter method operates on the underlying

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Stavros Macrakis
>> (B) you cannot (easily) predict whether or not x will be modified >> destructively > > that's fine, thanks, but i must be terribly stupid as i do not see how > this explains the examples above.  where is the x used by something else > in the first example, so that 'names<-'(x, 'foo') does *not*

Re: [Rd] bug of *switch* function

2009-03-09 Thread Stavros Macrakis
On Mon, Mar 9, 2009 at 8:55 AM, guangchuang yu asked why switch(..., a <- 3, ...) doesn't have the same effect as switch(..., a=3, ...). In most contexts, `<-` and `=` are synonymous in R, and mean assignment. In function-argument position, however, an infix `=` names the argument. Switch depend

Re: [Rd] E`<`

2009-03-09 Thread Stavros Macrakis
On Mon, Mar 9, 2009 at 5:40 PM, Wacek Kusnierczyk wrote: > Stavros Macrakis wrote: >> Tested in: R version 2.8.1 (2008-12-22) / Windows > when i run these examples, the execution seems to get into an endless > loop with no error messages whatsoever.  how much time does it take &

[Rd] E`<`

2009-03-09 Thread Stavros Macrakis
Tested in: R version 2.8.1 (2008-12-22) / Windows Recursive default argument references normally give nice clear errors. In the first set of examples, you get the error: Error in ... : promise already under evaluation: recursive default argument reference or earlier problems? (function(a

Re: [Rd] [R] Semantics of sequences in R

2009-02-22 Thread Stavros Macrakis
On Sun, Feb 22, 2009 at 10:34 PM, Berwin A Turlach wrote: > G'day Stavros, Hello, Berwin, > On Sun, 22 Feb 2009 16:50:13 -0500 > Stavros Macrakis wrote: >> ...sort(list(...))), I'd hope that wouldn't break existing code. [...] > ...sort is a generic function

Re: [Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)

2009-02-22 Thread Stavros Macrakis
> I hope he realizes that we do appreciate the report. That's why it got such > quick attention. (I don't expect him to thank me for fixing it, either.) Thanks for the amazingly quick fix. -s __ R-devel@r-project.org mailing list https://s

[Rd] Operations on difftime (abs, /, c)

2009-02-22 Thread Stavros Macrakis
Forwarded from the r-help group -- r-devel seems more appropriate per Duncan's recent email. -s -- Forwarded message -- From: Stavros Macrakis Date: Fri, Feb 6, 2009 at 6:17 PM Subject: Operations on difftime (abs, /, c) To: "r-h...@r-project.org"

Re: [Rd] [R] Semantics of sequences in R

2009-02-22 Thread Stavros Macrakis
On Sun, Feb 22, 2009 at 4:12 PM, Duncan Murdoch wrote: > I think this was posted to the wrong list, so my followup is going to > R-devel. OK. > On 22/02/2009 3:42 PM, Stavros Macrakis wrote: >> >> Inspired by the exchange between Rolf Turner and Wacek Kusnierczyk, I >&g

[Rd] gc(reset=TRUE) reset timing

2009-02-11 Thread Stavros Macrakis
The man page for gc reads: The final two columns show the maximum space used since the last call to 'gc(reset=TRUE)' (or since R started). The word 'last' here is ambiguous: does it include the *current* call to gc? When I first read this, I assumed that it did not; indeed, I only real

[Rd] Variable/function namespaces WAS: Bug in subsetting data frame (PR#13515)

2009-02-10 Thread Stavros Macrakis
On Tue, Feb 10, 2009 at 10:11 AM, Duncan Murdoch wrote: > Stavros Macrakis wrote: >> On Tue, Feb 10, 2009 at 8:31 AM, Duncan Murdoch wrote: >>> The evaluator recognizes the context of usage and will get the >>> function for a function call >> Can you poi

Re: [Rd] Bug in subsetting data frame (PR#13515)

2009-02-10 Thread Stavros Macrakis
On Tue, Feb 10, 2009 at 8:31 AM, Duncan Murdoch wrote: > Stavros Macrakis wrote: > >> It is a bad idea to set data.frame <- xxx since R has a single >> namespace for functions and variables. >> >> > That's not quite accurate. R mixes functions and vari

Re: [Rd] Bug in subsetting data frame (PR#13515)

2009-02-10 Thread Stavros Macrakis
Don't know if this is the problem, but It is a bad idea to set data.frame <- xxx since R has a single namespace for functions and variables. -s On 2/10/09, xinlee...@stat.math.ethz.ch wrote: > Full_Name: Xin Lee > Version: 2.8.0 > OS: Windows XP > Submission from: (NULL) (193.200.15

Re: [Rd] Defining an iterator

2009-01-25 Thread Stavros Macrakis
Thank you for your helpful reply, which clarified several issues for me. -s __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] Defining an iterator

2009-01-25 Thread Stavros Macrakis
Inspired by Rudolf Biczok's query of Fri, Jan 23, 2009 at 1:25 AM, I tried to implement iteration in a generic way using S4. (Though I am admittedly still struggling with learning S4.) > setClass("foo",representation(bar="list")) [1] "foo" > x<-new("foo",bar=list(1,2,3)) Given this, I would not e