Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

R Language Examples

R Language Examples

100

Total Examples

13

Topic Categories

R 4.x

Applicable Versions

Basic Math

Statistical Functions

Probability Distributions

Vector Operations

String

Data Frames

Apply Family

Plotting

Date and Time

Lists and Factors

File I/O

Missing Values

Basic Math Functions

17 articles

- mean() average

- median() median

- sum() sum total

- min() / max() min and max

- range() value range

- prod() product

- cumsum() cumulative sum

- diff() difference

- abs() absolute value

- round() rounding

- sqrt() square root

- log() logarithm

- exp() exponential

- sin() trigonometric functions

- factorial() factorial

- choose() combinations

- ceiling() / floor() rounding

Statistical Functions

11 articles

- sd() standard deviation

- var() variance

- quantile() quantiles

- summary() data summary

- cor() correlation coefficient

- cov() covariance

- scale() standardization

- t.test() t-test

- chisq.test() chi-square test

- aov() analysis of variance

- lm() linear regression

Probability Distributions

8 articles

- rnorm() normal distribution random numbers

▸dnorm() / pnorm() / qnorm()

- rbinom() binomial distribution

- rpois() Poisson distribution

- runif() uniform distribution

- rexp() exponential distribution

- sample() random sampling

- set.seed() random seed

Vector Operations

13 articles

- seq() generate sequence

- rep() repeat elements

- sort() sorting

- order() sort index

- rev() reverse

- unique() remove duplicates

- which() conditional index

- match() element matching

- append() append

- cut() binning

- ifelse() conditional judgment

- table() frequency count

- find the most frequent element

String Operations

9 articles

- paste() string concatenation

- sprintf() formatted output

- substr() extract substring

- strsplit() split

- grep() pattern matching

- gsub() replace

- nchar() character count

- toupper() / tolower() case conversion

- trimws() remove whitespace

Data Frame Operations

10 articles

- data.frame() create data frame

- subset() data filtering

- merge() merge

- rbind() / cbind() row and column binding

- head() / tail() view head and tail

- names() name operations

- str() view structure

- dim() / nrow() / ncol() dimensions

- colnames() / rownames() row and column names

- transform() data transformation

Apply Family Functions

5 articles

- apply() array application

- lapply() list application

- sapply() simplified application

- tapply() grouped statistics

- mapply() multivariate application

Basic Plotting

10 articles

- plot() scatter plot

- hist() histogram

- barplot() bar chart

- boxplot() box plot

- pie() pie chart

- plot() detailed explanation of plot types

- par() graphical parameters

- legend() add legend

- abline() reference line

- linear regression example

Date and Time

4 articles

- as.Date() date conversion

- format() date formatting

- difftime() time difference

- seq.Date() date sequence

Lists and Factors

5 articles

- list() create list

- unlist() flatten list

- factor() create factor

- levels() factor levels

- gl() generate factor

File I/O and System

7 articles

- read.csv() read CSV

- write.csv() write CSV

- read.table() read table

- scan() read data

- install.packages() install packages

- library() / require() load packages

- getwd() / setwd() working directory

Missing Values and Data Cleaning

1 article

- is.na() handle missing values