Skip to content

Commit

Permalink
Merge pull request #13 from neuropsychology/0.0.3-hotfix
Browse files Browse the repository at this point in the history
n_factors fix
  • Loading branch information
DominiqueMakowski committed Nov 11, 2017
2 parents 458d54f + 1cb4481 commit 2a6c22e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
38 changes: 27 additions & 11 deletions R/n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#'
#' @param df The dataframe
#' @param rotate What rotation to use c("none", "varimax", "oblimin","promax")
#' @param fm Factoring method – fm="pa" Principal Axis Factor Analysis,
#' fm = "minres" minimum residual (OLS) factoring fm="mle" Maximum Likelihood FA,
#' fm="pc" Principal Components"
#' @param fm Factoring method: "pa" for Principal Axis Factor Analysis,
#' "minres" (default) for minimum residual (OLS) factoring, "mle" for
#' Maximum Likelihood FA and "pc" for Principal Components
#' @param n_max How many factors to test.
#'
#' @return output
Expand Down Expand Up @@ -103,13 +103,30 @@ n_factors <- function(df, rotate="varimax", fm="minres", n_max=8){
stats$map <- vss$map
stats$n_factors <- 1:nrow(stats)

results2 <- data.frame(Method=c("Velicer MAP",
"BIC",
"Sample Size Adjusted BIC"),
n_optimal=c(na.omit(stats[stats$map==min(stats$map, na.rm = T),])$n_factors,
na.omit(stats[stats$BIC==min(stats$BIC, na.rm = T),])$n_factors,
na.omit(stats[stats$SABIC==min(stats$SABIC, na.rm = T),])$n_factors))
results <- rbind(results, results2)
# map
if (length(stats$map[!is.na(stats$map)]) > 0){
min <- min(stats$map[!is.na(stats$map)])
opt <- stats[stats$map==min,]$n_factors[!is.na(stats[stats$map==min,]$n_factors)]
results <- rbind(results,
data.frame(Method=c("Velicer MAP"),
n_optimal=c(opt)))
}
# bic
if (length(stats$BIC[!is.na(stats$BIC)]) > 0){
min <- min(stats$BIC[!is.na(stats$BIC)])
opt <- stats[stats$BIC==min,]$n_factors[!is.na(stats[stats$BIC==min,]$n_factors)]
results <- rbind(results,
data.frame(Method=c("BIC"),
n_optimal=c(opt)))
}
# sabic
if (length(stats$SABIC[!is.na(stats$SABIC)]) > 0){
min <- min(stats$SABIC[!is.na(stats$SABIC)])
opt <- stats[stats$SABIC==min,]$n_factors[!is.na(stats[stats$SABIC==min,]$n_factors)]
results <- rbind(results,
data.frame(Method=c("Sample Size Adjusted BIC"),
n_optimal=c(opt)))
}


cfits <- vss[grep("cfit", names(vss))]
Expand Down Expand Up @@ -174,7 +191,6 @@ n_factors <- function(df, rotate="varimax", fm="minres", n_max=8){
ylab("Eigenvalues\n") +
xlab("\nNumber of Factors") +
theme_minimal()
plot

# Output
# -------------
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ Want to get involved in the developpment of an open-source software and improve
- Looking for help to implement the `analyze` method for `t.test`, `cor.test` and `anova`.


## Features

The `psycho` package can already do the following:

- [x] Normalize your data
- [x] Enlight you on how many factors to retain for a PCA
- [x] Give you some clinically relevant info on a participant's score
- [x] Compute complex correlation matrices
- [x] Help you in the interpretation of various models (lme4, stan_lmer)



## General Workflow

Expand Down
6 changes: 3 additions & 3 deletions man/n_factors.Rd

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

2 comments on commit 2a6c22e

@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/n_factors.R:57:16: style: Put spaces around all infix operators.

return(sd/sqrt(n) * sqrt(p * (1 - p))/dnorm(qnorm(p)))
              ~^~

R/n_factors.R:57:44: style: Put spaces around all infix operators.

return(sd/sqrt(n) * sqrt(p * (1 - p))/dnorm(qnorm(p)))
                                          ~^~

R/n_factors.R:77:25: style: Put spaces around all infix operators.

ap <- parallel(subject=nrow(df), var=ncol(df))
                       ~^~

R/n_factors.R:77:39: style: Put spaces around all infix operators.

ap <- parallel(subject=nrow(df), var=ncol(df))
                                     ~^~

R/n_factors.R:78:27: style: Put spaces around all infix operators.

nS <- nFactors::nScree(x=eigen(cor)$values, aparallel=ap$eigen$qevpea)
                         ~^~

R/n_factors.R:78:56: style: Put spaces around all infix operators.

nS <- nFactors::nScree(x=eigen(cor)$values, aparallel=ap$eigen$qevpea)
                                                      ~^~

R/n_factors.R:83:33: style: Put spaces around all infix operators.

"Exp.Variance"="Prop",
                               ~^~

R/n_factors.R:84:33: style: Put spaces around all infix operators.

"Cum.Variance"="Cumu") %>%
                               ~^~

R/n_factors.R:85:24: style: Put spaces around all infix operators.

​    mutate_("n.Factors"= ~1:nrow(nS$Analysis))
                      ~^

R/n_factors.R:90:31: style: Put spaces around all infix operators.

results <- data.frame(Method=c("Optimal Coordinates",
                             ~^~

R/n_factors.R:94:34: style: Put spaces around all infix operators.

n_optimal=as.numeric(nS$Components[1,]))
                                ~^~

R/n_factors.R:98:22: style: Put spaces around all infix operators.

n=n_max,
                    ~^~

R/n_factors.R:99:26: style: Put spaces around all infix operators.

n.obs=nrow(df),
                        ~^~

R/n_factors.R:100:27: style: Put spaces around all infix operators.

rotate=rotate,
                         ~^~

R/n_factors.R:101:23: style: Put spaces around all infix operators.

fm=fm, plot=F)  # fm can be "pa", "pc", "minres", "mle"
                     ~^~

R/n_factors.R:101:32: style: Put spaces around all infix operators.

fm=fm, plot=F)  # fm can be "pa", "pc", "minres", "mle"
                              ~^~

