sum()

sum()

 The sum() function computes the sum of a series of values.

Example 1:

# Sum by indicating a series of values
sum(1, 2, 100)

Example output:

Output of sum() function for a series of values

Example 2:

# Sum by using a saved vector
expenses <- c(33, 74, 12, 248, 520)
sum(expenses)

Example output:

Output of sum() function for expenses

Example 3:

# Sum by indexing a column in a data frame
sum(Fingers$Thumb)

Example output:

Output of sum() function for Thumb

    • Related Articles

    • Sum of Squares (SS)

      Sum of Squares (SS) is the total area of the squared residuals; a way to quantify error, which gets around the problem of the sum of residuals adding up to 0; an important feature of SS is that the one number model that uniquely minimizes it is the ...
    • Sum of Absolute Deviations (SAD)

      Sum of Absolute Deviations (SAD) is the total of the absolute values of each deviation from the mean; a way to quantify error, which gets around the problem of the sum of deviations adding up to 0; also called SAE, Sum of Absolute Error.
    • variance

      Variance is also called MS, Mean Square; approximated by the sum of squares (SS) divided by the degrees of freedom (i.e., n-1); the MSE from the empty model can be thought of as roughly the average squared deviation.
    • Mean Square (MS)

      Mean Square (MS) is also called variance; approximated by the sum of squares (SS) divided by the degress of freedom (i.e., n-1); the MSE from the empty model can be thought of as roughly the average squared deviation.
    • proportion reduction in error (PRE)

      Proportion reduction in error (PRE) is the proportion of error that has been reduced by a more complex model compared with a simpler model, which in our course is always the empty model. When comparing to the empty model, PRE is calculated as SS ...