Skip to content

Commit 9e5af35

Browse files
authored
Merge pull request #48 from dustinfife/development
Merge dev into master post plot.types
2 parents 14f4d2f + 02a85a9 commit 9e5af35

File tree

126 files changed

+29750
-19108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+29750
-19108
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.Rbuildignore

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ README_files/
1717
tests/
1818
^doc$
1919
^Meta$
20+
jasp_documentation/
21+
paranormal.csv
2022
EJ notes.rtf
2123
R/flexplota.b.R
2224
# stuff to ignore jasp when doing CMD check
23-
R/glinmod_jasp.R
24-
R/linmod_jasp.R
25-
R/flexplot_jasp2.R
26-
R/mixedmod_jasp.R
27-
R/jasp_common.R
28-
25+
# R/glinmod_jasp.R
26+
# R/linmod_jasp.R
27+
# R/flexplot_jasp2.R
28+
# R/mixedmod_jasp.R
29+
# R/jasp_common.R
2930
R/flexplota.h.R
3031
R/glmbasic.b.R
3132
R/glmbasic.h.R

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: flexplot
22
Type: Package
33
Title: Graphically Based Data Analysis Using Flexplot
4-
Version: 0.7.2
4+
Version: 0.7.4
55
Author: Dustin Fife
66
Maintainer: Dustin Fife <[email protected]>
77
Description: The ‘flexplot’ suite is a graphically-based set of tools for doing data analysis. flexplot() allows users to specify a formula and the software automatically chooses what sort of graphic to present. Analysis can be paired with visuals using the visualize() function, such that the software will choose an appropriate graphic to match an R model object.
@@ -10,7 +10,6 @@ Encoding: UTF-8
1010
LazyData: true
1111
Depends: stats
1212
Imports: cowplot,
13-
ggplot2,
1413
MASS,
1514
tibble,
1615
withr,
@@ -19,7 +18,8 @@ Imports: cowplot,
1918
forcats,
2019
purrr,
2120
plyr,
22-
R6
21+
R6,
22+
ggplot2
2323
Suggests: jmvcore (>= 0.8.5),
2424
vdiffr,
2525
knitr,

R/compare.fits.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ compare.fits = function(formula, data, model1, model2=NULL, return.preds=F, repo
207207
if (return.preds){
208208
prediction.model
209209
} else {
210-
210+
### for logistic, add one to the predictions
211+
if (model1.type == "glm") {
212+
if (family(model1)$link=="logit" & !is.numeric(data[,outcome[1]])){
213+
prediction.model$prediction = prediction.model$prediction + 1
214+
}}
211215
flexplot(formula, data=data, prediction=prediction.model, suppress_smooth=T, se=F, ...)
212216
}
213217

R/data_documentation.R

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#' Simulated Dataset About Experiences with the Paranormal
2+
#'
3+
#' A dataset containing combat attributes of almost 812 fighters in the final
4+
#' Avengers battle. This dataset illustrates several types of problems one might
5+
#' encounter for univariate variables, including bimodality, zero-inflated data,
6+
#' outliers, mixed up labels, etc.
7+
#'
8+
#' @format A data frame with 1000 rows and 7 variables: \describe{
9+
#' \item{conviction}{Degree of conviction they have about the existence of the
10+
#' paranormal} \item{fear}{How much they fear being kidnapped by aliens}
11+
#' \item{time}{How much time they spend a year researching the paranormal}
12+
#' \item{kidnapped}{Whether they've been kidnapped by aliens}
13+
#' \item{experiences.type}{What type of experiences they have had with the
14+
#' paranormal? Can be "eerie feeling," "presence watching", "saw UFO", "saw ghost", or "heard voice"}
15+
#' \item{income}{How much money they make}
16+
#' \item{age}{Age of respondent}}
17+
"paranormal"
18+
119
#' Simulated Statistics on the Final Avengers Battle
220
#'
321
#' A dataset containing combat attributes of almost 812

R/estimates.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ estimates.lm = function(object, mc=TRUE){
226226
)
227227
}
228228
### this requires superassignment to work with JASP
229-
#dataset<<-object$model
229+
dataset<<-object$model
230230
all.terms = attr(terms(object), "term.labels")
231231
mc = t(sapply(1:length(all.terms), removed.one.at.a.time, terms=all.terms, object=object))
232232
mc = data.frame(cbind(all.terms,mc), stringsAsFactors = FALSE)

R/flexplot.R

