0

I am trying to get an array of with the first column being an x value and the second column to bee the probability of a sweked t-normal using the sn library function called "psn".

My x-value (finfl_new2) and parameter(par) to be used as with the function psn are stored in df1. Each row in my data set has for each element (x-value) a different set of parameters. My data looks like this.

I have the following:

myp <- function(par,value){
  par0 <- unlist(par)
  data.frame(x=value,prob=sn::psn(x=value,
                       xi=par0[1],
                       omega=par0[2], 
                       alpha=par0[3],
                       nu=par0[4]))
}

df1_bfgs <- filter(df1, par!="error") %>% mutate(prob=map(list(par,value=finfl_new2),myp))

I go the following error:

Error: Problem with mutate() column prob. i prob = map(list(par, value = finfl_new2), myp). x argument "value" is missing, with no default Run rlang::last_error() to see where the error occurred.

I appreciate all your help!

  • 1
    Hi there and welcome to SO. Please take a look at [How to Ask](https://stackoverflow.com/help/how-to-ask) for hints. It's a good start to give some data, make a [great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and give an example of your desired output. You could edit your question and put some sample data there using `dput()` or `data.frame()`. And please don't post data as images. – Martin Gal Sep 06 '21 at 16:53
  • Something like this is done in the `tibble %>% nest %>% map %>% unnest` schema. For example, you can look at the link I have provided here https://stackoverflow.com/questions/69048022/nesting-specific-elements-into-another-list-in-r/69050605#69050605. There you will find this schema. – Marek Fiołka Sep 06 '21 at 18:50
  • you can check out `do.call` – mnist Sep 06 '21 at 20:40
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 06 '21 at 23:29

0 Answers0