Welcome to Code Sharer, a code gallery for creating, saving and sharing all kinds of code snippets.

R — Simple Graph Plotting

Posted On: Monday, November 3, 2014 at 9:30 PM Last updated: Monday, November 3, 2014 at 9:40 PM


This is just a simple introduction to plotting graphs in R.





'type="l"' = line plot graph type

'xlab' and 'ylab' = x and y labels


'main' = title of graph
x<- c(1,2,3,4,5,6,7,8,9,10) # These values are for demonstration 
y<- c(10,9,8,7,6,5,4,3,2,1) # Respective y values
plot(x, y, type="l", xlab= "X", ylab= "Y", main="y over x", col="blue")

# If you use a script and have saved it in an appropriate place then, in the R Console write:

source("File Name.R")

# A graph should appear with your results.

Matt

Joined on Monday, November 3, 2014
Contributed 1 Snips

Get Social and Share

Tags