R语言 计算等距圆周率的序列 – pretty()函数
R语言中的 pretty() 函数用于决定等距圆值的序列。
语法: pretty(x, n)
参数:
x: 定义为矢量数据
n: 结果矢量的长度
返回: 等长区间的数据向量
例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")             
输出

极客教程