我有一个数据框,其组织如下
Location Date x1.1DCE C12DCE Ethane Ethylene PCE 12DCE TCE VC
"IN-1B1" 2013-01-29 5.00 98.000 0.050 0.900 4.10e+02 5.000 12.000 5.00
"IN-1B1" 2013-06-27 0.50 385.000 10.000 10.500 2.80e+02 1.000 24.500 19.50
"IN-1B1" 2013-10-24 0.50 74.000 5.000 11.500 2.65e+02 1.000 22.500 7.45
"IN-1B2" 2007-08-28 0.25 0.280 NA NA 1.50e+02 0.250 1.900 0.25
"IN-1B2" 2007-10-31 0.50 0.310 NA NA 2.10e+02 0.500 4.500 0.50
"IN-1B2" 2008-04-02 4.15 4.150 NA NA 1.30e+02 4.150 1.800 4.15
"IN-1B3" 2007-10-31 0.25 0.300 NA NA 1.90e+02 0.250 1.700 0.25
"IN-1B3" 2009-05-06 0.25 0.170 NA NA 2.00e+02 0.250 1.500 0.25
第1列中的位置标识符标识了随时间收集样本的位置。有20个地点,每个地点都有不同时间收集的样本结果。我想创建结果(在列中)与时间的散点图矩阵,并使用位置标识符来描绘要包含在每个散点图中的数据。任何帮助或参考将不胜感激。感谢
答案 0 :(得分:0)
我想你可能正在寻找这个:
# creating initial dataframe
df <- read.table(text = "
Location Date x1.1DCE C12DCE Ethane Ethylene PCE 12DCE TCE VC
IN-1B1 2013-01-29 5.00 98.000 0.050 0.900 4.10e+02 5.000 12.000 5.00
IN-1B1 2013-06-27 0.50 385.000 10.000 10.500 2.80e+02 1.000 24.500 19.50
IN-1B1 2013-10-24 0.50 74.000 5.000 11.500 2.65e+02 1.000 22.500 7.45
IN-1B2 2007-08-28 0.25 0.280 NA NA 1.50e+02 0.250 1.900 0.25
IN-1B2 2007-10-31 0.50 0.310 NA NA 2.10e+02 0.500 4.500 0.50
IN-1B2 2008-04-02 4.15 4.150 NA NA 1.30e+02 4.150 1.800 4.15
IN-1B3 2007-10-31 0.25 0.300 NA NA 1.90e+02 0.250 1.700 0.25
IN-1B3 2009-05-06 0.25 0.170 NA NA 2.00e+02 0.250 1.500 0.25", header = TRUE, strip.white = TRUE)
# converting dataframe into long format
require(reshape2)
df2 <- melt(df, id=c("Location","Date"))
# creating a facetted plot
require(ggplot2)
ggplot(df2, aes(x=as.Date(Date), y=value, color=variable)) +
geom_point() +
facet_grid(. ~ Location)
结果: