Displaying 20 results from an estimated 10000 matches similar to: "more errors (behavior)"
2010 Aug 20
1
strange behavior of ifelse with factors
Dear R experts: this is probably correct behavior, but I do want to
point out that it is unexpected to someone not too well versed:
> test=factor("A","B","C","A")
> ifelse(test=="A", as.factor("A"), test)
[1] 1 2 3 1
ok, my factor was just coerced into integers, even though I have a
logical vector as my condition and factors as
2013 Feb 04
2
Contract Syntactic Sugar
## the following is a dream: add some sugar syntax to allow for
contracts with teeth (in and out checking)
> is.positive <- function(x) (all(x>0))
> exponentiate <- function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric {
x$base :: is.positive ## error also if base does not exist
in x; may need some special IQ
x$base^exponent
}
2013 Aug 20
7
Extending suggestion for stopifnot
I am using a variant of stopifnot a lot. can I suggest that base R
extends its functionality? I know how to do this for myself. this is
a suggestion for beginners and students. I don't think it would break
anything.
first, I think it would be more useful if it had an optional character
string, so users could write
stopifnot( is.matrix(m), "m is not a matrix" )
this would
2013 Feb 26
1
Light Libraries
Dear R-Help group:
I have been tinkering with how I want my personal standard library
functions to look like. They are not designed to be professional and
heavyweight, but lightweight. There are probably dozens of little bugs,
because I don't know or have not properly taken care of a variety of
internal R code issues. still, I like how this ended up, and there is no
learning curve, so I
2011 Apr 02
1
uniroot speed and vectorization?
curiosity---given that vector operations are so much faster than
scalar operations, would it make sense to make uniroot vectorized? if
I read the uniroot docs correctly, uniroot() calls an external C
routine which seems to be a scalar function. that must be slow. I am
thinking a vectorized version would be useful for an example such as
of <- function(x,a) ( log(x)+x+a )
uniroot( of, c(
2010 May 11
1
nls() and nls2() behavior?
first, apologies for so many posts yesterday and today. I am
wrestling with nls() and nls2(). I have tried to whittle it down to a
simple example that still has my problem, yet can be cut-and-pasted
into R. here it is:
library(nls2)
options(digits=12);
y= c(0.4334,0.3200,0.5848,0.6214,0.3890,0.5233,0.4753,0.2104,0.3240,0.2827,0.3847,0.5571,0.5432,0.1326,0.3481)
x=
2012 Mar 30
4
list assignment syntax?
Dear R wizards: is there a clean way to assign to elements in a list?
what I would like to do, in pseudo R+perl notation is
f <- function(a,b) list(a+b,a-b)
(c,d) <- f(1,2)
and have c be assigned 1+2 and d be assigned 1-2. right now, I use the clunky
x <- f(1,2)
c <- x[[1]]
d <- x[[2]]
rm(x)
which seems awful. is there a nicer syntax?
regards, /iaw
----
Ivo Welch
2012 May 09
2
big quasi-fixed effects OLS model
dear R experts---now I have a case where I want to estimate very large
regression models with many fixed effects---not just the mean type, but
cross-fixed effects---years, months, locations, firms. Many millions of
observations, a few thousand variables (most of these variables are
interaction fixed effects). could someone please point me to packages, if
any, that would help me estimate such
2012 Dec 24
2
parallelized version of "by" and "ave"
Dear R experts---
Has anyone written parallel versions of "by" (i.e., mcby) and "ave"
(i.e. mcave) ? I did ask a question like this a year ago, and then
the answer was no.
for those who are googling the group for the answer to this question,
in the meantime, the poor man's version of "by" is mclapply( split(
ds, factor ), FUN )
I don't know the poor
2010 Aug 18
1
Fwd: \ell symbol (log-likelihood)
I sent this privately to ivo welch yesterday, and he thinks it might
be useful to someone else as well. Since I'm on a Mac the screen
device is quartz():
> quartz()
> plot( c(0,1), c(0,1) );
> text( 0.5, 0.5, "\u2113" )
# and then File/Save As/
--
David.
Begin forwarded message:
> From: David Winsemius <dwinsemius at comcast.net>
> Date: August 17,
2010 Jan 08
4
fast lm se?
dear R experts---I am using the coef() function to pick off the coefficients
from an lm() object. alas, I also need the standard errors and I need them
fast. I know I can do a "summary()" on the object and pick them off this
way, but this computes other stuff I do not need. Or, I can compute (X'
X)^(-1) s^2 myself. Has someone written a fast se() function?
incidentally, I think
2010 Jun 11
3
lm without error
this is not an important question, but I wonder why lm returns an
error, and whether this can be shut off. it would seem to me that
returning NA's would make more sense in some cases---after all, the
problem is clearly that coefficients cannot be computed.
I know that I can trap the lm.fit() error---although I have always
found this to be quite inconvenient---and this is easy if I have only
2010 Aug 22
2
on abort error, always show call stack?
Dear R Wizards---is it possible to get R to show its current call
stack (sys.calls()) upon an error abort? I don't use ESS for
execution, and it is often not obvious how to locate how I triggered
an error in an R internal function. Seeing the call stack would make
this easier. (right now, I sprinkle "cat" statements everywhere, just
to locate the line where the error appears.) Of
2013 Feb 06
5
First R Package --- Advice?
Dear R experts---
after many years, I am planning to give in and write my first R
package. I want to combine my collection of collected useful utility
routines.
as my guide, I am planning to use Friedrich Leisch's "Creating R
Packages: A Tutorial" from Sep 2009. Is there a newer or better
tutorial? this one is 4 years old.
I also plan on one change---given that the
2010 Nov 03
1
Rd installation (not markup language) primer?
I have a set of functions that I always load on startup. for example,
there is my now infamous "is.defined()" function.
I would like to add some documentation for these functions, so that I can do a
?is.defined
inside R. The documentation tells me how to mark up Rd files is very
good, but I wonder how one installs them for access by the R
executable (on OSX for me). Do I drop
2010 Dec 03
1
"Nash Equilibrium"
Dear R experts:
I searched cran (and r-help) for "nash equilibrium" and "game" but
nothing stuck out. has someone written a numerical nash optimizer for
two players?
player a has choices x1,x2,x3,... and cares about (maximizes)
pa(x1,x2,x3,...,y1,y2,y3)
player b has choices y1,y2,y3,..., and cares about (maximizes)
pb(x1,x2,x3,...,y1,y2,y3)
I can tune it to my problem, but
2010 Apr 29
1
lm() with non-linear coefficients constraints? --- nls?
dear R experts---quick question. I need to estimate a model that looks like
y = (b*T+d*T^3) + (1-b-3*d*T^2)*x + (3*d*T)*x^2 + (-d)*x^3
I only have three parameters. Is nls() the right tool for the job, or is
there something faster/better?
/iaw
----
Ivo Welch (ivo.welch@brown.edu, ivo.welch@gmail.com)
[[alternative HTML version deleted]]
2012 May 31
2
print.data.frame to string?
dear R experts---is there a function that prints a data frame to a string?
cat() cannot handle lists, so I cannot write cat("your data frame is:\n",
df, "\n").
regards, /iaw
----
Ivo Welch (ivo.welch@gmail.com)
[[alternative HTML version deleted]]
2010 Nov 03
2
programming questions
quick programming questions. I want to "turn on" more errors. there
are two traps I occasionally fall into.
* I wonder why R thinks that a variable is always defined in a data frame.
> is.defined(d)
[1] FALSE
> d= data.frame( x=1:5, y=1:5 )
> is.defined(d$z)
[1] TRUE
> is.defined(nonexisting$garbage)
[1] TRUE
this is a bit unfortunate
2010 Aug 20
3
Date Inconsistencies? Buglets?
The treatment of dates seems to be a little inconsistent in R 2.11.1
(2010-05-31):
[1] The choice of origins?
> as.integer(as.Date("1970-01-01"))
works and assumes as origin 1970-01-01. However,
> as.Date(1)
does not work. It requires an origin (as.Date(1,
origin="1970-01-01")). If we set a default origin in the former, it
should probably work when the input