How to create Needles chart in R?

Asked

Viewed 266 times

11

I am trying to make a chart of Needles suggested in the Matter of Non-parametric Methods in the study of Histograms.

I found a command called rug(), but it seems that the idea is not that.

1 answer

9


If you mean the Needle Plot, that is, plot the variables as sliders coming out of the zero (or minimum) axis, just put the parameter type = h in the plot.

For example:

with(economics, plot(date, unemploy, type="h"))

inserir a descrição da imagem aqui

As you mentioned histogram, you might want to see the points of a single variable along a line. For this you can use the dotplot of lattice.

The dotplot plot the points along a line:

set.seed(1)
y = rnorm(100)
library(lattice)
dotplot(y)

inserir a descrição da imagem aqui

You can complement the dotplot placing the "Needles":

dotplot(y, panel= function(x){
  panel.dotplot(x,factor(1))
  panel.xyplot(x, factor(1),col="black", type="h")
})

inserir a descrição da imagem aqui

  • 2

    That’s what I was looking for !

  • 1

    @Rafaelaraujo complemented with a univariate "Needle Plot", to see the distribution of points. If you think this answer answered, you can accept it by clicking on the "ok" symbol next to it, abs.

  • 2

    Very Top ! now yes and exactly what my teacher explained! I couldn’t find anywhere ! Thank you very much indeed !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.