xyy
xyy

Reputation: 547

error in count_combinations in statar

I'm trying to test out the count_combinations function in the statar package, and I'm encountering the following problem:

Here's the code:

id <- c(1, 1, 2, 2) 
name <- c("coca cola company", "coca cola incorporated",
          "apple incorporated", "apple corp") 
count_combinations(name, id = id)

And here's the error:

Error in setorderv(x, cols, order, na.last) : 
  some columns are not in the data.table: c,c,1,1,-1

What's the reason for getting this error?

Thanks!

Upvotes: 0

Views: 135

Answers (1)

David Arenburg
David Arenburg

Reputation: 92300

Next time, when asking a question regarding an unstable version on GitHub, please mention that

So the problem comes from the following line

setorder(dt, c("id", "count_across", "count_within"), order = c(1,1,-1))

The problem with this line is that quoted names were parsed to the setorder function, while the documentation clearly says

Do not quote column names

So you have two choices here (you will have to copy/modify the function manually in order to do that using the link provided by @Khashaa)

Either use setorderv instead which has the col parameter that can accept quoted column names

setorderv(dt, c("id", "count_across", "count_within"), order = c(1,1,-1))

Or, do not quote the column names and put - in the correct place

setorder(dt, id, count_across, -count_within)

I went ahead and filled a FR for you


Edit

Te source code on GitHub has been fixed and you can re-download from GitHub and and it will work now.

Upvotes: 4

Related Questions