-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMJ Table Organize
90 lines (70 loc) · 1.87 KB
/
SMJ Table Organize
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
Notes. Standard errors are reported in parentheses and p-values are reported in square brackets.
library(xtable)
library(gt)
library(tibble)
cleardata<-function(input){
names<-rownames(input)
final<-matrix("",nrow=nrow(input)*3,ncol=2)
j=1
for(i in 1:nrow(input)){
coe<-format(round(as.numeric(input[i,1]),digits=3),nsmall=3)
st<-paste("(",format(round(as.numeric(as.matrix(input[i,3])),digits=3),nsmall=3),")",sep="")
pvalue<-paste("[",format(round(as.numeric(as.matrix(input[i,5])),digits=3),nsmall=3),"]",sep="")
final[j,1]<-paste(names[i],"1")
final[j+1,1]<-paste(names[i],"2")
final[j+2,1]<-paste(names[i],"3")
final[j,2]<-coe
final[j+1,2]<-st
final[j+2,2]<-pvalue
j<-j+3
}
return(final)
}
createtable<-function(island, island_title, island_source_note ){
islands_tbl <-
tibble(
island
)
gt_tbl <- gt(data = islands_tbl,
rowname_col = NULL,
getOption("gt.row_group.sep", ""))%>%tab_style(
style = list(
cell_borders(
sides = c("top", "bottom"),
color = "white",
weight = px(1)
),
cell_borders(
sides = c("left", "right"),
color = "white",
weight = px(1)
)),
locations = cells_body(
columns = everything(),
rows = everything()
)
)
gt_tbl <-
gt_tbl %>%
tab_header(
title = island_title,
)
gt_tbl <- gt_tbl %>%
tab_source_note(
source_note = island_source_note
)
return(gt_tbl)
}
finalresults <- summary(results)
modelformat<-data.frame(rbind(
cleardata(finalresults$coefficients)
)
)
printmodel = modelformat
printmodel$label<-NULL
colnames(printmodel)[1]<-" "
library(rempsyc)
library(effectsize)
library(flextable)
mytable = nice_table(printmodel)
flextable::save_as_docx(mytable,path = '/nicetable.docx')