alteryx / alteryxrhelper Goto Github PK
View Code? Open in Web Editor NEWCreate, manage and edit R code outside Alteryx in an IDE
License: MIT License
Create, manage and edit R code outside Alteryx in an IDE
License: MIT License
# Configuration
config <- list(
inputMode = '%Question.inputMode%',
solver = '%Question.solver%'
)
# Inputs
inputs <- list(
A = read.Alteryx("#1"),
B = read.Alteryx("#2")
)
payload = list(config = config, inputs = inputs)
results <- outputs(payload)
write.Alteryx(results$data, 1)
write.Alteryx(results$plot, 2)
Hi Ramnath,
first of all, thanks for getting this great tool out! I was having a lot of issues with the R-Tool, especially with a bug for non-English locale settings kept crashing the built-in editor.
Right, I have closely followed the process described to use an external editor to develop R code. Using "inserRcode" the first time works fine, the code within the R-Tool of the macro gets updated. However, while having the macro workflow open in Alteryx and changing the code within the external vim editor, the following happens while committing the changes with "insertRCode":
My current workaround is to only run "insertRcode" once; later, I simply copy and paste the code from the editor the the R-tool.
Any feedback would be appreciated
Regards
Oli
Options to Persist
alteryx.path
#' Generate TextInput compatible XML for a Data Frame
df2TextInput <- function(x){
config <- read_xml("<Configuration />")
xml_add_child(config, "NumRows", value = as.character(NROW(x)))
fields <- xml_add_child(config, "Fields")
for (name in names(x)){
xml_add_child(fields, "Field", name = name)
}
data = xml_add_child(config, "Data")
for (i in 1:NROW(x)){
row = xml_add_child(data, "r")
for(j in 1:NCOL(x))
xml_add_child(row, "c", as.character(x[i,j]))
}
config
}
#' Generate Configuration XML from Configuration List.
config2xml <- function(props){
config <- read_xml("<Configuration />")
for (k in names(props)){
xml_add_child(config, "Value", name = k, paste(props[[k]], collapse = " + "))
}
config
}
#' Make workflow given data, template and tool ids.
makeWorkflow <- function(template, data, config, inputs_id, config_id, outFile){
getTool <- function(id){
sprintf("//Node[@ToolID = '%s']/Properties/Configuration", id)
}
doc <- read_xml(template)
n2 <- xml_find_first(doc, getTool(inputs_id))
textinput <- df2TextInput2(data)
invisible(xml_replace(n2, textinput))
n3 <- xml_find_first(doc, getTool(config_id))
xmlConfig <- list2xml(config)
invisible(xml_replace(n3, xmlConfig))
write_xml(doc, outFile)
}
There are many situations that dictate the need for using a hidden textbox to persist a JSON stringified representation of a dataItem. In such situations, the makeInput
function can be smart about it and automatically run it through jsonlite::fromJSON(..., auto_unbox = TRUE)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.