在 R 编程中计算等距舍入值的序列 - pretty()函数
R 语言中的pretty()
函数用于确定等距舍入值的序列。
Syntax: pretty(x, n)
Parameters:
x: It is defined as vector data
n: length of resultant vector
Returns: data vector of equal length interval
示例 1:
# Create example vector
# Apply pretty function to vector
x <- 1:50
pretty(x)
输出:
[1] 0 10 20 30 40 50
示例 2:
# Create example vector
x <- 1:50
# Apply pretty function to vector
pretty(x, n = 10)
输出:
[1] 0 5 10 15 20 25 30 35 40 45 50
这里n = 10 表示由十个区间组成的区间向量,即n+1 个元素。
示例 3:
# Create example vectors
x <- 1:50
y <- 1:50
# Create plot of two vectors
plot(x, y,
# Default axis labels
main = " Axis Labels")
输出: