I have a problem while using a subset of a data.frame in R.
The subset gets created and displayed correctly, but when I try to plot it using qplot(), the rows which were not selected by the subset() also get shown along one axis.
The actual file I am reading in is a web server log, but I have created a small example to illustrate my pr...
I am newbie and have been searching for the past hour on how to do a simple function in R.
I have a very large dataframe with rows as observations and columns as genetic markers. I would like to create a new column that contains the sum of a select number of columns for each observation using R.
If I have 200 columns and 100 rows, I w...
I have a data.frame that contains historic data by day for several months. I would like to add a forecast to the end of this data.frame.
For example, I can run the following to create a simple example data.frame.
months <- c("2010-10-17","2010-10-18","2010-10-19","2010-10-20")
revenue <- c(10000,11000,10500,9500)
results <- data.fram...
I am working on finishing up a graph generated using ggplot2 like so...
ggplot(timeSeries, aes(x=Date, y=Unique.Visitors, colour=Revenue))
+ geom_point() + stat_smooth() + scale_y_continuous(formatter=comma)
I have attached the result and you can see the numeric values in the legend for Revenue do not have a comma. How can I add a co...
I have 5 items each of which can take on the value of 1 or -1. I want to generate a matrix that consists of rows of the possible combinations. The order of the items does not matter and the order of the combinations does not matter. I know I could do this mechanically, but I thought that someone must know a shortcut to generating this ma...
(please ignore this question - it is foolish...)
I want something that will do this:
rep(1:3, each = 1:3)
# And will output this vector:
c(1,2,2,3,3,3)
Does it exist? (and if so, how?)
Update: I can write it like this -
rep2 <- function(x, each)
{
output <- NULL
for(i in 1:length(x))
{
output <- c(output, rep(x...
How to convert ' in a string to \' in R?
Example: from Bob's to Bob\'s
...
I have a complicated combined model for which I can define a likelihood in a function, and I need to optimize the parameters. Problem is, the parameters go all directions if not restricted. Hence, I need to implement a restriction on the parameters, and the one proposed by the professor is that the sum of squared parameter values should ...
Hi all,
i´d like to assign factors representing quantiles. Thus I need them to be numeric.
That´s why I wrote the following function, which is basically the answer to my problem:
qdum <- function(v,q){
qd = quantile(v,1:(q)/q)
v = as.data.frame(v)
v$b = 0
names(v) <- c("a","b")
i=1
for (i in 1:q){
if(i == 1)
v$b[ v$a < ...
I tried to order csv file but the rank() function acting weird on number with -E notation.
> comparison = read.csv("e:/thesis/comparison/output.csv", header=TRUE)
> comparison$proxygeneld_full.txt[0:20]
[1] 9.34E-07 4.04E-06 4.16E-06 7.17E-06 2.08E-05 3.00E-05
[7] 3.59E-05 4.16E-05 7.75E-05 9.50E-05 0.000...
I am looking for an example of the r code for using Ornstein-Uhlenbeck to estimate time for mean reversion when considering cointegrated securities
...
Possible Duplicate:
Limiting variable scope
Is there a way to force R to ignore all objects set in the global environment? For example, let's say I have 'df' as an object outside of my function and I wish to use the same shorthand within my function, but not in reference to the object in the global environment
...
I have a data.frame with entries like:
variable importance order
1 foo 0.06977263 1
2 bar 0.05532474 2
3 baz 0.03589902 3
4 alpha 0.03552195 4
5 beta 0.03489081 5
...
When plotting the above, with the breaks = variable, I would like for the order to be preserved, rather t...
I love the plots that ggplot generates. However, it is still somewhat cumbersome to get publication quality plots directly. I usually have to do some post processing in Illustrator (i.e. changing fonts, numbering figures etc). While I could save as tiff or png, eps is best for manipulating figures in Illustrator (I can ungroup objects, m...
Hi,
I'm comparing some classifiers. My procedure is to compute the confusion matrix with the table command, and then calculate the false positive and true positive rates from the table. The routine I wrote requires that the table be square. There should be an easy way to do it.
My setup:
cm <- table(classifiers$teacher[which(classi...
Dear R users,
I have a set of data (1000+ animals) from two seasons (winter and summer) and would like to demonstrate the differences in the gestation length (days) pattern in these two seasons. My data is similar to this:
id <- c(1,2,3,4,5,6,7,8,9,10)
season <- c(1,1,2,2,1,2,1,1,2,1)
gest <- c(114,NA,123,116,NA,120,110,NA,116,119)
da...
I have performed statistical matching in R. For each case "VAR2002", I have found one or more statistical twin(s) "VAR2004".
In R, I have a data frame "TwinWeight" like this:
VAR2002 VAR2004 Weight
1 2955 1.00000000
2 3961 1.00000000
3 2913 0.33333333
3 3430 0.33...
I want to take a csv export of my bibtex literature database and analyse the correlation between keywords and Journals. I start off with a csv file containing one row per piece of literature, each one with a Journal name, and a keyword list, which is a slash deliminated list. I want to end up with either a matrix of Journal by Keyword ...
I have results from a survey. I am trying to create a graphic displaying the relationship of two variables: "Q1" and "Q9.1". "Q1" is the independent and "Q9.1" is the dependent. Both variables have responses from like scale questions: -2,-1,0,1,2. A typical plot places the answers on top of each other - not very interesting or informativ...
Because SO is a bit slow lately, I'm posting an easy question. I would appreciate it if big fishes stayed on the bench for this one and give rookies a chance to respond.
Sometimes we have objects that have a ridiculous amount of large list elements (vectors). How would you "unlist" this object into a single vector. Show proof that your ...