r - Stacking Scatterplots in ggplot2 -


I'm making scatterplots in R by ggplot2 to visualize the population over time. My data set looks like the following:

  sample_piper cage total_1 total_2 total_3 4 y 34 95 12 4n 89 12 13 5n 23 10 2  

I am creating individual scatterplots for total_1, total_2, and total number of variables with total code:

  qplot (data = blpcaged, x = sampling_period, y = total_1, color = cage_or_control) Qplot (data <= code = = sample_production, x = sampling_period, y = total_2, color = cage_or_control) qplot (data = BLPcaged, x = sampling_period, y = total_3, color = cage_or_control)  

I want to create a scatterplot in which over time Also contains information about the three people I want the final product to be made up of three Skatrplots top of each other and on the same scale axes. In this way I can compare all three populations in one scene.

I know that I can use the aspect to make different plots for one aspect level, but it is used for different variables << P>

You can use melt () to resize your code to total one factor As you can do the aspect:

  BLPcaged = data.frame (sampling_period = c (4,4,5), cage = c ('y' 'n', ' N '), total_1 = c (34, 9, 23), total_2 = c (95,12,10), total_3 = (12, 13, 2)) library (reshape2) BLPcaged.melted = Melt (BLPcaged, id.vars = c ('sampling_period', 'cage'), variable.name = 'total')  

Now looks like BLPcaged.melted :

  Sampling period cage total value 1 4 y total_1 34 2 4 n total_1 89 3 5 n Total_1 23 4 4 y Total_2 95 5 4 N Total_2 12 6 5 N Total_2 10 7 4 y Total 13 12 8 4 Total Total 13 9 5 N Total_3 2  

You can find it < Code> Total :

  ggplot (BLPcaged.melted, aes (sampling_period, value, color = cage)) + geom_point () + facet_grid (total ~.)  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -