Load the following libraries

library(stargazer)

Please cite as: 
 Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
 R package version 5.2.3. https://CRAN.R-project.org/package=stargazer 
library(tinytex)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(gtsummary)
#Uighur
library(magrittr)
library(ggplot2)
library(knitr)
library(flextable)

Attaching package: 'flextable'
The following objects are masked from 'package:gtsummary':

    as_flextable, continuous_summary
library(report)
library(broom)
library(gapminder)
library(xtable)

Attaching package: 'xtable'
The following object is masked from 'package:report':

    display
The following object is masked from 'package:flextable':

    align
library(gridExtra)

Attaching package: 'gridExtra'
The following object is masked from 'package:dplyr':

    combine
library(ggplot2)
library(dplyr)
library(jtools)

Attaching package: 'jtools'
The following object is masked from 'package:flextable':

    theme_apa
library(gtsummary)
library(broom)
library(kableExtra)

Attaching package: 'kableExtra'
The following objects are masked from 'package:flextable':

    as_image, footnote
The following object is masked from 'package:dplyr':

    group_rows
library(rempsyc)
Suggested APA citation: Thériault, R. (2023). rempsyc: Convenience functions for psychology. 
Journal of Open Source Software, 8(87), 5466. https://doi.org/10.21105/joss.05466

Regression Analysis

Manual Data Entry

Age <- c(23,45,43,56,43,78,32,54,34,20)
Blood_pressure <- c(124,143,110,129,132,155,121,110,123,130)
data <- data.frame(Age, Blood_pressure)
head(data,10)
   Age Blood_pressure
1   23            124
2   45            143
3   43            110
4   56            129
5   43            132
6   78            155
7   32            121
8   54            110
9   34            123
10  20            130

Importing CSV File

data1 <- read.csv("regression.class.work.csv")
head(data1,10)
   Age Blood_pressure
1   23            124
2   45            143
3   43            110
4   56            129
5   43            132
6   78            155
7   32            121
8   54            110
9   34            123
10  20            130

Estimating the Regression Model

model1 <- lm(Blood_pressure ~ Age, data = data1)
summary(model1)

Call:
lm(formula = Blood_pressure ~ Age, data = data1)

Residuals:
     Min       1Q   Median       3Q      Max 
-21.6963  -3.2690   0.9024   8.8836  14.7403 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 112.4286    11.6616   9.641 1.11e-05 ***
Age           0.3568     0.2547   1.401    0.199    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 13.11 on 8 degrees of freedom
Multiple R-squared:  0.197, Adjusted R-squared:  0.09665 
F-statistic: 1.963 on 1 and 8 DF,  p-value: 0.1988
library(stargazer)
stargazer(model1, type = "text")

===============================================
                        Dependent variable:    
                    ---------------------------
                          Blood_pressure       
-----------------------------------------------
Age                            0.357           
                              (0.255)          
                                               
Constant                    112.429***         
                             (11.662)          
                                               
-----------------------------------------------
Observations                    10             
R2                             0.197           
Adjusted R2                    0.097           
Residual Std. Error       13.109 (df = 8)      
F Statistic              1.963 (df = 1; 8)     
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

CLASS WORK [MATH 843 PARAMETRIC REGRESSION]

Import the data

data2 <- read.csv("reg.class.csv")
head(data2,5)
   X  Y
1 44 10
2 60 17
3 38 15
4 45 16
5 62 25
attach(data2)

Alternatively

render = 'normal_print'

Estimate the model

fit <- lm(Y~X)
summ(fit,confint = TRUE, digits = 3)
Observations 10
Dependent variable Y
Type OLS linear regression
F(1,8) 0.970
0.108
Adj. R² -0.003
Est. 2.5% 97.5% t val. p
(Intercept) 9.513 -3.039 22.064 1.748 0.119
X 0.104 -0.140 0.349 0.985 0.354
Standard errors: OLS

Alternatively

View the Results Using Stargazer

stargazer(fit, report = "vc*stp",type = "text",out = "./q7results.txt")

===============================================
                        Dependent variable:    
                    ---------------------------
                                 Y             
-----------------------------------------------
X                              0.104           
                              (0.106)          
                             t = 0.985         
                             p = 0.354         
                                               
Constant                       9.513           
                              (5.443)          
                             t = 1.748         
                             p = 0.119         
                                               
-----------------------------------------------
Observations                    10             
R2                             0.108           
Adjusted R2                   -0.003           
Residual Std. Error       4.329 (df = 8)       
F Statistic              0.970 (df = 1; 8)     
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01