Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Linear graphics

I have a dataset in this way:

maximum <- c(10) #for each time
minim <- c(2) #for each time
Quantity c(4, 2, 10, 2, 10, 6, 2)

How can I structure my dataset to create a linear graphic like this? Time is always constant except when you go from 2 to 10 (they are at the same instant)

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Using base R plot functions, just create a Time vector (x-axis):

maximum <- c(10) #for each time
minim <- c(2) #for each time
Time <- c(1, 2, 2, 3, 3, 4, 5)
Quantity <-c(4, 2, 10, 2, 10, 6, 2)

plot(Time, Quantity, type = "l", col = "lightblue", xaxt = "n")
abline(h = maximum, col = "darkblue")
abline(h = minim, col = "orange")

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading