Problem when Tibble column name includes parentheses

I am dealing with a tibble with column name N(m). I want to use filter with ! to remove empty rows.

if I went with filter(!, it gave an error 'could not find function "N"'
if I went with filter (!'N(m)')), no error was reported but the empty rows were not removed.

I am wondering what should be the correct way to handle this.


Try using back ticks. On a US keyboard, the back tick is just to the left of the 1 key.

DF <- tibble(`N(m)` = c(1,2,NA,4,NA,6))
# A tibble: 6 x 1
1      1
2      2
3     NA
4      4
5     NA
6      6
DF %>% filter(!`N(m)`))
# A tibble: 4 x 1
1      1
2      2
3      4
4      6

It works! Thanks.
When I was searching the solution in google, I saw someone mention backtick but I did not pay close attention to what it actually means. Thank you for pointing out where the key is.

This topic was automatically closed 7 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.