diff --git a/DESCRIPTION b/DESCRIPTION index eb6a9497d..bef6f43ec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: radiant Title: Business Analytics using R and Shiny -Version: 0.1.75 -Date: 2015-3-17 +Version: 0.1.83 +Date: 2015-3-24 Authors@R: person("Vincent", "Nijs", , "radiant@rady.ucsd.edu", c("aut", "cre")) Description: A platform-independent browser-based interface for business analytics in R, based on the Shiny package. @@ -31,7 +31,7 @@ Suggests: rmarkdown (>= 0.4.2), ggvis (>= 0.4), testthat (>= 0.9.1) -URL: https://github.com/mostly-harmless/radiant, http://mostly-harmless.github.io/radiant/ -BugReports: https://github.com/mostly-harmless/radiant/issues +URL: https://github.com/vnijs/radiant, http://vnijs.github.io/radiant/ +BugReports: https://github.com/vnijs/radiant/issues License: AGPL-3 | file LICENSE LazyData: true diff --git a/NAMESPACE b/NAMESPACE index 61be95a30..c4d31ecd2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ S3method(plot,kmeans_clus) S3method(plot,mds) S3method(plot,pmap) S3method(plot,pre_factor) +S3method(plot,reg_predict) S3method(plot,regression) S3method(plot,single_mean) S3method(plot,single_prop) @@ -62,7 +63,6 @@ export(sample_size) export(sampling) export(save_factors) export(save_glm_resid) -export(save_kmeans) export(save_membership) export(save_reg_resid) export(set_class) diff --git a/R/compare_means.R b/R/compare_means.R index 596511395..4ffe311b3 100644 --- a/R/compare_means.R +++ b/R/compare_means.R @@ -1,6 +1,6 @@ #' Compare means for two or more variables #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_means.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_means.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param cm_var1 A numeric variable or factor selected for comparison @@ -80,7 +80,7 @@ compare_means <- function(dataset, cm_var1, cm_var2, #' Summary method for the compare_means function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_means.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_means.html} for an example in Radiant #' #' @param object Return value from \code{\link{compare_means}} #' @param ... further arguments passed to or from other methods @@ -133,7 +133,7 @@ summary.compare_means <- function(object, ...) { #' Plot method for the compare_means function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_means.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_means.html} for an example in Radiant #' #' @param x Return value from \code{\link{compare_means}} #' @param cm_plots One or more plots ("bar", "box", or "density") diff --git a/R/compare_props.R b/R/compare_props.R index e10b265d2..11a1640de 100644 --- a/R/compare_props.R +++ b/R/compare_props.R @@ -1,6 +1,6 @@ #' Compare proportions across groups #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_props.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_props.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param cp_var1 A grouping variable to split the data for comparisons @@ -93,7 +93,7 @@ compare_props <- function(dataset, cp_var1, cp_var2, #' Summary method for the compare_props function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_props.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_props.html} for an example in Radiant #' #' @param object Return value from \code{\link{compare_props}} #' @param ... further arguments passed to or from other methods @@ -144,7 +144,7 @@ summary.compare_props <- function(object, ...) { #' Plot method for the compare_props function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/compare_props.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/compare_props.html} for an example in Radiant #' #' @param x Return value from \code{\link{compare_props}} #' @param cp_plots One or more plots of proportions or counts ("props" or "counts") diff --git a/R/conjoint.R b/R/conjoint.R index e518eaff3..03105135a 100644 --- a/R/conjoint.R +++ b/R/conjoint.R @@ -1,6 +1,6 @@ #' Conjoint analysis #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param ca_dep_var The dependent variable (e.g., profile ratings) @@ -44,7 +44,7 @@ conjoint <- function(dataset, ca_dep_var, ca_indep_var, #' Summary method for the conjoint function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint.html} for an example in Radiant #' #' @param object Return value from \code{\link{conjoint}} #' @param ca_vif Shows multicollinearity diagnostics. @@ -104,7 +104,7 @@ summary.conjoint <- function(object, #' Plot method for the conjoint function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint.html} for an example in Radiant #' #' @param x Return value from \code{\link{conjoint}} #' @param ca_plots Show either the part-worth ("pw") or importance-weights ("iw") plot @@ -164,7 +164,7 @@ plot.conjoint <- function(x, #' Function to calculate the PW and IW table for conjoint #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint.html} for an example in Radiant #' #' @param model Tidied model results (broom) output from \code{\link{conjoint}} passed on by summary.conjoint #' @param dat Conjoint data diff --git a/R/conjoint_profiles.R b/R/conjoint_profiles.R index a5a099ff1..a025510bb 100644 --- a/R/conjoint_profiles.R +++ b/R/conjoint_profiles.R @@ -1,6 +1,6 @@ #' Create fractional factorial design for conjoint analysis #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @@ -47,7 +47,7 @@ conjoint_profiles <- function(dataset) { #' Summary method for the conjoint_profiles function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant #' #' @param object Return value from \code{\link{conjoint_profiles}} #' @param ... further arguments passed to or from other methods. @@ -81,7 +81,7 @@ summary.conjoint_profiles <- function(object, ...) { #' Function to generate a fractional factorial design #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/conjoint_profiles.html} for an example in Radiant #' #' @param attr Attributes used to generate profiles #' @param trial Number of trials that have already been run diff --git a/R/correlation.R b/R/correlation.R index e6893640a..06d1ac405 100644 --- a/R/correlation.R +++ b/R/correlation.R @@ -1,6 +1,6 @@ #' Calculate correlations for two or more variables #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/correlation.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/correlation.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param cor_var Variables to include in the analysis @@ -34,7 +34,7 @@ correlation <- function(dataset, cor_var, #' Summary method for the correlation function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/correlation.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/correlation.html} for an example in Radiant #' #' @param object Return value from \code{\link{correlation}} #' @param cor_cutoff Show only corrlations larger than the cutoff in absolute value. Default is a cutoff of 0 @@ -81,7 +81,7 @@ summary.correlation <- function(object, #' Plot method for the correlation function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/correlation.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/correlation.html} for an example in Radiant #' #' @param x Return value from \code{\link{correlation}} #' @param ... further arguments passed to or from other methods. diff --git a/R/cross_tabs.R b/R/cross_tabs.R index afb1638c1..9b2466c4a 100644 --- a/R/cross_tabs.R +++ b/R/cross_tabs.R @@ -1,6 +1,6 @@ #' Evaluate associations between categorical variables #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/cross_tabs.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/cross_tabs.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param ct_var1 A categorical variable @@ -37,7 +37,7 @@ cross_tabs <- function(dataset, ct_var1, ct_var2, #' Summary method for the cross_tabs function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/cross_tabs.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/cross_tabs.html} for an example in Radiant #' @param object Return value from \code{\link{cross_tabs}} #' @param ct_check Show table(s) for variables ct_var1 and ct_var2. "observed" for the observed frequencies table, "expected" for the expected frequencies table (i.e., frequencies that would be expected if the null hypothesis holds), "chi_sq" for the contribution to the overall chi-squared statistic for each cell (i.e., (o - e)^2 / e), "dev_std" for the standardized differences between the observed and expected frequencies (i.e., (o - e) / sqrt(e)), and "dev_perc" for the percentage difference between the observed and expected frequencies (i.e., (o - e) / e) @@ -129,7 +129,7 @@ summary.cross_tabs <- function(object, #' Plot method for the cross_tabs function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/cross_tabs.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/cross_tabs.html} for an example in Radiant #' #' @param x Return value from \code{\link{cross_tabs}} #' @param ct_check Show plots for variables ct_var1 and ct_var2. "observed" for the observed frequencies table, "expected" for the expected frequencies table (i.e., frequencies that would be expected if the null hypothesis holds), "chi_sq" for the contribution to the overall chi-squared statistic for each cell (i.e., (o - e)^2 / e), "dev_std" for the standardized differences between the observed and expected frequencies (i.e., (o - e) / sqrt(e)), and "dev_perc" for the percentage difference between the observed and expected frequencies (i.e., (o - e) / e) diff --git a/R/full_factor.R b/R/full_factor.R index 860ea1eeb..1dbf989f4 100644 --- a/R/full_factor.R +++ b/R/full_factor.R @@ -1,6 +1,6 @@ #' Factor analysis (PCA) #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/full_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/full_factor.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param ff_var Variables to include in the analysis @@ -58,7 +58,7 @@ full_factor <- function(dataset, ff_var, #' Summary method for the full_factor function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/full_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/full_factor.html} for an example in Radiant #' #' @param object Return value from \code{\link{full_factor}} #' @param ff_cutoff Show only loadings with (absolute) values above ff_cutoff (default = 0) @@ -138,7 +138,7 @@ summary.full_factor <- function(object, #' Plot method for the full_factor function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/full_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/full_factor.html} for an example in Radiant #' #' @param x Return value from \code{\link{full_factor}} #' @param ... further arguments passed to or from other methods @@ -190,7 +190,7 @@ plot.full_factor <- function(x, ...) { #' Save factor scores to active dataset #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/full_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/full_factor.html} for an example in Radiant #' #' @param object Return value from \code{\link{full_factor}} #' diff --git a/R/glm_reg.R b/R/glm_reg.R index 1393766bd..dd0a7837a 100644 --- a/R/glm_reg.R +++ b/R/glm_reg.R @@ -1,6 +1,6 @@ #' Generalized linear models (GLM) #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param glm_dep_var The dependent variable in the logit (probit) model @@ -80,7 +80,7 @@ glm_reg <- function(dataset, glm_dep_var, glm_indep_var, #' Summary method for the glm_reg function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param object Return value from \code{\link{glm_reg}} #' @param glm_sum_check Optional output or estimation parameters. "rsme" to show the root mean squared error. "sumsquares" to show the sum of squares table. "vif" to show multicollinearity diagnostics. "confint" to show coefficient confidence interval estimates. @@ -230,7 +230,7 @@ summary.glm_reg <- function(object, #' Plot method for the glm_reg function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param x Return value from \code{\link{glm_reg}} #' @param glm_plots Plots to produce for the specified GLM model. Use "" to avoid showing any plots (default). "hist" shows histograms of all variables in the model. "scatter" shows scatter plots (or box plots for factors) for the dependent variable with each independent variable. "dashboard" is a series of four plots used to visually evaluate model. "coef" provides a coefficient plot @@ -329,7 +329,7 @@ plot.glm_reg <- function(x, #' Predict method for the glm_reg function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param object Return value from \code{\link{glm_reg}} #' @param glm_predict_cmd Generate predictions using a command. For example, `pclass = levels(pclass)` would produce predictions for the different levels of factor `pclass`. To add another variable use a `,` (e.g., `pclass = levels(pclass), age = seq(0,100,20)`) @@ -338,9 +338,7 @@ plot.glm_reg <- function(x, #' #' @examples #' result <- glm_reg("titanic", "survived", c("pclass","sex"), glm_levels = "Yes") -#' pred <- predict(result, glm_predict_cmd = "pclass = levels(pclass)") -#' str(pred) -#' names(pred) +#' predict(result, glm_predict_cmd = "pclass = levels(pclass)") #' predict(result, glm_predict_cmd = "sex = c('male','female')") #' #' @seealso \code{\link{glm_reg}} to generate the result @@ -457,7 +455,7 @@ predict.glm_reg <- function(object, #' Plot method for the predict.glm_reg function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param x Return value from \code{\link{predict.glm_reg}}. #' @param glm_xvar Variable to display along the X-axis of the plot @@ -527,7 +525,7 @@ plot.glm_predict <- function(x, #' Save residuals generated in the glm_reg function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/glm_reg.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/glm_reg.html} for an example in Radiant #' #' @param object Return value from \code{\link{glm_reg}} #' diff --git a/R/hier_clus.R b/R/hier_clus.R index 869c37f8c..94f256fcc 100644 --- a/R/hier_clus.R +++ b/R/hier_clus.R @@ -1,6 +1,6 @@ #' Hierarchical cluster analysis #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/hier_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/hier_clus.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param hc_vars Vector of variables to include in the analysis @@ -36,7 +36,7 @@ hier_clus <- function(dataset, hc_vars, #' Summary method for the hier_clus function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/hier_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/hier_clus.html} for an example in Radiant #' #' @param object Return value from \code{\link{hier_clus}} #' @param ... further arguments passed to or from other methods @@ -63,7 +63,7 @@ summary.hier_clus <- function(object, ...) { #' Plot method for the hier_clus function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/hier_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/hier_clus.html} for an example in Radiant #' #' @param x Return value from \code{\link{hier_clus}} #' @param hc_plots Plots to return. "diff" shows the percentage change in within-cluster heterogeneity as respondents are group into different number of clusters, "dendro" shows the dendrogram, "scree" shows a scree plot of within-cluster heterogeneity diff --git a/R/kmeans_clus.R b/R/kmeans_clus.R index d5be5d305..fe0112d59 100644 --- a/R/kmeans_clus.R +++ b/R/kmeans_clus.R @@ -1,6 +1,6 @@ #' K-means cluster analysis #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param km_vars Vector of variables to include in the analysis @@ -18,7 +18,6 @@ #' #' @seealso \code{\link{summary.kmeans_clus}} to summarize results #' @seealso \code{\link{plot.kmeans_clus}} to plot results -#' @seealso \code{\link{save_kmeans}} to save the table of cluster means to a csv file #' @seealso \code{\link{save_membership}} to add cluster membership to the selected dataset #' #' @export @@ -72,7 +71,7 @@ kmeans_clus <- function(dataset, km_vars, #' Summary method for kmeans_clus #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant #' #' @param object Return value from \code{\link{kmeans_clus}} #' @param ... further arguments passed to or from other methods @@ -83,7 +82,6 @@ kmeans_clus <- function(dataset, km_vars, #' #' @seealso \code{\link{kmeans_clus}} to generate results #' @seealso \code{\link{plot.kmeans_clus}} to plot results -#' @seealso \code{\link{save_kmeans}} to save the table of cluster means to a csv file #' @seealso \code{\link{save_membership}} to add cluster membership to the selected dataset #' #' @export @@ -123,7 +121,7 @@ summary.kmeans_clus <- function(object, ...) { #' Plot method for kmeans_clus #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant #' #' @param x Return value from \code{\link{kmeans_clus}} #' @param ... further arguments passed to or from other methods @@ -134,7 +132,6 @@ summary.kmeans_clus <- function(object, ...) { #' #' @seealso \code{\link{kmeans_clus}} to generate results #' @seealso \code{\link{summary.kmeans_clus}} to summarize results -#' @seealso \code{\link{save_kmeans}} to save the table of cluster means to a csv file #' @seealso \code{\link{save_membership}} to add cluster membership to the selected dataset #' #' @export @@ -156,29 +153,9 @@ plot.kmeans_clus <- function(x, ...) { sshh( do.call(grid.arrange, c(plots, list(ncol = min(length(plots),2)))) ) } -#' Save cluster means to a csv file -#' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant -#' -#' @param object Return value from \code{\link{kmeans_clus}} -#' @param file Filename and path to use -#' -#' @examples -#' result <- kmeans_clus("shopping", km_vars = c("v1:v6")) -#' save_kmeans(result, file = "~/shopping_kmeans.csv") -#' -#' @seealso \code{\link{kmeans_clus}} to generate results -#' @seealso \code{\link{summary.kmeans_clus}} to summarize results -#' @seealso \code{\link{plot.kmeans_clus}} to plot results -#' @seealso \code{\link{save_membership}} to add cluster membership to the selected dataset -#' -#' @export -save_kmeans <- function(object, file = "kmeans.csv") - object$clus_means %>% write.csv(., file = file) - #' Add a cluster membership variable to the active dataset #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/kmeans_clus.html} for an example in Radiant #' #' @param object Return value from \code{\link{kmeans_clus}} #' @@ -190,7 +167,6 @@ save_kmeans <- function(object, file = "kmeans.csv") #' @seealso \code{\link{kmeans_clus}} to generate results #' @seealso \code{\link{summary.kmeans_clus}} to summarize results #' @seealso \code{\link{plot.kmeans_clus}} to plot results -#' @seealso \code{\link{save_kmeans}} to save the table of cluster means to a csv file #' #' @export save_membership <- function(object) { diff --git a/R/mds.R b/R/mds.R index 9731d9726..9678e4a11 100644 --- a/R/mds.R +++ b/R/mds.R @@ -1,6 +1,6 @@ #' (Dis)similarity based brand maps (MDS) #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/mds.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/mds.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param mds_id1 A character variable or factor with unique entries @@ -80,7 +80,7 @@ mds <- function(dataset, mds_id1, mds_id2, mds_dis, #' Summary method for the mds function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/mds.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/mds.html} for an example in Radiant #' #' @param object Return value from \code{\link{mds}} #' @param mds_round Rounding to use for output (default = 0). +1 used for coordinates. +2 used for stress measure. Not currently accessible in Radiant @@ -125,7 +125,7 @@ summary.mds <- function(object, mds_round = 1, ...) { #' Plot method for the mds function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/mds.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/mds.html} for an example in Radiant #' #' @param x Return value from \code{\link{mds}} #' @param mds_rev_dim Flip the axes in plots diff --git a/R/merge.R b/R/merge.R index 096fdd64d..5fe2dba66 100644 --- a/R/merge.R +++ b/R/merge.R @@ -1,6 +1,6 @@ #' Merge datasets using dplyr's join functions #' -#' @details See \url{http://mostly-harmless.github.io/radiant/base/merge.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/base/merge.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param dataset2 Dataset name (string) to merge with `dataset`. This can be a dataframe in the global environment or an element in an r_data list from Radiant diff --git a/R/pmap.R b/R/pmap.R index b4f7e54de..d9a5881b8 100644 --- a/R/pmap.R +++ b/R/pmap.R @@ -1,6 +1,6 @@ #' Attribute based brand maps #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pmap.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pmap.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param pmap_brand A character variable with brand names @@ -59,7 +59,7 @@ pmap <- function(dataset, pmap_brand, pmap_attr, #' Summary method for the pmap function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pmap.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pmap.html} for an example in Radiant #' #' @param object Return value from \code{\link{pmap}} #' @param pmap_cutoff Show only loadings with (absolute) values above pmap_cutoff (default = 0) @@ -130,7 +130,7 @@ summary.pmap <- function(object, #' Plot method for the pmap function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pmap.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pmap.html} for an example in Radiant #' #' @param x Return value from \code{\link{pmap}} #' @param pmap_plot Components to include in the plot ("brand", "attr"). If data on preferences is available use "pref" to add preference arrows to the plot diff --git a/R/pre_factor.R b/R/pre_factor.R index 83e95ba97..c9a78a9af 100644 --- a/R/pre_factor.R +++ b/R/pre_factor.R @@ -1,6 +1,6 @@ #' Evaluate if data are appropriate for PCA / Factor analysis #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pre_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pre_factor.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param pf_var Variables to include in the analysis @@ -55,7 +55,7 @@ pre_factor <- function(dataset, pf_var, #' Summary method for the pre_factor function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pre_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pre_factor.html} for an example in Radiant #' #' @param object Return value from \code{\link{pre_factor}} #' @param ... further arguments passed to or from other methods @@ -114,7 +114,7 @@ summary.pre_factor <- function(object, ...) { #' Plot method for the pre_factor function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/marketing/pre_factor.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/marketing/pre_factor.html} for an example in Radiant #' #' @param x Return value from \code{\link{pre_factor}} #' @param ... further arguments passed to or from other methods diff --git a/R/radiant.R b/R/radiant.R index f50fb8ee3..6f13a6ebe 100644 --- a/R/radiant.R +++ b/R/radiant.R @@ -1,6 +1,6 @@ #' Launch Radiant in the default browser #' -#' @details See \url{http://mostly-harmless.github.io/radiant} for documentation and tutorials +#' @details See \url{http://vnijs.github.io/radiant} for documentation and tutorials #' #' @param app Choose the app to run. Either "base", "quant", or "marketing". "marketing" is the default #' @@ -192,7 +192,7 @@ win_launcher <- function(app = c("marketing", "quant", "base")) { if(!file.exists(local_dir)) dir.create(local_dir, recursive = TRUE) filepath <- normalizePath(paste0(Sys.getenv("USERPROFILE") ,"/Desktop/"), winslash='/') - launch_string <- paste0(Sys.which('R'), " -e \"if(!require(radiant)) { options(repos = c(XRAN = 'http://mostly-harmless.github.io/radiant_miniCRAN/')); install.packages('radiant'); }; require(radiant); shiny::runApp(system.file(\'", app[1], "\', package='radiant'), port = 4444, launch.browser = TRUE)\"") + launch_string <- paste0(Sys.which('R'), " -e \"if(!require(radiant)) { options(repos = c(XRAN = 'http://vnijs.github.io/radiant_miniCRAN/')); install.packages('radiant'); }; require(radiant); shiny::runApp(system.file(\'", app[1], "\', package='radiant'), port = 4444, launch.browser = TRUE)\"") cat(launch_string,file=paste0(filepath,"radiant.bat"),sep="\n") } @@ -224,7 +224,7 @@ mac_launcher <- function(app = c("marketing", "quant", "base")) { if(!file.exists(local_dir)) dir.create(local_dir, recursive = TRUE) filename <- paste0("/Users/",Sys.getenv("USER"),"/Desktop/radiant.command") - launch_string <- paste0("#!/usr/bin/env Rscript\n if(!require(radiant)) {\n options(repos = c(XRAN = 'http://mostly-harmless.github.io/radiant_miniCRAN/'))\n install.packages('radiant')\n }\n\nrequire(radiant)\nshiny::runApp(system.file(\'", app[1], "\', package='radiant'), port = 4444, launch.browser = TRUE)\n") + launch_string <- paste0("#!/usr/bin/env Rscript\n if(!require(radiant)) {\n options(repos = c(XRAN = 'http://vnijs.github.io/radiant_miniCRAN/'))\n install.packages('radiant')\n }\n\nrequire(radiant)\nshiny::runApp(system.file(\'", app[1], "\', package='radiant'), port = 4444, launch.browser = TRUE)\n") cat(launch_string,file=filename,sep="\n") Sys.chmod(filename, mode = "0755") } diff --git a/R/regression.R b/R/regression.R index 0d6a46ab5..71f2d67f3 100644 --- a/R/regression.R +++ b/R/regression.R @@ -1,6 +1,6 @@ #' Linear regression using OLS #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param reg_dep_var The dependent variable in the regression @@ -68,7 +68,7 @@ regression <- function(dataset, reg_dep_var, reg_indep_var, #' Summary method for the regression function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param object Return value from \code{\link{regression}} #' @param reg_sum_check Optional output or estimation parameters. "rsme" to show the root mean squared error. "sumsquares" to show the sum of squares table. "vif" to show multicollinearity diagnostics. "confint" to show coefficient confidence interval estimates. @@ -224,7 +224,7 @@ summary.regression <- function(object, #' Plot method for the regression function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param x Return value from \code{\link{regression}} #' @param reg_plots Regression plots to produce for the specified regression model. Enter "" to avoid showing any plots (default). "hist" to show histograms of all variables in the model. "correlations" for a visual representation of the correlation matrix selected variables. "scatter" to show scatter plots (or box plots for factors) for the dependent variables with each independent variable. "dashboard" for a series of six plots that can be used to evaluate model fit visually. "resid_pred" to plot the independent variables against the model residuals. "coef" for a coefficient plot with adjustable confidence intervals. "leverage" to show leverage plots for each independent variable @@ -365,7 +365,6 @@ plot.regression <- function(x, ymin = "Low", ymax = "High")) + geom_hline(yintercept = 0, linetype = 'dotdash', color = "blue") + coord_flip() -> p return(p) - # -> plots[["coef"]] } } @@ -381,7 +380,7 @@ plot.regression <- function(x, #' Predict method for the regression function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param object Return value from \code{\link{regression}} #' @param reg_predict_cmd Command used to generate data for prediction @@ -424,8 +423,8 @@ predict.regression <- function(object, vars <- object$reg_indep_var if(reg_predict_cmd != "") { reg_predict_cmd %<>% gsub("\"","\'", .) - pred_df <- try(eval(parse(text = paste0("with(object$model$model, expand.grid(", reg_predict_cmd ,"))"))), silent = TRUE) - if(is(pred_df, 'try-error')) { + pred <- try(eval(parse(text = paste0("with(object$model$model, expand.grid(", reg_predict_cmd ,"))"))), silent = TRUE) + if(is(pred, 'try-error')) { return(cat("The command entered did not generate valid data for prediction. Please try again.\nExamples are shown in the helpfile.\n")) } @@ -444,21 +443,23 @@ predict.regression <- function(object, if(sum(isFct) > 0) plug_data %<>% bind_cols(., summarise_each_(dat, funs(max_freq), vars[isFct])) + rm(dat) + if(sum(isNum) + sum(isFct) < length(vars)) { cat("The model includes data-types that cannot be used for\nprediction at this point\n") } else { - if(sum(names(pred_df) %in% names(plug_data)) < length(names(pred_df))) { + if(sum(names(pred) %in% names(plug_data)) < length(names(pred))) { return(cat("The expression entered contains variable names that are not in the model.\nPlease try again.\n\n")) } else { - plug_data[names(pred_df)] <- list(NULL) - pred_df <- data.frame(plug_data[-1],pred_df) + plug_data[names(pred)] <- list(NULL) + pred <- data.frame(plug_data[-1],pred) } } } else { - pred_df <- getdata(reg_predict_data) - pred_names <- names(pred_df) - pred_df <- try(select_(pred_df, .dots = vars), silent = TRUE) - if(is(pred_df, 'try-error')) { + pred <- getdata(reg_predict_data) + pred_names <- names(pred) + pred <- try(select_(pred, .dots = vars), silent = TRUE) + if(is(pred, 'try-error')) { cat("Model variables: ") cat(vars,"\n") cat("Profile variables to be added: ") @@ -468,18 +469,18 @@ predict.regression <- function(object, reg_predict_type <- "data" } - pred <- try(predict(object$model, pred_df, interval = 'prediction', level = reg_conf_level), silent = TRUE) - if(!is(pred, 'try-error')) { - pred %<>% data.frame %>% mutate(diff = .[,3] - .[,1]) + pred_val <- try(predict(object$model, pred, interval = 'prediction', level = reg_conf_level), silent = TRUE) + if(!is(pred_val, 'try-error')) { + pred_val %<>% data.frame %>% mutate(diff = .[,3] - .[,1]) cl_split <- function(x) 100*(1-x)/2 cl_split(reg_conf_level) %>% round(1) %>% as.character %>% paste0(.,"%") -> cl_low (100 - cl_split(reg_conf_level)) %>% round(1) %>% as.character %>% paste0(.,"%") -> cl_high - colnames(pred) <- c("Prediction",cl_low,cl_high,"+/-") + colnames(pred_val) <- c("Prediction",cl_low,cl_high,"+/-") - pred_df <- data.frame(pred_df, pred, check.names = FALSE) + pred <- data.frame(pred, pred_val, check.names = FALSE) # return predicted values - if(reg_save_pred) return(pred_df) + # if(reg_save_pred) return(pred) if(reg_predict_type == "cmd") { cat("Predicted values for:\n") @@ -487,26 +488,91 @@ predict.regression <- function(object, cat(paste0("Predicted values for profiles from dataset: ",object$reg_predict_data,"\n")) } - pred_df %>% print(., row.names = FALSE) + pred %>% print(., row.names = FALSE) # pushing predictions into the clipboard - os_type <- Sys.info()["sysname"] - if (os_type == 'Windows') { - write.table(pred_df, "clipboard", sep="\t", row.names=FALSE) - } else if (os_type == "Darwin") { - write.table(pred_df, file = pipe("pbcopy"), row.names = FALSE, sep = '\t') - } - if (os_type != "Linux") - cat("\nPredictions were pushed to the clipboard. You can paste them in Excel or\nuse Manage > Data to paste the predictions as a new dataset.\n\n") + # os_type <- Sys.info()["sysname"] + # if (os_type == 'Windows') { + # write.table(pred, "clipboard", sep="\t", row.names=FALSE) + # } else if (os_type == "Darwin") { + # write.table(pred, file = pipe("pbcopy"), row.names = FALSE, sep = '\t') + # } + # if (os_type != "Linux") + # cat("\nPredictions were pushed to the clipboard. You can paste them in Excel or\nuse Manage > Data to paste the predictions as a new dataset.\n\n") + + return(pred %>% set_class(c("reg_predict",class(.)))) } else { cat("The expression entered does not seem to be correct. Please try again.\nExamples are shown in the helpfile.\n") } } +#' Plot method for the predict.regression function +#' +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant +#' +#' @param x Return value from \code{\link{predict.regression}}. +#' @param reg_xvar Variable to display along the X-axis of the plot +#' @param reg_facet_row Create vertically arranged subplots for each level of the selected factor variable +#' @param reg_facet_col Create horizontally arranged subplots for each level of the selected factor variable +#' @param reg_color Adds color to a scatter plot to generate a heat map. For a line plot one line is created for each group and each is assigned a different colour +#' @param reg_conf_level Confidence level to use for prediction intervals (.95 is the default). Note that the error bars for predicitions are approximations at this point. +#' @param ... further arguments passed to or from other methods +#' +#' @examples +#' result <- regression("diamonds", "price", c("carat","clarity")) +#' pred <- predict(result, reg_predict_cmd = "carat = 1:10") +#' plot(pred, reg_xvar = "carat") +#' result <- regression("diamonds", "price", c("carat","clarity"), reg_int_var = "carat:clarity") +#' dpred <- getdata("diamonds") %>% slice(1:100) +#' pred <- predict(result, reg_predict_data = "dpred") +#' plot(pred, reg_xvar = "carat", reg_color = "clarity") +#' +#' @seealso \code{\link{regression}} to generate the result +#' @seealso \code{\link{summary.regression}} to summarize results +#' @seealso \code{\link{plot.regression}} to plot results +#' @seealso \code{\link{predict.regression}} to generate predictions +#' +#' @export +plot.reg_predict <- function(x, + reg_xvar = "", + reg_facet_row = ".", + reg_facet_col = ".", + reg_color = "none", + reg_conf_level = .95, + ...) { + + if(is.null(reg_xvar) || reg_xvar == "") return(invisible()) + + object <- x; rm(x) + + cn <- colnames(object) + cn[which(cn == "Prediction") + 1] <- "ymin" + cn[which(cn == "Prediction") + 2] <- "ymax" + colnames(object) <- cn + + if (reg_color == 'none') { + p <- ggplot(object, aes_string(x=reg_xvar, y="Prediction")) + + geom_line(aes(group=1)) + } else { + p <- ggplot(object, aes_string(x=reg_xvar, y="Prediction", color=reg_color)) + + geom_line(aes_string(group=reg_color)) + } + + facets <- paste(reg_facet_row, '~', reg_facet_col) + if (facets != '. ~ .') p <- p + facet_grid(facets) + + if(length(unique(object[[reg_xvar]])) < 10) + p <- p + geom_pointrange(aes_string(ymin = "ymin", ymax = "ymax"), size=.3) + else + p <- p + geom_smooth(aes_string(ymin = "ymin", ymax = "ymax"), stat="identity") + + sshhr( p ) +} + #' Save regression residuals #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param object Return value from \code{\link{regression}} #' @@ -525,7 +591,7 @@ save_reg_resid <- function(object) { #' Check if main effects for all interaction effects are included in the model #' If ':' is used to select a range _indep_var_ is updated -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param indep_var List of independent variables provided to _regression_ or _glm_ #' @param cn Column names for all independent variables in _dat_ @@ -558,7 +624,7 @@ var_check <- function(indep_var, cn, int_var = "") { #' Add interaction terms to list of test variables if needed #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/regression.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/regression.html} for an example in Radiant #' #' @param test_var List of variables to use for testing for _regression_ or _glm_ #' @param int_var Interaction terms specified diff --git a/R/sample_size.R b/R/sample_size.R index 63e2039bd..6eb8cdf63 100644 --- a/R/sample_size.R +++ b/R/sample_size.R @@ -3,7 +3,7 @@ ############################### #' Sample size calculation #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/sample_size.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/sample_size.html} for an example in Radiant #' #' @param ss_type Choose "mean" or "proportion" #' @param ss_mean_err Acceptable Error for Mean @@ -54,7 +54,7 @@ sample_size <- function(ss_type = "mean", #' Summary method for the sample_size function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/sample_size} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/sample_size} for an example in Radiant #' #' @param object Return value from \code{\link{sample_size}} #' @param ... further arguments passed to or from other methods diff --git a/R/sampling.R b/R/sampling.R index 272630f69..14ff30076 100644 --- a/R/sampling.R +++ b/R/sampling.R @@ -1,6 +1,6 @@ #' Simple random sampling #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/sampling.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/sampling.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param smp_var The variable to sample from @@ -32,7 +32,7 @@ sampling <- function(dataset, smp_var, smp_sample_size, #' Summary method for the sampling function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/sampling} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/sampling} for an example in Radiant #' #' @param object Return value from \code{\link{sampling}} #' @param ... further arguments passed to or from other methods diff --git a/R/single_mean.R b/R/single_mean.R index 56fd04b01..7a1b3b0cd 100644 --- a/R/single_mean.R +++ b/R/single_mean.R @@ -1,6 +1,6 @@ #' Compare a sample mean to a population mean #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_mean.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_mean.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param sm_var The variable selected for the mean comparison @@ -36,7 +36,7 @@ single_mean <- function(dataset, sm_var, #' Summary method for the single_mean function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_mean.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_mean.html} for an example in Radiant #' #' @param object Return value from \code{\link{single_mean}} #' @param ... further arguments passed to or from other methods @@ -84,7 +84,7 @@ summary.single_mean <- function(object, ...) { #' Plot method for the single_mean function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_mean.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_mean.html} for an example in Radiant #' #' @param x Return value from \code{\link{single_mean}} #' @param sm_plots Plots to generate. "hist" shows a histogram of the data along with vertical lines that indicate the sample mean and the confidence interval. "simulate" shows the location of the sample mean and the comparison value (sm_comp_value). Simulation is used to demonstrate the sampling variability in the data under the null-hypothesis diff --git a/R/single_prop.R b/R/single_prop.R index 257ab38de..f251bc597 100644 --- a/R/single_prop.R +++ b/R/single_prop.R @@ -1,6 +1,6 @@ #' Compare a sample proportion to a population proportion #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_prop.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_prop.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant #' @param sp_var The variable selected for the proportion comparison @@ -47,7 +47,7 @@ single_prop <- function(dataset, sp_var, #' Summary method for the single_prop function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_prop.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_prop.html} for an example in Radiant #' #' @param object Return value from \code{\link{single_prop}} #' @param ... further arguments passed to or from other methods @@ -96,7 +96,7 @@ summary.single_prop <- function(object, ...) { #' Plot method for the single_prop function #' -#' @details See \url{http://mostly-harmless.github.io/radiant/quant/single_prop.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/quant/single_prop.html} for an example in Radiant #' #' @param x Return value from \code{\link{single_prop}} #' @param sp_plots Plots to generate. "hist" shows a histogram of the data along with vertical lines that indicate the sample proportion and the confidence interval. "simulate" shows the location of the sample proportion and the comparison value (sp_comp_value). Simulation is used to demonstrate the sampling variability in the data under the null-hypothesis diff --git a/R/visualize.R b/R/visualize.R index 89850e694..9e8f85ea5 100644 --- a/R/visualize.R +++ b/R/visualize.R @@ -1,10 +1,10 @@ #' Visualize data using ggplot2 \url{http://docs.ggplot2.org/current/} #' -#' @details See \url{http://mostly-harmless.github.io/radiant/base/visualize.html} for an example in Radiant +#' @details See \url{http://vnijs.github.io/radiant/base/visualize.html} for an example in Radiant #' #' @param dataset Dataset name (string). This can be a dataframe in the global environment or an element in an r_data list from Radiant -#' @param viz_vars1 One or more variables to display along the X-axis of the plot -#' @param viz_vars2 Variable to display along the Y-axis of the plot (default = "none") +#' @param viz_xvar One or more variables to display along the X-axis of the plot +#' @param viz_yvar Variable to display along the Y-axis of the plot (default = "none") #' @param data_filter Expression used to filter the dataset. This should be a string (e.g., "price > 10000") #' @param viz_type Type of plot to create. One of Histogram ('hist'), Density ('density'), Scatter ('scatter'), Line ('line'), Bar ('bar'), or Box-plot ('box') #' @param viz_facet_row Create vertically arranged subplots for each level of the selected factor variable @@ -20,10 +20,10 @@ #' @examples #' visualize("diamonds", "carat", "price", viz_type = "scatter", viz_check = "loess") #' visualize("diamonds", "price:x", viz_type = "hist") -#' visualize("diamonds", "carat:x", viz_vars2 = "price", viz_type = "scatter") +#' visualize("diamonds", "carat:x", viz_yvar = "price", viz_type = "scatter") #' @export -visualize <- function(dataset, viz_vars1, - viz_vars2 = "none", +visualize <- function(dataset, viz_xvar, + viz_yvar = "none", data_filter = "", viz_type = "hist", viz_facet_row = ".", @@ -35,12 +35,12 @@ visualize <- function(dataset, viz_vars1, viz_axes = "") { # inspired by Joe Cheng's ggplot2 browser app http://www.youtube.com/watch?feature=player_embedded&v=o2B5yJeEl1A#! - vars <- viz_vars1 + vars <- viz_xvar if(!viz_type %in% c("scatter","line")) viz_color = "none" - if(viz_vars2 != "none") vars %<>% c(., viz_vars2) + if(viz_yvar != "none") vars %<>% c(., viz_yvar) if(viz_color != "none") vars %<>% c(., viz_color) if(viz_facet_row != ".") vars %<>% c(., viz_facet_row) if(viz_facet_col != ".") vars %<>% c(., viz_facet_col) @@ -55,9 +55,9 @@ visualize <- function(dataset, viz_vars1, # if : is used to specify a range of variables if(length(vars) < ncol(dat)) { - fl <- strsplit(viz_vars1,":") %>% unlist + fl <- strsplit(viz_xvar,":") %>% unlist cn <- colnames(dat) - viz_vars1 <- cn[which(fl[1] == cn):which(fl[2] == cn)] + viz_xvar <- cn[which(fl[1] == cn):which(fl[2] == cn)] } # dat$x <- as.character(dat$x) @@ -72,56 +72,58 @@ visualize <- function(dataset, viz_vars1, plots <- list() if (viz_type == "hist") { - for (i in viz_vars1) { + for (i in viz_xvar) { plots[[i]] <- ggplot(dat, aes_string(x=i)) if ("factor" %in% class(dat[,i])) { plots[[i]] <- plots[[i]] + geom_histogram() } else { bw <- select_(dat,i) %>% range %>% diff(.)/viz_bins plots[[i]] <- plots[[i]] + geom_histogram(binwidth = bw) + # + stat_ecdf() } } } else if (viz_type == "density") { - for (i in viz_vars1) { + for (i in viz_xvar) { plots[[i]] <- ggplot(dat, aes_string(x=i)) + geom_density(adjust=viz_smooth, fill = "green", alpha=.3) } } else if (viz_type == "scatter") { itt <- 1 - for (i in viz_vars1) { - for (j in viz_vars2) { + for (i in viz_xvar) { + for (j in viz_yvar) { plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j)) + geom_point(alpha = .5) itt <- itt + 1 } } } else if (viz_type == "line") { itt <- 1 - for (i in viz_vars1) { - for (j in viz_vars2) { + for (i in viz_xvar) { + for (j in viz_yvar) { if (viz_color == 'none') { - plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j)) + geom_line(aes(group = 1)) + if(is.factor(dat[,i])) + plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j)) + geom_line(aes(group = 1)) + else + plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j)) + geom_line() } else { plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j, color = viz_color)) + geom_line() - # plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j, color = viz_color)) + - # geom_line(aes_string(group = viz_color)) - # geom_line(aes(group=1)) + # plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j, color = viz_color)) + geom_line(aes_string(group = viz_color)) } itt <- itt + 1 } } } else if (viz_type == "bar") { itt <- 1 - for (i in viz_vars1) { - for (j in viz_vars2) { + for (i in viz_xvar) { + for (j in viz_yvar) { plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j)) + geom_bar(stat="identity") itt <- itt + 1 } } } else if (viz_type == "box") { itt <- 1 - for (i in viz_vars1) { + for (i in viz_xvar) { dat[,i] %<>% as.factor - for (j in viz_vars2) { + for (j in viz_yvar) { plots[[itt]] <- ggplot(dat, aes_string(x=i, y=j, fill=i)) + geom_boxplot(alpha = .7) + theme(legend.position = "none") @@ -164,6 +166,9 @@ visualize <- function(dataset, viz_vars1, for (i in 1:length(plots)) plots[[i]] <- plots[[i]] + scale_x_continuous(trans = "log") + + + sshh(do.call(grid.arrange, c(plots, list(ncol = min(length(plots), 2))))) } diff --git a/R/zzz.R b/R/zzz.R index 4426c7a57..b18b5f6ae 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,4 +1,4 @@ .onLoad <- function(libname, pkgname) { - options(repos = c(XRAN = "http://mostly-harmless.github.io/radiant_miniCRAN/")) + options(repos = c(XRAN = "http://vnijs.github.io/radiant_miniCRAN/")) } diff --git a/README.md b/README.md index 012b324d4..33073f1c6 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,84 @@ # Radiant - Business analytics using R and Shiny -A platform-independent browser-based interface for business analytics in [R](http://www.r-project.org/), based on the [Shiny](http://www.rstudio.com/shiny/) package. Radiant is designed to facilitate decision making in business using data and models. It is currently used in the Research for Marketing Decisions and Quantitative Analysis classes at the Rady School of Management by Vincent Nijs and Terrence August. Developed by Vincent Nijs. For questions and comments please contact me at radiant@rady.ucsd.edu. +Radiant is a platform-independent browser-based interface for business analytics in [R](http://www.r-project.org/), based on the [Shiny](http://www.rstudio.com/shiny/) package. Developed by Vincent Nijs. Please send questions and comments to: radiant@rady.ucsd.edu. -[![Travis-CI Build Status](https://travis-ci.org/mostly-harmless/radiant.png?branch=master)](https://travis-ci.org/mostly-harmless/radiant) -Version: 0.1.75, Date: 2015-3-17 +[![Travis-CI Build Status](https://travis-ci.org/vnijs/radiant.png?branch=master)](https://travis-ci.org/vnijs/radiant) +Version: 0.1.83, Date: 2015-3-24 ## Key features -- Explore: Quickly and easily summarize and visualize your data -- Interactive: Results update immediately when inputs are changed (i.e., no separate dialog boxes) -- Save and share your work: Load and save the state of the application to continue your analysis at a later time or on another computer. Share the state-file with others or create a (reproducible) report using [Rmarkdown document](http://rmarkdown.rstudio.com/). You will not lose your work if you accidentally leave the radiant page in your browser -- Cross-platform: It runs in a browser (e.g., Chrome or Firefox) on Windows, Mac, and Linux. No data will leave your computer and you can run it without an internet connection. You can, however, also run it as a web application on a server. +- Explore: Quickly and easily summarize, visualize, and analyze your data +- Cross-platform: It runs in a browser on Windows, Mac, and Linux +- Reproducible: Recreate results at any time and share work with others as a state file or an [Rmarkdown](http://rmarkdown.rstudio.com/) report +- Programming: Integrate Radiant's analysis functions into your own R-code - Context: Data and examples focus on business applications -## Goal + -Provide access to the power of R for business and marketing analytics. Radiant also provides a bridge to programming in R(studio). For example, you can run your analyses in Radiant and output the relevant function calls to an [Rmarkdown document](http://rmarkdown.rstudio.com/) (see `R > Report`). Reproducible research, with no programming required. Most pages have an icon you can click (e.g., the book icon on the bottom left on the `Base > Single mean` page) to start working on your report. Press `Update` to render the report to HTML. +#### Explore -You can also use Rstudio to render and edit rmarkdown documents created in Radiant. When you install and load Radiant it exports functions that can be called from R-code and/or an rmarkdown document. If you close Radiant using `Quit > Quit` after launching it from Rstudio or Rgui you can paste the commands below into the command console to get the same output as in the browser. +Radiant is interactive. Results update immediately when inputs are changed (i.e., no separate dialog boxes). This greatly facilitates exploration and understanding of the data. -```r -result <- single_mean("diamonds","price", sm_comp_value = 3500) -summary(result) -plot(result, sm_plot = c("hist","simulate")) -``` +#### Cross-platform -You can call functions for visualization and analysis in your R-code and access basic help from the R(studio) console using: +Radiant works on Windows, Mac, or Linux. It can run without an Internet connection and no data will leave your computer. You can also run the app as a web application on a server. -```r -?single_mean -``` +#### Reproducible -As an example, compile the [`single_mean.Rmd`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/single_mean.Rmd?raw=true) file to html (or pdf or word if you prefer) in Rstudio. Try the code in [`radiant_rcode.R`](https://raw.githubusercontent.com/mostly-harmless/radiant/master/inst/examples/radiant_rcode.R) for a more extensive example. +Simply saving output is not enough. You need the ability to recreate results for the same data and/or when new data become available. Moreover, others may want to review your analysis and results. Save and load the state of the application to continue your work at a later time or on another omputer. Share state files with others and create reproducible reports using [Rmarkdown](http://rmarkdown.rstudio.com/). See also the section on `Saving and loading state` below -Note: If you exit the app by stopping the process in R(studio) or closing the browser, rather than using `Quit > Quit`, calling analysis functions may produce an error if the data cannot be found. +#### Programming -## Documentation +Although Radiant's web-interface can handle quite a few data and analysis tasks, at times you may prefer to write your own code. Radiant provides a bridge to programming in R(studio) by exporting the functions used for analysis. For more information about programming with Radiant see the [programming](http://vnijs.github.io/radiant/programming.html) page on the documentation site. -Documentation and tutorials for Radiant are available at and through the help files in the Radiant interface (see the `?` icon on most pages and the Help menu in the navbar). +#### Context -To help you get started you can also take a look at this [playlist](https://www.youtube.com/watch?v=e02LFmNysoM&list=PLNhtaetb48EfAAlfQMJsuvLCSLvcn_0BC). +Radiant focuses on business data and decisions. It offers tools, examples, and documentation relevant for that context, effectively reducing the business analytics learning curve. -## How-to install Radiant +## How to install Radiant -- Required: [R](http://cran.cnr.berkeley.edu/), version 3.1.2 or later -- Required: A modern browser (e.g., Chrome, Safari, or Firefox). The latest version of internet explorer may work as well. +- Required: [R](http://cran.rstudio.com/) version 3.1.2 or later +- Required: A modern browser (e.g., [Chrome](https://www.google.com/intl/en/chrome/browser/desktop/) or Safari). Internet Explorer (version 11 or higher) should work as well - Recommended: [Rstudio](http://www.rstudio.com/products/rstudio/download/) -Radiant is now available on [CRAN](http://cran.r-project.org/web/packages/radiant/index.html). To install the latest version of the package with complete documentation for off-line access use the [radiant_miniCRAN](https://github.com/mostly-harmless/radiant_miniCRAN) repository (created using [miniCRAN](https://github.com/andrie/miniCRAN)). Open R(studio) and copy-and-paste the commands below. +Radiant is available on [CRAN](http://cran.r-project.org/web/packages/radiant/index.html). To install the latest version with complete documentation for offline access, open R(studio) and copy-and-paste the commands below: ```r -options(repos = c(XRAN = 'http://mostly-harmless.github.io/radiant_miniCRAN/')) -install.packages('radiant') +options(repos = 'http://vnijs.github.io/radiant_miniCRAN/') +install.packages("radiant") ``` -Once all packages are installed use the commands below to start the app: +Once all packages are installed use the commands below to launch the app: ```r library(radiant) -radiant('marketing') +radiant("marketing") ``` -`marketing` is the default app so you could also use the command `radiant()` to launch it. To start the `quant` app use: +See also the `Installing Radiant` video: -```r -library(radiant) -radiant('quant') -``` + -See also the [installing Radiant](https://www.youtube.com/watch?v=AtB2SsmzBsk) video. +You can create a launcher on your Desktop to start Radiant. On Windows type `win_launcher()` in the R-console and press return. A file called `radiant.bat` will be created that you can double-click to start Radiant in your default browser. - +On a Mac you can create a launcher for Radiant by typing `mac_launcher()` in the R-console. This will create a file called `radiant.command` on your Desktop. Double-click the icon to start Radiant in your default browser. + +When Radiant starts you will see data on diamond prices. To close the application click on `Quit` in the Navigation bar and then click the `Quit` button on the left of the screen. The Radiant process will stop and the browser window will close (or gray-out). -## Creating a desktop launcher +## Documentation -You can create a launcher on your Desktop to make it easy to start Radiant. On Windows type `win_launcher()` in the R-console and press return. A file called `radiant.bat` will be created that you can double-click to start Radiant in your default browser. +Documentation and tutorials are available at and in the Radiant web-interface (the `?` icons and the `Help` menu). -On a Mac you can create a launcher for Radiant by typing `mac_launcher()` in the R-console. This will create a file called `radiant.command` on your Desktop. Double-click the icon to start Radiant in your default browser. +Want some help getting started? Watch the tutorials on the [documentation site](http://vnijs.github.io/radiant/tutorials.html) -Radiant runs in a browser window. You will see data on diamond prices. To close the application click on `Quit` in the Navigation bar and then click the `Quit` button on the left of the screen. The Radiant process will stop and the browser window will close (or gray-out). +## Online + +Not ready to install Radiant on your computer? Try it out online at . Note that this is a test server only! ## Saving and loading state -To save your analyses save the state of the app to a file (Data > Manage). You can open this state file at a later time or on another computer to continue where you left off. You can also share the file with others that may want to replicate your analyses. As an example, load the state_file [`RadiantState.rda`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/RadiantState.rda?raw=true) in the `examples` folder. Go to `Data > View`, `Data > Visualize` to see some of the settings. There is also a report in `R > Report` that was created using the Radiant interface. The html file [`RadiantState.html`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/RadiantState.html?raw=true) contains the output. +To save your analyses save the state of the app to a file (Data > Manage). You can open this state file at a later time or on another computer to continue where you left off. You can also share the file with others that may want to replicate your analyses. As an example, load the state_file [`RadiantState.rda`](https://github.com/vnijs/radiant/blob/master/inst/examples/RadiantState.rda?raw=true) in the `examples` folder. Go to `Data > View`, `Data > Visualize` to see some of the settings. There is also a report in `R > Report` that was created using the Radiant interface. The html file [`RadiantState.html`](https://github.com/vnijs/radiant/blob/master/inst/examples/RadiantState.html?raw=true) contains the output. A related feature in Radiant is that state is maintained if you accidentally navigate to another page, close (and reopen) the browser, and/or hit refresh. Use Quit > Reset to return to a clean/new state. @@ -99,11 +94,6 @@ numericInput("sm_comp_value", "Comparison value:", state_init('sm_comp_value',sm Three (related) apps are included in the inst/ directory. `Base`, offers data loading, saving, viewing, visualizing, merging, and transforming tools. The `quant` app sources the code from base and extends it. Finally, the `marketing` app sources the code from `base` and `quant` and extends it with additional tools. The `quant` app focuses on (basic) quantitative analysis (e.g., comparing means, regression, etc.). The `marketing` app focuses on marketing analytics by adding clustering, principle component analysis, conjoint analysis, etc. - ## License @@ -113,4 +103,4 @@ As a summary, the AGPLv3 license requires, attribution, including copyright and If you are interested in using Radiant please email me at radiant@rady.ucsd.edu -© Vincent Nijs (2015) Creative Commons License +© Vincent Nijs (2015) Creative Commons License diff --git a/build/build_mac_win.sh b/build/build_mac_win.sh index bb6426ecc..76c6b9926 100644 --- a/build/build_mac_win.sh +++ b/build/build_mac_win.sh @@ -19,15 +19,15 @@ rm $dirmac/radiant* rm $dirmac_mav/radiant* rm $dirwin/radiant* -rm $dirsource/shinyAce* -rm $dirmac/shinyAce* -rm $dirmac_mav/shinyAce* -rm $dirwin/shinyAce* - -rm $dirsource/rpivotTable* -rm $dirmac/rpivotTable* -rm $dirmac_mav/rpivotTable* -rm $dirwin/rpivotTable* +# rm $dirsource/shinyAce* +# rm $dirmac/shinyAce* +# rm $dirmac_mav/shinyAce* +# rm $dirwin/shinyAce* +# +# rm $dirsource/rpivotTable* +# rm $dirmac/rpivotTable* +# rm $dirmac_mav/rpivotTable* +# rm $dirwin/rpivotTable* # build source and mac version R --save < build/build_mac_source.R 2>&1 diff --git a/build/build_win.R b/build/build_win.R index 17616c0d8..20c7f287b 100644 --- a/build/build_win.R +++ b/build/build_win.R @@ -6,9 +6,9 @@ library(devtools) document(roclets=c('rd', 'collate', 'namespace')) -build('../radiant_dev', binary = TRUE) build('../shinyAce', binary = TRUE) build('../rpivotTable', binary = TRUE) +build('../radiant_dev', binary = TRUE) setwd('../') rfile <- Sys.glob("*zip") diff --git a/build/package_dev_notes.R b/build/package_dev_notes.R index 69dae63ea..f8d38bc20 100644 --- a/build/package_dev_notes.R +++ b/build/package_dev_notes.R @@ -7,8 +7,8 @@ local_dir <- Sys.getenv("R_LIBS_USER") if(!file.exists(local_dir)) dir.create(local_dir, recursive = TRUE) # setting the url for the miniCRAN, using XRAN as in yihui/xran :) -# options(repos = c(XRAN="http://mostly-harmless.github.io/radiant_miniCRAN/", CRAN="http://cran.rstudio.com")) -options(repos = c(XRAN = "http://mostly-harmless.github.io/radiant_miniCRAN/")) +# options(repos = c(XRAN="http://vnijs.github.io/radiant_miniCRAN/", CRAN="http://cran.rstudio.com")) +options(repos = "http://vnijs.github.io/radiant_miniCRAN/") # udpate old-packages update.packages(lib.loc = local_dir, ask = FALSE) @@ -24,7 +24,7 @@ if(length(to_inp) != 0) dep_list <- function() { # get list of packages() - devtools::source_url("https://raw.githubusercontent.com/mostly-harmless/radiant_miniCRAN/gh-pages/pkgs.R") + devtools::source_url("https://raw.githubusercontent.com/vnijs/radiant_miniCRAN/gh-pages/pkgs.R") # setwd("~/Desktop/GitHub/radiant_dev") # for(i in pkgs) diff --git a/build/remove_screenshots.R b/build/remove_screenshots.R index 710c25275..8f0a05a20 100644 --- a/build/remove_screenshots.R +++ b/build/remove_screenshots.R @@ -8,8 +8,7 @@ cat("--", file="figures/place_holder.txt") filenames <- list.files(pattern="\\.(md|Rmd)$") for( f in filenames ){ org <- readLines(f) - changed <- gsub( "figures_quant/", "http://mostly-harmless.github.io/radiant/quant/figures_quant/", org ) -# changed <- gsub( "http://mostly-harmless.github.io/radiant/marketing/figures_quant/", "http://mostly-harmless.github.io/radiant/quant/figures_quant/", org ) + changed <- gsub( "figures_quant/", "http://vnijs.github.io/radiant/quant/figures_quant/", org ) cat(changed, file=f, sep="\n") } @@ -22,6 +21,7 @@ cat("--", file="figures/place_holder.txt") filenames <- list.files(pattern="\\.(md|Rmd)$") for( f in filenames ){ org <- readLines(f) - changed <- gsub( "figures_marketing/", "http://mostly-harmless.github.io/radiant/marketing/figures_marketing/", org ) + changed <- gsub( "figures_marketing/", "http://vnijs.github.io/radiant/marketing/figures_marketing/", org ) cat(changed, file=f, sep="\n") } + diff --git a/cran-comments.md b/cran-comments.md index 2f40cc801..826977c4c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,13 @@ ## Resubmission This is a resubmission. In this version I have: +* Removed the offending function save_kmeans in R/kmeans_clus.R + +## Resubmission +This is a resubmission. In this version I have: + * Fixed the invalid URL mentioned below. Note that none of the checkdevtools::submit_cran() -showed me this error. Please advise how I can best check for these types of +showed me this error. Please advise how I can best check for these types of problems in the future. Thank you. * checking CRAN incoming feasibility … NOTE diff --git a/inst/base/data/DirectMarketing.rda b/inst/base/data/DirectMarketing.rda deleted file mode 100644 index 41b14e735..000000000 Binary files a/inst/base/data/DirectMarketing.rda and /dev/null differ diff --git a/inst/base/data/CampusMarket.rda b/inst/base/data/campus_market.rda similarity index 100% rename from inst/base/data/CampusMarket.rda rename to inst/base/data/campus_market.rda diff --git a/inst/base/data/direct_marketing.rda b/inst/base/data/direct_marketing.rda new file mode 100644 index 000000000..6aa4643bd Binary files /dev/null and b/inst/base/data/direct_marketing.rda differ diff --git a/inst/base/dependencies.R b/inst/base/dependencies.R index 98abb6d30..5267eb208 100644 --- a/inst/base/dependencies.R +++ b/inst/base/dependencies.R @@ -4,7 +4,7 @@ local_dir <- Sys.getenv("R_LIBS_USER") if(!file.exists(local_dir)) dir.create(local_dir, recursive = TRUE) # setting the url for the miniCRAN, using XRAN as in yihui/xran -options(repos = c(XRAN = "http://mostly-harmless.github.io/radiant_miniCRAN/")) +options(repos = "http://vnijs.github.io/radiant_miniCRAN/") # udpate old-packages update.packages(lib.loc = local_dir, ask = FALSE) diff --git a/inst/base/tools/app/about.md b/inst/base/tools/app/about.md index aa741892a..33073f1c6 100644 --- a/inst/base/tools/app/about.md +++ b/inst/base/tools/app/about.md @@ -1,89 +1,84 @@ # Radiant - Business analytics using R and Shiny -A platform-independent browser-based interface for business analytics in [R](http://www.r-project.org/), based on the [Shiny](http[://www.rstudio.com/shiny/) package. Radiant is designed to facilitate decision making in business using data and models. It is currently used in the Research for Marketing Decisions and Quantitative Analysis classes at the Rady School of Management by Vincent Nijs and Terrence August. Developed by Vincent Nijs. For questions and comments please contact me at radiant@rady.ucsd.edu. +Radiant is a platform-independent browser-based interface for business analytics in [R](http://www.r-project.org/), based on the [Shiny](http://www.rstudio.com/shiny/) package. Developed by Vincent Nijs. Please send questions and comments to: radiant@rady.ucsd.edu. -[![Travis-CI Build Status](https://travis-ci.org/mostly-harmless/radiant.png?branch=master)](https://travis-ci.org/mostly-harmless/radiant) -Version: 0.1.75, Date: 2015-3-17 +[![Travis-CI Build Status](https://travis-ci.org/vnijs/radiant.png?branch=master)](https://travis-ci.org/vnijs/radiant) +Version: 0.1.83, Date: 2015-3-24 ## Key features -- Explore: Quickly and easily summarize and visualize your data -- Interactive: Results update immediately when inputs are changed (i.e., no separate dialog boxes) -- Save and share your work: Load and save the state of the application to continue your analysis at a later time or on another computer. Share the state-file with others or create a (reproducible) report using [Rmarkdown document](http://rmarkdown.rstudio.com/). You will not lose your work if you accidentally leave the radiant page in your browser -- Cross-platform: It runs in a browser (e.g., Chrome or Firefox) on Windows, Mac, and Linux. No data will leave your computer and you can run it without an internet connection. You can, however, also run it as a web application on a server. +- Explore: Quickly and easily summarize, visualize, and analyze your data +- Cross-platform: It runs in a browser on Windows, Mac, and Linux +- Reproducible: Recreate results at any time and share work with others as a state file or an [Rmarkdown](http://rmarkdown.rstudio.com/) report +- Programming: Integrate Radiant's analysis functions into your own R-code - Context: Data and examples focus on business applications -## Goal + -Provide access to the power of R for business and marketing analytics. Radiant also provides a bridge to programming in R(studio). For example, you can run your analyses in Radiant and output the relevant function calls to an [Rmarkdown document](http://rmarkdown.rstudio.com/) (see `R > Report`). Reproducible research, with no programming required. Most pages have an icon you can click (e.g., the book icon on the bottom left on the `Base > Single mean` page) to start working on your report. Press `Update` to render the report to HTML. +#### Explore -You can also use Rstudio to render and edit rmarkdown documents created in Radiant. When you install and load Radiant it exports functions that can be called from R-code and/or an rmarkdown document. If you close Radiant using `Quit > Quit` after launching it from Rstudio or Rgui you can paste the commands below into the command console to get the same output as in the browser. +Radiant is interactive. Results update immediately when inputs are changed (i.e., no separate dialog boxes). This greatly facilitates exploration and understanding of the data. -```r -result <- single_mean("diamonds","price", sm_comp_value = 3500) -summary(result) -plot(result, sm_plot = c("hist","simulate")) -``` +#### Cross-platform -You can call functions for visualization and analysis in your R-code and access basic help from the R(studio) console using: +Radiant works on Windows, Mac, or Linux. It can run without an Internet connection and no data will leave your computer. You can also run the app as a web application on a server. -```r -?single_mean -``` +#### Reproducible -As an example, compile the [`single_mean.Rmd`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/single_mean.Rmd?raw=true) file to html (or pdf or word if you prefer) in Rstudio. Try the code in [`radiant_rcode.R`](https://raw.githubusercontent.com/mostly-harmless/radiant/master/inst/examples/radiant_rcode.R) for a more extensive example. +Simply saving output is not enough. You need the ability to recreate results for the same data and/or when new data become available. Moreover, others may want to review your analysis and results. Save and load the state of the application to continue your work at a later time or on another omputer. Share state files with others and create reproducible reports using [Rmarkdown](http://rmarkdown.rstudio.com/). See also the section on `Saving and loading state` below -Note: If you exit the app by stopping the process in R(studio) or closing the browser, rather than using `Quit > Quit`, calling analysis functions may produce an error if the data cannot be found. +#### Programming -## Documentation +Although Radiant's web-interface can handle quite a few data and analysis tasks, at times you may prefer to write your own code. Radiant provides a bridge to programming in R(studio) by exporting the functions used for analysis. For more information about programming with Radiant see the [programming](http://vnijs.github.io/radiant/programming.html) page on the documentation site. -Documentation and tutorials for Radiant are available at and through the help files in the Radiant interface (see the `?` icon on most pages and the Help menu in the navbar). +#### Context -To help you get started you can also take a look at this [playlist](https://www.youtube.com/watch?v=e02LFmNysoM&list=PLNhtaetb48EfAAlfQMJsuvLCSLvcn_0BC). +Radiant focuses on business data and decisions. It offers tools, examples, and documentation relevant for that context, effectively reducing the business analytics learning curve. -## How-to install Radiant +## How to install Radiant -- Required: [R](http://cran.cnr.berkeley.edu/), version 3.1.2 or later -- Required: A modern browser (e.g., Chrome, Safari, or Firefox). The latest version of internet explorer may work as well. +- Required: [R](http://cran.rstudio.com/) version 3.1.2 or later +- Required: A modern browser (e.g., [Chrome](https://www.google.com/intl/en/chrome/browser/desktop/) or Safari). Internet Explorer (version 11 or higher) should work as well - Recommended: [Rstudio](http://www.rstudio.com/products/rstudio/download/) -Radiant is now available on [CRAN](http://cran.r-project.org/web/packages/radiant/index.html). To install the latest version of the package with complete documentation for off-line access use the [radiant_miniCRAN](https://github.com/mostly-harmless/radiant_miniCRAN) repository (created using [miniCRAN](https://github.com/andrie/miniCRAN)). Open R(studio) and copy-and-paste the commands below. +Radiant is available on [CRAN](http://cran.r-project.org/web/packages/radiant/index.html). To install the latest version with complete documentation for offline access, open R(studio) and copy-and-paste the commands below: ```r -options(repos = c(XRAN = 'http://mostly-harmless.github.io/radiant_miniCRAN/')) -install.packages('radiant') +options(repos = 'http://vnijs.github.io/radiant_miniCRAN/') +install.packages("radiant") ``` -Once all packages are installed use the commands below to start the app: +Once all packages are installed use the commands below to launch the app: ```r library(radiant) -radiant('marketing') +radiant("marketing") ``` -`marketing` is the default app so you could also use the command `radiant()` to launch it. To start the `quant` app use: +See also the `Installing Radiant` video: -```r -library(radiant) -radiant('quant') -``` + -See also the [installing Radiant](https://www.youtube.com/watch?v=AtB2SsmzBsk) video. +You can create a launcher on your Desktop to start Radiant. On Windows type `win_launcher()` in the R-console and press return. A file called `radiant.bat` will be created that you can double-click to start Radiant in your default browser. - +On a Mac you can create a launcher for Radiant by typing `mac_launcher()` in the R-console. This will create a file called `radiant.command` on your Desktop. Double-click the icon to start Radiant in your default browser. + +When Radiant starts you will see data on diamond prices. To close the application click on `Quit` in the Navigation bar and then click the `Quit` button on the left of the screen. The Radiant process will stop and the browser window will close (or gray-out). -## Creating a desktop launcher +## Documentation -You can create a launcher on your Desktop to make it easy to start Radiant. On Windows type `win_launcher()` in the R-console and press return. A file called `radiant.bat` will be created that you can double-click to start Radiant in your default browser. +Documentation and tutorials are available at and in the Radiant web-interface (the `?` icons and the `Help` menu). -On a Mac you can create a launcher for Radiant by typing `mac_launcher()` in the R-console. This will create a file called `radiant.command` on your Desktop. Double-click the icon to start Radiant in your default browser. +Want some help getting started? Watch the tutorials on the [documentation site](http://vnijs.github.io/radiant/tutorials.html) -Radiant runs in a browser window. You will see data on diamond prices. To close the application click on `Quit` in the Navigation bar and then click the `Quit` button on the left of the screen. The Radiant process will stop and the browser window will close (or gray-out). +## Online + +Not ready to install Radiant on your computer? Try it out online at . Note that this is a test server only! ## Saving and loading state -To save your analyses save the state of the app to a file (Data > Manage). You can open this state file at a later time or on another computer to continue where you left off. You can also share the file with others that may want to replicate your analyses. As an example, load the state_file [`RadiantState.rda`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/RadiantState.rda?raw=true) in the `examples` folder. Go to `Data > View`, `Data > Visualize` to see some of the settings. There is also a report in `R > Report` that was created using the Radiant interface. The html file [`RadiantState.html`](https://github.com/mostly-harmless/radiant/blob/master/inst/examples/RadiantState.html?raw=true) contains the output. +To save your analyses save the state of the app to a file (Data > Manage). You can open this state file at a later time or on another computer to continue where you left off. You can also share the file with others that may want to replicate your analyses. As an example, load the state_file [`RadiantState.rda`](https://github.com/vnijs/radiant/blob/master/inst/examples/RadiantState.rda?raw=true) in the `examples` folder. Go to `Data > View`, `Data > Visualize` to see some of the settings. There is also a report in `R > Report` that was created using the Radiant interface. The html file [`RadiantState.html`](https://github.com/vnijs/radiant/blob/master/inst/examples/RadiantState.html?raw=true) contains the output. A related feature in Radiant is that state is maintained if you accidentally navigate to another page, close (and reopen) the browser, and/or hit refresh. Use Quit > Reset to return to a clean/new state. @@ -99,11 +94,6 @@ numericInput("sm_comp_value", "Comparison value:", state_init('sm_comp_value',sm Three (related) apps are included in the inst/ directory. `Base`, offers data loading, saving, viewing, visualizing, merging, and transforming tools. The `quant` app sources the code from base and extends it. Finally, the `marketing` app sources the code from `base` and `quant` and extends it with additional tools. The `quant` app focuses on (basic) quantitative analysis (e.g., comparing means, regression, etc.). The `marketing` app focuses on marketing analytics by adding clustering, principle component analysis, conjoint analysis, etc. - ## License @@ -113,4 +103,4 @@ As a summary, the AGPLv3 license requires, attribution, including copyright and If you are interested in using Radiant please email me at radiant@rady.ucsd.edu -© Vincent Nijs (2015) Creative Commons License +© Vincent Nijs (2015) Creative Commons License diff --git a/inst/base/tools/app/report.R b/inst/base/tools/app/report.R index d99f33c01..c7cdab4f0 100644 --- a/inst/base/tools/app/report.R +++ b/inst/base/tools/app/report.R @@ -38,7 +38,7 @@ plot(result, reg_plots = 'hist') ``` ```{r fig.width=7, fig.height=7} -visualize(dataset = 'diamonds', viz_vars1 = 'carat', viz_vars2 = 'price', viz_type = 'scatter', viz_color = 'clarity') +visualize(dataset = 'diamonds', viz_xvar = 'carat', viz_yvar = 'price', viz_type = 'scatter', viz_color = 'clarity') ``` " diff --git a/inst/base/tools/app/tutorials.md b/inst/base/tools/app/tutorials.md index 72baf7bd0..63eb86c14 100644 --- a/inst/base/tools/app/tutorials.md +++ b/inst/base/tools/app/tutorials.md @@ -3,20 +3,25 @@ ## Installing Radiant - + ## Starting and stopping - + ## Getting help - + ## Getting data in and out - + +## Selecting variables for fast and efficient analysis + + + +