New user here - I am trying to use jvm package in R.
I have written a function that takes lists of variables and a histogram T/F argument.
The function works, but I can not get the results out.
I would like to return the descriptives table and histogram plots back and render to html via rmarkdown.
Things that did not work:
- wrapping the descriptives in print() or show()
- print(results$descriptives) inside the for loop and outside of it
- return(results$descriptives)
The errors I am getting are: object 'results' not found or similar
here is my function code:
Code: Select all
func_DescriptivesPlots <- function(df, anova_str, histogram_on){
# get the number of Descriptives analyses from # of rows
len <- length(anova_str)
for(i in seq(1,len)){
# get variable (column) names from list of strings
descr_list <- unlist(anova_str[[i]])
var <- names(df)[descr_list]
target<- var[2:length(var)]
# jvm function
descriptives(df[target],
missing = FALSE,
sd = TRUE,
se = FALSE,
freq = FALSE,
hist = histogram_on
)
}
return(results$descriptives) # error!
return(results$plots) # error!
}