User Defined Function

In case of R Udf when you are describing an 'outtypecallback' function, I am wondering if there is any example of describing scale for example: ret = data.frame(datatype = rep(NA,1), length = rep(NA,1), scale = rep(NA,1), name = rep(NA,1)). How do you define scale ??

Comments

  • Hi Sudip, thanks for your question! We'll see if any of our community members can give you a hand with this.
  • Hi Sudip, The scale parameter is used only for the NUMERIC data type - e.g., if your UDF wants to return a NUMERIC(10,2), you'd use length=rep(10, 1), scale=rep(2, 1). E.g.:
       NumericReturntype <- function(x)  {        ret <- data.frame(datatype=rep("numeric", 1), length=rep(10, 1), scale=rep(2,1), name=rep("my_numeric_col",1))         ret  }  
    You can also use the input data types to determine your length and scale - in the above example, 10 and 2 need not be constants - you can compute them in the function. Hope this helps!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file