R/n_factors.R:109: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:109:27: style: Put spaces around all infix operators.

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

R/n_factors.R:109:67: style: Put spaces around all infix operators.

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

R/n_factors.R:111:39: style: Put spaces around all infix operators.

data.frame(Method=c("Velicer MAP"),
                                     ~^~

R/n_factors.R:112:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:117: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:117:27: style: Put spaces around all infix operators.

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

R/n_factors.R:117:67: style: Put spaces around all infix operators.

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

R/n_factors.R:119:39: style: Put spaces around all infix operators.

data.frame(Method=c("BIC"),
                                     ~^~

R/n_factors.R:120:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:125: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:125:29: style: Put spaces around all infix operators.

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

R/n_factors.R:125:71: style: Put spaces around all infix operators.

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

R/n_factors.R:127:39: style: Put spaces around all infix operators.

data.frame(Method=c("Sample Size Adjusted BIC"),
                                     ~^~

R/n_factors.R:128:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:136:28: style: Put spaces around all infix operators.

cfit <- data.frame(cfit=cfit, n_factors=1:length(cfit))
                          ~^~

R/n_factors.R:136:44: style: Put spaces around all infix operators.

cfit <- data.frame(cfit=cfit, n_factors=1:length(cfit))
                                          ~^~

R/n_factors.R:138:33: style: Put spaces around all infix operators.

result3 <- data.frame(Method=c(gsub("cfit.", "VSS Complexity ", name)),
                               ~^~

R/n_factors.R:139: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:139:36: style: Put spaces around all infix operators.

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

R/n_factors.R:139:61: style: Put spaces around all infix operators.

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

R/n_factors.R:147:26: style: Put spaces around all infix operators.

​    summarise_("n_method"=~n()) %>%
                        ~^~

R/n_factors.R:148:24: style: Put spaces around all infix operators.

​    mutate_("n_optimal"=~factor(n_optimal, levels=1:nrow(eigenvalues))) %>%
                      ~^~

R/n_factors.R:148:50: style: Put spaces around all infix operators.

​    mutate_("n_optimal"=~factor(n_optimal, levels=1:nrow(eigenvalues))) %>%
                                                ~^~

R/n_factors.R:149:32: style: Put spaces around all infix operators.

​    complete_("n_optimal", fill=list(n_method = 0)) %>%
                              ~^~

R/n_factors.R:151:24: style: Put spaces around all infix operators.

​    rename_("n.Factors"="n_optimal",
                      ~^~

R/n_factors.R:152:23: style: Put spaces around all infix operators.

"n.Methods"="n_method") %>%
                     ~^~

R/n_factors.R:153:24: style: Put spaces around all infix operators.

​    mutate_("n.Factors"=~as.integer(n.Factors)) %>%
                      ~^~

R/n_factors.R:154:30: style: Put spaces around all infix operators.

​    left_join(eigenvalues, by="n.Factors")
                            ~^~

R/n_factors.R:159:29: style: Put spaces around all infix operators.

values <- list(eigenvalues=eigenvalues, methods=results)
                           ~^~

R/n_factors.R:159:50: style: Put spaces around all infix operators.

values <- list(eigenvalues=eigenvalues, methods=results)
                                                ~^~

R/n_factors.R:173:51: style: Put spaces around all infix operators.

plot_data$n.Methods.Ratio <- plot_data$n.Methods/sum(plot_data$n.Methods)
                                                 ~^~

R/n_factors.R:174: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:174:57: style: Put spaces around all infix operators.

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

R/n_factors.R:174:60: style: Put spaces around all infix operators.

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

R/n_factors.R:175: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:175:46: style: Put spaces around all infix operators.

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

R/n_factors.R:176: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:176:42: style: Put spaces around all infix operators.

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

R/n_factors.R:179:24: style: Put spaces around all infix operators.

​    ggplot(aes_string(x="n.Factors", y="Eigenvalues")) +
                      ~^~

R/n_factors.R:179:39: style: Put spaces around all infix operators.

​    ggplot(aes_string(x="n.Factors", y="Eigenvalues")) +
                                     ~^~

R/n_factors.R:180:27: style: Put spaces around all infix operators.

​    geom_area(aes_string(y="area"),
                         ~^~

R/n_factors.R:181:19: style: Put spaces around all infix operators.

fill="#FFC107",
                 ~^~

R/n_factors.R:182:20: style: Put spaces around all infix operators.

alpha=0.5) +
                  ~^~

R/n_factors.R:183:21: style: Put spaces around all infix operators.

​    geom_line(colour="#E91E63",
                   ~^~

R/n_factors.R:184:19: style: Put spaces around all infix operators.

size=1) +
                 ~^~

R/n_factors.R:185:40: style: Put spaces around all infix operators.

​    geom_hline(yintercept = 1, linetype="dashed", colour="#607D8B") +
                                      ~^~

R/n_factors.R:185:57: style: Put spaces around all infix operators.

​    geom_hline(yintercept = 1, linetype="dashed", colour="#607D8B") +
                                                       ~^~

R/n_factors.R:187:21: style: Put spaces around all infix operators.

colour="#2196F3",
                   ~^~

R/n_factors.R:188:19: style: Put spaces around all infix operators.

size=1) +
                 ~^~

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

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:189:49: style: Put spaces around all infix operators.

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
                                               ~^

R/n_factors.R:189:53: style: Put spaces around all infix operators.

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
                                                   ~^~

R/n_factors.R:190:51: style: Only use double-quotes.

name = 'Cumulative Variance\n')) +
                                                  ^~~~~~~~~~~~~~~~~~~~~~~

@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/n_factors.R:57:16: style: Put spaces around all infix operators.

return(sd/sqrt(n) * sqrt(p * (1 - p))/dnorm(qnorm(p)))
              ~^~

R/n_factors.R:57:44: style: Put spaces around all infix operators.

return(sd/sqrt(n) * sqrt(p * (1 - p))/dnorm(qnorm(p)))
                                          ~^~

R/n_factors.R:77:25: style: Put spaces around all infix operators.

ap <- parallel(subject=nrow(df), var=ncol(df))
                       ~^~

R/n_factors.R:77:39: style: Put spaces around all infix operators.

ap <- parallel(subject=nrow(df), var=ncol(df))
                                     ~^~

R/n_factors.R:78:27: style: Put spaces around all infix operators.

nS <- nFactors::nScree(x=eigen(cor)$values, aparallel=ap$eigen$qevpea)
                         ~^~

R/n_factors.R:78:56: style: Put spaces around all infix operators.

nS <- nFactors::nScree(x=eigen(cor)$values, aparallel=ap$eigen$qevpea)
                                                      ~^~

R/n_factors.R:83:33: style: Put spaces around all infix operators.

"Exp.Variance"="Prop",
                               ~^~

R/n_factors.R:84:33: style: Put spaces around all infix operators.

"Cum.Variance"="Cumu") %>%
                               ~^~

