[英]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.