with_qfun() function throwing error in {patentsview} package

On the subject, the function with_qfun() from {patentview} package is returning errors. For example, consider the sample code in the help of with_qfun():

.query ← with_qfuns(
and(
gte(patent_date = “2007-01-01”),
text_phrase(patent_abstract = c(“computer program”)),
or(
eq(inventor_last_name = “ihaka”),
eq(inventor_first_name = “chris”)
)
)
)

res ← search_pv(
query = .query,
config = httr::timeout(40)
)

Running the above code throw the error: Error in names(x) %in% c("_not", "_and", "_or") || is.na(names(x)) : 'length = 3' in coercion to 'logical(1)'

I have searched online for information on how to resolve the problem but couldn’t find any. All helps shall be highly appreciated.

Thanks

Wow, I’m really late to the party but this is a bug in the R package that we didn’t know about. It’s fixed in my repo but the API team is planning to shutdown the original version of the API in favor of a new one. The shutdown was supposed to have been two days ago but the new version isn’t stable yet- leaving the updated package in limbo for now. We’ll submit the updated package to CRAN after the original version of the API is shutdown.

The fix is here devtools::install_github("mustberuss/patentsview@original-api") though it will only work until the shutdown.

The new version requires an API key which can be requested here. There are a lot of changes, just about all of them breaking changes. We’ll probably submit a Tech Note when the updated package is on CRAN. As a tease, here’s your query using the new version of the API and R package.

library(patentsview)

query <- with_qfuns(
  and(
    gte(patent_date = "2007-01-01"),
    text_phrase(patent_abstract = c("computer program")),
    or(
      eq(inventors.inventor_name_last = "Ihaka"),
      eq(inventors.inventor_name_first = "Chris")
    )
  )
)

res <- search_pv(
  query = query,
  timeout = 40
)

res
#> $data
#> #### A list with a single data frame on patents level:
#> 
#> List of 1
#>  $ patents:'data.frame': 168 obs. of  3 variables:
#>   ..$ patent_id   : chr [1:168] "10048105" ...
#>   ..$ patent_title: chr [1:168] "System and method for providing a self valid"..
#>   ..$ patent_date : chr [1:168] "2018-08-14" ...
#> 
#> $query_results
#> #### Distinct entity counts across all downloadable pages of output:
#> 
#> total_hits = 168

Created on 2025-02-14 with reprex v2.1.1