buhtz
buhtz

Reputation: 12152

How to generate random data with R to create a positive or negative skewed curve?

How can I create randomized data to create a positive or negative skewed curve in R and show them with hist().

Upvotes: 1

Views: 3576

Answers (1)

Elia
Elia

Reputation: 2584

It is straightforward to plot a skewed distribution with the beta distribution rbeta(). The beta distribution takes values from 0 to 1. If you want can rescale the data by multiplying it by a constant. You can generate right and left skewness by adjusting the shape1 and shape1 parameters

set.seed(5)
#left skewness 
hist(rbeta(100000,100,1)*10)
#right skewness 
hist(rbeta(100000,1,100)*10)

Upvotes: 5

Related Questions