-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprocs-faq.Rmd
More file actions
234 lines (155 loc) · 6.8 KB
/
Copy pathprocs-faq.Rmd
File metadata and controls
234 lines (155 loc) · 6.8 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
---
title: "Frequently Asked Questions"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{FAQ}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
options(rmarkdown.html_vignette.check_title = FALSE)
```
Below are some frequently asked questions about the **procs** package. Click
on the links below to navigate to the full question and answer content.
## Index{#top}
* [Why did you write the procs package?](#why)
* [Are these functions validated?](#validation)
* [Why is the output different?](#different)
* [Can you do N-way tables?](#nway)
* [Can these procedures create plots?](#plots)
* [Does the package support Cochran-Mantel-Haenszel Statistics?](#cmh)
* [What about PROC COMPARE?](#compare)
* [Are there any other statistics procedures coming?](#other)
* [How do I get my statistics into a report?](#outputs)
* [How do I order my frequencies?](#order)
## Content
### Why did you write the **procs** package? {#why}
**Q:** There are already many statistical functions and packages in R. Why did
you write **procs**?
**A:** I wrote the **procs** package to help SAS® programmers. There are
many SAS® programmers trying to learn R and struggling with the many
differences between these two languages. The **procs** package provides them with
a set of functions that are conceptually similar to SAS® procedures. The aim
is to make them more productive and comfortable working in R in a shorter
time frame.
[top](#top)
******
### Are these functions validated? {#validation}
**Q:** My company requires that all software be validated before using in
production. Is the **procs** package validated?
**A:** Yes. The functions were validated by comparing to SAS®. The validation
documentation is [here](https://r-sassy.org/validation/Procs_Validation.pdf).
[top](#top)
******
### Why is the output different? {#different}
**Q:** The output dataset columns and column names are a little bit
different from SAS®. Why?
**A:** The output datasets and column names have been standardized. They should be
more predictable and easier to manipulate programmatically. They were
changed intentionally as an improvement over the corresponding SAS® procedures.
[top](#top)
******
### Can you do N-way tables? {#nway}
**Q:** I see you can do one-way and two-way frequency tables. What about
N-way tables? Does the package support them?
**A:** No. N-way tables are less common, and were not seen as a priority.
These types of tables are on the list for a future enhancement. The package
does support 2-way frequency tables with one or more by variables.
[top](#top)
******
### Can these procedures create plots? {#plots}
**Q:** I'm trying to find the option to produce a plot, and can't find it.
Does the package support plots or not?
**A:** Yes. As of **procs** version 1.0.8, the `proc_freq()`, `proc_ttest()`,
and `proc_reg()` functions produce plots. To get a default set of plots,
set `plots = TRUE` for the desired function. The documentation for each
function has more information on the types of charts that can be produced,
and various options.
[top](#top)
******
### Does the package support Cochran-Mantel-Haenszel Statistics? {#cmh}
**Q:** I see the frequency function supports Chi-square and Fishers's exact
tests. What about Cochran-Mantel-Haenszel?
**A:** CMH statistics were left out of the of the **procs** package because the
corresponding R function does not match SAS® reliably. You can run CMH statistics
yourself using using the
[mantelhaen.test](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/mantelhaen.test.html)
function
from the [stats](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/00Index.html)
package.
[top](#top)
******
### What about PROC COMPARE? {#compare}
**Q:** I see you have PROC TRANSPOSE and PROC SORT. How come you didn't include
PROC COMPARE?
**A:** There are already several dataset comparison packages in R, such as
[diffdf](https://cran.r-project.org/package=diffdf)
and [comparedf](https://cran.r-project.org/package=compareDF).
The functionality of these packages is also similar to SAS® PROC COMPARE.
If you wish to do dataset comparisons, please research these existing packages.
[top](#top)
******
### Are there any other statistics procedures coming? {#other}
**Q:** The `proc_freq()` and `proc_means()` functions are helpful. But what about
some other stats procedures? What about PROC GLM and PROC ANOVA?
**A:** These functions are planned for a future release. In the meantime,
please see the excellent package [sasLM](https://cran.r-project.org/package=sasLM)
for functions that replicate SAS® statistics related to linear modeling.
[top](#top)
******
### How do I get my statistics into a report? {#outputs}
**Q:** I created some frequencies, and need to output them to a report. Is there
a way to create a PDF or RTF directly from the **procs** package?
**A:** Yes. Put your data frames in a list, and send to `proc_print()`. You can
use the parameters to assign the titles, the output location, and the output
type. The function supports PDF, RTF, HTML, DOCX, and TXT. For more advanced
reporting features, see the [reporter](https://reporter.r-sassy.org/) package.
[top](#top)
******
### How do I order my frequencies? {#order}
**Q:** The `proc_freq()` function seems to always order the categories alphabetically.
But I have a specific order in mind that is not alphabetical. Is there a way
to order the frequency categories in a specific way?
**A:** Yes. The `order` parameter on `proc_freq()` allows you to order your
frequencies in four different ways: internal order (the default), data order,
format order, or frequency order. See the `proc_freq()` documentation on the
specific keywords needed to control the order.
Also note that if your frequency variable is defined as a factor, the
`proc_freq()` function will order the frequency categories by that factor.
Here is an example:
```
library(procs)
# Turn off printing for CRAN checks
options("procs.print" = FALSE)
# Create sample data
df <- as.data.frame(HairEyeColor, stringsAsFactors = FALSE)
# Assign factor for ordering
df$Eye <- factor(df$Eye, c("Green", "Hazel", "Blue", "Brown"))
# Use factor in tables parameter
res <- proc_freq(df,
tables = Eye,
weight = Freq)
# Output is now ordered by the factor
res
# VAR CAT N CNT PCT
# 1 Eye Green 592 64 10.81081
# 2 Eye Hazel 592 93 15.70946
# 3 Eye Blue 592 215 36.31757
# 4 Eye Brown 592 220 37.16216
```
[top](#top)
******
<!-- ### Question 2? {#q2} -->
<!-- **Q:** Question here. -->
<!-- **A:** Answer here. -->
<!-- [top](#top) -->
<!-- ****** -->
<!-- ### Question 1? {#q1} -->
<!-- **Q:** Question here. -->
<!-- **A:** Answer here. -->
<!-- [top](#top) -->
<!-- ****** -->