Error in the r package "pubmed.mineR"
1
0
Entering edit mode
6.1 years ago
library(pubmed.mineR)

myabs <- readabs("pubmed_result.txt") # OR xmlreadabs("pubmed_result.xml")
words <- word_atomizations(myabs)

Then, I got following error.

Error in strsplit(tempb, ",", fixed = T) : non-character argument In addition: Warning message: In strsplit(x, ". ", fixed = T) : input string 1 is invalid in this locale

Does anyone know the solutions?

R version 3.5.1

R software error • 1.4k views
ADD COMMENT
0
Entering edit mode

can you show what the pubmed_result.txt contains? like what field it contains or header ?

ADD REPLY
0
Entering edit mode

I got the .txt file with "Send to" function as "File" of "abstract (text)" format. Please refer to your files.

ADD REPLY
1
Entering edit mode
6.1 years ago
zx8754 12k

To reproduce the error, try:

# example data
tempb <-  factor(c("1,2", "11,22"))

As expected we get an error, saying input for strsplit must be character class:

strsplit(tempb, ",", fixed = TRUE)

Error in strsplit(tempb, ",", fixed = TRUE) : non-character argument

Now, wrap it with as.character to convert, then it works fine:

strsplit(as.character(tempb), ",", fixed = TRUE)
# [[1]]
# [1] "1" "2"
# 
# [[2]]
# [1] "11" "22"

In your case from the manuals readabs returns:

An S4 object of class "Abstracts"

We need to convert this object into character, before we can use strsplit.

Read author's blog to get started:

ADD COMMENT
0
Entering edit mode

Thank you for your answer.

According to the manual, objects of class "Abstracts" have 3 slots, Journal, Abstract, and PMID.

the slot "abstract" is an object of class "character."

In addition, this "word_atomizations(m)" function gives "m@abstract" slot to strsplit, probably. show here

I checked this.

class(myabs@Abstract) [1] "character"

Please correct my idea.

ADD REPLY

Login before adding your answer.

Traffic: 2554 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6