Simple conditional formatting in R

Hi, I have a sample data frame as follows:

structure(list(CellType = structure(c(1L, 2L, 3L, 3L, 1L), .Label = c("CellA", "CellB", "CellC"), class = "factor"), Gene1 = c(0.1, 0.2, 0.1, 0.3, 0.5), Gene2 = c(0.1, 0.2, 0.1, 0.3, 0.5), Gene3 = c(0.1, 0.2, 0.1, 0.3, 0.5)), class = "data.frame", row.names = c(NA, -5L))

Is there a simple way to apply conditional formatting to numerical values to the entire data frame such that all values below 0.3 appear in red and rest in standard black colour?

Thanks!

You can't apply aesthetic formatting to the data frame it self but to a table which is a graphical representation, what would the the desired output format (e.g. Latex, HTML, etc.) ?

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

Yes, but how to do it depends on the output format, can you give more detail on that?

Thanks @andresrcs is it possible to convert the dataframe into a table in order to apply this type of conditional formatting?

@andresrcs Essentially, I just want to be able to re-print the dataframe/table in the R console with the coloured formatting of numerical values. There are no restrictions regarding a specific output format.

Sorry I don't know how to apply that kind of format to console output, maybe the crayon package could help you but I'm not sure.