[R-es] ggplot2 vs plot
Hola David,
Quizás esto te puede ayudar.
He comentado la lineas de los otros métodos de ajuste disponibles en la función status_smooth().
library("tidyverse")
pet <- ggplot(data = cars, aes(x = speed, y = dist)) +
geom_point(stat="identity", color = "blue", alpha=0.9) +
stat_smooth(method="lm", color = "red")+
#stat_smooth(method="loess", color = "red")+
#stat_smooth(method="gam", color = "red")+
theme_bw()
pet
Las salidas con ?loess? y ?lm"
Espero ayude
Saludos
On 13-05-2022, at 10:34, David Aguinaga <egarense21 en gmail.com> wrote: 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.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.png>
_______________________________________________ R-help-es mailing list R-help-es en r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
C*ertificación ISO 9001/2015*: Sistema de Datos Biológico-Pesqueros (Arica, Iquique, Coquimbo, ValparaÃso, San Antonio, Talcahuano y Calbuco, pesquerÃas industriales y artesanales) ------------ próxima parte ------------ Se ha borrado un adjunto en formato HTML... URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/4ef7153a/attachment-0003.html> ------------ próxima parte ------------ Se ha borrado un adjunto en formato HTML... URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/4ef7153a/attachment-0004.html> ------------ próxima parte ------------ A non-text attachment was scrubbed... Name: pet Type: application/octet-stream Size: 47418 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/4ef7153a/attachment-0002.obj> ------------ próxima parte ------------ A non-text attachment was scrubbed... Name: petlo Type: application/octet-stream Size: 45567 bytes Desc: no disponible URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/4ef7153a/attachment-0003.obj> ------------ próxima parte ------------ Se ha borrado un adjunto en formato HTML... URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20220513/4ef7153a/attachment-0005.html>