Description Usage Arguments Value Examples
Fitting any curve you like, really.
1 | curve_fitter(dataFrame = "dataframe", expr = "", columns = "c(x, y)")
|
dataFrame |
A dataframe |
columns |
Column with variable to be sorted |
A least squares solution for the given curve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | coef <- curve_fitter(mtcars, "x", columns=c(4, 6))
plot(mtcars[[4]], mtcars[[6]])
curve(coef[1] + coef[2]*x, add = TRUE)
coef <- curve_fitter(mtcars, "x, x^2", columns=c(1, 3))
plot(mtcars[[1]], mtcars[[3]])
curve(coef[1] + coef[2]*x + coef[3]*x^2, add = TRUE)
# Everything below should run together.
x <- -10:10
y <- jitter(-(-10:10)*10 + (-10:10)^2 + (-10:10)^3, 500)
xy <- data.frame("x" = x, "y" = y)
plot(x, y)
coeff <- curve_fitter(dataFrame = xy, "x, x^2, x^3", c(1, 2))
# coeff[[1]] is the constant value. Everything else corresponds to the order in which it was inputted.
curve(coeff[[1]] + coeff[[2]]*x + coeff[[3]]*x^2 + coeff[[4]]*x^3, add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.