Thursday, May 2, 2019

r - How to plot multiple columns at the same time?

 Name     A         D
ChN 24.22 21.66
YuE 17.26 21.26
MiE 14.90 12.25
ChS 13.45 20.68
ZhW 12.51 23.02
HeW 10.47 12.50
HeE 12.87 22.39
LeW 15.01 22.43
ChW 12.05 12.83
LeE 15.26 12.94
Shg 12.96 12.18
YiW 13.36 12.74
Qig 10.47 12.98
GuN 12.66 12.80

I have the above data frame, and I want to plot both columns A and D with respect to column name in R using the following lines, however in the R, X axis becomes numbers and Y axis shows two different labels.
Can you please help me to know where the problem is and what is the correct method to do it?


plot(df$D, xlab=NULL,ylab=NULL, type="b",las=2,pch = 1,add=TRUE)
par(new=TRUE)
plot(df$A,xaxt = "n", xlab="", type="b",las=2,pch = 1,add=TRUE)

Thanks!
Leo!

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...