Skip to content

Commit

Permalink
Merge pull request #20 from neuropsychology/0.0.8
Browse files Browse the repository at this point in the history
0 0 8
  • Loading branch information
DominiqueMakowski committed Jan 10, 2018
2 parents 301a7e0 + 900c643 commit 62eba06
Show file tree
Hide file tree
Showing 9 changed files with 851 additions and 12 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: psycho
Type: Package
Title: Efficient and Publishing-Oriented Workflow for Psychological Science
Version: 0.0.7
Version: 0.0.8
Authors@R: c(
person("Dominique",
"Makowski",
Expand Down Expand Up @@ -30,8 +30,6 @@ Imports:
dplyr,
tidyr,
purrr,
tidyverse,
rtf,
psych,
MASS,
nFactors,
Expand All @@ -42,6 +40,7 @@ Imports:
MuMIn,
lmerTest
Suggests:
tidyverse,
knitr,
rmarkdown,
testthat,
Expand Down
2 changes: 2 additions & 0 deletions R/analyze.stanreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @return output
#'
#' @examples
#' \dontrun{
#' library(psycho)
#' require(rstanarm)
#' fit <- rstanarm::stan_glm(vs ~ mpg * cyl, data=mtcars)
Expand All @@ -26,6 +27,7 @@
#' summary(results)
#' plot(results)
#' print(results)
#' }
#'
#' @author \href{https://dominiquemakowski.github.io/}{Dominique Makowski}
#'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
|----------------|---|
|Stable|[![CRAN](https://www.r-pkg.org/badges/version/psycho)](https://CRAN.R-project.org/package=psycho)|
|Documentation|[![Rdoc](http://www.rdocumentation.org/badges/version/psycho)](http://www.rdocumentation.org/packages/psycho)|
|Examples|[![](https://img.shields.io/badge/vignettes-0.0.2-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=psycho/vignettes/overview.html)|
|Examples|[![](https://img.shields.io/badge/vignettes-0.0.8-orange.svg?colorB=FF5722)](https://CRAN.R-project.org/package=psycho/vignettes/overview.html)|
|Questions|[![](https://img.shields.io/badge/issue-create-purple.svg?colorB=FF9800)](https://github.com/neuropsychology/psycho.R/issues)|
|Authors|[![](https://img.shields.io/badge/CV-D._Makowski-purple.svg?colorB=9C27B0)](https://dominiquemakowski.github.io/)|

Expand Down
2 changes: 2 additions & 0 deletions man/analyze.stanreg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions psycho.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace,vignette
2 changes: 1 addition & 1 deletion tests/testthat/test-analyze.stanreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test_that("If it works.", {

model <- psycho::analyze(fit)
values <- psycho::values(model)
testthat::expect_equal(round(values$mpg$median, 2), -0.64, tolerance = 0.05)
testthat::expect_equal(round(values$mpg$median, 2), -0.64, tolerance = 0.10)


fit <- rstanarm::stan_glmer(
Expand Down
157 changes: 157 additions & 0 deletions vignettes/overview.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
## ---- echo=F, message=FALSE, warning=FALSE-------------------------------
library(knitr)
library(tidyverse)
library(broom)
library(rstanarm)

## ------------------------------------------------------------------------
# Do this once (uncomment if needed)
# install.packages("devtools")
# library(devtools)
# devtools::install_github("https://github.com/neuropsychology/psycho.R")

# Load psycho (at the beginning of every script)
library(psycho)

## ---- out.width=700, echo = FALSE, eval = TRUE, fig.align='center'-------
knitr::include_graphics("images/workflow.PNG")

## ---- fig.width=8, eval = TRUE, fig.align='center', results='hide'-------
library(psycho)

df <- iris

cor <- psycho::correlation(df,
type = "full",
method = "pearson",
adjust = "none")

print(cor)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(print(cor))

## ---- fig.width=8, eval = TRUE, fig.align='center'-----------------------
plot(cor)

## ---- fig.width=8, eval = TRUE, fig.align='center', results='hide'-------
library(psycho)

df <- iris

pcor <- psycho::correlation(df,
type = "partial",
method = "pearson",
adjust = "bonferroni")

print(pcor)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(print(pcor))

## ---- out.width=8, eval = TRUE, fig.align='center', results='markup'-----
library(psycho)
library(tidyverse)

iris %>%
select(Species, Sepal.Length, Petal.Length) %>%
psycho::normalize() %>%
summary()

## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'----
library(psycho)

results <- psycho::assess(124, mean=100, sd=15)

# Print it
print(results)

# Plot it
plot(results)

## ----echo=FALSE, message=FALSE, warning=FALSE, results='hide'------------
results <- attitude %>%
select_if(is.numeric) %>%
psycho::n_factors()

# Get a summary
summary(results)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(summary(results))

## ----echo=FALSE, message=FALSE, warning=FALSE, results='hide'------------
psycho::values(results)$methods

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(psycho::values(results)$methods)

## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'----
plot(results)

## ---- results='hide'-----------------------------------------------------
set.seed(666)
df <- data.frame(Participant = as.factor(rep(1:25, each = 4)),
Item = rep_len(c("i1", "i2", "i3", "i4"), 100),
Condition = rep_len(c("A", "B", "A", "B", "B"), 20),
Error = as.factor(sample(c(0, 1), 100, replace = T)),
RT = rnorm(100, 30, .2),
Stress = runif(100, 3, 5))

# Normalize the numeric variables.
df <- psycho::normalize(df)

# Take a look at the first 10 rows
head(df)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(head(df))

## ----message=FALSE, warning=FALSE, results='markup'----------------------
# Format data
df_for_anova <- df %>%
dplyr::group_by(Participant, Condition) %>%
dplyr::summarise(RT = mean(RT))

# Run the anova
anova <- aov(RT ~ Condition + Error(Participant), df_for_anova)
summary(anova)

## ----fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='markup'----
library(lmerTest)

fit <- lmerTest::lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df)

# Traditional output
summary(fit)

## ---- message=FALSE, results="hide"--------------------------------------
results <- psycho::analyze(fit)

# We can extract a formatted summary table
summary(results, round = 2)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(summary(results, round = 2))

## ---- results='markup'---------------------------------------------------
print(results)

## ----fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='hide'----
library(rstanarm)

fit <- rstanarm::stan_lmer(RT ~ Condition + (1|Participant) + (1|Item), data=df)

# Traditional output
results <- psycho::analyze(fit, effsize=T)
summary(results, round=2)

## ----echo=FALSE, message=FALSE, warning=FALSE----------------------------
kable(summary(results, round = 2))

## ---- results='markup'---------------------------------------------------
print(results)

## ---- fig.width=7, fig.height=4.5, eval = TRUE, results='markup', fig.align='center'----
plot(results)

15 changes: 8 additions & 7 deletions vignettes/overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract: |
vignette: >
%\VignetteIndexEntry{Overview}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteDepends{tidyverse}
\usepackage[utf8]{inputenc}
---

Expand Down Expand Up @@ -156,7 +157,7 @@ plot(results)
The `n_factors()` function is useful in before running principal component (PCA) or factor (FA) analysis. As many statistical methods exists to that purpose, this function gathers them together and gives an overview on the most frequent result. It also draw a nice plot with the eigenvalues and the proportion of explained variance.


```{r echo=FALSE, message=FALSE, warning=FALSE, results='hide'}
```{r echo=TRUE, message=FALSE, warning=FALSE, results='hide'}
results <- attitude %>%
select_if(is.numeric) %>%
psycho::n_factors()
Expand Down Expand Up @@ -190,11 +191,11 @@ plot(results)

## Analyze the Mixed-Modelling Framework

This is possibly the most important function of the `psycho` package. Its goal is to transform complex outputs of complex statistical routines into something readable, interpretable, and formatted. It is designed to work with frequentist and Bayesian mixed models, which is the central statistical routine used in psychological science.
This is possibly the most important function of the `psycho` package. Its goal is to transform complex outputs of complex statistical routines into something readable, interpretable, and formatted. It is designed to work with frequentist and Bayesian mixed models, which is the central statistical method for psychological science.

### Data Creation

Let's start by creating a dataframe similar to those find in psychological science.
Let's start by creating a dataframe similar to those found in psychological science.

```{r, results='hide'}
set.seed(666)
Expand All @@ -216,11 +217,11 @@ head(df)
kable(head(df))
```

This dataframe contains the data of 25 participants (labelled from 1 to 25), that saw 4 items (i1-i4) in two conditions (A and B). We measured, for each item, if the response was correct or not (Error), its reaction time (RT) and the stress associated with the trial.
This dataframe contains the data of 25 participants (labelled from 1 to 25). Each saw 4 different items (i1-i4) in two conditions (A and B). We measured, for each item, if the response was correct or not (Error), its reaction time (RT) and the stress associated with the trial.

### Ancient Approach

In order to investigate the effect of the condition on the reaction time RT, the traditional, ancient and obsolete routines are to compute the mean for each participant, and run an ANOVA.
In order to investigate the effect of the condition on the reaction time RT, the traditional, ancient and obsolete routine is 1) to compute the mean for each participant, and 2) run an ANOVA.

```{r message=FALSE, warning=FALSE, results='markup'}
# Format data
Expand All @@ -233,7 +234,7 @@ anova <- aov(RT ~ Condition + Error(Participant), df_for_anova)
summary(anova)
```

As we can see, the effect of condition is not significant (unsuprisingly, as data was generated randomly). One of the many flaws of this approach is that we lose information about intra-individual and item-related variability.
As we can see, the effect of the condition is not significant (unsuprisingly, as data was generated randomly). One of the many flaws of this approach is that we lose information about intra-individual and item-related variability.


### Mixed Linear Regressions (lme4, lmerTest)
Expand Down Expand Up @@ -271,7 +272,7 @@ print(results)

### Bayesian Mixed Linear Regressions (rstanarm)

However, as the frequentist framework is criticized, it is advised to switch to a Bayesian framework. However, the interpretation of these models is even more complex and unfamiliar to regular psychologists. But stay calm, because `analyze()` handles this difficulty for you.
However, as the frequentist framework is criticized, it is advised to switch to the Bayesian framework. Unfortunately, interpretation of these models remain unfamiliar to regular psychologists. But stay calm, because `analyze()` handles this for you.

```{r fig.align='center', message=FALSE, warning=FALSE, val=TRUE, results='hide'}
library(rstanarm)
Expand Down

2 comments on commit 62eba06

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/analyze.stanreg.R:143:1: style: lines should not be more than 80 characters.

​      warning("Interpreting effect size following Cohen (1977, 1988)... Make sure your variables were normalized!")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/analyze.stanreg.R:292:1: style: lines should not be more than 80 characters.

​  names(summary) <- c("Variable", "MPE", "Median", "MAD", "Mean", "SD", paste0(CI, "_CI_lower"), paste0(CI, "_CI_higher"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:59:1: style: lines should not be more than 80 characters.

corr <- psych::corr.test(df, y = df2, use = "pairwise", method = method, adjust = "none")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:92:3: warning: local variable ‘n’ assigned but may not be used

n <- nrow(df)
  ^

R/correlation.R:97:1: style: lines should not be more than 80 characters.

p[lower.tri(p)] <- p.adjust(p[lower.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:98:1: style: lines should not be more than 80 characters.

p[upper.tri(p)] <- p.adjust(p[upper.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:133:1: style: lines should not be more than 80 characters.

table <- cbind(table[1:length(table) - 1]) # remove last column and return the matrix (which is now a data frame)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:154:1: style: lines should not be more than 80 characters.

corr <- psych::corr.test(cbind(df, df2), use = "pairwise", method = method, adjust = "none")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:157:1: style: lines should not be more than 80 characters.

p[lower.tri(p)] <- p.adjust(p[lower.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:158:1: style: lines should not be more than 80 characters.

p[upper.tri(p)] <- p.adjust(p[upper.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:159:1: style: lines should not be more than 80 characters.

​    warning("Due to the presence of two dataframes, the plot might be incorrect. Consider with caution.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:165:1: style: lines should not be more than 80 characters.

title = paste("A ", type, "'s correlation matrix (correction: ", adjust, ")\n", sep = ""),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:179:1: style: lines should not be more than 80 characters.

title = paste("A ", type, "'s correlation matrix (correction: ", adjust, ")\n", sep = ""),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/formatting.R:26:60: style: Put spaces around all infix operators.

formatted <- paste0(formatted, strrep("0", digits-1))
                                                          ~^~

R/n_factors.R:124:1: style: lines should not be more than 80 characters.

opt <- stats[stats$map == min, ]$n_factors[!is.na(stats[stats$map == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:136:1: style: lines should not be more than 80 characters.

opt <- stats[stats$BIC == min, ]$n_factors[!is.na(stats[stats$BIC == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:148:1: style: lines should not be more than 80 characters.

opt <- stats[stats$SABIC == min, ]$n_factors[!is.na(stats[stats$SABIC == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:167:1: style: lines should not be more than 80 characters.

n_optimal = c(na.omit(cfit[cfit$cfit == max(cfit$cfit, na.rm = T), ])$n_factors)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:205:1: style: lines should not be more than 80 characters.

plot_data$n.Methods.Ratio <- plot_data$n.Methods.Ratio * (1 / max(plot_data$n.Methods.Ratio))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:206:1: style: lines should not be more than 80 characters.

plot_data$area <- plot_data$n.Methods.Ratio / (max(plot_data$n.Methods.Ratio) / max(plot_data$Eigenvalues))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:207:1: style: lines should not be more than 80 characters.

plot_data$var <- plot_data$Cum.Variance / (max(plot_data$Cum.Variance) / max(plot_data$Eigenvalues))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:227:1: style: lines should not be more than 80 characters.

trans = ~. * (max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-normalize.R:13:42: style: Put spaces around all infix operators.

Participant = as.factor(rep(1:50,each=2)),
                                        ~^~

tests/testthat/test-normalize.R:19:30: style: Put spaces around all infix operators.

dfZ <- normalize(df, except="V3")
                            ~^~

tests/testthat/test-normalize.R:21:30: style: Put spaces around all infix operators.

dfZ <- normalize(df, except=c("V1", "V2"))
                            ~^~

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/analyze.stanreg.R:143:1: style: lines should not be more than 80 characters.

​      warning("Interpreting effect size following Cohen (1977, 1988)... Make sure your variables were normalized!")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/analyze.stanreg.R:292:1: style: lines should not be more than 80 characters.

​  names(summary) <- c("Variable", "MPE", "Median", "MAD", "Mean", "SD", paste0(CI, "_CI_lower"), paste0(CI, "_CI_higher"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:59:1: style: lines should not be more than 80 characters.

corr <- psych::corr.test(df, y = df2, use = "pairwise", method = method, adjust = "none")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:92:3: warning: local variable ‘n’ assigned but may not be used

n <- nrow(df)
  ^

R/correlation.R:97:1: style: lines should not be more than 80 characters.

p[lower.tri(p)] <- p.adjust(p[lower.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:98:1: style: lines should not be more than 80 characters.

p[upper.tri(p)] <- p.adjust(p[upper.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:133:1: style: lines should not be more than 80 characters.

table <- cbind(table[1:length(table) - 1]) # remove last column and return the matrix (which is now a data frame)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:154:1: style: lines should not be more than 80 characters.

corr <- psych::corr.test(cbind(df, df2), use = "pairwise", method = method, adjust = "none")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:157:1: style: lines should not be more than 80 characters.

p[lower.tri(p)] <- p.adjust(p[lower.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:158:1: style: lines should not be more than 80 characters.

p[upper.tri(p)] <- p.adjust(p[upper.tri(p)], method = adjust, n = choose(nrow(p), 2))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:159:1: style: lines should not be more than 80 characters.

​    warning("Due to the presence of two dataframes, the plot might be incorrect. Consider with caution.")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:165:1: style: lines should not be more than 80 characters.

title = paste("A ", type, "'s correlation matrix (correction: ", adjust, ")\n", sep = ""),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/correlation.R:179:1: style: lines should not be more than 80 characters.

title = paste("A ", type, "'s correlation matrix (correction: ", adjust, ")\n", sep = ""),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/formatting.R:26:60: style: Put spaces around all infix operators.

formatted <- paste0(formatted, strrep("0", digits-1))
                                                          ~^~

R/n_factors.R:124:1: style: lines should not be more than 80 characters.

opt <- stats[stats$map == min, ]$n_factors[!is.na(stats[stats$map == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:136:1: style: lines should not be more than 80 characters.

opt <- stats[stats$BIC == min, ]$n_factors[!is.na(stats[stats$BIC == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:148:1: style: lines should not be more than 80 characters.

opt <- stats[stats$SABIC == min, ]$n_factors[!is.na(stats[stats$SABIC == min, ]$n_factors)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:167:1: style: lines should not be more than 80 characters.

n_optimal = c(na.omit(cfit[cfit$cfit == max(cfit$cfit, na.rm = T), ])$n_factors)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:205:1: style: lines should not be more than 80 characters.

plot_data$n.Methods.Ratio <- plot_data$n.Methods.Ratio * (1 / max(plot_data$n.Methods.Ratio))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:206:1: style: lines should not be more than 80 characters.

plot_data$area <- plot_data$n.Methods.Ratio / (max(plot_data$n.Methods.Ratio) / max(plot_data$Eigenvalues))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:207:1: style: lines should not be more than 80 characters.

plot_data$var <- plot_data$Cum.Variance / (max(plot_data$Cum.Variance) / max(plot_data$Eigenvalues))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:227:1: style: lines should not be more than 80 characters.

trans = ~. * (max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-normalize.R:13:42: style: Put spaces around all infix operators.

Participant = as.factor(rep(1:50,each=2)),
                                        ~^~

tests/testthat/test-normalize.R:19:30: style: Put spaces around all infix operators.

dfZ <- normalize(df, except="V3")
                            ~^~

tests/testthat/test-normalize.R:21:30: style: Put spaces around all infix operators.

dfZ <- normalize(df, except=c("V1", "V2"))
                            ~^~

Please sign in to comment.