【发布时间】:2017-06-29 15:37:26
【问题描述】:
我的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$Date转换为factor,并按日期排序library(dplyr); dat %>% arrange(dat, Date) -
它不起作用。输出图与帖子中的图相同。我能做些什么?我只是想看看胆红素水平随时间的变化趋势。
-
尝试将日期列转换为日期对象
dat$Date<-as.Date(dat$Date, format="%m/%d/%Y") -
@Dave2e 非常感谢。但它也不起作用。我想我使用了错误的功能。但我不知道该使用哪个函数。