I am new to R and actually, I knew nothing about R syntax. So, I found the rpy2 package(version 2.6.1) and trying to make use of the R regression fitting function for data analysis. However, I failed to extract the regression coefficients using rpy2. If anyone can help to tell how to pull out the regression equation coefficients, like R^2, P etc., Really thanks a lot.
I found out a R code to achieve this however, I cannot convert it to python code currently. The R code I have found is shown following:
ggplotRegression <- function (fit) {
require(ggplot2)
ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) +
geom_point() +
stat_smooth(method = "lm", col = "red") +
labs(title = paste("Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),
"Intercept =",signif(fit$coef[[1]],5 ),
" Slope =",signif(fit$coef[[2]], 5),
" P =",signif(summary(fit)$coef[2,4], 5)))
}