This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error in the r package "pubmed.mineR"
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

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

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

1 answer

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:

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.

Log in to answer this question.