codeGK
Code it ALL
R Line Graph - CodeGK
♦ R Line Graph

♣ About R Line Graph

Line Graph simply plots the vector values on the graph(vs x) and then connects the points by a line.
R language uses the function plot() function to create a Line Graph.

♣ R Line Graph Syntax

Below is the representation of R Line Graph Syntax.
Basic Syntax
plot(v, main, type, col, xlab, ylab)
Syntax Explanation:
Table Info
ParameterUsage
vvector containing numeric values of y-coordinate to be plotted
maintitle of the Line Graph
typep : to draw only the points
l : to draw only the lines
o : to draw both points and lines
colvector specifying color of each line(optional)
xlablabel for x-axis
ylablabel for y-axis

♣ Example1: Plotting Data using Line Graph in R

In this example: Plotting square of x values range from -3 to +3.
Example
Input:
Output:
Prev_LessonNext_Lesson
R Line Graph