Problem when Tibble column name includes parentheses

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

if I went with filter(!is.na(N(m))), it gave an error 'could not find function "N"'
if I went with filter (!is.na('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.

Thanks

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

library(tibble)
library(dplyr)
DF <- tibble(`N(m)` = c(1,2,NA,4,NA,6))
DF
# A tibble: 6 x 1
  `N(m)`
   <dbl>
1      1
2      2
3     NA
4      4
5     NA
6      6
DF %>% filter(!is.na(`N(m)`))
# A tibble: 4 x 1
  `N(m)`
   <dbl>
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.