rguides

Reference

Tidyverse

Common dplyr, purrr, and tibble workflows.

  1. dplyr::*_join()

    Join two data frames by matching rows based on key columns. Learn how to use dplyr join functions to combine datasets in R.

  2. dplyr::across()

    Apply functions across multiple columns in dplyr: across() modifies columns in place while where() selects columns by type or condition.

  3. dplyr::arrange()

    Sort rows of a data frame by column values in ascending or descending order using dplyr. arrange() reorder rows of a data frame based on column values.

  4. dplyr::bind_cols

    dplyr's bind_cols() combines data frames column-wise, matching rows by position rather than by key. Fast for aligned data, but risky when row orders differ.

  5. dplyr::bind_rows

    Stack two or more data frames by row with dplyr, matching columns by name and filling mismatches with NA. The optional .id column records each row's source.

  6. dplyr::bind_rows() / dplyr::bind_cols()

    Combine data frames by stacking rows or joining columns horizontally. bind_rows() and bind_cols() are dplyr functions for combining data frames.

  7. dplyr::case_when

    Create a new column using vectorized conditional logic with case_when(), handling multiple conditions in order, the dplyr equivalent of SQL's CASE WHEN.

  8. dplyr::count()

    Count the number of observations in each group. These dplyr verbs provide a convenient way to summarise data by grouping variables.

  9. dplyr::distinct

    Remove duplicate rows from an R data frame with dplyr::distinct(), keeping only unique combinations of specified columns.

  10. dplyr::filter()

    Subset rows of a data frame based on logical conditions using expressive dplyr syntax. keeps rows where all conditions are .

  11. dplyr::group_by()

    Group data by one or more columns with dplyr::group_by() and compute summary statistics using summarise(). Adds grouping metadata to a data frame.

  12. dplyr::if_else

    Type-strict vectorized if-else for R via dplyr::if_else(). Stricter than base ifelse(), handles NAs explicitly, and preserves factor types.

  13. dplyr::mutate()

    Create new columns or modify existing ones in a tibble using dplyr::mutate(). Adds or modifies columns through vectorised operations.

  14. dplyr::pull

    Extract a column from a data frame as a vector with dplyr::pull(). Defaults to the last column, supports negative indexing, and can produce named vectors.

  15. dplyr::relocate

    Move data frame columns to new positions with dplyr::relocate() using tidy-select syntax, including .before, .after, and renaming during the move.

  16. dplyr::select()

    Select columns from a data frame by name, position, or pattern with dplyr::select(). Supports helpers like starts_with(), ends_with(), and where().

  17. dplyr::slice()

    Select rows by position, head, tail, random sampling, or rank using dplyr slice functions. - is very fast; it uses integer indexing.

  18. dplyr::summarise()

    Collapse a tibble to one row per group using summary functions. Use .by (dplyr 1.1+) or group_by(). It accepts bare column names directly: instead of .

  19. fct_lump

    Collapse uncommon factor levels into an Other category. Covers fct_lump_n, fct_lump_prop, fct_lump_min, and fct_lump_lowfreq.

  20. fct_reorder

    Reorder factor levels with fct_reorder() by a summary statistic of a second variable. Reorders levels according to the summary without changing values.

  21. ggplot2::aes()

    Map variables to visual aesthetics in ggplot2. Covers aes(), aes_string(), aes_quosures(), and how column names become plot labels.

  22. ggplot2::coord_flip

    Flip horizontal and vertical axes in ggplot2. Swaps x and y so horizontal bar charts, boxplots, and histograms display cleanly without re-coding aesthetics.

  23. ggplot2::facet_wrap

    Wrap a 1D sequence of panels into a 2D grid with ggplot2. Control nrow, ncol, scales, strip position, and which axes are displayed.

  24. ggplot2::geom_bar()

    Draw bars with ggplot2::geom_bar() where height is proportional to count or value. Uses stat_count by default, mapping x to categories and y to frequencies.

  25. ggplot2::geom_boxplot

    Create box and whiskers plots in ggplot2 to visualise the distribution of a continuous variable across groups. **Returns:** A Layer object.

  26. ggplot2::geom_histogram()

    Use ggplot2 geom_histogram to show the distribution of a continuous variable. Bins the data and draws bars proportional to the count in each bin.

  27. ggplot2::geom_line()

    Use ggplot2 geom_line to connect observations in order with a line. Draws a line through data in sequence, suitable for time series.

  28. ggplot2::geom_point()

    Use ggplot2 geom_point to add a scatter plot layer. Covers position, size, colour, shape, alpha aesthetics, and position_jitter for overplotting.

  29. ggplot2::labs

    Use ggplot2 labs to set axis labels, legend title, plot title, subtitle, caption, and tag for a ggplot all in one place.

  30. ggplot2::scale_color_manual

    Define your own colour mappings in ggplot2 for discrete variables. Map factor levels to exact colours using a named or unnamed vector.

  31. ggplot2::theme

    Control non-data plot elements in ggplot2: titles, axis labels, legend, panel background, grid lines, and more.

  32. glue()

    Use the glue() function in R to format and interpolate strings with expressions inside braces. Evaluates R expressions inside braces for templating.

  33. interval

    Create an Interval object in lubridate, representing a time span between two specific datetime endpoints with calendar awareness.

  34. keep() / discard() / compact()

    Use purrr keep, discard, and compact to filter list or vector elements. Keep those matching a predicate, discard ones that don't, or remove NULL and empty.

  35. lubridate::ymd

    Parse dates in lubridate using ymd() for year-month-day format from character or numeric input, with automatic separator detection and truncation support.

  36. now

    Use lubridate now() to get the current system time as a POSIXct object. Controls timezone via the tzone argument with IANA strings like 'UTC'.

  37. purrr::discard

    Use purrr discard() to drop elements from a list or vector that match a predicate. Removes items where predicate is TRUE, the opposite of keep().

  38. purrr::map()

    Use purrr map() to apply a function to each element of a list or vector, returning a list. Typed variants like map_chr() return atomic vectors.

  39. purrr::map2

    Use purrr map2 to iterate over two vectors in parallel, applying a function pairwise. Type-specific variants return atomic vectors.

  40. purrr::pmap

    Use purrr pmap to iterate over multiple inputs simultaneously with a list of parameters. Feeds corresponding elements from each list as arguments.

  41. purrr::possibly

    Use purrr possibly to wrap any function and return a default value instead of crashing. Suppress errors or let them surface. The counterpart to safely().

  42. purrr::reduce

    Apply a binary function cumulatively to a list or vector with purrr reduce. Fold left, fold right, provide an initial value, and inspect intermediate results.

  43. purrr::safely() / purrr::possibly() / purrr::quietly()

    Use purrr safely to wrap functions, handle errors gracefully, and continue execution without failing. Returns list with result and error.

  44. purrr::walk()

    Use purrr walk to apply a function for its side effects, returning the input invisibly. For single vectors and walk2 for parallel iteration over two vectors.

  45. read_csv

    read_csv() reads a CSV file into a tibble with automatic type inference. Part of the readr package, supporting local files, URLs, and inline data.

  46. readr::write_csv()

    Write a data frame to a CSV file with readr. Covers parameters, NA handling, quoting, appending, compression, and common gotchas.

  47. rename() / relocate()

    Rename and reorder columns in a tibble or data frame using dplyr's rename() and relocate() functions. Both always return a new tibble.

  48. replace_na

    Replace NA values in R vectors and data frames with tidyr::replace_na(). replaces missing values () with a specified replacement value.

  49. separate()

    Split a character column into multiple columns using separate() by splitting on a delimiter pattern. Part of the tidyr package in the tidyverse.

  50. str_sub

    Extract a substring from a character vector using str_sub with inclusive start/end positions, with support for negative indexing from the end of the string.

  51. stringr::str_c()

    Join multiple strings into one string with optional separators. The function from stringr combines multiple strings into one.

  52. stringr::str_detect()

    Detect the presence or absence of a pattern in a string. The function from stringr detects whether a pattern exists within a string.

  53. stringr::str_extract()

    Extract the first matching pattern from a string. The function from stringr extracts the first matching pattern from a string.

  54. stringr::str_length()

    Get the length of a string in characters. The function from stringr returns the number of characters in a string.

  55. stringr::str_pad()

    Pad a string to a specified width by adding characters. The function from stringr pads a string to a specified width by adding filler characters.

  56. stringr::str_replace()

    Replace the first occurrence or all occurrences of a pattern in a string. The function from stringr replaces the first occurrence of a pattern in a string.

  57. stringr::str_trim()

    Remove leading and trailing whitespace from strings. The function from stringr removes leading and trailing whitespace from strings.

  58. tibble

    Create a tibble, a modern reimagining of the data frame in R, with better printing, stricter subsetting, and consistent behavior.

  59. tidyr::complete()

    Complete missing combinations with tidyr::complete(). Expands data to include all variable combinations, turning implicit NAs into explicit ones.

  60. tidyr::drop_na()

    Drop rows containing any missing values from a data frame using tidyr::drop_na(). Use drop_na() to quickly clean data before analysis or modelling.

  61. tidyr::fill

    Fill missing values in selected columns using the previous or next value with tidyr::fill(). Supports down, up, and bidirectional filling within groups.

  62. tidyr::nest()

    Nest data frames into list-columns with tidyr. Groups rows into nested data frames stored within a single row per group.

  63. tidyr::pivot_longer()

    Pivot data from wide to long format with tidyr. Stacks multiple columns into key-value pairs for tidy data analysis.

  64. tidyr::pivot_longer() / tidyr::pivot_wider()

    Reshape data between long and wide formats using tidyr's pivot functions. is the inverse: it spreads a key-value pair across multiple columns.

  65. tidyr::pivot_wider()

    Pivot data from long to wide format with tidyr. Spreads key-value pairs across multiple columns for presentation or analysis.

  66. tidyr::unnest()

    Unnest list-columns in data frames with tidyr. Expands nested data frames stored in list-columns back into regular rows and columns.

  67. tribble

    Create a tibble using a readable row-by-row layout with tribble(), the tidyverse alternative to data.frame() for small, human-readable tables.

  68. unite

    Unite multiple columns into one by pasting strings together. combines multiple columns into a single new column by pasting the values together as strings.