Tagging errors problem

Hi everybody, I need some advice or clue. I have xlsx file with few columns. One column contains paths (c://folder/folder/name etc). I need to add one column with error in the path. I used such code:

file$name <- ifelse((file$Type == "data" &
file$Subtype == "excel" &
grepl("folder[/|\]folder", file$'column_name') == TRUE), "OK", "wrong path") and so on.
The code works fine when only one mistake in the path is present, however when second error is present (eg "wrong name"), the value in the column is overwritten. I would like to add new error (eg "wrong path, wrong name" etc) Or make the path with mistakes color or bold. Please give some clue, r-packages, book, examples. I don't need ready code, I can figure it by myself. I have spend some time with it without any success. Thanks a lot.

My first thought is to look for each error sequentially and build up the file$name column using paste. Here is a simple example where I look for FileNames that contain W or Z

DF <- data.frame(FileName = c("AB", "AW", "AWZ", "AZ"))
DF$BadLetters <- ifelse(!grepl("W", DF$FileName), "", "Found W") 
DF$BadLetters <- ifelse(!grepl("Z", DF$FileName), DF$BadLetters, paste(DF$BadLetters, "FoundZ"))
  FileName     BadLetters
1       AB               
2       AW        Found W
3      AWZ Found W FoundZ
4       AZ         FoundZ
1 Like

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