+20-8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
##' Users can export the string, in case they want to modify the ggplot object
3232
##' @param silent Should all messages be suppressed? Defaults to F.
3333
##' @param third.eye Should the "third eye" be employed? The third eye will be implemented shortly.
34+
##' @param plot.type This argument allows the user to control the type of plot used. Flexplot defaults to histograms (for univariate variables)
35+
##' but could also do qqplots (using "qq" as the argument) or density plots (using "density"). Also, the user can specify "boxplot" for boxplots and
36+
##' "violin" for violin plots.
3437
##' @author Dustin Fife
3538
##' @import tibble ggplot2 R6
3639
##' @export
@@ -91,7 +94,8 @@ flexplot = function(formula, data=NULL, related=F,
9194
spread=c('quartiles', 'stdev', 'sterr'), jitter=NULL, raw.data=T,
9295
sample=Inf,
9396
prediction = NULL, suppress_smooth=F, alpha=.99977, plot.string=F, silent=F,
94-
third.eye=NULL){
97+
third.eye=NULL,
98+
plot.type = c("histogram")){
9599

96100
#data = exercise_data
97101
##### use the following to debug flexplot
@@ -102,10 +106,11 @@ flexplot = function(formula, data=NULL, related=F,
102106
#formula = formula(weight.loss~rewards+gender|income+motivation); data=d;
103107
#ghost.reference = list(income=90000)
104108

109+
105110
spread = match.arg(spread, c('quartiles', 'stdev', 'sterr'))
106-
107-
### prepare the variables
108111

112+
### prepare the variables
113+
109114
varprep = flexplot_prep_variables(formula, data,
110115
breaks = breaks, labels=labels, bins=bins,
111116
related=related,
@@ -124,6 +129,12 @@ flexplot = function(formula, data=NULL, related=F,
124129
##### make models into a factor if they supply predictions
125130
if (!is.null(prediction)){
126131
prediction$model = factor(prediction$model)
132+
133+
### make the levels consistent between prediction/data for axis 1
134+
if (!is.numeric(data[[varprep$axis[1]]])){
135+
prediction[[varprep$axis[1]]] = factor(prediction[[varprep$axis[1]]], levels=levels(data[[varprep$axis[1]]]))
136+
}
137+
127138
varprep$prediction = prediction
128139
}
129140

@@ -150,19 +161,20 @@ flexplot = function(formula, data=NULL, related=F,
150161
### PLOT UNIVARIATE PLOTS
151162
bivariate = with(varprep, flexplot_bivariate_plot(formula = NULL, data=data, prediction = prediction, outcome=outcome, predictors=predictors, axis=axis,
152163
related=related, alpha=alpha, jitter=jitter, suppress_smooth=suppress_smooth,
153-
method=method, spread=spread))
164+
method=method, spread=spread, plot.type=plot.type))
154165
p = bivariate$p
155166
points = bivariate$points
156167
fitted = bivariate$fitted
157-
168+
158169
#### all the above should take care of ALL possible plots, but now we add paneling
170+
# browser()
159171
facets = flexplot_panel_variables(varprep,
160172
related=related, labels=labels, bins=bins,
161173
suppress_smooth=suppress_smooth, method=method,
162174
spread=spread, prediction=prediction)
163175

164176
if (!is.null(ghost.line) & !is.na(varprep$given[1])){ # with help from https://stackoverflow.com/questions/52682789/how-to-add-a-lowess-or-lm-line-to-an-existing-facet-grid/52683068#52683068
165-
177+
166178
### bin the ghost reference if it's not null
167179
ghost.reference = with(varprep, create_ghost_reference(ghost.reference=ghost.reference, data=data,
168180
bins=bins, breaks=breaks, given=given, axis=axis, labels=labels))
@@ -184,7 +196,7 @@ flexplot = function(formula, data=NULL, related=F,
184196
} else {
185197
ghost = "xxxx"
186198
}
187-
199+
188200
### add prediction lines
189201
if (!is.null(prediction)){
190202
### see how many models are being compared
@@ -216,7 +228,7 @@ flexplot = function(formula, data=NULL, related=F,
216228
#### change the y axis labels
217229
theme = paste0(theme, " + scale_y_continuous(breaks = c(0,1), labels=factor.to.logistic(data,outcome, labels=T))")
218230
}
219-
231+
220232
### put objects in this environment
221233
axis = varprep$axis; outcome = varprep$outcome; predictors = varprep$predictors; levels = length(unique(data[,outcome]))
222234

0 commit comments

Comments
 (0)