How do you generate a histogram using sample size of 1000 from a bin(50,0.8) distribution. I've found this hist() function but not sure how to get the bin distribution into R ?

How do you generate a histogram using sample size of 1000 from a bin(50,0.8) distribution. I've found this hist() function but not sure how to get the bin distribution into R ?

#create a place to store your resamples
histdat=rep(NA,1000)
#loop
for(i in 1:1000){
histdat=sum(sample(c(0,1),50,replace=T,prob=c(0.2,0.8)))
}
#plot
hist(histdat,breaks=seq(30,50,1))

#Check with theorectical curve
lines(seq(30,50,1),dbinom(seq(30,50,1),50,0.8)* 1e+3 ,col="green")