Compute a Sequence of Equally Spaced Round values in R Programming – pretty() Function
pretty()
function in R Language is used to decide sequence of equally spaced round values.
Syntax: pretty(x, n)
Parameters:
x: It is defined as vector data
n: length of resultant vectorReturns: data vector of equal length interval
Example 1:
# Create example vector # Apply pretty function to vector x <- 1:50 pretty (x) |
chevron_right
filter_none
Output:
[1] 0 10 20 30 40 50
Example 2:
# Create example vector x <- 1:50 # Apply pretty function to vector pretty (x, n = 10) |
chevron_right
filter_none
Output:
[1] 0 5 10 15 20 25 30 35 40 45 50
Here n = 10 states that the interval vector consisting of ten intervals, i.e. n+1 elements.
Example 3:
# Create example vectors x <- 1:50 y <- 1:50 # Create plot of two vectors plot (x, y, # Default axis labels main = " Axis Labels" ) |
chevron_right
filter_none
Output: