Returns the slope from linear regression with x values as equally spaced 1:length

Description

Returns the slope from linear regression with x values as equally spaced 1:length

Usage

1

Arguments

data

Returns the slope from linear regression with x values as equally spaced 1:length

Details

Returns the slope (i.e. localised tangent) from linear regression with x values as equally spaced 1:length. The usefulness of this function is to reduce a time series type of data collected at equal time intervals.

N=number of data points over which to calculate the slope.

Value

An object of type numeric.

Author(s)

Glenn J. Tattersall

See Also

lm

Examples

1
2
3
4
5
6
7
8
9
## Define a vector of 50 random numbers from 1 to 100
y<-ceiling(runif(50, 0, 100))
# Calculate the slope with respect to the index values (i.e. 1 to 50)
# instead of an x axis, this will provide a slope value of y vs. index
s<-slopebypoint(y)
s

# same as if typing: 
lm(y~seq(0,length(y)-1,1))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.