简体   繁体   中英

Plotting line graph in R with missing data in x-axis

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!

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.

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")

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM