Build a function in R to calculate the mean and respectively, the variance where the distribution type of the v.a. is transmitted either by a name, or by the mass function in the discrete case, or by the probability density function in the continuous case.
so I have the idea,but I don't know how to implement it in R, especially when you have to introduce the name. Can you show me the start idea?