I would like to plot y1 and y2 in the same plot.
x <- seq(-2, 2, 0.05)
y1 <- pnorm(x)
y2 <- pnorm(x,1,1)
plot(x,y1,type="l",col="red")
plot(x,y2,type="l",col="green")
But when I do it like this, they are not plotted in the same plot together.
In Matlab can one do hold on, but does anyone know how to do this in R?
...
This is strange - I think?
library(ggplot2)
tf <- which(sapply(diamonds, is.factor))
diamonds.tf <- diamonds[,tf]
So far so good. But next comes the trouble:
pl.f <- ggplot(diamonds.tf, aes(x=diamonds.tf[,i]))+
geom_bar()+
xlab(names(diamonds.tf[i]))
for (i in 1:ncol(diamonds.tf)) {
ggsave(paste("plot.f",i,".png",sep=""), plot=pl.f,...
I'm using by() to evaluate a function by factors in my dataframe, but I need to use the results in a table form.
I've seen a use of as.data.frame.table to get a "By" class object into a data frame, but I'm not sure if this only works when the number of factors employed in the by() function is the same as the length of the "by" output. U...
The default value of a parameter of my function contains a "%". This seems to be a problem for roxygen, it produces a lot of warnings and R CMD check fails when trying to build latex documentation.
How can I make this function (and its documentation) work? Using %% or \% instead of % does not help.
#' Test escape \% from in-source docu...
If you have 2 cross classifying variables you can use rowSums and colSums to produce margin totals on an xtabs output. But how can it be done if you have 3 classifying variables (ie margin totals in each sub table)?
...
In R, given a vector
casp6 <- c(0.9478638, 0.7477657, 0.9742675, 0.9008372, 0.4873001, 0.5097587, 0.6476510, 0.4552577, 0.5578296, 0.5728478, 0.1927945, 0.2624068, 0.2732615)
and a factor:
trans.factor <- factor (rep (c("t0", "t12", "t24", "t72"), c(4,3,3,3)))
I want to create a plot where the data points are grouped as defined by ...
Suppose I have a dataframe like this one:
df <- data.frame (id = c("a", "b", "a", "c", "e", "d", "e"), n=1:7)
and a vector with ids like this one:
v <- c("a", "b")
How can I select the rows of the dataframe that match the ids in v? I can't use the id column for rownames because they are not unique. When I try that, I get:
rowname...
Okay, I'm fairly new to R and I've tried to search the documentation for what I need to do but here is the problem.
I have a data.frame called heeds.data in the following form (some columns omitted for simplicity)
eval.num, eval.count, ... fitness, fitness.mean, green.h.0, green.v.0, offset.0, green.h.1, green.v.1,...green.h.7, green.v....
I'm not sure how to do this without getting an error. Here is a simplified example of my problem.
Say I have this data frame DF
a b c d
1 2 3 4
2 3 4 5
3 4 5 6
Then I have a variable
x <- min(c(1,2,3))
Now I want do do the following
y <- DF[a == x]
But when I try to refer to some variable like "x" I get an erro...
I have data in the following format called DF (this is just a made up simplified sample):
eval.num, eval.count, fitness, fitness.mean, green.h.0, green.v.0, offset.0 random
1 1 1500 1500 100 120 40 232342
2 2 1000 1250 100 120 40 11843
...
I am using Python 3.1.1 on Mac OS X 10.6.2 and need an interface to R. When browsing the internet I found out about RPy. Is this the right choice?
Currently, a program in Python computes a distance matrix and, stores it in a file. I invoke R separately in an interactive way and read in the matrix for cluster analysis. In order to
simpl...
Is there an R package that connects to the Google Analytics API? Does anyone have any pointers otherwise?
...
I need to use a function on a vector that does not take a ts object. I'm trying to convert it to a plain old vector but I just can't seem to figure it out. I googled around but mostly people are trying to convert data types into ts object. I want to go the other way. Any help would be appreciated.
...
I've been using R v2.8.1 for a long time. Normally I would upgrade it to the latest version but something keeps me away from the builds later than 2.8.1:
I use
read.table(file=file.choose(),header=TRUE)
frequently in my libraries. After upgrading to 2.9.0, R started not to remember the latest directory used while selecting file. I do...
I often have to make stacked barplots to compare variables, and because I do all my stats in R, I prefer to do all my graphics in R with ggplot2. I would like to learn how to do two things:
First, I would like to be able to add proper percentage tick marks for each variable rather than tick marks by count. Counts would be confusing, whi...
In R, the plot() function takes a pch argument that controls the appearance of the points in the plot. I'm making scatterplots with tens of thousands of points and prefer a small, but not too small dot. Basically, I find pch='.' to be too small, but pch=19 to be too fat. Is there something in the middle or some way to scale the dots d...
I have this data frame:
structure(list(month_num = 1:24, founded_month = c(4L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 1L, 2L, 3L), founded_year = c(2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L,...
Hi,
In old DOS script, I can run an R script with the following syntax:
Rterm.exe --quiet --slave --vanilla < "C:\some_script.R"
However, Powershell seems to have reserved "<" for future expansion. I am wondering if there is a direct way to run R script within another powershell script.
Thanks
...
I have a data frame in R that has come about from running some stats on the result of a melt/cast operation. I want to add a row into this dataframe containing a Nominal value. That Nominal Value is present in the names for each column
df<-as.data.frame(cbind(x=c(1,2,3,4,5),`Var A_100`=c(5,4,3,2,1),`Var B_5`=c(9,8,7,6,5)))
> df
x Va...
(second question today - must be a bad day)
I have a dataframe with various columns, inculding a concentration column (numeric), a flag highlighting invalid results (boolean) and a description of the problem (character)
df <- structure(list(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), rawconc = c(77.4,
52.6, 86.5, 44.5, 167, 16.2, 59.3, 123,...