Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

masking conflicts

Tags:

r

data.table

When loading a .csv with sqldf, everything goes fine until I load data.table. For example:

library(sqldf)
write.table(trees, file="trees.csv", row.names=FALSE, col.names=FALSE, sep=",")
my.df <- read.csv.sql("trees.csv", "select * from file", 
        header = FALSE, row.names = FALSE)

works, while

library(data.table)
my.df <- read.csv.sql("trees.csv", "select * from file", 
        header = FALSE, row.names = FALSE)
# Error in list(...)[[1]] : subscript out of bounds

Doesn't. When loaded, data.table informs you that

The following object(s) are masked from 'package:base':

   cbind, rbind

So, I tried this

rbind <- base::rbind  # `unmask` rbind from base::
library(data.table)
my.df <- read.csv.sql("trees.csv", "select * from file", 
        header = FALSE, row.names = FALSE)
rbind <- data.table::rbind # `mask` rbind with data.table::rbind

which works. Before I litter all my code with this trick:

What is the best practise solution to deal with masking conflicts in R?

EDIT: There is a closely related thread here, but no general solution is suggested.

like image 949
Ryogi Avatar asked Oct 15 '11 04:10

Ryogi


People also ask

What are the side effects of the new COVID-19 booster?

Side effects are not expected to differ from those associated with the current vaccine, which include redness and swelling at the vaccine site, as well as occasional fatigue, headache and muscle soreness, according to the CDC. More serious reactions are rare.

How safe are vaccinated people around unvaccinated people?

Vaccinated people had lower infection rates when they mixed with other vaccinated people and lower rates when they mixed with unvaccinated people.

Are masks effective against the coronavirus disease?

Wearing a well-fitted mask along with vaccination, self-testing, and physical distancing, helps protect you and others by reducing the chance of spreading COVID-19.

Can teachers wear only a face shield without a mask while teaching?

Instructors and teachers should not consider wearing only a face shield in a return to in-person instruction. To be used correctly, face shields should be coupled with face masks. Face masks that cover the nose and mouth are protective for the people around you.


1 Answers

As per the comments, yes, please file a bug report :

bug.report(package="data.table")

That way it won't be forgotten, you'll get an automatic email each time the status changes and you can reopen it if the fix proves to be insufficient.

EDIT:

Now in v1.6.7 on R-Forge :

  • Compatibility with package sqldf (which can call do.call("rbind",...) on an empty ...) is fixed and test added. data.table was switching on list(...)[[1]] rather than ..1. Thanks to RYogi for reporting #1623.
like image 56
Matt Dowle Avatar answered Oct 12 '22 23:10

Matt Dowle