R/n_factors.R:85:24: style: Put spaces around all infix operators.

​    mutate_("n.Factors"= ~1:nrow(nS$Analysis))
                      ~^

R/n_factors.R:90:31: style: Put spaces around all infix operators.

results <- data.frame(Method=c("Optimal Coordinates",
                             ~^~

R/n_factors.R:94:34: style: Put spaces around all infix operators.

n_optimal=as.numeric(nS$Components[1,]))
                                ~^~

R/n_factors.R:98:22: style: Put spaces around all infix operators.

n=n_max,
                    ~^~

R/n_factors.R:99:26: style: Put spaces around all infix operators.

n.obs=nrow(df),
                        ~^~

R/n_factors.R:100:27: style: Put spaces around all infix operators.

rotate=rotate,
                         ~^~

R/n_factors.R:101:23: style: Put spaces around all infix operators.

fm=fm, plot=F)  # fm can be "pa", "pc", "minres", "mle"
                     ~^~

R/n_factors.R:101:32: style: Put spaces around all infix operators.

fm=fm, plot=F)  # fm can be "pa", "pc", "minres", "mle"
                              ~^~

R/n_factors.R:109: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:109:27: style: Put spaces around all infix operators.

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

R/n_factors.R:109:67: style: Put spaces around all infix operators.

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

