I'm using R scripts to make some statistical calculations. When I use the interactive terminal, this code works without problems:
# Load libraries to read ods tables, calcs alpha and pearson
print("Loading libraries...")
library(readODS)
# library(arules)
# library(arulesViz);
print("Done!")
# Read table ods
print("Calc results...")
table_votes = read_ods("table.ods", col_names = TRUE)
# Remove columns from dataframe where ALL values are NA
table_votes <- table_votes[,colSums(is.na(table_votes))<nrow(table_votes)]
matrix_votes <- as.matrix(table_votes)
matrix_votes[!is.finite(matrix_votes)] <- 0
transactions <- as(matrix_votes, 'transactions')
apriori(transactions)
But, when I'm passing this code to the file to run with Rscript, I have a problem with function as():
"Error: Could not find function 'as'"
I solve this using R -r my_file.R... But, why doesn't work with Rscript?