On Jun 11, 2013, at 10:44 AM, Brian Smith wrote:
> Hmm...I think it used to work before, but it gives an error now. Here is
> some sample code:
>
> =
> library(ggplot2)
> Sample <- rep(c('A','B'),rep(10,2))
> Vals <- sample(1:1000,20)
> dataf <- as.data.frame(cbind(Sample,Vals))
It'
s)
> str(dataf)
> #'data.frame':20 obs. of 2 variables:
> # $ Sample: Factor w/ 2 levels "A","B": 1 1 1 1 1 1 1 1 1 1 ...
> # $ Vals : int 96 712 765 121 154 78 821 258 812 51 ...
>
> ggplot(dataf,aes(x=Vals,colour=Sample))+geom_density() #no error
1 1 1 1 1 1 1 1 1 1 ...
# $ ValsĀ : intĀ 96 712 765 121 154 78 821 258 812 51 ...
ggplot(dataf,aes(x=Vals,colour=Sample))+geom_density() #no error
A.K.
- Original Message -
From: Brian Smith
To: r-help Help
Cc:
Sent: Tuesday, June 11, 2013 1:44 PM
Subject: [R] ggplot2 error: "E
I just wanted to point out that the construction:
dataf <- as.data.frame(cbind(Sample,Vals))
is **EVIL** .
Why?
cbind() constructs a matrix out of the separate vectors, and must
coerce columns of different types, as is the case here, to do so (a
matrix must be of one data type). Consequently
>
Hmm...I think it used to work before, but it gives an error now. Here is
some sample code:
=
library(ggplot2)
Sample <- rep(c('A','B'),rep(10,2))
Vals <- sample(1:1000,20)
dataf <- as.data.frame(cbind(Sample,Vals))
myplot <- ggplot(dataf,aes(x=Vals,colour=Sample)) + geom_density()
mypl
5 matches
Mail list logo