You can also use is.element(els,set) instead of the equivalent
els%in%set and leave your precedence problems behind.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, May 5, 2014 at 10:35 PM, peter dalgaard wrote:
>
> On 06 May 2014, at 01:05 , Hervé Pagès wrote:
>
>>
>> BTW, that %in% has p
Here is source code for help(Syntax) from S+, which I think follows
closely the original S help file:
.Ix precedence
The following \f6infix\fP operators are recognized by the parser.
They are listed in decreasing precedence.
In the event of ties, evaluation is from left to right.
.sp
.in +.5i
.nf
.
08:54 AM, William Dunlap wrote:
>>
>> You can also use is.element(els,set) instead of the equivalent
>> els%in%set
>
>
> No they are not *equivalent*. Equivalent means you could substitute
> one by the other in your code without changing its behavior.
>
> H.
/06/2014 12:36 PM, William Dunlap wrote:
>>
>> When does els%in%set give a different result than is.element(els,set)?
>> I assumed they were copied form S+, where they are the same except
>> for argument names, but I may be wrong.
>
>
> > els <- 2:1
>
errors with %in%.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, May 6, 2014 at 1:28 PM, Hervé Pagès wrote:
> On 05/06/2014 01:15 PM, William Dunlap wrote:
>>
>> In your example els%in%set gave the same result as
>> is.element(els,set), but because of precedence issues
It may come a time before the pchisq() function had the lower.tail
argument. In those days you had the compute the upper tail as
1-pchisq(x2, df). For any eps<2.2e-16 (.Machine$double.eps), 1-eps==1
so 1-(1-eps)==0 so you would get, e.g.,
> 1-pchisq(100,2)
[1] 0
and people would say 'but the
> It seems that when a vector has 10 elements, it prints out differently than
> one with 9 (extra space before the opening bracket). I can't see why this
> is happening.
It is happening because the print routine wants to be ready to print
all the line-beginning [index] tags aligned with each other
subsitute(expr), with only one argument, is only useful inside of a
function and then only when the expression, expr, involves an argument
to the function. Then the unevaluated actual arguments to the
function are substituted into the [unevaluated] expression.
E.g.,
f <- function(x, y=stop("y
You can make an environment called streamsEnv in your package by adding
streamsEnv <- new.env()
to one of your R/*.R files. (its parent environment will be
namespace:yourPackage) and your functions can assign things to this
environment instead of to .GlobalEnv.
Bill Dunlap
TIBCO Software
wdunla
Would you allow a list argument to diag() as well? I see that
Matrix::Diagonal does not accept it. Perhaps nothing in Matrix deals
with matrices of lists, but they are handy and for diag() it may be
simpler to allow lists than to check for and reject them.
Bill Dunlap
TIBCO Software
wdunlap tibco
The same is true in R-2.14.1 on Ubuntu 12.04.4 LTS . Put a trace on
system with
trace(system, quote(print(command)))
parallel::detectCores(TRUE)
and you will see the offending shell command.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Aug 22, 2014 at 1:03 PM, Marius Hofert
wrote:
uot;system" in package "base"
> [1] "system"
>>
> Tracing system(cmd, TRUE) on entry
> [1] "/usr/sbin/sysctl -n hw.ncpu 2>/dev/null"
> Error in system(cmd, TRUE) : error in running command
>>
>
> On Fri, Aug 22, 2014 at 6:13 PM,
In S+ and S it was valid to pass logicals to .Fortran, where they got
mapped into the
appropriate bit pattern. (The trouble was that 'appropriate' was
compiled into the program -
so you were locked into our compiler vendor's choice). Passing them
between Fortran
code and C code has always been a
R has support for options(warning.expression=...), but it acts
differently than the options(error=...).
S (and S+) let the user override the default '.Program' expression.
Its default value was essentially
print(.Last.value <- eval(parse(file=stdin(
but a replacement could add stuff like pr
I would use eval(), but I think that most formula-using functions do
it more like the following.
getRHSLength <-
function (formula, data = parent.frame())
{
rhsExpr <- formula[[length(formula)]]
rhsValue <- eval(rhsExpr, envir = data, enclos = environment(formula))
length(rhsValue)
}
length(rhsValue)
}
so that the function firstHalf is found in the following
> X <- 1:10
>
getRHSLength((function(){firstHalf<-function(x)x[seq_len(floor(length(x)/2))];
~firstHalf(X)})())
[1] 5
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Oct 17, 2014 a
>> y <- 10:1
>> z <- 11:20
>> afun(z ~ fun(x) + y)
> [[1]]
> [1] 11 12 13 14 15 16 17 18 19 20
>
> [[2]]
> [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
>
> [[3]]
> [1] 10 9 8 7 6 5 4 3 2 1
>
> It might be I'm walkin
You can put the following 3 objects, an environment and 2 functions
that access it, in any package that need some package-specific
storage (say your pkgB1 and pkgB2).
.pkgLocalStorage <- new.env(parent = emptyenv())
assignInPkgLocalStorage <- function(name, object) {
.pkgLocalStorage[[
> Presumably, the help file wording goes back to S-PLUS which
> (to my recollection) didn't allow zero-extent matrices.
Splus (and S) started having reasonable support for zero-extent
matrices in May 2001 (i.e., Splus 6.0, which I think corresponds
to S version 4-m of June 2, 1999), Splus5.0 (Nov
'Writing R Extensions', section 2.1 Rd format, says"
Comments run from a percent symbol % to the end of the line in all types of
text (as on the first line of the load example).
Because backslashes, braces and percent symbols have special meaning, to
enter them into text sometimes requires escape
> why is there no setcontains()?
Several packages define is.subset(), which I am assuming is what you are
proposing, but it its arguments reversed. E.g., package:algstat has
is.subset <- function(x, y) all(x %in% y)
containsQ <- function(y, x) all(x %in% y)
and package:rje has essentially t
There was recently a discussion here on how to tell if a number was
integral.
Did that prod someone into change as.hexmode in R-3.1.2 so that it aborts if
given a number to big to fit into a 32-bit integer? It returned NA, with
two warnings
in R-3.1.1.
% R-3.1.2 --quiet --vanilla
> as.hexmode(c(1
> if I want to use foo::bar many times, say
> in a loop, I would do
>
> foo_bar <- foo::bar
>
> and use foo_bar, or something along those lines.
The foreach package does that with a function from the compiler package,
so that foreach can work on old version of R:
comp <- if (getRversion() < "2.1
I wish it didn't have to depend on the name '.local'.
Back when I wrote a lot of S4 methods I avoided the auto-generated .local
and named the local function something that made sense so that is was easier
for a user to track down the source of an error.
E.g., define the generic QQQ with numeric a
You can start diagnosing the problem by capturing the matrix that caused
eigen() to stop. You can do this in a variety of ways; here is one
trace(eigen, quote(lastEigenX <<- x))
After setting the trace, make your offending function call and after the
error the global variable 'lastEigenX' wil
Would introducing the new frame, with the call to local(), cause problems
when you use frame counting instead of <<- to modify variables outside the
scope of lapply's FUN, I think the frame counts may have to change. E.g.,
here is code from actuar::simul() that might be affected:
x <- unl
Look at the 'self-starting' functions for nls(), such as SSasymp().
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Mar 4, 2015 at 5:01 AM, Evans Otieno Ochiaga <
evansochi...@aims.ac.za> wrote:
> Hi to all,
>
> Is there a way we can fit a non linear model to a data using non linear
> least
You can use nls's 'control' argument to work around this problem.
Read help(nls.control) for details.
nls(control = nls.control(minFactor=2^-20), ...)
will allow a smaller step factor than the default 2^-10 and loosening
the convergence tolerance with
nls(control = nls.control(tol=1e-4))
may
You said you changed F77_NAME(DGESV) to dgesv_ to make it
work and inferred that F77_NAME was the the problem.
I suspect that things got better because you changed the capitalization
and that F77_NAME(dgesv) would have worked as well.
Adding
#include
to your code would declare these things as
Did you leave out the warning from "+", which should be an error,
as it produces an illegal ordered factor in this case and factor+factor
is nonsensical? Or is the warning missing in the current development
version of R?
> x <- factor("A", ordered=FALSE) + factor(c("B","C"), ordered=TRUE)
Warning
For consistency with factor+factor and factor+numeric, factor+ordered
should produce a logical vector filled with NAs, not throw an error.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Mar 30, 2015 at 1:50 PM, William Dunlap wrote:
> Did you leave out the warning from "+",
One could redefine the "{" function with something like
`{` <- function(...) simplify2array(list(...))
but then you would have to live with the syntax it requires
(semicolons for separators instead of commas)
> {1; 2; 3}
[1] 1 2 3
> {{11;12;13}; {21;22;23}; {31;32;33}}
[,1] [,2
e_scalar$`{`
function (x)
{
build_sql("(", x, ")")
}
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Apr 17, 2015 at 7:49 AM, William Dunlap wrote:
> One could redefine the "{" function with something like
> `{` <- function(...)
> "Save the model frame in case you need to refit something next month"
> does not appear to be a safe approach to reproducible research.
Is this a standard recommendation? It will not work in many cases. E.g.,
if
you use lm() to model the sum of some variables the model.frame contains
only the
> And in general a developer would avoid masking a function
> in a base package, so as not to require the user to distinguish
> between stats::density() and igraph::density(). Maybe the
> example is not meant literally.
The 'filter' function in the popular 'dplyr' package masks the one
that has be
The difference in the return value of close(pipeConnectionObject)
seems to depend on whether the pipe connection was opened via
the pipe() or open() functions (close() returns NULL)
> con <- pipe("ls")
> open(con, "r")
> readLines(con, n=1)
[1] "1032.R"
> print(close(con))
NULL
Have you tried using trace()? E.g.,
> library(lavaan)
> trace(lavaan)
> HS.model <- ' visual =~ x1 + x2 + x3
+textual =~ x4 + x5 + x6
+speed =~ x7 + x8 + x9 '
>
> fit <- cfa(HS.model, data=HolzingerSwineford1939)
trace: lavaan(
Good luck in tracking down the problem. I won't give
any help there.
I've seen this sort of error message (or worse) when using
system.file() and the desired file didn't exist. If that
is the problem, add the newish argument mustWork=TRUE to
the call to system.file so you get an error message fr
> plotx <- "someName"
> modx <- "otherName"
> data.frame( structure(list(c(1, 2, 3, 4)), names=plotx), structure(list(c(4,
> 4, 4, 4)), names=modx))
someName otherName
11 4
22 4
33 4
44 4
(I think this is more of an R-help question
The shell command
R CMD something
currently acts as though it puts R_HOME/bin on the front
of PATH, looks for an executable file called 'something'
in PATH, and then executes it. The executable may call R
or it may not.
I think that running an R script file is sufficiently different
from runnin
I had noticed the same thing but figured that most
people (writers of predict methods) would be looking
up entries in dataClasses by name and not by position,
since predict's newdata argument need not have entries
in the same order as the data used to fit the model.
Hence the extra entry would not
BCO Software
wdunlap tibco.com
> -Original Message-
> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On
> Behalf Of William Dunlap
> Sent: Thursday, January 05, 2012 12:57 PM
> To: Paul Johnson; R Devel List
> Subject: Re: [Rd] delete.response
> -Original Message-
> From: Paul Johnson [mailto:pauljoh...@gmail.com]
> Sent: Friday, January 06, 2012 11:17 AM
> To: William Dunlap
> Cc: R Devel List
> Subject: Re: [Rd] delete.response leaves response in attribute dataClasses
>
> Thanks, Bill
>
> Counte
Using the precompiled R 2.14.1 on 32-bit Windows XP strtoi(x)
gives 2^31-1 for x>2^31-1 but NA when x goes out of range
in the negative direction:
> x <- c("2147483646", "2147483647", "2147483648", "2147483649")
> str(strtoi(x))
int [1:4] 2147483646 2147483647 2147483647 2147483647
> str(strtoi(s
Here is code that does make factor() work on a new
class like yours. It uses Sv3 methods.
> setClass("foo", contains="numeric")
[1] "foo"
> as.character.foo <- function(x) paste("x=",x@.Data,sep="")
> unique.foo <- function(x, ...) structure(NextMethod("unique"),
class=class(x))
> someF
Put the formula first in the argument list or label
the data argument data= and put the formula after it
if you want to use the formula method for ftable.
> ftable(data=UCBAdmissions, Gender + Admit ~ Dept)
Gender MaleFemale
Admit Admitted Rejected Admitted Rejecte
Since the problem can only occur if the 'to' file
exists, a check like
if (normalizePath(from) == normalizePath(to)) {
stop("'from' and 'to' files are the same")
}
(after verifying that 'to', and 'from', exist)
would avoid the problem.
S+ has a function, match.path, that can say if two
With most sorts of objects the following three expression
have the same value:
names(obj)
attr(obj, "names")
attributes(obj)$names
However, for call objects the last gives NULL, whether there
are names or not.
> obj <- quote(func(one=1))
> obj
func(one = 1)
> names(obj)
For what it is worth, the S+ package system uses
the java directory in source packages to store
java source code (under pkg/java/src/, using the usual
directory structure that follows the class structure
under there), prebuilt jar files (in pkg/java/prebuiltjars,
no subdirectories), and a Makevars
nesday, February 08, 2012 1:46 PM
> To: William Dunlap
> Cc: Roebuck,Paul L; R-Devel
> Subject: Re: [Rd] Canonical package directory name for JAR files?
>
> Unfortunately we cannot mandate JDK so packages have to use the build stage
> for compilation so the S+
> model doesn
Does the following example help? I installed Duncan Murdoch's
Rtools-2.13 into E:\Rtools-2.13 and R into E:\Program Files\R\R-2.14.1.
I put a small file of C code into E:\temp\junk.c. Here is record
of what I did after opening a new cmd.exe window. Setting PATH
is critical: put the 2 bin directo
It looks like my original path had R_HOME for
2.14.0 in it, but what I did works when that
was changed.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On
> Behalf Of Willi
If you put your prebuilt.exe into a directory under the
'source' package's inst directory, say yourPkg/inst/executables/win32,
then the installed package will have them in in
yourPkg/executables/win32 and the user (via code you
write, presumably) can get the full path to the executable
in the insta
I haven't used Julia yet, but from my quick reading
of the docs it looks like arguments to functions are
passed by reference and not by value, so functions
can change their arguments. My recollection from when
I first started using S (in the course of a job helping
profs and grad students do stati
rom: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On
> Behalf Of Hervé Pagès
> Sent: Monday, March 05, 2012 3:59 PM
> To: oliver
> Cc: R-devel
> Subject: Re: [Rd] Julia
>
> Hi Oliver,
>
> On 03/05/2012 09:08 AM, oliver wrote:
> > On Mon, Mar
; -Original Message-
> From: oliver [mailto:oli...@first.in-berlin.de]
> Sent: Tuesday, March 06, 2012 1:12 AM
> To: William Dunlap
> Cc: Hervé Pagès; R-devel
> Subject: Re: [Rd] Julia
>
> On Tue, Mar 06, 2012 at 12:35:32AM +, William Dunlap wrote:
> [...]
>
do that.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: oliver [mailto:oli...@first.in-berlin.de]
> Sent: Wednesday, March 07, 2012 10:22 AM
> To: Dominick Samperi
> Cc: William Dunlap; R-devel
> Subject: Re: [Rd] Julia
>
> On
functions (hence packages) difficult.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: oliver [mailto:oli...@first.in-berlin.de]
> Sent: Thursday, March 08, 2012 7:40 AM
> To: William Dunlap
> Cc: R-devel
> Subject: Re: [Rd] Julia
>
of
easily reusable functions that S allows.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: oliver [mailto:oli...@first.in-berlin.de]
> Sent: Thursday, March 08, 2012 2:23 PM
> To: William Dunlap
> Cc: R-devel
> Subject: Re: [Rd] Julia
Wouldn't within.environment be identical to with.environment?
> e <- new.env()
> with(e, { One <- 1 ; Two <- 2+2i ; Theee <- One + Two })
> objects(e)
[1] "One" "Theee" "Two"
It might make the transition between lists and environments
simpler if within.environment existed.
Bill Dunlap
S
> -Original Message-
> From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On
> Behalf
> Of Terry Therneau
> Sent: Thursday, March 29, 2012 7:02 AM
> To: r-devel@r-project.org
> Subject: Re: [Rd] CRAN policies
>
> On 03/29/2012 05:00 AM, r-devel-requ...@r-project.or
ubject: Re: [Rd] CRAN policies
>
> William Dunlap tibco.com> writes:
>
> > > -Original Message-
> > > The survival package has a similar special case: the routines for
> > > expected population survival are set up to accept multiple types of date
>
ot;local" "poisson" "quasi"
[28] "quasibinomial" "quasipoisson" "quote"
[31] "Quote" "require" "substitute"
[34] "with"
Bill Dunlap
Spotfire,
0
> people who have written CRAN packages by now; every extra check and non-back-
> compatible additional requirement runs the risk of generating false-negatives
> and
> incurring many extra person-hours to "fix" non-problems. Plus someone needs to
> document and explain the che
plot(1:10, xlim=c(10,1)) reverses the x axis.
If we allow plot(1:10, xlim=c(5,NA)), which
direction should it go?Would this require new
parameters, {x,y}{min,max} or new paremeters
{x,y}{axisDirection}?
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> Fro
S+ has such functions with a slightly different naming convention:
it puts an 's' after each function. E.g., colMaxs instead of your
colMax.
"colMaxs" "colMeans" "colMedians" "colMins" "colProds"
"colQuantiles" "colRanges""colStdevs""colSums" "colVars"
"ro
For what it's worth, S+'s substitute() has had an evaluate=FALSE argument
to substitute() for quite a while (I think it came with Sv4). evaluate=TRUE
means to evaluate its first arument:
> myCall <- call("myFunc", as.name("arg1"))
> substitute(myCall, list(arg1=as.name("newArg1")), evaluate=TR
If R's bs() and ns() are like S+'s (they do give very similar results* and
S+'s were written by Doug Bates), then bs() does not do any linear algebra
(like qr()) on splineDesign's output. bs() needs to come up with a default
set of knots (if the user didn't supply them), combine the Boundary.knots
That would have been essentially my suggestion as well. I prefer its clarity
(and speed). I didn't know if you wanted your solution to also apply
to matrices embedded in data.frames. In S+ rownames<-() works on vectors
(because it calls the generic rowId<-()) so the following works:
> f4 <- fu
Is the following behavior with as.data.frame(nm=...) a bug? It is an
inconsistency:
> as.data.frame(LETTERS[1:10], nm="FirstTenLetters")
Error in as.data.frame.vector(x, ..., nm = nm) :
formal argument "nm" matched by multiple actual arguments
nm= works for integer arguments:
> as.data.fram
q_len(100)), nm="x"))
user system elapsed
0.170.000.17
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> Sent: Friday, September 14, 2012 6:25 AM
> To: Bert
Why not write the RDS file more atomically - write it to a
temporary file and rename that file to its final name when
it is completely written? E.g.,
saveRDS.atomically
function (object, file, ...)
{
tfile <- tempfile(basename(file), dirname(file))
on.exit(if (file.exists(tfile)) unlink(
Thomas,
I noticed the delete.response() just returns its input if the input
is not of class "terms". Hence we get surprising (to me) results like
> env <- new.env()
> env # formulae have an environment, calls do not
> with(env, delete.response(y ~ x1 + x2)) # class "formula"
y ~ x1 +
That is an error in Splus 8.3. It must have changed quite a while
ago - it was an error in Splus 5.1, released in 1999 and I don't have
an older version handy right now. Current behavior is
> 1:10 + 0:1
[1] 1 3 3 5 5 7 7 9 9 11
> 1:10 + 0:2
Problem in 1:10 + 0:2: length of longer operan
Should simplify2array(higher=TRUE) treat 1 by 1 matrices differently than
others?
I expected a 3-dimensional array from all of the following 3 examples, not just
the last 2.
> str(simplify2array(list(array(11,c(1,1)), array(21,c(1,1))), higher=TRUE))
num [1:2] 11 21
> str(simplify2array(l
Hi Charley,
You can use the idiom
oldNaAction <- options(na.action=na.fail)
on.exit(options(oldNaAction))
or the slightly safer (protected again an interrupt
between the first two lines or an error calling options
to set them)
oldNaAction <- getOption("na.action")
on.exit(options(oldNa
> (even worse, path may contain '..' or
> likewise from a list.files(all.names=TRUE) call)
Would anyone's code break if "." and ".." were never in the output of
list.files() (or dir())? I find it tedious to skip them
whenever doing anything recursive in the file system. They are
not in the outpu
Would you mind elaborating on how rJava and RCaller
"are not useful after a certain extent"? I.e., are there
bugs, memory leaks, too limited an API, or other problems
with them?
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-devel-boun...@r-project
Ordinary functions should not alter their inputs but in R-2.15.2
svd(LINPACK=TRUE,X) does. (It worked in 2.15.0 but not in 2.15.1
or 2.15.2 and became deprecated in 2.15.2.)
> X <- matrix(c(1,2,3, 5,7,11, 13,17,19), 3, 3)
> X
[,1] [,2] [,3]
[1,]15 13
[2,]27 17
[3,]3
Why not just use some tag that R doesn't already use, say "Comment:", instead
of a #? If you allow # in position one of a line to mean a comment then people
may expect # to be used as a comment anywhere on a line.
(It may also mess up some dcf parsing code that I've written - it checks that
line
Note that changing this does not just mean getting rid of "silly warnings".
Currently, predict.lm() can give wrong answers when stringsAsFactors is FALSE.
> d <- data.frame(x=1:10, f=rep(c("A","B","C"), c(4,3,3)), y=c(1:4, 15:17,
28.1,28.8,30.1))
> fit_ab <- lm(y ~ x + f, data = d, subset = f
> I suspect it's only when you have a function in the quoted call, not a symbol:
Add a call to 'function' (as opposed to the function made by evaluating that
call)
to your test suite:
> Q <- list(
q1 = quote(getFunction("-")(x)),
q2 = substitute(f(x), list(f = function(x) {-x
Which part of the read-eval-print loop loop ("REPL loop") do you need?
source(file, print=TRUE) gives you the printing part, which is what I usually
want.
Opening a file connection and repeatedly calling parse(n=1) gives you the read
part,
> tf <- tempfile()
> cat(file=tf, sep="\n", "x <- 1
Circa 80 CRAN and core-R packages have duplicate export entries in their
NAMESPACE files. E.g.,
bit 1.1.9 : c("as.bit", "as.bitwhich", "as.which", "physical", "virtual")
forecast 4.1 : "forecast.lm"
graphics 2.15.3 : "barplot"
mcmc 0.9.1 : "morph"
RCurl 1.95.3 : "curlOptions"
util
Will you be doing the same for attribute names?
> options(prompt=with(version, paste0(language,"-",major,".",minor,"> ")))
R-2.15.3> x <- structure(17, AnAttr="an attribute", Abcd="a b c d")
R-2.15.3> attr(x, "A")
NULL
R-2.15.3> attr(x, "An")
[1] "an attribute"
R-2.15.3> attr(x, "Ab"
A user here noticed the following difference between Linux and Windows versions
of R-2.15.3 (and R-3.0.0, I think) when using times within a second of the end
of 1969:
f <- function (sec = -1)
{
x1 <- as.POSIXct(c(2 * sec, sec, 0), origin = "1970-01-01", tz = "UTC")
x2 <- as.POSIXlt(x1)
Hi Pat,
You could use substitute(),
> mycall <- quote(list(lm(Y ~ x1), lm(Y ~ x2)))
> do.call("substitute", list(mycall, list(lm=quote(stats::lm
list(stats::lm(Y ~ x1), stats::lm(Y ~ x2))
The do.call is necessary because substitute() does not evaluate
its first argument and we want 'myc
>>>> is.unsorted(NA)
>>> [1] NA
>>> => Contradicts "all objects of length 0 or 1 are sorted".
>
> Ok. I really think we should change the above.
> If NA is for a missing number, it still cannot be unsorted if it
> is of length one.
>
> --> the above will give FALSE "real soon now".
What is the intended difference between objects of class "ts",
which must have an attribute called "tsp", and objects with that
attribute but not that class?
Calling time series oriented functions like time() or window()
on vectors of numbers produce the classless objects with the
tsp attribute.
Shouldn't the F statistic (and p value) for the x2 term in the following calls
to anova() and add1() be the same? I think anova() gets it right and add1()
does not.
> d <- data.frame(y=1:10, x1=log(1:10), x2=replace(1/(1:10), 2:3, NA))
> anova(lm(y ~ x1 + x2, data=d))
Analysis of Variance Table
If you look at
data(package="Ecat")$results[,"Item"]
you will see the items "Hstarts", "Hstarts (Intratesm)", and "Hstarts
(Intratesq)"
which I think means that the dataset Hstarts is found in 3 .rda files,
"Hstarts.rda",
"Intratesq.rda", and "Intratesm.rda". There are duplicate, modulo (file
t; all.equal(envViet$MedExp, envMed$MedExp)
[1] "Names: 11 string mismatches"
[2] "Length mismatch: comparison on first 11 components"
[3] "Component 1: 'current' is not a factor"
...
[18] &qu
Had you tried using the new-to-3.0.0 options(CBoundCheck=TRUE)?
[from the NEWS file]
There is a new option, options(CBoundsCheck=), which controls how .C()
and .Fortran() pass arguments to compiled code. If true (which can be
enabled by setting the environment variable R_C_BOUNDS_C
Another way to avoid using rm() in loops is to use throw-away
functions. E.g.,
> t3 <- system.time(for (k in 1:ncol(x)) { # your last, fastest, example
+ a <- x[,k]
+ colSum <- sum(a)
+ a <- NULL # Not needed anymore
+ b <- x[k,]
+ rowSum <- sum(b)
+ b <- NULL # Not needed anymore
+ }
>> identical(ns(x, df = 2), ns(x, df = 2, knots = NULL))
> [1] FALSE
>> identical(ns(x, df = 2), ns(x, df = 2, knots = NULL))
> [1] TRUE
If you used a function like
identicalOrReturnInputs <- function(x, y) {
if (identical(x, y)) {
TRUE
} else {
list(x=x, y=y)
With today's R 2.10.0(devel) I get:
> anyDuplicated(c(1,NA,3,NA,5), incomp=NA) # expect 0
Warning: stack imbalance in 'anyDuplicated', 20 then 21
Warning: stack imbalance in '.Internal', 19 then 20
Warning: stack imbalance in '{', 17 then 18
[1] 0
> anyDuplicated(c(1,NA,3,NA,3), incomp=NA) # expec
I noticed the following file descriptor leak when I couldn't remove
a package unless I shut down the R session that had loaded and
used it. The function that triggered the problem printed the output
of a call to parse(). Each time one prints a srcref a connection is
opened and not closed. It loo
> ...
> The idea is that if the srcfile is already open, then it
> should be left
> open; but if it is not open, it should be closed at the end.
> open() on
> an open srcfile is supposed to make no change to the srcfile, just
> return the already open connection.
>
> > (It looks like the sr
Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com
> -Original Message-
> From: r-devel-boun...@r-project.org
> [mailto:r-devel-boun...@r-project.org] On Behalf Of Wacek Kusnierczyk
> Sent: Thursday, May 28, 2009 5:30 AM
> Cc: R help project; r-devel@r-project.org; A
It looks like the 'seq' variable to 'for' can be altered from
within the loop, leading to incorrect answers. E.g., in
the following I'd expect 'sum' to be 1+2=3, but R 2.10.0
(svn 48686) gives 44.5.
> x = c(1,2); sum = 0; for (i in x) { x[i+1] = i + 42.5; sum = sum +
i }; sum
[1] 44.5
or,
101 - 200 of 499 matches
Mail list logo