【发布时间】:2016-06-29 13:37:46
【问题描述】:
我正在尝试使用 matplot 在 R 中绘制我的数据,但是,它不是从数据集中绘制数据。我的代码如下所示:
#----------------------------------------------------------------------------------------#
# RING data: Mikkel
#----------------------------------------------------------------------------------------#
# Set working directory
setwd
#### Read data & Converting factors ####
dat <- read.table("R SUM kopi.txt", header=TRUE)
str(dat)
dat$Vial <- as.factor(dat$Vial)
dat$Line <- as.factor(dat$Line)
dat$rep <- as.factor(dat$rep)
dat$fly <- as.factor(dat$fly)
str(dat)
mtdata <- droplevels(dat[dat$Line=="20",])
mt1data <- droplevels(mtdata[mtdata$rep=="1",])
lab<- c(expression(t[5]),expression(t[10]),expression(t[15]),expression(t[20]),
expression(t[25]),expression(t[30]))
matplot(mt1data, type="p", bty="n", xlim=c(7,12), ylim=c(1,1150), xlab="Time",
ylab="mm above bottom (sum)", las=1, xaxt="n", pch=1, col="black")
axis(side=1, at=c(7:12), label=lab)
我的数据集的输出如下所示:
结构(列表(小瓶=结构(c(6L,14L,4L,10L,13L,8L,5L,9L, 7L, 12L, 3L, 2L, 1L, 11L), .Label = c("82", "84", "86", "90", "99", “102”、“105”、“106”、“107”、“114”、“128”、“136”、“148”、“154”)、类 = "因子"), 浓度 = 结构 (c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("a", “b”、“c”、“d”、“e”、“x”、“y”), class= "因子"), Line = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "20", class= "factor"), 性别 = 结构(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("f", "m"), class= "factor"), 代表=结构(C(1L,1L,1L,1L,1L,1L,1L,1L,1L,1L, 1L, 1L, 1L, 1L), .Label = "1", class= "factor"), fly = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "1", class= "factor"), t05 = 结构(c(1L, 3L, 4L, 14L, 2L, 12L, 10L, 5L, 7L, 6L, 8L, 13L, 11L, 9L), .Label = c("227,58", "240,39", "244,35", “252,56”、“274,05”、“293,01”、“307,41”、“307,96”、“349,65”、 "359,25", "382,18", "440,50", "466,01", "580,44"), class= "因子"), t10 = 结构(c(1L, 4L, 3L, 14L, 2L, 12L, 11L, 9L, 7L, 6L, 5L, 13L, 10L, 8L), .Label = c("293,88", "335,89", "374,51", “376,65”、“380,28”、“383,73”、“405,51”、“423,63”、“425,79”、 "426,08", "427,69", "552,84", "615,73", "725,58"), class= "因子"), t15 = 结构(c(2L, 7L, 10L, 14L, 1L, 12L, 3L, 9L, 4L, 8L, 11L, 13L, 5L, 6L), .Label = c("423,10", "445,26", "469,83", “476,26”、“488,00”、“519,04”、“526,80”、“532,71”、“547,83”、 "577,98", "596,84", "683,46", "739,32", "795,60"), class= "因子"), t20 = 结构(c(4L, 8L, 7L, 13L, 1L, 12L, 3L, 10L, 5L, 11L, 6L, 14L, 2L, 9L), .Label = c("527,28", "551,07", "553,50", “575,46”、“581,73”、“627,94”、“635,94”、“654,21”、“661,23”、 "674,73", "724,77", "777,60", "862,02", "991,80"), class= "因子"), t25 = 结构(c(5L, 10L, 7L, 12L, 3L, 13L, 4L, 11L, 6L, 14L, 8L, 1L, 2L, 9L), .Label = c("1077,48", "603,97", "633,06", “652,59”、“674,40”、“680,19”、“721,18”、“748,74”、“757,89”、 "760,05", "792,99", "845,70", "864,54", "876,39"), class= "因子"), t30 = 结构(c(10L, 7L, 6L, 11L, 4L, 13L, 3L, 12L, 5L, 14L, 8L, 1L, 2L, 9L), .Label = c("1099,08", "638,59", "703,89", “744,06”、“751,95”、“772,48”、“795,15”、“800,40”、“820,53”、 "821,16", "828,24", "869,67", "912,66", "938,97"), class= "factor")), .Names = c("Vial", "Conc ", "Line", "Sex", "rep", "fly", “t05”,“t10”,“t15”,“t20”,“t25”,“t30”),row.names = c(1L,5L,8L, 12L, 13L, 18L, 21L, 23L, 25L, 28L, 32L, 35L, 38L, 42L), class= "data.frame")
【问题讨论】: