Frown
Frown

Reputation: 259

How can I retrieve a list of specific person names from DBPedia by using SPARQL query in R

I am currently using the SPARQL package in R to query DBPedia and get the information for a list of specific person names. But I only know how to query one person or the "person category", such as

query= "SELECT *{
    dbpedia:Veit_Dietrich ?p ?o 
}"

qd=SPARQL(endpoint,query)
df=qd$results

Is there anyway to iterative query several names (a,b and c) by only using one single query?

Upvotes: 1

Views: 467

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85833

For a query like this, the easiest thing is to use values. E.g.,

select * { 
  values ?person { dbpedia:Johnny_Cash dbpedia:Johann_Sebastian_Bach }
  ?person ?p ?o 
}

SPARQL results

I'm not familiar with R, but hui pointed out in the comments that R's paste function can be used to concatenate the list of URIs to produce the content for values.

Upvotes: 3

Related Questions