The simplest kind of work we can do in R with a vector is to compute various elementary statistics.
For numerical vectors, a number of statistics can be computed:
min
and max
.mean
and median
.sd
.We can even combine these to compute, for example, standardized z-scores for the x values:
For character vectors, we typically want to build a count/frequency table, or a percent/relative frequency table:
y <- c("M", "F", "M", "F", "No Answer", "F", "M", "No Answer")
tally(y)
tally(y, format="percent") # for proportions
The tally command requires the hanoverbase package