Displaying 20 results from an estimated 9000 matches similar to: "SUMMARY: "elementary sapply question""
2004 Jun 21
2
Elementary sapply question
I am discovering sapply! :-) Could you please help me with a very
elementary question?
Here is what I know. The following two programs generate the same answer.
--------------------------------+----------------------------------------
Loops version | sapply version
--------------------------------+----------------------------------------
2004 Jun 22
1
RE: summaries (was: SUMMARY: "elementary sapply question")
Ajay,
thank you very much for picking up that age-old habit of
posting summaries.
It existed years ago on s-help and I find it is still a great
thing: I would not have bothered to read your original question
nor the answers you got, but I did read the summary -- and I
learned something quite interesting!
Maybe some others who receive multiple non-elementary answers to their
questions could
2004 Aug 06
1
Elementary questions about data structures
Folks,
S_t = (x_t, y_t) is the state of a system at time t. There is an
iterative function which converts S_t into S_{t+1}. I can easily write
this in R like this:
iterate <- function(S) {
list(S$x+1, S$y+1)
}
So this function eats S_t and makes S_{t+1} and I can say
S2 <- iterate(S1)
My question: suppose I want to iterate from 1..10, what is the data
structure
2006 Mar 06
3
Interleaving elements of two vectors?
Suppose one has
x <- c(1, 2, 7, 9, 14)
y <- c(71, 72, 77)
How would one write an R function which alternates between elements of
one vector and the next? In other words, one wants
z <- c(x[1], y[1], x[2], y[2], x[3], y[3], x[4], y[4], x[5], y[5])
I couldn't think of a clever and general way to write this. I am aware
of gdata::interleave() but it deals
2004 Feb 09
1
Subset function of lm(); "rolling regressions"
Folks,
I asked a question on this mailing list about the subset support of
lm(). In a flash, I got three helpful responses from
Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
Erin Hodgess <hodgess at gator.uhd.edu>
and
Peter Dalgaard <p.dalgaard at biostat.ku.dk>
:-) and it was just great.
The mistake I was making was in not understanding the notion of a
2005 Jun 14
1
Puzzled in utilising summary.lm() to obtain Var(x)
I have a program which is doing a few thousand runs of lm(). Suppose
it is a simple model
y = a + bx1 + cx2 + e
I have the R object "d" where
d <- summary(lm(y ~ x1 + x2))
I would like to obtain Var(x2) out of "d". How might I do it?
I can, of course, always do sd(x2). But it would be much more
convenient if I could snoop around the contents of summary.lm and
2004 Jun 17
2
Question on lists and vectors of lists
I have an elementary programming question. Could someone please point
me in the right direction?
I have a function which will run for thousands of companies. At each
invocation, it returns 2 numbers. I plan to do something like:
think_one_firm <- function(filename) {
# Do stuff
return(list(x=x,y=y))
}
So for each of the firms in my dataset, I will call
2007 Aug 31
2
Bugreport on integration of Sweave and latex beamer
I think I have isolated a problem with integration between Sweave and beamer.
Could you please see the file:
http://www.mayin.org/ajayshah/tmp/bugdemo.Rnw
Unfortunately, it uses some of my internal libraries, so you can't run
it. When I put it through Sweave, I get:
http://www.mayin.org/ajayshah/tmp/bugdemo.tex
which is, of course, a generic latex file which you can read and
2005 Jun 07
1
R and MLE
I learned R & MLE in the last few days. It is great! I wrote up my
explorations as
http://www.mayin.org/ajayshah/KB/R/mle/mle.html
I will be most happy if R gurus will look at this and comment on how
it can be improved.
I have a few specific questions:
* Should one use optim() or should one use stats4::mle()?
I felt that mle() wasn't adding much value compared with optim, and
2005 Aug 26
1
update.packages() is broken?
Folks,
I am using R 2.1.1 on Apple OS X 10.3.
Earlier, I used to say
$ sudo R
> update.packages()
and all the packages used to get installed.
For several weeks, I noticed that nothing has been coming through. I
used the R-for-Mac graphics console and I find that there are many
packages where new versions have come out which I don't have. Is
something wrong with update.packages()?
I
2008 Mar 18
3
Puzzled at generating combinations
I have two data frames. Suppose the first has rows
r1
r2
r3
and the second has rows
R1
R2
R3
I'd like to generate the data frame:
r1 R1
r1 R2
r1 R3
r2 R1
r2 R2
r2 R3
r3 R1
r3 R2
r3 R3
How would I go about doing this? I'm sure there's a clean way to do it
but I find myself thinking in loops.
--
Ajay Shah
2004 May 27
3
Date parsing question
How do I parse a date "yyyymmdd"? I tried asking chron(s, "ymd") but
that didn't work. Would the date parsing routines of the Date class of
1.9 grok this?
--
Ajay Shah Consultant
ajayshah at mayin.org Department of Economic Affairs
http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
2008 Oct 15
2
"Heuristic optimisation"?
I wondered was people on this list felt about this article:
http://www.voxeu.org/index.php?q=node/2363
which talks about the problems of obtaining sound answers in numerical
optimisation in settings such as MLE or NLS.
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org http://ajayshahblog.blogspot.com
<*(:-? -
2004 Aug 17
1
An entire data frame which is a time-series?
I have :
raw <- read.table("monthly.text", skip=3, sep="|",
col.names=c("junk", "junk2",
"wpi", "g.wpi", "wpi.primary", "g.wpi.primary",
"wpi.fuel", "g.wpi.fuel", "wpi.manuf", "g.wpi.manuf",
2008 Mar 17
4
How does one do simple string concatenation?
How does one convert objects c("a","b","c") and "d" into "abcd"?
> paste(c("a","b","c"), "d")
of course yields
[1] "a d" "b d" "c d"
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org
2009 Mar 15
1
Stuck on building a package
Folks,
I have a personal package which used to build fine. Today when I tried
to build the package again, some errors popped up. Could you please
help? When I paste the offending function into an R it works
correctly. But the package build breaks.
$ R CMD check ansecon
* checking for working pdflatex ... OK
* using log directory '/Users/ajayshah/L/R/packages/ansecon.Rcheck'
* using R
2007 May 27
0
Not able to understand the behaviour of boot
Folks,
I have a time-series of 875 readings of the weekly returns of a stock
market index (India's Nifty). I am interested in the AR(1)
coefficient. When I do arima(r, order=c(1,0,0)) I get a statistically
significant AR1 coefficient.
If we apply the ordinary bootstrap to this problem, this involves
sampling with replacement, which destroys the time-series
structure. Hence, if we do
2004 Jun 13
0
MCMC tutorials
Hi Ajay:
A casual search of google using terms like "MCMC", "Markov Chains", "Monte
Carlo", and "tutorial" pulled up over 4000 hits. A few links that may
interest you, I thought, like:
http://csep1.phy.ornl.gov/CSEP/MC/MC.html
http://www.stat.fi/isi99/proceedings/arkisto/varasto/gree0167.pdf
http://www.maths.soton.ac.uk/staff/Sahu/utrecht/
...
and so
2007 Oct 28
1
maximizing a function
See
http://mayin.nfshost.com/ajayshah/KB/R/documents/mle/mle.html
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.
2008 Mar 05
1
New data source - now how do we build an R interface?
Folks,
A nice new data resource has come up -- http://data.un.org/
I thought it would be wonderful to setup an R function like
tseries::get.hist.quote() which would be able to pull in some or all
of this data.
I walked around a bit of it and I'm not able to map the resources to
predictable URLs which can then be wget. There's some javascript going
on that I'm not understanding.