replacement has 10000 rows, data has 20

I am trying to assign distribution to some parameters and then calculate the probability of profit from it. The parameters are assigned the distribution fine, but when I try to run the for loop, I get the following errors: "replacement has 10000 rows, data has 20". How can I fix this error please?

Hi, which package is rpert() from?

Also you're missing a ) here:

capex_vec <- cut(rpert(10000, min = 365, mode = 429, max = 600, shape=4)) # closing parentheses added here

Where is NPV_fun() from?
What is ndraw?

Can you edit your original post to have these defined?

I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions. For example, the guide emphasizes asking coding questions with formatted code-chunks and a reprex, which would make it easier for people who want to help you to pick up your issue and attempt to run with a solution.

Thank you. I have done it. Please see the code now. This was my post, so just learned how to do it

NPV_fun() still isn't defined anywhere. Nor is ndraw.

you can use browser() to step through your code.
The technical point of failure is easy to identify, the question of what should be done, would require knowledge of your calculation which I don't have but...
if you alter NPV_fun() to contain

  CF <- rbind(CF1,CF2)
  CF <- cbind(Year=1:nrow(CF),CF)
  CF$EBIT <- ebit

you will see that CF1 and CF2 which are 40 rows each, are bound together to make an 80 row CF (which you've labelled each resulting row, as a number 1:80 labelled year.
Then it breaks down with CF$EBIT <- ebit which tries but fails to put the 10,000 values of ebit into the 80 rows of CF.
You will have to do some thinking to understand how ebit should relate to CF ...

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.