![](/img/trans.png)
[英]Multiple lines graph but I want to show the texts and the points in only one specific line
[英]How can I connect the line graph points one by one using lines function in R?
我的excel数据是这样的:
Date Total Bilirubin(umol/l)
10/18/2015 336.9
10/21/2015 352.7
10/24/2015 330.4
10/27/2015 310.2
10/30/2015 390.3
11/2/2015 378.3
11/5/2015 435.8
11/8/2015 449.3
11/11/2015 460.7
11/14/2015 385.3
11/17/2015 350.7
11/20/2015 278.6
11/23/2015 252.1
11/26/2015 180.8
11/29/2015 159.4
12/2/2015 105.5
12/5/2015 83.2
12/8/2015 64.4
12/11/2015 60.8
我用R画这样的线图:
dat<-read.xlsx("/Users/user/Research/Obstructive Jaundice/liuxuebin bilirubin.xlsx",sheetName = "liuxuebin_bilirubin")
dat$Date<-factor(dat$Date)
lines(dat$Date,dat$Total.Bilirubin.umol.l.,type="b",lwd=1.5,lty=3,col="red",pch=16)
我得到这样的图:
我想一点一点地连接点,以观察胆红素的变化趋势。
我怎样才能做到这一点?
我相信您的问题是“日期”列正在作为因子变量导入。 如果是这种情况,则将列转换为字符对象,然后转换为日期对象。 然后,绘图功能应该可以正常工作。
dat<-read.table(text="Date Total.Bilirubin(umol/l)
10/18/2015 336.9
10/21/2015 352.7
10/24/2015 330.4
10/27/2015 310.2
10/30/2015 390.3
11/2/2015 378.3
11/5/2015 435.8
11/8/2015 449.3
11/11/2015 460.7
11/14/2015 385.3
11/17/2015 350.7
11/20/2015 278.6
11/23/2015 252.1
11/26/2015 180.8
11/29/2015 159.4
12/2/2015 105.5
12/5/2015 83.2
12/8/2015 64.4
12/11/2015 60.8", header=TRUE)
#convert dat$Date from a factor to a Date object
dat$Date<-as.Date(as.character(dat$Date), format="%m/%d/%Y")
#plot image
plot(dat$Date,dat$Total.Bilirubin.umol.l.,type="b",lwd=1.5,lty=3,col="red",pch=16)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.