2013-10-22 12 views
10

Cố gắng tìm hiểu cách thêm điểm hoặc chuỗi dữ liệu vào bảng điều khiển mạng hiện có khi nó được tạo. Điều này có cái gì để làm với plot.points và/hoặc chức năng cập nhật?Sáp nhập hoặc xếp lớp xyplots trong bảng điều khiển mạng

# Initialize first plot 
library(lattice) 
a <- xyplot(Sepal.Length~Sepal.Width, groups=Species, data=iris 
      , subset=Species %in% levels(Species)[1:2]) 
print(a) 

# Create second plot to overlay or merge with the first plot 
b <- xyplot(Sepal.Length~Sepal.Width, groups=Species, data=iris 
      , subset=Species %in% levels(Species)[3]) 

# Initial attempt at merging plots: 
library(latticeExtra) 
print(c(a,b)) # this displays the data in an adjacent second panel 
print(c(a,b,layout=c(1,1))) # and this only shows series "b" 

Lưu ý: trong ví dụ này, cả lô "a" và "b" đến từ bản gốc iris dataframe, nhưng lý tưởng, giải pháp sẽ làm việc với dataframes riêng biệt.

Bất kỳ ý tưởng nào? Cảm ơn!
Bryan

Trả lời

19

Bạn đang tìm kiếm as.layer, tôi nghĩ; thử cái này. Nó cũng nằm trong thư viện latticeExtra.

library(latticeExtra) 
a + as.layer(b) 

Xem tài liệu ở đây: http://latticeextra.r-forge.r-project.org/#as.layer

+0

+1! Bạn có lẽ nên đề cập đến sử dụng gói 'latticeExtra'. – agstudy

Các vấn đề liên quan