[R] plot: want only dots
Sarah Goslee
sarah.goslee at gmail.com
Tue Oct 15 18:47:42 CEST 2013
Hi,
Genotype is a factor, and R is giving you the default type for that data type.
I changed your data frame to mydata because df() is a function, but see this:
> str(mydata)
'data.frame': 20 obs. of 2 variables:
$ Genotype: Factor w/ 3 levels "0","1","2": 1 1 1 1 1 1 1 1 2 2 ...
$ z : num 0.0703 2.1574 0.514 0.4873 0.1558 ...
It sounds like you might want:
with(mydata, plot(as.numeric(as.character(Genotype)), z))
but if Genotype is best represented as a factor, that may not be the
most informative type of plot.
Sarah
On Tue, Oct 15, 2013 at 10:23 AM, Hermann Norpois <hnorpois at gmail.com> wrote:
> Hello,
>
> I would like to plot some values referring to the genotype (which is 0,1
> and 2). My data is organised like this:
>
> head (df)
> Genotype z
> 1 0 0.07029379
> 2 0 2.15739115
> 3 0 0.51395897
> 4 0 0.48733029
> 5 0 0.15584074
> 6 0 0.27755294
>
> I tried:
>> plot (df)
> And.
>> plot (z ~ Genotype, data=df)
>
> But it is always the same. As demonstrated in the attachment there are bars
> with mean etc... But I want dots only. How does this work?
>
> Thanks
> Hermann
>
>> dput (df)
> structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L), .Label = c("0",
> "1", "2"), class = "factor"), z = c(0.0702937908415368, 2.15739115226985,
> 0.513958971085714, 0.487330287677455, 0.155840743875606, 0.277552938739661,
> 0.507384510251828, 9.25159831317385e-05, 0.420814150642641,
> 10.628270981371,
> 0.518650521289299, 0.644448203670876, 0.133539811585953, 0.248985608185673,
> 0.152636019877717, 0.00964805339859479, 7.57036184259711e-05,
> 0.649435257991169, 0.38951827610564, 75.6011068681301)), .Names =
> c("Genotype",
> "z"), row.names = c(NA, 20L), class = "data.frame")
>>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list