Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

R tool not populating data in new column

IamStuti8765
5 - Atom

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)

 

3 REPLIES 3
jrgo
14 - Magnetar

According to ChatGPT, you have 1 too many closing parentheses on the "df$Capital.K" line. Remove the last one.

IamStuti8765
5 - Atom

Removing that parenthesis created an error. That doesnt seem to be an issue

jrgo
14 - Magnetar

I copy/pasted your script into an R tool and running it did return an error indicating the extra ) also.

image.png

 

When I remove it as per my last post, the script does run fine 

image.png

 

What's the error you're getting?

Labels
Top Solution Authors