I am trying to plot two Y values row by row onto the same plot. Here is an example dataset (5 rows):
T0 <- c(1842,2047,1831,2627,1769)
T3 <- c(13842,6847,4480,15873,17163)
test <- data.frame(T0, T3)
test
T0 T3
1 1842 13842
2 2047 6847
3 1831 4480
4 2627 15873
5 1769 17163
I would like to produce a plot of the paired Y values (T0 and T3) for each row like this: 
My question is, how to iterate across rows and plot each pair of values?
Use matplot(), comes with R.
matplot(t(test), type='l')

You could use geom_segment, supplying fixed values of x = 0 and xend = 1 while supplying your two columns as y = T0 and yend = T3
library(ggplot2)
ggplot(test) +
geom_segment(aes(x = 0, xend = 1, y = T0, yend = T3))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With