Reputation: 167
I want to put the following expression:
2<= x<3, but if I put c(paste0(2 ," <= x <", 3), the result is the one in image 1, which I don't like.
On the other hand , if I put c(paste0(2 ," <= x", 3), the expression less or equal, is the correct one. Image 2
The code is this:
dataP2 <- data.frame(c("F(x)"),c("0") ,c(0.1), c(0.29), c(0.59),c(0.74), c(0.89), c(1))
colnames (dataP2) <- c( c("X"), c(paste0("x <", 2)),c(paste0(2 ," <= x", 3),c(4),c(5),c(6),c(7), c(paste0("x >=",7))))
tt <- ttheme_default(colhead=list(fg_params = list(parse=TRUE)))
grid.table(dataP2, rows = NULL, theme=tt)
What do I have to put so that the expression is this way? Image 3
"theme" works fine, but when I add "<", it already breaks down and displays <=. It seems that it does not support two mathematical symbols.
Upvotes: 0
Views: 69
Reputation: 312
To add the formulas to the column names as you would like in Image 3, you can use regular quotes without the paste function. For example:
dataP2 <- data.frame(c("F(x)"), 0 , 0.21, 0.29, 0.59, 0.74, 0.89, 1)
colnames(dataP2) <- c('X', 'x<2', '2≤x<3', '4','5','6','7','x≥7')
gridExtra::grid.table(dataP2, rows = NULL)
Then to access the columns since they contain non-standard characters you would need to wrap the names in backticks like:
dataP2$`2≤x<3`
Upvotes: 0