Buenos dÃas, Estoy intentando representar una curva suavizada con smooth.spline() usando ggplot2 en lugar de plot, que ofrece un gráfico más simple: attach(cars) cars.spline1 <- smooth.spline(speed, dist) *# gráfico simple* plot(speed, dist) lines(cars.spline1, col="red") [image: image.png] *# ggplot2* Quisiera usar ggplot2, pero el resultado que obtengo no es el mismo: pet = ggplot() + geom_point(data = cars, aes(x = speed, y = dist), color = "blue") + geom_line(data = cars, aes(x = speed, y = cars.spline1$data$y, color = "red"))
pet
[image: image.png] ------------ próxima parte ------------ Se ha borrado un adjunto en formato HTML... URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/58025315/attachment-0001.html> ------------ próxima parte ------------ A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 8359 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/58025315/attachment-0002.png> ------------ próxima parte ------------ A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 10922 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/58025315/attachment-0003.png>