When i tried to run from R GUI it didnt pop this message
Warning messages: 1: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'https://query1.finance.yahoo.com/v7/finance/download/BBCA.JK?period1=-2208988800&period2=1643846400&interval=1d&events=split&crumb=8Gq/FpXrgCY'
2: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'https://query1.finance.yahoo.com/v7/finance/download/BBCA.JK?period1=-2208988800&period2=1643846400&interval=1d&events=split&crumb=8Gq/FpXrgCY' Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid 'trim' argument Calls: format -> format.default -> prettyNum Execution halted
the Rscript
library(TTR)
library(TSA)
library(tseries)
library(urca)
library(AnalyzeTS)
library(forecast)
library(zoo)
library(quantmod)
library(RMySQL)
args = commandArgs(TRUE)
N = args[1]
start = args[2]
end = args[3]
mydb = dbConnect(MySQL(), user='root', password='root', dbname='skripsi',host='127.0.0.1')
user=dbReadTable(mydb,"users")
getSymbols(N, from = start, to = end, src = "yahoo", adjust = TRUE,)
temp_df = as.data.frame(get(N))
df = temp_df[4]
df = na.locf(df)
colnames(df)[1]="Price"
mins=min(df$Price)
maxs=max(df$Price)
n=1+3.332*log10(nrow(df))
a=as.numeric(df$Price)
dates=index(df)
years = as.numeric(format(dates[1], "%Y"))
day = as.numeric(format(dates[1], "%j"))
fuzzy.ts=ts(a,start=c(years,day),frequency=365)
chen=fuzzy.ts1(fuzzy.ts,n=round(n),type="Chen",plot=T,grid=T,trace=T)
singh=fuzzy.ts1(fuzzy.ts,n=round(n),type="Singh",plot=T,grid=T,trace=T)
price=a
f_singh=as.numeric(singh$table2$forecasted)
f_chen=as.numeric(chen$table2$forecasted)
acc.chen=chen$accuracy[4]
acc.singh=singh$accuracy[4]
dbSendQuery(mydb, "SET GLOBAL local_infile = true;")
dbSendQuery(mydb,paste0("INSERT INTO forecasts(user_id,data_id,acc_chen,acc_singh,flag,created_at,updated_at) VALUES (", userID, "", dataID, "", acc.chen, ",", acc.singh, ",1,NOW(),NOW());")
)
id=dbGetQuery(mydb, "SELECT id FROM forecasts WHERE flag=1;")
id=id[1,]
f_id=data.frame(price)
f_id$price=id
f_id=f_id$price
dbSendQuery(mydb,paste0("INSERT INTO data_details (f_id,date,price,fChen,fSingh,created_at,updated_at) VALUES (",f_id,",'",dates,"',",price,",",f_chen,",",f_singh,",NOW(),NOW());")
)
the exec function
$saham="BBCA.JK";
$start="2021-03-01";
$end="2021-06-01";
exec('D:\R 4.1.0\bin\Rscript.exe D:\applications\coba-laravel\public\js\cicip.R ' . $saham . ' ' . $start. ' ' .$end);