Gibt es eine Möglichkeit, eine mathematische Funktion mit ggplot über die Daten zu legen?Plotten von Funktionen über Datenpunkte in R
## add ggplot2
library(ggplot2)
# function
eq = function(x){x*x}
# Data
x = (1:50)
y = eq(x)
# Make plot object
p = qplot(
x, y,
xlab = "X-axis",
ylab = "Y-axis",
)
# Plot Equation
c = curve(eq)
# Combine data and function
p + C#?
In diesem Fall wird meine Daten erzeugt, um die Funktion, aber ich möchte wissen, wie curve()
mit ggplot zu verwenden.