I have a function that is calcualting a profitmargin (PM) given a principal(P).
PMfunction<- function(P,InterestRate,Expenses){
...
There are quite a lot of calcualtions in the middle that come off a table and it's irrelevant
...
return(PM)
}
I now want to calculate the P given a PM so I attempted the below:
uniroot(PMfunction,InterestRate=0.02,Expenses=0.07,lower=0,upper=20000)$root
But this only gives me the value of P such that PM=0. Is there a way I can change the uniroot's defult to find the roots from 0 to my chosen PM?