R/n_factors.R:111:39: style: Put spaces around all infix operators.

data.frame(Method=c("Velicer MAP"),
                                     ~^~

R/n_factors.R:112:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:117: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:117:27: style: Put spaces around all infix operators.

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

R/n_factors.R:117:67: style: Put spaces around all infix operators.

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

R/n_factors.R:119:39: style: Put spaces around all infix operators.

data.frame(Method=c("BIC"),
                                     ~^~

R/n_factors.R:120:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:125: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:125:29: style: Put spaces around all infix operators.

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

R/n_factors.R:125:71: style: Put spaces around all infix operators.

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

R/n_factors.R:127:39: style: Put spaces around all infix operators.

data.frame(Method=c("Sample Size Adjusted BIC"),
                                     ~^~

R/n_factors.R:128:42: style: Put spaces around all infix operators.

n_optimal=c(opt)))
                                        ~^~

R/n_factors.R:136:28: style: Put spaces around all infix operators.

cfit <- data.frame(cfit=cfit, n_factors=1:length(cfit))
                          ~^~

R/n_factors.R:136:44: style: Put spaces around all infix operators.

cfit <- data.frame(cfit=cfit, n_factors=1:length(cfit))
                                          ~^~

R/n_factors.R:138:33: style: Put spaces around all infix operators.

result3 <- data.frame(Method=c(gsub("cfit.", "VSS Complexity ", name)),
                               ~^~

R/n_factors.R:139: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:139:36: style: Put spaces around all infix operators.

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

R/n_factors.R:139:61: style: Put spaces around all infix operators.

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

R/n_factors.R:147:26: style: Put spaces around all infix operators.

​    summarise_("n_method"=~n()) %>%
                        ~^~

R/n_factors.R:148:24: style: Put spaces around all infix operators.

​    mutate_("n_optimal"=~factor(n_optimal, levels=1:nrow(eigenvalues))) %>%
                      ~^~

R/n_factors.R:148:50: style: Put spaces around all infix operators.

​    mutate_("n_optimal"=~factor(n_optimal, levels=1:nrow(eigenvalues))) %>%
                                                ~^~

R/n_factors.R:149:32: style: Put spaces around all infix operators.

​    complete_("n_optimal", fill=list(n_method = 0)) %>%
                              ~^~

R/n_factors.R:151:24: style: Put spaces around all infix operators.

​    rename_("n.Factors"="n_optimal",
                      ~^~

R/n_factors.R:152:23: style: Put spaces around all infix operators.

"n.Methods"="n_method") %>%
                     ~^~

R/n_factors.R:153:24: style: Put spaces around all infix operators.

​    mutate_("n.Factors"=~as.integer(n.Factors)) %>%
                      ~^~

R/n_factors.R:154:30: style: Put spaces around all infix operators.

​    left_join(eigenvalues, by="n.Factors")
                            ~^~

R/n_factors.R:159:29: style: Put spaces around all infix operators.

values <- list(eigenvalues=eigenvalues, methods=results)
                           ~^~

R/n_factors.R:159:50: style: Put spaces around all infix operators.

values <- list(eigenvalues=eigenvalues, methods=results)
                                                ~^~

R/n_factors.R:173:51: style: Put spaces around all infix operators.

plot_data$n.Methods.Ratio <- plot_data$n.Methods/sum(plot_data$n.Methods)
                                                 ~^~

R/n_factors.R:174: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:174:57: style: Put spaces around all infix operators.

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

R/n_factors.R:174:60: style: Put spaces around all infix operators.

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

R/n_factors.R:175: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:175:46: style: Put spaces around all infix operators.

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

R/n_factors.R:176: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:176:42: style: Put spaces around all infix operators.

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

R/n_factors.R:179:24: style: Put spaces around all infix operators.

​    ggplot(aes_string(x="n.Factors", y="Eigenvalues")) +
                      ~^~

R/n_factors.R:179:39: style: Put spaces around all infix operators.

​    ggplot(aes_string(x="n.Factors", y="Eigenvalues")) +
                                     ~^~

R/n_factors.R:180:27: style: Put spaces around all infix operators.

​    geom_area(aes_string(y="area"),
                         ~^~

R/n_factors.R:181:19: style: Put spaces around all infix operators.

fill="#FFC107",
                 ~^~

R/n_factors.R:182:20: style: Put spaces around all infix operators.

alpha=0.5) +
                  ~^~

R/n_factors.R:183:21: style: Put spaces around all infix operators.

​    geom_line(colour="#E91E63",
                   ~^~

R/n_factors.R:184:19: style: Put spaces around all infix operators.

size=1) +
                 ~^~

R/n_factors.R:185:40: style: Put spaces around all infix operators.

​    geom_hline(yintercept = 1, linetype="dashed", colour="#607D8B") +
                                      ~^~

R/n_factors.R:185:57: style: Put spaces around all infix operators.

​    geom_hline(yintercept = 1, linetype="dashed", colour="#607D8B") +
                                                       ~^~

R/n_factors.R:187:21: style: Put spaces around all infix operators.

colour="#2196F3",
                   ~^~

R/n_factors.R:188:19: style: Put spaces around all infix operators.

size=1) +
                 ~^~

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

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/n_factors.R:189:49: style: Put spaces around all infix operators.

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
                                               ~^

R/n_factors.R:189:53: style: Put spaces around all infix operators.

​    scale_y_continuous(sec.axis = sec_axis(trans= ~.*(max(eigenvalues$Cum.Variance) / max(eigenvalues$Eigenvalues)),
                                                   ~^~

R/n_factors.R:190:51: style: Only use double-quotes.

name = 'Cumulative Variance\n')) +
                                                  ^~~~~~~~~~~~~~~~~~~~~~~

Please sign in to comment.