I am trying to learn Spotfire Expression Functions so that I can more effectively create calculated columns.
I have this script put together (below) that calculates flags where changes in the row values in Column "x" occur and numbers them increasingly. The script works well in R. However I keep messing things up to effectively use it as an Expression Function.
#this is the script
RNC <- function(x) { c(TRUE, x[1:(length(x) - 1)] != x[2:length(x)])}
What I tried was to replaces all the "x"'s with "input1" and then add another line that will make the output a new column called "NewColumn"
I called my expression function NEWFUNC1 and defined it as
RNC <- function(input1) { c(TRUE, input1[1:(length(input1) - 1)] != input1[2:length(input1)])}
NewColumn <- as.data.frame(input1)
I then went to create a new calculated columnd as NEWFUNC1([ColumA]) and had no luck...I know I'm making an error in understanding how to connect the R script to an expression function but I'm totally lost. Any advice would be so helpful - THANKS!
output=c(TRUE, input1[1:(length(input1) - 1)] != input1[2:length(input1)])
That is your entire expression function, with return type boolean