Search code examples
rplotscale

Making a one-dimensional plot with names of the data points in R


I have a list of data points (0.2, 0.8, 0.95) that I want to plot on a line. I want to create a one-dimensional scale (vertical or horizontal) of this range of values with the names of those data points (apples, bananas, tomatoes) juxtaposed to the data points, which are positioned on the scale. I know there is a relatively easy function to this in a package but I can't find it anymore! Please help :).

Thank you, Annemarie


Solution

  • I found a handy function in the vegan library to do this:

    x <- c(1,3.4,7,8,9,15,19)
    names <- c("apple","pear","banana","grapefruit","orange","tomato","cucumber")
    library(vegan)
    linestack(x, names, side = "left")
    

    Hopefully it is of use to somebody some time.