Ggplot Line Graph. With x-axis treated as categorical. Create a line graph to compare the life expectancy lifeExp in the countries Japan Brazil and India.
You create a plot object using ggplot passing the economics DataFrame to the constructor. If the x variable is a factor you must also tell ggplot to group by that same variable as described below. This R tutorial describes how to change line types of a graph generated using ggplot2 package.
Running the above code yields the following output.
An ordered numeric variable for the X axis. For this we have to specify our x-axis values within the aes of the ggplot. Another numeric variable for the Y axis. Nov 16 2018 Plotting separate slopes with geom_smooth The geom_smooth function in ggplot2 can plot fitted lines from models with a simple structure.
