tags:

views:

88

answers:

3

I have a vector of integers, e.g.: 2,8,11,19.

I would like to plot a line of length e.g. 20 then plot a dot for each value that exist in the list (at some constant height), so I get something like this:

-+-----+--+-------+-

+2  A: 
library(lattice)


x <- c(2, 8, 11, 19)
stripplot(x)

you can adjust the scales to your liking. see ?stripplot

Greg
+1 Thanks for the quick reply!
David B
+3  A: 

With the base graphics:

x <- c(2,8,11,19)
x <- data.frame(x,1) ## 1 is your "height"
plot(x, type="b")
Brandon Bertelsen
+1 Thanks for the quick reply!
David B
A: 

Brandon Bertelsen is really close...

x <- c(2,8,11,19)
x <- data.frame(x,1) ## 1 is your "height"
plot(x, type = 'o', pch = '|', ylab = '')

But I wrote this mostly to mention that you might also in base graphics look at stripchart() and rug() for ways to look at 1-d data.

John
Bertel"sen"! :P
Brandon Bertelsen
oops... fixed now
John