Displaying 20 results from an estimated 6000 matches similar to: "Improving on edit()?"
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
2005 May 27
1
R commandline editor question
I am using R 2.1 on Apple OS X.
When I get the ">" prompt, I find it works well with emacs commandline
editing. Keys like M-f C-k etc. work fine.
The one thing that I really yearn for, which is missing, is bracket
matching When I am doing something which ends in )))) it is really
useful to have emacs or vi-style bracket matching, so as to be able
to visually keep track of whether I
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
2005 Aug 19
1
Problem with get.hist.quote() in tseries
When using get.hist.quote(), I find the dates are broken. This is with
R 2.1.1 on Mac OS X `panther'.
> library(tseries)
Loading required package: quadprog
'tseries' version: 0.9-27
'tseries' is a package for time series analysis and computational
finance.
See 'library(help="tseries")' for details.
> x <-
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 Jul 05
2
More difficulties in getting data into R
In order to get around the problems of my posting a few minutes ago, I
thought:
$ awk -F\| '(NR > 2) {print $2}' cmie_firm_data.text > col2
$ awk -F\| '(NR > 2) {print $4}' cmie_firm_data.text > col4
$ paste col2 col4 | head -2
-510.45 -510.27
60700 101900
$ paste col2 col4 | tail -2
28648.12 31617.02
491014.77 494308.52
$ wc -l col2 col4
89323 col2
2005 Sep 25
1
Question on lm(): When does R-squared come out as NA?
I have a situation with a large dataset (3000+ observations), where
I'm doing lags as regressors, where I get:
Call:
lm(formula = rj ~ rM + rM.1 + rM.2 + rM.3 + rM.4)
Residuals:
1990-06-04 1994-11-14 1998-08-21 2002-03-13 2005-09-15
-5.64672 -0.59596 -0.04143 0.55412 8.18229
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.003297 0.017603
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
2004 Mar 11
1
Difficulties in interaction between R and latex (prosper)
Hello, folks! I'm trying to use R as a graphics program, to make some
pretty graphs that will go into prosper slideshows.
I wrote this fragment, from the R manual, into a file demo.R:
x=seq(-3,3,0.1)
postscript("cm_test.eps", width = 4.0, height = 3.0,
horizontal = FALSE, onefile = FALSE, paper = "special",
family =
2005 May 08
2
Need a factor level even though there are no observations
I'm in this situation:
factorlabels <- c("School", "College", "Beyond")
with data for 8 families:
education.man <- c(1,2,1,2,1,2,1,2) # Note : no "3" values
education.wife <- c(1,2,3,1,2,3,1,2) # 1,2,3 are all present.
My goal is to create this table:
School College Beyond
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
2004 Oct 03
3
Making a 'joint distribution'?
Suppose I make two discrete variables --
> D <- data.frame(f1=sample(1:5,100,replace=T), f2=sample(1:5,100,replace=T))
I know I can do:
> table(D$f1, D$f2)
0 1 2 3 4
0 5 5 5 5 4
1 4 2 6 7 3
2 5 3 5 3 6
3 3 1 3 1 2
4 6 4 3 3 6
> table(D$f1)
0 1 2 3 4
24 22 22 10 22
> table(D$f2)
0 1 2 3 4
23 15 22 19 21
which is all great. But how do I produce the
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",
2005 Oct 01
1
Placing axes label strings closer to the graph?
Folks,
I have placed an example of a self-contained R program later in this
mail. It generates a file inflation.pdf. When I stare at the picture,
I see the "X label string" and "Y label string" sitting lonely and far
away from the axes. How can these distances be adjusted? I read ?par
and didn't find this directly.
I want to hang on to 2.8 x 2.8 inches as the overall size
2005 May 24
1
Catching an error with lm()
Folks,
I'm in a situation where I do a few thousand regressions, and some of
them are bad data. How do I get back an error value (return code such
as NULL) from lm(), instead of an error _message_?
Here's an example:
> x <- c(NA, 3, 4)
> y <- c(2, NA, NA)
> d <- lm(y ~ x)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
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
2005 Aug 16
1
Extracting some rows from a data frame - lapses into a vector
I have a data frame with one column "x":
> str(data)
`data.frame': 20 obs. of 1 variable:
$ x: num 0.0495 0.0986 0.9662 0.7501 0.8621 ...
Normally, I know that the notation dataframe[indexes,] gives you a new
data frame which is the specified set of rows. But I find:
> str(data[1:10,])
num [1:10] 0.0495 0.0986 0.9662 0.7501 0.8621 ...
Here, it looks like the operation
2004 Apr 08
2
Clever R syntax for extracting a subset of observations
I know that if:
x = seq(1,10)
d = c(7,3,2)
and if I say
y = x[d]
then I get the vector y as (7,3,2). Very clever! This idea is used
intensively with the boot library.
Now consider the following code (which works):
---------------------------------------------------------------------------
library(boot)
sdratio <- function(D, d) {
return(sd(D$x[d])/sd(D$y[d]))
}
x =
2004 Oct 03
1
How might one write this better?
I am trying to simulate the trajectory of the pension assets of one
person. In C-like syntax, it looks like this:
daily.wage.growth = 1.001 # deterministic
contribution.rate = 0.08 # deterministic 8%
Wage = 10 # initial
Asset = 0 # initial
for (10,000 days) {
Asset += contribution.rate * Wage
2004 Mar 01
6
Find out the day of week for a chron object?
I know that this is correct:
library(chron)
x = dates("01-03-04", format="d-m-y", out.format="day mon year")
print(x)
It gives me the string "01 Mar 2004" which is correct.
I also know that I can say:
print(day.of.week(3,1,2004))
in which case he says 1, for today is monday.
My question is: How do I combine these two!? :-) I have a