Commonly used commands in R language
()
//Open the help document
q()
//Exit function
ls()
//Return the object name in the current namespace
rm()
//Clear the object; rm(list=ls()) clears all memory data
gc()
//Garbage collection data
sqrt(x)
//Standard deviation
rnorm() function
rnorm(n, mean = 0, sd = 1)
n is the number of random values (length), mean is the mean, sd is the standard deviation, and if mean and sd are not set, their default values are 0 and 1 respectively. When using this function, it is generally assigned 3 values.rnorm() function will be randomly normally distributed, and then randomly sample or take values n times.
>rnorm(5, 0, 1) Lists 5 values with normal distribution of N(0, 1). This column r represents random, which can be replaced by dnorm, pnorm, qnorm for different calculations norm=normal distribution, r = random = random, d= density = density, p= probability = probability, q =quantile = quantile
Brownian Movement
cumsum//#Cumulative sum
cumprod//#Continuous multiplication product
cummin//Sorted in descending order
cummax//arrange in ascending order
Time series
ts(data vector, frequency= represents the time interval that separates time, start=c(year, month represented by the first data))
frequency=1 represents annual data, frequency=4 represents quarterly data, frequency=12 represents monthly data
plot drawing images
The plot function is the most commonly used function, and its parameters are very numerous. Let's summarize it for easy reference in the future.
plot(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
ann = par("ann"), axes = TRUE, = axes,
= NULL, = NULL, asp = NA, ...)
plot supports R modules such as: functions, density, factor, table, etc.
Set all available parameters
- plot(x = mtcars$wt,
- y = mtcars$mpg,
- type="o",#linear type
- main="Title",
- sub="subtitle",
- xlab="x-axis",
- ylab="y-axis",
- asp=0.1)#y/x ratio, the ratio of y-axis numerical length to x-axis numerical length
Click "p" for points,
line "l" for lines,
dotted line "b" for both,
Remove the point "c" for the lines part alone of "b",
Covered wire "o" for both 'overplotted',
Similar to histogram "h" for 'histogram' like (or 'high-density') vertical lines,
stairs-shaped "s" for stair steps,
stairs-shaped "S" for other steps, see 'Details' below,
"n" is not displayed for no plotting.
("data", """ , package="datasets")#File path to obtain experimental data from object morley
(filepath)#View file content
(filepath)#Read data in the form of a data frame
This is the end of this article about the collection of commonly used commands in R language. For more relevant commonly used commands in R language, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!