1

There is a very dense set of points I need to show - the pdf gets very large and I was thinking about only plotting every 10th data point

Example

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

How do I only plot every 4th data? I know I could create a new input data frame but isn't there some easier thing?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
heinheo
  • 537
  • 1
  • 4
  • 14
  • 1
    http://stackoverflow.com/questions/5237557/extracting-every-nth-element-of-a-vector might help you. – alexforrence Jun 14 '15 at 18:06
  • 1
    Also see http://www.r-bloggers.com/fix-overplotting-with-colored-contour-lines/ for some ideas to help with overplotting. `smoothScatter` is the base R solution – ping Jun 14 '15 at 18:19

1 Answers1

1

You could do something like this:

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)])
JasonAizkalns
  • 19,278
  • 6
  • 52
  • 107