Azume ML Cannot Find timeSeries function - r

I am trying to run an R Script in Azure ML Studio. Unfortunately, I receive the following error:
Error 0063: The following error occurred during evaluation of R script:
---------- Start of error message from R ----------
could not find function "timeSeries"
It seems strange that Azure ML cannot find the function timeSeries as the timeSeries package is installed by default. Here is the proof, you can see that timeSeries is listed.
Here is my code and the Azure diagram. The 1st R script was used to write a CSV of the installed packages (1st Picture). The code in the second R script is displayed to the right of the 2nd picture.
Thanks

The library needs to be loaded as it is an external library
library(timeSeries)
#Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) #class: data.frame
HOLD <- maml.mapInputPort(2) #class: data.frame
colnames(HOLD) <- c("Dates", "Val")
Daily.TS <- timeSeries(HOLD$Val, as.Date(HOLD$Dates),
format="%Y-%m-%d")

Related

Quantmod/getOptionChain Error in .Date(Exp/86400) : could not find function ".Date"

I'm getting an error when running getOptionChain from quantmod package.
The code should get Option chain data and subset into a new list that contains only the puts.
The error I get is: Error in .Date(Exp/86400) : could not find function ".Date"
Same code, sometimes runs without error. If I shorten the list of Symbols, there's no error, but the error as far as I know is not related to a specific symbol, because I made to run successfully. Seems random but frequent error.
All symbols are weekly expirations and the desired output is the next weekly expiration, so from my understanding, there's no need to specify a exp date.
library(quantmod)
library(xts)
Symbols<-c ("AA","AAL","AAOI","AAPL","ABBV","ABC","ABNB","ABT","ACAD","ACB","ACN","ADBE","ADI","ADM","ADP",
"ADSK","AEO","AFL","AFRM","AG","AGNC","AHT","AIG","AKAM","ALGN","AMAT","AMBA","AMC","AMD","AMGN",
"AMPX","AMRN","AMRS","AMZN","ANET","ANF","ANY","APA","APO","APPH","APPS","APRN","APT","AR","ARVL")
Options.20221118 <- lapply(Symbols, getOptionChain)
names(Options.20221118) <- Symbols
only_puts_list <- lapply(Options.20221118, function(x) x$puts)
After upgrading to R 4.2.2 the issue is fixed.

How to fix "unused argument" error message in R studio?

