Using the qdap::polarity()
function can sometimes run into the error:
Error in derive_pubkey(key) : RAW() can only be applied to a 'raw', not a 'list'
I'm fairly certain this is due qdap
's key
class conflicting with the openssl
package's key
class (since derive_pubkey()
from openssl
is referenced in the error msg).
The error happens when openssl
appears in the loaded via a namespace (and not attached):
section of sessionInfo()
, and it seems to throw off method dispatch for the key class and cause the error.
I've only been able to fix the error by restarting my R session. Is there a way to remove openssl
's footprint from the session to fix this issue? Or is there another way to avoid this issue without restarting R?
> successful <- qdap::polarity("testing")
> load_openssl_ns <- body(openssl:::print.key)
> fails <- qdap::polarity("testing")
Error in derive_pubkey(key) :
RAW() can only be applied to a 'raw', not a 'list'
If a page contains N components, there will be at least N + 1 naming conflicts. As far as one of our specific projects is concerned, there have been at least 500 + conflicts. The or [as] solution does not solve the intrinsic conflict problem.
As you can guess, the names conflict when both classes are referenced in the same Java file. com.myapp.model (package) - Device (class) - ... com.myapp.data (package) - Device (class) - ... We had a debate on what's the best practice to treat these cases and the following options came up:
We've divided our business logic into multiple packages. some of which have classes with identical names. As you can guess, the names conflict when both classes are referenced in the same Java file.
This type of problem is precisely why Java uses the package naming convention that it does. It prevents these sorts of problems, whether it's two teams in the same company or two teams on opposite sides of the earth. Show activity on this post.
For a dirty fix run
`[[.qdap_hash` <- `[[.data.frame`
Checking...
> qdap::polarity("test")
all total.sentences total.words ave.polarity sd.polarity stan.mean.polarity
1 all 1 1 0 NA NA
> library(openssl)
Warning message:
package ‘openssl’ was built under R version 3.3.3
> qdap::polarity("test")
Error in derive_pubkey(key) :
RAW() can only be applied to a 'raw', not a 'list'
> `[[.qdap_hash` <- `[[.data.frame`
> qdap::polarity("test")
all total.sentences total.words ave.polarity sd.polarity stan.mean.polarity
1 all 1 1 0 NA NA
>
The offending line in polarity
is words <- c(posneg, alter[[1]])
The object alter
gets created with alter_env
which creates an object which has classes "qdap_hash", "key", ...
qdap_hash doesn't have it's own '[[' method so it checks to see if key has a '[[' method which it typically doesn't. Once openssl gets loaded there is a [[ method for key so it uses that and gives the error since it isn't in the form expected. If we define our own method for qdap_hash that gets called before even attempting to use [[.key
so we bypass the issue. The author of qdap has been informed of the issue and the possible fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With