2015-03-02 45 views
-2

我想繪製不同行數的三個數據幀。我怎樣才能做到這一點我可以繪製多行數據相同的行數,但沒有其他。具有不同行數的數據幀的ggplot

如果想要一些數據。這裏是

selu    
47.05770 
44.56958 
45.83640 
54.03050 
51.02456 
42.87440 
47.90603 
48.32686 
45.52641 
50.60718 
52.70967 
48.82412 
50.42237 
50.13677 
49.09525 
53.59709 
51.51466 
50.36027 
50.87862 
49.93741 


selm 
41.66651 
41.31582 
42.03833 
39.62356 
38.36130 
36.48573 
42.38672 
35.25409 
32.86074 
45.82076 
42.23158 
44.24341 


sell 
42.64645 
45.15626 
44.93606 
46.84997 
46.11966 
48.22673 
46.02169 
46.22279 
49.61320 
46.91678 
47.42474 
44.53632 
41.92584 
43.34548 
37.15877 
40.92660 
36.46766 
49.43382 
50.75494 
50.99439 
47.70022 
44.02300 
44.80945 
48.05542 
46.93999 
46.18448 
48.04409 
46.97649 
45.24175 
42.72160 
43.40993 
49.23922 

我要像之下,但這裏的一個情節節數的值是相同的兩個數據幀,但data.frames上述不具有相同數量的值。在這種情況下,我如何去製作這樣一個情節

enter image description here

+1

你可以提供樣本數據嗎?我剛剛添加了 – cory 2015-03-02 20:27:49

+0

。謝謝。 – Jio 2015-03-02 20:33:58

回答

1

沒有任何類型的每個向量的時間段,我們剛離開去猜測,所以這裏亞去...

a <- read.table(textConnection("selu    
47.05770 
44.56958 
45.83640 
54.03050 
51.02456 
42.87440 
47.90603 
48.32686 
45.52641 
50.60718 
52.70967 
48.82412 
50.42237 
50.13677 
49.09525 
53.59709 
51.51466 
50.36027 
50.87862 
49.93741"), header=T, stringsAsFactors=F) 

b <- read.table(textConnection("selm 
41.66651 
41.31582 
42.03833 
39.62356 
38.36130 
36.48573 
42.38672 
35.25409 
32.86074 
45.82076 
42.23158 
44.24341"), header=T, stringsAsFactors=F) 

c <- read.table(textConnection("sell 
42.64645 
45.15626 
44.93606 
46.84997 
46.11966 
48.22673 
46.02169 
46.22279 
49.61320 
46.91678 
47.42474 
44.53632 
41.92584 
43.34548 
37.15877 
40.92660 
36.46766 
49.43382 
50.75494 
50.99439 
47.70022 
44.02300 
44.80945 
48.05542 
46.93999 
46.18448 
48.04409 
46.97649 
45.24175 
42.72160 
43.40993 
49.23922"), header=T, stringsAsFactors=F) 

names(a) <- names(b) <- names(c) <- "data" 
a$index <- 1:nrow(a) 
b$index <- 1:nrow(b) 
c$index <- 1:nrow(c) 
a$name <- rep("selu", nrow(a)) 
b$name <- rep("selm", nrow(b)) 
c$name <- rep("sell", nrow(c)) 

all <- rbind(a,b,c) 

library("ggplot2") 
ggplot(all) + geom_line(aes(x=index, y=data, color=name)) 

This is the result

+0

那正是我想要的。數據是河流上,中,下游水質指標的數據。因爲在這些流的每一箇中都有不相等的站點分類,因此不等長的數據。反正謝謝cory。我欣賞。 – Jio 2015-03-02 21:06:27

相關問題