-
Notifications
You must be signed in to change notification settings - Fork 0
/
RMarkdown.Rmd
93 lines (70 loc) · 2.94 KB
/
RMarkdown.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
title: "Replication_sample"
author: "Jacob Grippin"
date: "7/7/2024"
output:
word_document: default
html_document:
df_print: paged
pdf_document: default
---
## Introdouction
```{r preparations, include=FALSE}
#Load packages
#This code chunk is used to generate the output that is needed, but do not print the results. I will print those later.
library(glue)
attach(mtcars)
library(gtsummary)
library(gt)
library(ggplot2)
library(ggcorrplot)
#Import and load datasets.
mydata = read.csv("EquationCitations.csv")
#Store column names of dataset as a new object. Will print these later.
names = colnames(mydata)
SelfvOthercites <-mydata %>%
select(journal, cites)
#This shows median, first and 3rd quartile.
journal_cites_table = tbl_summary(SelfvOthercites, by = journal, statistic = list(all_continuous() ~ "{mean} ({sd})"))
SelfvOthercites2 <- mydata %>%
select(journal, cites, mainequations, pages, selfcites, othercites)
EqReg <- glm(cites ~ mainequations + journal + pages, data = SelfvOthercites2) %>%
tbl_regression(conf.level= .95, tidy_fun = broom.helpers::tidy_parameters)
SelfvOthercites3 <- mydata %>%
select(cites, mainequations, pages)
corr <- round(cor(SelfvOthercites3), 1)
# Plot
corrPlot = ggcorrplot(corr, hc.order = TRUE,
type = "lower",
lab = TRUE,
lab_size = 3,
method="circle",
colors = c("tomato2", "white", "springgreen3"),
title="Correlogram of Equation Citations",
ggtheme=theme_bw)
```
This is a short *memo*. Describing a dataset, showing some visuals. Put 2 spaces at end of line for output to go to next line.
Load EquationCitations. Column names of dataset included below. [Link to dataset description ](https://rdrr.io/cran/AER/man/EquationCitations.html)
**`r colnames(mydata)` **
### Variable Descriptions
I am interested in variables for journal and cites. Their variable information is included below in a nice frequency counts table.
`r journal_cites_table`
### Results
I am interested in displaying a regression equation. Predicting the number of cites based on the number of main equations, journal type and number of pages. View the table below to see the results of the regression equation.
`r EqReg`
Here is the correlation plot.
```{r, echo = FALSE, fig.height=4}
# Plot
ggcorrplot(corr, hc.order = TRUE,
type = "lower",
lab = TRUE,
lab_size = 3,
method="circle",
colors = c("tomato2", "white", "springgreen3"),
title="Correlogram of Equation Citations",
ggtheme=theme_bw)
```
## Conclusion
Following links have good reference information:
[Rmarkdown Webiste](https://rmarkdown.rstudio.com/) - tutorial rmarkdown
[Rmarkdown cheatsheet](https://rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf) - cheatsheet