1

I have orders data with me with several columns. My task is mapping the orders which have extensions and storing it in new column "PPARENT_ID" column.

I have written the following code for mapping the orders.

library(purrr)
find_parent <- function(ID,`Extention of`){
  if(is.null(`Extention of`)){
    return(ID)
  }else{
    ptnt <- mis$`Extention of`[mis$ID==`Extention of`]
    return(find_parent(`Extention of`,ptnt ))
  }
}
mis$PPARENT_ID<- map2_chr(mis$ID, mis$`Extention of`, find_parent)
mis %>% select(PPARENT_ID)

when I run the mis %>% select(PPARENT_ID) command, it is throwing error as

"Error in FUN(X[[i]], ...) : object 'PPARENT_ID' not found"

please help me to resolve the issue.

  • 1
    Are you 100% sure that `PPARENT_ID` exists in `mis`? Maybe `map2_chr(mis$ID, mis$`Extention of`, find_parent)` returns NULL value. But these are assumptions, to better help you please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Flo.P Apr 14 '18 at 10:44
  • PPARENT_ID is the column I am deriving. map2_chr(mis$ID, mis$Extention of, find_parent block only executes if there is a value in PPARENT_ID column. It wont return null value. – Srujan Teja Apr 14 '18 at 12:29

0 Answers0