Displaying 20 results from an estimated 20000 matches similar to: "static variable?"
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
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
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
2010 May 11
3
Revolution R and the R Community?
As an end-user, I wonder about Revolution R. Is the relationship
between Revolution R and the R community at-large a positive one? Do
the former contribute to the development efforts of the latter? Is
there a competitive aspect? is their forum competitive with r-help?
any other thoughts? (most of all, I simply hope that they help some
of the many helpful experts on this forum, who have
2010 Jan 22
2
sorted reshaping?
dear R wizards:? I am wrestling with reshape.? I have a long data set
that I want to convert into a wide data set, in which rows are firms
and columns are years.
> summary(rin)
firm fyear sim1
Min. :1004.00 Min. :1964.0 Min. : -1.00000
1st Qu.:1010.00 1st Qu.:1979.0 1st Qu.: -0.14334
Median :1016.00 Median :1986.0 Median : 0.00116
Mean
2006 Apr 03
4
argv[0] --- again
dear R group: I have the probably fairly common problem that I would
like to have one code.R file do different things if it is invoked from
a symbolic link, which should be easy to uncover.
$ ln -s code.R code-0.R
$ ln -s code.R code-1.R
$ R CMD BATCH code-1.R
what needs to be in code-1.R to put code-1.r into a character vector?
help appreciated.
regards, /ivo welch
PS : I read
2009 Sep 15
2
why is nrow() so slow?
dear R wizards: here is the strange question for the day. It seems to me
that nrow() is very slow. Let me explain what I mean:
ds= data.frame( NA, x=rnorm(10000) ) ## a sample data set
> system.time( { for (i in 1:10000) NA } ) ## doing nothing takes
virtually no time
user system elapsed
0.000 0.000 0.001
## this is something that should take time; we need to add 10,000
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
2011 Mar 01
3
inefficient ifelse() ?
dear R experts---
t <- 1:30
f <- function(t) { cat("f for", t, "\n"); return(2*t) }
g <- function(t) { cat("g for", t, "\n"); return(3*t) }
s <- ifelse( t%%2==0, g(t), f(t))
shows that the ifelse function actually evaluates both f() and g() for
all values first, and presumably then just picks left or right results
based on t%%2.
2010 May 24
1
Fixed Effects Estimations (in Panel Data)
dear readers---I struggled with how to do nice fixed-effects
regressions in large economic samples for a while. Eventually, I
realized that nlme is not really what I needed (too complex), and all
I really wanted is the plm package. so, I thought I would share a
quick example.
################ sample code to show fixed-effects models? in R
# create a sample panel data set with firms and years
2008 Aug 25
8
SQL Primer for R
Dear R wizards:
I decided to take the advice in the R data import/export manual and
want to learn how to work with SQL for large data sets. I am trying
SQLite with the DBI and RSQLite database interfaces. Speed is nice.
Alas, I am struggling to find a tutorial that is geared for the kind
of standard operations that I would want in R. Simple things:
* how to determine the number of rows in a
2011 Oct 10
5
multicore by(), like mclapply?
dear r experts---Is there a multicore equivalent of by(), just like
mclapply() is the multicore equivalent of lapply()?
if not, is there a fast way to convert a data.table into a list based
on a column that lapply and mclapply can consume?
advice appreciated...as always.
regards,
/iaw
----
Ivo Welch (ivo.welch at gmail.com)
2013 Feb 07
4
Hard Stop?
is it possible to throw a stop() that is so hard that it will escape
even tryCatch?
/iaw
----
Ivo Welch (ivo.welch at gmail.com)
2007 May 17
4
bug or feature?
R version 2.5.0, under gentoo linux. This may be just my ignorance
about naming conventions inside loops and subsets, but the following
appears like a bug to me.
y = c( 1963, 1963, 1964, 1964, 1965, 1965 );
r1= rnorm(6);
d= data.frame ( y=y, r1=r1 );
## note: I am not attach()ing anything anywhere
## this should give me two results, which it does
ahw.y= subset(d, d$y==1963);
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]]
2007 Apr 20
2
cat() to STDERR
Dear R wizards---I read Brian Ripley's post from 2004 which said that
it was not possible to print to STDERR. Alas, I have more modest
needs. I was wondering if it was possible to just send a string to
STDERR with cat() while in CMD BATCH mode.
Is it not possible to open STDERR in R? (Or does R use STDERR for
itself and redirect it into the output stream?)
This would be on a standard Unix
2011 Jul 02
5
%dopar% parallel processing experiment
dear R experts---
I am experimenting with multicore processing, so far with pretty
disappointing results. Here is my simple example:
A <- 100000
randvalues <- abs(rnorm(A))
minfn <- function( x, i ) { log(abs(x))+x^3+i/A+randvalues[i] } ?## an
arbitrary function
ARGV <- commandArgs(trailingOnly=TRUE)
if (ARGV[1] == "do-onecore") {
?library(foreach)
?discard <-
2013 Feb 09
2
character strings with embedded commands: perl "/gee" ?
dear R experts---I am trying to replicate a perl feature. I want to be
able to embed R commands inside a character string, and have the
string be printed with the command executed. my perl equivalent is
my $a=10;
my $teststring = "the expression, $a+1, is ::$a+1::, but add one
more for ::$a+2::\n";
$teststring =~ s/::(.*?)::/$1/gee;
print $teststring;
of course, R does not use
2004 Jul 07
3
fast NA elimination ?
dear R wizards: an operation I execute often is the deletion of all
observations (in a matrix or data set) that have at least one NA. (I
now need this operation for kde2d, because its internal quantile call
complains; could this be considered a buglet?) usually, my data sets
are small enough for speed not to matter, and there I do not care
whether my method is pretty inefficient (ok, I