escape special character in colmns in DT table

I am trying to escape special character "--" in column of DT table but formatPercentage is not letting this happen , manually passing formatPercentage(c(2,3,5)) is working and i want to make it dynamic. so i am looking for a solution through which column having "--" can be displayed in DT table.

I have tried ifelse but doesn't work , this code is just a part of my function.

df <- mtcars[1:6,1:5]
df$drat <- "--"
df$disp <- "--"

#c <- ifelse(df[length(df)] == "--",2:length(df),2:length(df)+1)
datatable(df, escape = FALSE) %>% 
  formatPercentage(2:5)requirement is how can we pass a list of vector of column through format percentage which can show "--" in DT table output.

I suppose I dont understand your reprex, as it shows a data table with columns contain double dashes ?

i am looking for a solution through which column having "--" can be displayed in DT table.

yes actually i am trying to mask columns of output summary table if there is any NA values in Column, This is just a simple example.

so the actual problem is I am trying to mask one column in my DT table output but formatPercentage not providing the require output. so i am looking for a solution .

My function is big thats why i am unable to create a reproducible example. because there are many sub functions but you can refer last part of function below

What do you mean when you say mask?
It's not all that helpful to give code in lieu of an explanation, as your code doesn't do what you wish to do, but you haven't been clear on that would be.
What should happen that doesn't yet happen for a cell with dashes in it?

THe only objective is in line 2 , if t2 have any column with dashes then it should show as dashes in dt table also. but formatpercentage is not allowing it

What should be seen instead of dashes?

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.