I used the data, aml in survival package in R and computed a survival function by
"survfit". Since the result of survfit doesn't show the mean value,
I used the following code to print the mean:
print(survfit(Surv(aml1$time,aml1$status)~1),show.rmean=T)
(the data I used is, aml1 <-aml[aml$x="Maintained",])
The code above worked in...
I want to create a histogram from a number of observations (i.e. d <- c(1,2.1,3.4,4.5) ) and then highlight the bin that a particular observation falls in, such that I have an output that looks like this:
how do I do this in R?
...
How can I create a new on-screen R plot window with a particular width and height (in pixels, etc.)?
...
I have imported data with a five minute interval into a zoo object, where the index is a chron with both date and time:
> d
(09/09/09 16:45:10) 13.2 5.8
(09/09/09 16:50:10) 8.3 0.7
(09/09/09 16:55:10) 4.7 0.7
(09/09/09 17:00:10) 6.6 0.7
(09/09/09 17:05:10) 4.6 0.7
I am trying to aggregate by quarter hour intervals.
I f...
One of the most important issues in using factor analysis is its interpretation. Factor analysis often uses factor rotation to enhance its interpretation. After a satisfactory rotation, the rotated factor loading matrix L' will have the same ability to represent the correlation matrix and it can be used as the factor loading matrix, inst...
I'm using the SQlite package to interface with a database from R. However, I'm running into the issue that the results from exactly the same query are different when I run it in R or from the command-line interface.
For instance, the minimum value in a column is 0, but R somehow gives the result -2147332296. As I just copy-n-paste the q...
Is there a way, in R, to pop up an error message if a function uses a variable
not declared: i.e, i want someone to flag this type of functions
aha<-function(p){
return(p+n)
}
see; if there happens to be a "n" variable lying somewhere, aha(p=2) will give me an "answer" since R will just take "n" from that mysterious place called the...
Among the choices I have for quickly parallelizing simple code (snowfall, foreach, and so on), what are my options for showing the progress of all the slave processes? Do any of the offerings excel in this regard?
I've seen that snowfall 1.70 has sfCat(), but it doesn't seem to cat output to the master R session.
...
I would like to place the value for each bar in barchart (lattice) at the top of each bar. However, I cannot find any option with which I can achieve this. I can only find options for the axis.
...
How do I use strptime or any other functions to parse timestamps with milliseconds in R?
> time[1]
[1] "2010-01-15 13:55:23.975"
> strptime(time[1], format="%Y-%m-%d %H:%M:%S.%f")
[1] NA
> strptime(time[1], format="%Y-%m-%d %H:%M:%S")
[1] "2010-01-15 13:55:23"`
...
I have a bunch of Stata .dta files that I would like to use in R.
My problem is that the variable names are not helpful to me as they are like "q0100," "q0565," "q0500," and "q0202." However, they are labelled like "psu," "number of pregnant," "head of household," and "waypoint."
I would like to be able to grab the labels ("psu," "way...
I've got a R script for which I'd like to be able to supply several command-line parameters (rather than hardcode parameter values in the code itself). The script runs on Windows.
I can't find info on how to read parameters supplied on the command-line into my R script. I'd be surprised if it can't be done, so maybe I'm just not using...
I always have difficulty in finding all available alternative ways to produce a specific graph, either one that I have already decided to use (looking for different variations) or one that I have not yet thought of.
The R Graphical Manual site provides a complete list of samples of R's graphics functions, however it's easier for me to s...
Hello ,
Im trying to check for constance of variance for residuals with boxplots .
But when I ran the following expression in R I get this error . What is it aobut ?
boxplot(split(model$res,parental))
Error in split.default(model$res, parental) : object 'parental' not found
...
Dear R user,
I am searching for good R package to allign multiple spectra.
Thanks.
...
How do I write R code that allows me to execute a different path in my code if an error condition happens? I'm using a function that tends to throw an error. When it meets an error condition I would like to execute a different function. Here's a specific example:
require(SuppDists)
parms <- structure(list(gamma = -0.841109044800762, del...
I have some data that looks like the following. It is grouped by variable "Year" and I want to extract the percentiles of each observation of Score, with respect to the Year it is from, preferably as a vector.
Year Score
2001 89
2001 70
2001 72
2001 ...
..........
2004 87
2004 90
etc.
How can I do this? aggregate will n...
How can I create a chart like
http://junkcharts.typepad.com/junk_charts/2010/01/leaving-ink-traces.html
where several time series (one per country) are displayed horizontally as symmetric areas?
I think if I could display one time series in this way, it is easy to generalize to several using mfrow.
Sample data:
#Solar energy produ...
I've recently started using Sweave* for creating reports of analyses run with R, and am now looking to do the same with my python scripts.
I've found references to embedding python in Sweave docs, but that seems like a bit of a hack. Has anyone worked out a better solution, or is there an equivalent for python I'm not aware of?
* Swea...
If I have data like this
DF <- data.frame(
date = seq(Sys.Date()-1000, len=1000, by="1 day")[sample(1000, 500)],
price = runif(500)
)
How do I plot e.g. mean of price in the function of time, e.g. in months, using ggplot2?
...