Suppose I have an exponential distribution with rate 0.5 and n=1000 together with a uniform distribution between 0 and 1. And I also need to draw a histogram. Write the R code.

The R code I wrote is :

x=rexp(1000,0.5)

u=runif(1000,min=0,max=1)

hist(x)

Just wanna know whether my R code is correct? Do I need to perform the inversion method here?