Search code examples
rscatter-plot

Scatterplot age against no y variable


I am trying to recreate a graph like below using R to visualize the age distribution of a sample with no success. It is a scatterplot of age, which I assume has been jittered or something similar to spread out the values up the y axis, and there is no y variable.

Any help would be much appreciated!

age distribution scatterplot


Solution

  • If you are trying to do an scatterplot,

    set.seed(5)
    
    ages <- rnorm(100,mean=50, sd=7)
    random_values <- rnorm(100, 0, 7) 
    
    plot(ages, random_values)
    

    If you have age as a single variable you always can do an Histogramm

    hist(ages)
    

    If you have number of t by age, you may be want to do a pyramid population plot