I tried to run my code like I usually do, and I got an "unused argument" error message. I have previously run the code multiple times and everything worked perfectly fine, this is the first time I have gotten an error message (I haven't changed the code). The only thing I've done different is I cleared the workspace at the end of my previous session (though I have no idea if this would actually affect it?).
Below is the code:
pacman::p_load(
rio, # importing data
here, # relative file pathways
janitor, # data cleaning and tables
lubridate, # working with dates
epikit, # age_categories() function
tidyverse, # data management and visualization
skimr,
psych,
reshape2, #for reshaping dataset
dplyr,
miscFuncs,
foreign, #read data formats
rcompanion, # group means
eeptools,
plyr)
mesh_dat <- import(here("R", "BTmeshdata.xlsx"))
The error message:
Error in here("R", "BTmeshdata.xlsx") :
unused argument ("BTmeshdata.xlsx")
The issue seems to be in how the dataset is imported because I have the same issue with importing a dataset from a different project.
.here and my folder "R" are located in my Documents folder.
Thanks!

send2cy doesn't work in Rstudio ~ Cyrest, Cyotoscape

When I run "send2cy" function in R studio, I got error.
# Basic setup
library(igraph)
library(RJSONIO)
library(httr)
dir <- "/currentdir/"
setwd(dir)
port.number = 1234
base.url = paste("http://localhost:", toString(port.number), "/v1", sep="")
print(base.url)
# Load list of edges as Data Frame
network.df <- read.table("./data/eco_EM+TCA.txt")
# Convert it into igraph object
network <- graph.data.frame(network.df,directed=T)
# Remove duplicate edges & loops
g.tca <- simplify(network, remove.multiple=T, remove.loops=T)
# Name it
g.tca$name = "Ecoli TCA Cycle"
# This function will be published as a part of utility package, but not ready yet.
source('./utility/cytoscape_util.R')
# Convert it into Cytosccape.js JSON
cygraph <- toCytoscape(g.tca)
send2cy(cygraph, 'default%20black', 'circular')
Error in file(con, "r") : cannot open the connection
Called from: file(con, "r")
But I didn't find error when I use "send2cy" function from terminal R (Run R from terminal just calling by "R").
Any advice is welcome.
I tested your script with local copies of the network data and utility script, and with updated file paths. The script ran fine for me in R Studio.
Given the error message you are seeing "Error in file..." I suspect the issue is with your local files and file paths... somehow in an R Studio-specific way?
FYI: an updated, consolidated and update set of R scripts for Cytoscape are available here: https://github.com/cytoscape/cytoscape-automation/tree/master/for-scripters/R. I don't think anything has significantly changed, but perhaps trying in a new context will resolve the issue you are facing.

Error: could not find function "includePackage"

I am trying to execute Random Forest algorithm on SparkR, with Spark 1.5.1 installed. I am not getting clear idea, why i am getting the error -
Error: could not find function "includePackage"
Further even if I use mapPartitions function in my code , i get the error saying -
Error: could not find function "mapPartitions"
Please find the below code:
rdd <- SparkR:::textFile(sc, "http://localhost:50070/explorer.html#/Datasets/Datasets/iris.csv",5)
includePackage(sc,randomForest)
rf <- mapPartitions(rdd, function(input) {
## my function code for RF
}
This is more of a comment and a cross question rather than an answer (not allowed to comment because of the reputation) but just to take this further, if we are using the collect method to convert the rdd back to an R dataframe, isnt that counter productive as if the data is too large, it would take too long to execute in R.
Also does it mean that we could possibly use any R package say, markovChain or a neuralnet using the same methodology.
Kindly check the functions that can be in used in sparkR http://spark.apache.org/docs/latest/api/R/index.html
This doesn't include function mapPartitions() or includePackage()
#For reading csv in sparkR
sparkRdf <- read.df(sqlContext, "./nycflights13.csv",
"com.databricks.spark.csv", header="true")
#Possible way to use `randomForest` is to convert the `sparkR` data frame to `R` data frame
Rdf <- collect(sparkRdf)
#compute as usual in `R` code
>install.packages("randomForest")
>library(rainForest)
......
#convert back to sparkRdf
sparkRdf <- createDataFrame(sqlContext, Rdf)

quantmod 3d graphics

I am trying to use the code on the quantmod website for a 3d graph. I followed the instructions and entered the year as 2010 (since 2008 link was not found). However, when I enter this command at the R prompt:
chartSeries3d0(TR)
I get the following error:
Error in if (on == "years") { : missing value where TRUE/FALSE needed
I am relatively new to R, so can anyone help me fix it.
The Treasury has re-designed its website since that example was created, so the code is not downloading any data (no matter what year you enter). Instead of using the getUSTreasuries function, you can just pull the data from FRED.
library(quantmod)
source("http://www.quantmod.com/examples/chartSeries3d/chartSeries3d.alpha.R")
getSymbols("DGS1MO;DGS3MO;DGS6MO;DGS1;DGS2;DGS3;DGS5;DGS7;DGS10;DGS20;DGS30",
src="FRED")
TR <- merge(DGS1MO,DGS3MO,DGS6MO,DGS1,DGS2,DGS3,DGS5,
DGS7,DGS10,DGS20,DGS30, all=FALSE)
colnames(TR) <- c("1mo","3mo","6mo","1yr","2yr","3yr","5yr",
"7yr","10yr","20yr","30yr")
TR <- na.locf(TR)
chartSeries3d0(TR["2011"])

Resources