Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
summarySE() is a function in the R package Rmisc that returns the count, mean, standard deviation, standard error of the mean and a confidence interval for one numeric column, optionally split by one or more grouping columns. If you typed “summaryse” meaning the tidyverse verb, that is summarise() (also spelled summarize()) from dplyr, covered below along with a dplyr recipe that reproduces summarySE exactly.
What it is used for in research
Researchers use summarySE() to get the numbers behind a means-with-error-bars plot: one row per group, with the mean and its uncertainty. The Rmisc documentation describes the return value as “a data frame with count, mean, standard deviation, standard error of the mean, and confidence interval (default 95%).” For background on the quantities, see the guides on the standard error of the mean and standard deviation in R, and the dictionary entry for confidence interval.
How to install or access it
Rmisc (“Ryan Miscellaneous”) is distributed on CRAN. The CRAN reference manual lists version 1.5.1 (2013-10-21), maintained by Ryan M. Hope. Install and load it with:
install.packages("Rmisc")
library(Rmisc)
Rmisc imports ddply from the plyr package, so plyr is installed alongside it. The package has not been updated since that 2013 release, which is one reason to know the dplyr route described under the steps below.
Step-by-step: mean, SE and confidence interval by group
The function signature
summarySE(data = NULL, measurevar, groupvars = NULL,
na.rm = FALSE, conf.interval = 0.95, .drop = TRUE)
| Argument | What the documentation says |
|---|---|
data |
A data frame. |
measurevar |
The name of the column that contains the variable to be summarized. |
groupvars |
A vector containing the names of the columns that contain grouping variables. |
na.rm |
A boolean that indicates whether to ignore NAs (default FALSE). |
conf.interval |
The percent range of the confidence interval (default 0.95, i.e. 95%). |
.drop |
Whether combinations of grouping variables that do not appear in the input data are dropped (TRUE, the default) or preserved (FALSE). |
Steps
- Load the package:
library(Rmisc). - Have your data in a data frame with one numeric column to summarize and one or more grouping columns (here called
df,score,groupandtime). - Pass the column names as quoted strings:
res <- summarySE(df, measurevar = "score", groupvars = c("group", "time"), na.rm = TRUE). - Change the interval if needed:
conf.interval = 0.99for a 99% interval. - Print
res, or pass it to ggplot2 as the data for a bar or point-and-error-bar layer.
The dplyr route: summarise() and summarize()
In dplyr, summarise() and summarize() are synonyms. According to the dplyr reference, it “creates a new data frame” and “returns one row for each combination of grouping variables”; with no grouping it returns a single row. Grouping is set with group_by() or with the per-operation .by argument. The following reproduces the quantities summarySE() returns, using the same formulas as the Rmisc source (SE = sd / sqrt(N); the interval multiplier is the t quantile with N – 1 degrees of freedom):
library(dplyr)
df |>
group_by(group, time) |>
summarise(
N = sum(!is.na(score)),
mean = mean(score, na.rm = TRUE),
sd = sd(score, na.rm = TRUE),
se = sd / sqrt(N),
ci = se * qt(0.975, N - 1),
.groups = "drop"
)
Expressions in summarise() can use columns created earlier in the same call, which is why se can use sd and N. For 0.975 substitute conf.interval / 2 + 0.5 to match a different interval. The dplyr documentation also warns that reusing an existing column name overwrites it: in its example, after disp is replaced by its mean, a later sd(disp) returns NA. That is why the code above names the new columns mean and sd rather than reusing score. See also grouping in R and mutate() in R for the related verbs.
Output and how to read it
Reading the Rmisc source (R/summarySE.R, via the rdrr.io source view), summarySE() computes per group the count N, the mean, the standard deviation sd, then se = sd / sqrt(N) and ci = se * qt(conf.interval/2 + .5, N - 1). The returned data frame has the grouping columns, then N, the mean (its column is renamed to the name you gave in measurevar), sd, se and ci.
- se is the standard error of the mean, the spread of the sample mean, not of the individual observations. Use
sdto describe the data andseto describe the precision of the mean. - ci is a half-width: the interval is mean – ci to mean + ci. It is a t-based interval, so it widens for small groups.
- With
N = 1the standard deviation is undefined, sosd,seandciwill not be usable for that group.
Troubleshooting
- could not find function “summarySE”: Rmisc is not installed or not loaded. Run
install.packages("Rmisc")thenlibrary(Rmisc). - NA in the mean, sd, se and ci columns:
na.rmdefaults toFALSE, so a missing value in a group propagates. Setna.rm = TRUE. - Missing group combinations: with
.drop = TRUE(the default) combinations absent from the data do not appear in the output; set.drop = FALSEto keep them. - Different arguments or column names than described here: other packages and tutorials define their own function called
summarySEwith their own defaults. Run?summarySEandpackageVersion("Rmisc")to confirm which one is attached. - “object not found” or variable errors: in summarySE() the column names go in as quoted strings (
"score"); in dplyr they are bare names.
Free alternatives
| Route | What it gives | Source |
|---|---|---|
| Rmisc::summarySE() | Count, mean, sd, SE and CI by group in one call | CRAN Rmisc reference manual |
| dplyr summarise() / summarize() | One row per group of any statistics you define, including the SE and t-based CI above; .by or group_by() sets the grouping |
dplyr reference, summarise() |
For a broader tour of built-in summaries, see summary statistics in R.
FAQ
What does summarySE do in R?
It summarizes one numeric column, by group if you supply grouping columns, and returns a data frame with count, mean, standard deviation, standard error of the mean and a confidence interval (95% by default).
Is summarySE the same as summarise?
No. summarySE() is a single-purpose function from the Rmisc package. summarise() (or summarize()) is a general dplyr verb in which you write each statistic yourself.
Which package is summarySE in?
Rmisc, on CRAN. Its reference manual lists version 1.5.1.
Is the confidence interval returned by summarySE a margin or the bounds?
Per the source, ci is the standard error multiplied by the t quantile, so it is a half-width to add to and subtract from the mean.
Sources
- Rmisc reference manual, summarySE (CRAN mirror: cran.csiro.au/web/packages/Rmisc/refman/Rmisc.html) and rdrr.io/cran/Rmisc/man/summarySE.html, read 2026-11-12.
- Rmisc source, R/summarySE.R: rdrr.io/cran/Rmisc/src/R/summarySE.R, read 2026-11-12.
- dplyr reference, summarise(): dplyr.tidyverse.org/reference/summarise.html, read 2026-11-12.







