Error in `[<-` ! Assigned data ... must be compatible with row subscript `i`....

I am new to R. I have an error message:

! Assigned data c(analysis$"Net Present Value", analysis$"Internal Rate of Return") must be compatible with row subscript i.

when I try to run this function:

function(nsim = 1000, seed = 123, ...){
output_simple <- tibble('Net Present Value' = numeric(nsim),
'Internal Rate of Return' = numeric(nsim))
output_complex_l <- list()

for(i in 1:nsim){
analysis <- cba_single(...)
output_simple[i, ] <- c(analysis$'Net Present Value', analysis$'Internal Rate of Return')
tmp <- analysis$time_series_output
tmp$id <- i
output_complex_l[[i, ]] <- tmp # was [i]

output_complex <-, output_complex_l) %>%
gather(variable, value, -id, -year) %>%
group_by(variable, year) %>%
summarise(mid = mean(value),
lower = quantile(value, 0.1),
upper = quantile(value, 0.9))

output_simple = output_simple,
output_complex = output_complex)

net_present_value(discount = 7, cost = costs, benefit = benefits)

Could somebody guide me as to where I need to start looking to solve this please?

This topic was automatically closed 42 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.