First, create a data frame of the probability distribution. We will use Table 1 from Section 6.1.

Table1 <- data.frame("x" = c(0,1,2,3), "Prob" = c(.01,.1,.38,.51))
Table1
##   x Prob
## 1 0 0.01
## 2 1 0.10
## 3 2 0.38
## 4 3 0.51

To find the mean and standard deviation, use the Weighted.Desc.Stat package.

install.packages(("Weighted.Desc.Stat"))
library(Weighted.Desc.Stat)
w.mean(Table1$x,Table1$Prob)
## [1] 2.39
w.sd(Table1$x,Table1$Prob)
## [1] 0.7056203

So, \(\mu_X\) = 2.39 and \(\sigma_X\) = 0.7.

Note: There is also a weighted.mean command that is part of base R (so does not need a package).

weighted.mean(Table1$x,Table1$Prob)
## [1] 2.39