To plot a graph in R using a CSV file, we need a CSV file with two-column, the values in the first column will be considered as the points at the x-axis and the values in the second column will be considered as the points at the y-axis. In this article, we will be looking at the way to plot a graph using a CSV file in R language.
- Import csv file
- Pass required parameters to plot function
- Plot graph
- Display plot
- To import/read the CSV file to the R console, the user must need to use the read.csv() function in R.This function will read a CSV file available in your current working directory.
- plot() function for plotting of R objects. With the provided parameters this function returns a scatter plot by default.
- x:-the x coordinates of points in the plot
- y:-the y coordinates of points in the plot
- main:-an overall title for the plot
- sub:-a subtitle for the plot
- xlab:-a title for the x-axis
- ylab:-a title for the y-axis
- asp:-the y/x aspect ratio
Scatter plot of the given x and y values.