Friday, 15 June 2012

ggplot2 - line graph with 2 categorical variables and 1 continuous in R -


I am fairly new to R and figures in general. I am trying to plot a line graph in 2 ggplot2 (clear position of speech "position", position "truck") and a numerical one (score "total view").

  & gt; Df1 & lt; -df [, c ("trcond", "subtitle", "pos", "totacc")]> Head (DF1) Traction Subtitle Status Total 7 L New Sini_16 Lex 0.250 29 N New Sny_16 Lex 0.500 8 L New Seene 295 Lex 0.875 30 N New Sene 265 Lex 0.666 9 L New Scene 9 Lex 1.000 31 N New Scene 9 Lex 0.833  

I have used this ggplot2 command:

  & gt; Ggplot (data = summdfo, aes (x = pos, y = totacc, group = trcond, color = trcond)) + Geom_line () + geom_point ()  

but it is not working The graph is more colorful (blue and red) points in place and more than the two rows connecting to them. I have to post this article, as I lack words to understand, but this is my first post and I The image does not seem to be able to upload.

I have a standard simple 2 line graph in this page as blue and red (where y = total bill, x = time (grouped by gender):

Is this possible with my data? If so, what's wrong with the code?

< P> Here I tried to create a data frame

  df1 & lt; - data.frame (trcond = rep (c ('L', 'N') on your sample from your data. , 3), subtitles = delegate ('new view' 9 ', 6), # not use Only one dummy pause = C ('Lex', 'Lex', 'Lex', 'Knowles', 'Knowles', 'Knowles'), Nosycic = C (0.250, 0.5, 0.875, 0.666, 1.000, 0.833) )  

Because trcond is not balanced in this data frame, the plot is going to be messed up like this:

  ggplot (data = df1, aes (x) = Pos, y = totacc, group = trcond, color = trcond)) + geom_line () + geom_point ()  

However, if you apply a summary function which means the tools for each condition A perfect plot will appear:

  ggplot (data = df1, aes (x = pause, y = etx, group = trunk, color = truckman)) + GOML line (state = 'Summary', funny. '=' Mean ') + GOM_point (state =' summary ', funny. Y =' mean ')  

again, it is trying to figure out what's in your data. The best part is that here you provide a sample of your data using DTP (head (DF1, 50)) to give you better answers.


No comments:

Post a Comment