R Language: A Quick Reference Guide – IV

R Quick Reference Guide

Quick Reference Quide R Language

R language: A Quick Reference Guide about learning R Programming with a short description of the widely used commands. It will help the learner and intermediate user of the R Programming Language to get help with different functions quickly. This Quick Reference is classified into different groups. Let us start with R Language: A Quick Reference – IV.

This Quick Reference will help in performing different descriptive statistics on vectors, matrices, lists, data frames, arrays, and factors.

Basic Descriptive Statistics in R Language

The following is the list of widely used functions that are further helpful in computing descriptive statistics. The functions below are not direct descriptive statistics functions, however, these functions are helpful to compute other descriptive statistics.

R CommandShort Description
sum(x1, x2, … , xn)Computes the sum/total of $n$ numeric values given as argument
prod(x1, x2, … , xn)Computes the product of all $n$ numeric values given as argument
min(x1, x2, … , xn)Gives smallest of all $n$ values given as argument
max(x1, x2, …, xn)Gives largest of all $n$ values given as argument
range(x1, x2, … , xn)Gives both the smallest and largest of all $n$ values given as argument
pmin(x1, x2, …)Returns minima of the input values
pmax(x1, x2, …)Returns maxima of the input values

Statistical Descriptive Statistics in R Language

The following functions are used to compute measures of central tendency, measures of dispersion, and measures of positions.

R CommandShort Description
mean(x)Computes the arithmetic mean of all elements in $x$
sd(x)Computes the standard deviation of all elements in $x$
var(x)Computes the variance of all elements in $x$
median(x)Computes the median of all elements in $x$
quantile(x)Computes the median, quartiles, and extremes in $x$
quantile(x, p)Computes the quantiles specified by $p$

Cumulative Summaries in R Language

The following functions are also helpful in computing the other descriptive calculations.

R CommandShort Description
cumsum(x)Computes the cumulative sum of $x$
cumprod(x)Computes the cumulative product of $x$
cummin(x)Computes the cumulative minimum of $x$
cummax(x)Computes the cumulative maximum of $x$

Sorting and Ordering Elements in R Language

The sorting and ordering functions are useful in especially non-parametric methods.

R CommandShort Description
sort(x)Sort the all elements of $x$ in ascending order
sort(x, decreasing = TRUE)Sor the all elements of $x$ in descending order
rev(x)Reverse the elements in $x$
order(x)Get the ordering permutation of $x$

Sequence and Repetition of Elements in R Language

These functions are used to generate a sequence of numbers or repeat the set of numbers $n$ times.

R CommandShort Description
a:bGenerates a sequence of numbers from $a$ to $b$ in steps of size 1
seq(n)Generates a sequence of numbers from 1 to $n$
seq(a, b)Generates a sequence of numbers from $a$ to $b$ in steps of size 1, it is the same as a:b
seq(a, b, by=s)Generates a sequence of numbers from $a$ to $b$ in steps of size $s$.
seq(a, b, length=n)Generates a sequence of numbers having length $n$ from $a$ to $b$
rep(x, n)Repeats the elements $n$ times
rep(x, each=n)Repeats the elements of $x$, each element is repeated $n$ times
R Quick Reference Guide Frequently Asked Questions About R

R Language: A Quick Reference – I

https://gmstat.com

Leave a Reply

Discover more from R Language Frequently Asked Questions

Subscribe now to keep reading and get access to the full archive.

Continue reading