0

I am very new to R and would like to draw a line graph. I have got as far as importing my data into R and don't really know where to go next! I've searched the internet for examples of how to plot a line graph, but can't find anything that explains why the various commands are being used (which I think that I need to learn what is going on). Can anyone recommend any such tutorials/instructions that are aimed at the beginner?

Probably complicating the matter further, the line graph I'd like to draw doesn't have evenly spaced data points on the x-axis (0.19, 0.31 and 0.36). I'd like to reflect this in the plot, but have no idea how to program this.

Thanks in advance for everyone's help!

2 Answers2

0

There are many ways to plot in R. One is with Base r commands, like this

x <- c(0.19, 0.31, 0.36)

y <- c(1,2,3)

plot(x,y,type = "l")

Look online for plot examples for ggplot and lattice graphs.

Luis Candanedo
  • 907
  • 2
  • 9
  • 12
0

I suggest to report some data and and example of the code you are dealing with. It helps the community to examine your problem. Anyway, if I got your problem correctly, R deals automatically with NAs, that are not reported in the plot. You can have a line graph with type = "l" ("l" stands for "line") in the plot() function.

x <- rnorm(100)
plot(x, type = "l")

enter image description here

Worice
  • 3,847
  • 3
  • 28
  • 49