Search code examples
rwarningslapply

Suppress unknown or uninitialised column


I keep getting the following warning:

"Warning messages: 1: Unknown or uninitialised column: LinkStatus. 2: Unknown or uninitialised column: LinkStatus. “

but the Column LinkStatus does not exist.

Below is my code for reading in multiple .xlsx files:

DR <- list.files(path = Delivery_Status_Rep,pattern = "*.xlsx",full.names = TRUE ) %>% 
  lapply(read_xlsx, skip = 10) %>% 
  bind_rows   

I have checked the files and there is no such column. I have also run names() and it not showing. I have tried dplyr::select(.data) to try and just select the Columns that are there/I want but nothing works.

Is there a way to suppress a specific warning because as soon as I start working with the data I get warning after warning?

Any help would be greatly appreciated.


Solution

  • Hi found a solution and thought it may be useful for others. I have simply added as.data.table

    DR <- list.files (path = Delivery_Status_Rep,    
                         pattern = "*.xlsx",
                         full.names = TRUE) %>% 
    lapply(read_xlsx,skip = 10) %>%
     bind_rows   
    
    DR<- as.data.table(DR)
    

    Works a treat now