Question

I have a vector:

a<-runif(100)

I would like to plot each of the values of a on the y axis with the same position on the x axis using dots.

I tried

x<-1

barplot(x,a) 

but it gave me the error

Error in barplot.default(x = 1, a) : 
  argument 1 matches multiple formal arguments

what am I doing wrong?

No correct solution

OTHER TIPS

Use plot() instead of barplot() and turn the x values into a vector:

a<-runif(100)
x<-rep(1,times=length(a))       # x & a same length
plot(x,a,type="p")              #type = "p" : point

enter image description here

or in ggplot2

require(ggplot2)
a<-runif(100)
x<-rep(1,times=length(a))
qplot(x,a,geom="point") 
#OR
ggplot()+geom_point(aes(x,a))

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top