2015-06-14 105 views
1

有一個非常密集的點的集合,我需要證明 - 在PDF變得非常大,我想只繪製每10個數據點情節只有R中的某些點

plot(c(1:100),runif(100)) 

我如何只繪製每第四個數據?我知道我可以創建一個新的輸入數據框,但不是有一些更容易的事情嗎?

+1

http://stackoverflow.com/questions/5237557/extracting-every-nth-element-of-a-vector可以幫助你。 – alexforrence

+1

另請參閱http://www.r-bloggers.com/fix-overplotting-with-colored-contour-lines/瞭解一些有助於繪圖的想法。 'smoothScatter'是基本的R解決方案 – ping

回答

1

你可以做這樣的事情:

x <- runif(100) 

# Every 10th element 
plot(x[seq.int(1, length(x), 10)]) 

# Every 4th element 
plot(x[seq.int(1, length(x), 4)])