How to avoid or sanitize a slash with a regular expression in R?

I am trying to read in a file (csv) in a file (tab separted) in R. When I want to read a column, including /, I get an error message.

doSomething <- function(dataset) {
     a <- dataset$data_transfer.Jingle/TCP.total_size_kb
     ...
     }

The error says that this object could not be found. I tried to escape with a backslash, but that didn't work.

If anyone has any idea, I would really appreciate it!

+3
source share
2 answers

Give

head(dataset)

and look at the name that it was assigned. Perhaps it will be something like:

dataset$data_transfer.Jingle.TCP.total_size_kb
+2
source

Two ways:

dataset[["data_transfer.Jingle/TCP.total_size_kb"]]

or

dataset$`data_transfer.Jingle/TCP.total_size_kb`
+1
source

Source: https://habr.com/ru/post/1735574/


All Articles