Help log all none match value from Excel upload


I'm using the following to insert new prices to products in df via the product name from a excel upload, product name is the only option

here is the bit of code that does it,

  import <- readNewData(newDataFileName)
  if( !is.null(import)){    
    for(i in seq_len(nrow(import))){  #Make replacements <- import$newVariable[i] 
      col.from <- import$lookupVariable[i]
      if({ # apply to whole column
        data[] <- import$newValue[i]
      } else { # apply to subset
        rows <- which(import$lookupValue[i] == data[[col.from]])
        data[rows,'now_cost'] <- import$newValue[i]

I want to log the import$lookupValue[i] that are not matched so I can manually correct afterwards, can anyone help please. I works great for values it can find but I'm blind to what it can't match.


Add a line like

if (length(rows) == 0) {
  warning("Didn't match row ", i, " with lookup value ", import$lookupValue[i])

to print a warning to standard error.

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.