Your code is correct, although the output you got is not correct, because the mean is way too far from 50 to have come from a binomial distribution. So I don't think that your alive1
was actually generated by the code you wrote. Here's a more typical sample:
set.seed(123)
alive<-100
alive1<-rbinom(20,alive,0.5)
alive1
## [1] 49 50 46 61 44 54 48 54 59 46 54 54 49 55 52 50 48 47 56 46
If you want it as a column vector (i.e. a matrix with one column), you can call as.matrix
:
alive1<-as.matrix(alive1)
alive1
## [,1]
## [1,] 49
## [2,] 50
## [3,] 46
## [4,] 61
## [5,] 44
## [6,] 54
## [7,] 48
## [8,] 54
## [9,] 59
## [10,] 46
## [11,] 54
## [12,] 54
## [13,] 49
## [14,] 55
## [15,] 52
## [16,] 50
## [17,] 48
## [18,] 47
## [19,] 56
## [20,] 46