similar to: Bug in ecdf? Or what am I missing?

Displaying 20 results from an estimated 900 matches similar to: "Bug in ecdf? Or what am I missing?"

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
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
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
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
2008 Mar 07
4
Reading microsoft .xls format and openoffice OpenDocument files
1. I have used gdata::read.xls() with much happiness. But every now and then it breaks. I have not, as yet, been able to construct a mental model about the class of .xls files for which it works. Does someone have a simple rule for predicting the circumstances under which it will work? 2. Just like there is a read.xls(), it'd be great if we have a read.ods() which directly
2006 Jan 22
6
Making a markov transition matrix
Folks, I am holding a dataset where firms are observed for a fixed (and small) set of years. The data is in "long" format - one record for one firm for one point in time. A state variable is observed (a factor). I wish to make a markov transition matrix about the time-series evolution of that state variable. The code below does this. But it's hardcoded to the specific years that I
2006 Jan 26
2
Prediction when using orthogonal polynomials in regression
Folks, I'm doing fine with using orthogonal polynomials in a regression context: # We will deal with noisy data from the d.g.p. y = sin(x) + e x <- seq(0, 3.141592654, length.out=20) y <- sin(x) + 0.1*rnorm(10) d <- lm(y ~ poly(x, 4)) plot(x, y, type="l"); lines(x, d$fitted.values, col="blue") # Fits great! all.equal(as.numeric(d$coefficients[1] + m
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 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 --------------------------------+----------------------------------------
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
2004 Feb 19
6
R for economists (was: Almost Ideal Demand System)
Hi, I did not find any web page about using R in economics and econometrics so far. However, this does not mean that there is none (searching with google for "R" and "economics" gives many pages about economics and a name like Firstname R. Lastname on it ;-)). Does anybody in the list does know such a web page? If not, I will be happy if you, Ajay, could build and
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.
2009 Oct 17
2
How do I access with the name of a (passed) function
How would I do something like this: f <- function(x, g) { s <- as.character(g) # THIS DOES NOT WORK sprintf("The %s of x is %.0f\n", s, g(x)) } f(c(2,3,4), "median") f(c(2,3,4), "mean") and get the results "The median of x is 3" "The mean of x is 3" -- Ajay Shah
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 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 <-
2009 Mar 15
1
cbind(NULL,zoo.object)?
Folks, I often build up R objects starting from NULL and then repeatedly using rbind() or cbind(). This yields code like: a <- NULL for () { onerow <- craft one more row a <- rbind(a, onerow) } This works because rbind() and cbind() are forgiving when presented with a NULL arg: they act like nothing happened, and you get all.equal(x,rbind(NULL,x)) or all.equal(x,cbind(NULL,x)).
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
2009 May 14
2
How to do a pretty panel plot?
The pretty picture that I saw at: http://chartsgraphs.wordpress.com/2009/02/09/r-panel-chart-beats-excel-chart/#more-1096 inspired me to try something similar. The code that I wrote is: ------snipsnip--------------------------------------------------------------------- M <- structure(list(date = structure(c(13634, 13665, 13695, 13726, 13757, 13787, 13818, 13848, 13879, 13910, 13939, 13970,
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 =