RStudio ggplot2 tutorial (multi-line timeline)

Поділитися
Вставка
  • Опубліковано 27 лип 2024
  • #RStudio #Tutorial #Coding
    An extension of my previous video to clear up any confusions or issues you might be having!
    ---------Contents of this video------------
    0:00 Intro
    0:16 Data organization
    0:48 The wrong plot!
    1:17 The right script
    2:04 Correct data configuration
    2:43 Why we need 2 geom_lines
    3:31 Configuring your legend
    4:44 Coloring your lines
    5:34 Geom_point
    6:03 Making a clean graph
    6:28 Showing the new plot
    7:04 Saving the plot
    7:14 Conclusion
  • Наука та технологія

КОМЕНТАРІ • 5

  • @tuhocr
    @tuhocr Рік тому

    Thanks for very useful video!

  • @christinazhang3703
    @christinazhang3703 Рік тому

    Hi, thanks for the video. which function can I use if I only want to show one of the lines, rather than all of them? Thanks

    • @ecomattp
      @ecomattp  Рік тому

      You can use the same exact syntax, just only tell it to select the single set of data you want to show in the line plot. For instance in this video I tell it to select both 2018 AND 2019 in the geom_line section. If I remove the geom_line for 2019 it would show the timeline with just 2018 data. You will also need to remove the geom_point line that calls on the 2019 data or else the data will show up still without a line. I hope this helps!

  • @raylsonmello6742
    @raylsonmello6742 2 роки тому +1

    Good Morning! can you make the script available?
    where it is?
    Very nice video.

    • @ecomattp
      @ecomattp  2 роки тому +1

      Here is the script including the packages I typically use for all of my figures:
      install.packages("dplyr") # one of the core packages of the tidyverse, extremely helpful for dataframe manipulation
      install.packages("tidyr") # used to help reshape data into tidy data that is easier to manipulate
      install.packages("permute") # allows you to perform permutations
      install.packages("lattice") # aids in graphics to provide better defaults to easily display multivariate relationships
      install.packages("vegan") # this is your go-to community ecology package. Used for ordination, diversity analysis and more.
      install.packages("goeveg") # aids your vegan package in ordination diagrams, species response curves, and rank-abundance curves
      install.packages("ggplot2") # your optimal package for creating excellent graphs and figures
      install.packages("tidyverse") # a collecton of R packages designated for data science (the parent package to ggplot2, dplyr, tidyr and more)
      install.packages("nlme") # for Gaussian linear and nonlinear mixed-effects models
      install.packages("ordinal") # facilitates analysis of ordinal data
      install.packages("ggsignif", type="win.binary") # significance brackets for ggplot2
      install.packages("ggpubr", type="win.binary") #This is the package for running anova with the stat_compare_means line
      install.packages("multcompView")
      install.packages("ggthemes")
      #now that we have installed our packages we need to access them by loading them in our library.
      library(ggpubr)
      library(ggplot2)
      library(dplyr)
      library(tidyr)
      library(permute)
      library(lattice)
      library(vegan)
      library(goeveg)
      library(tidyverse)
      library(nlme)
      library(ordinal)
      library(multcompView)
      library(ggthemes)
      #making a timeline with multiple lines and a legend
      precip