Hi,
I am trying this below code in alteryx R tool but the new column Capital K is not populating, the column is getting created but it is returning blank in the excel output file:
df <- read.Alteryx("#1", mode="data.frame")
names(df)<-str_replace_all(names(df), c(" " = "."))
BasePD <- df$Probability
LGD <- df$Final.Loss
M <- df$Maturity.in.Years
BaseR <- df$Correlation.R
Baseb <- df$Maturity.b
df$Capital.K = (((LGD)*pnorm((qnorm(BasePD)+BaseR^0.5)*qnorm(0.999))/((1-BaseR)^0.5))-((LGD)*BasePD))*(1+(M-2.5)*Baseb)/(1-1.5*Baseb))
names (df) <-str_replace_all(names(df), c("[.]" = " "))
dfOut <- as.data.frame(df)
write.Alteryx(dfOut,1)
According to ChatGPT, you have 1 too many closing parentheses on the "df$Capital.K" line. Remove the last one.
Removing that parenthesis created an error. That doesnt seem to be an issue
I copy/pasted your script into an R tool and running it did return an error indicating the extra ) also.
When I remove it as per my last post, the script does run fine
What's the error you're getting?