Delete column from a DataTables (DT)

I have created a new data frame from two data frames through a join. I then convert the data frame to a DataTable and want to remove some columns from the DataTable. The following is my code:

     actions <- segments %>% left_join(segment_action, by = "segment")
      
      segmentAction <-  DT::datatable(actions, options = list(autoWidth = TRUE))
      
      segmentAction[,c('recency_score','frequency_score' ,  'monetary_score'):=NULL] 

I am getting the following error message:

`:=` can only be used within a quasiquoted argument

This should be possible as per the documentation of the package "data.table"

Kindly assist 

Created on 2019-08-23 by the reprex package (v0.3.0)

Managed to find a solution by doing it at the data frame level as follows:

actionsRev <- actions[,c(1,2,3,5,6,7,11)]

i.e keeping only the required columns and then converting to a data table

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.