argument "male" is missing, with no default

Viewed 30

I'm trying to create a function that performs calculations based off of a patient's information. However, I keep getting the same error message that says "Error in SMARTRISK(PATIENT1): argument "male" is missing, with no default". Here is the function:

SMARTRISK=function(age,male,smoker,systolic,diabetic,CAD,CVD,AAA,PAD,yrs,HDL,
                   TCHOL,eGFR,loghsCRP)
{
  SMARTRISK=(-0.0850*age)+(0.00105*(age^2))+(0.156*male)+(0.262*smoker)+
    (0.00429*systolic)+(0.223*diabetic)+(0.140*CAD)+(0.406*CVD)+(0.558*AAA)+
    (0.283*PAD)+(0.0229*yrs)-(0.426*HDL)+(0.0959*TCHOL)-(0.0532*eGFR)+
    (0.000306*(eGFR^2))+(0.139*loghsCRP)
  return(SMARTRISK) #return the SMARTRISK linear predictor as an output of the function
}

Then I initiated the following data frame:

age=65
male=0
smoker=1
systolic=160
diabetic=1
CAD=0
CVD=0
AAA=0
PAD=1
yrs=12
HDL=2
TCHOL=4
eGFR=100
loghsCRP=1
PATIENT1=data.frame(age,male,smoker,systolic,diabetic,CAD,CVD,AAA,PAD,yrs,HDL,
                    TCHOL,eGFR,loghsCRP)

And here is the final calculation I'm trying to perform:

(1-(0.81066^(exp(SMARTRISK(PATIENT1))+2.099)))*100

I am not understanding why things are getting caught up at "male". I have also tried print(male) and print(male)==1 within the function, but keep getting the same results. Why would it not understand the argument "male" but understand the "age" argument?

1 Answers

I am working on the same thing. I had set up mine a bit differently Data= data.frame('age',.....) then SMARTRISK= function(Data) and the long formula that goes under it then for the patient data, I did PATIENT1= data.frame(65,....) and got my answer that way

Related