i have question can't seem find answer anywhere online. apologize if it's been answered, here goes. i've written script in r go through process of forecasting me, , returning best point forecast based on cross validation , other criteria. i'm wanting save script function, way don't have use full script every time go forecast. basic set of script following:
output <- read.csv("c:/users/data.csv", header = t) colnames(output) month_count = length(output[,1]) ##used in calculations throughout code current_year = output[1,1] current_month = output[1,2] months = 5 #months forecast out m = 0 data <- ts(output[,3][c(1:(month_count-m))], frequency = 12, start = c(current_year,current_month)) #runs other steps here on the function i'm writing looking takes various inputs , runs script , prints forecasts
forecastme = function(sourcefile,months,m) { #runs data prints out result } the problem i'm having want able enter directory , file name such c:/users/documents/data1.csv function (for sourcefile part) , pick @ step of r script.
output <- read.csv("c:/users/sourcefile.csv", header = t) i can't seem find way right. ideas or suggestions?
so...
function(sourcefile, etc) { output <- read.csv(sourcefile, header = t) etc } ...that? don't see you're asking exactly.
Comments
Post a Comment