The goal of amcat4r is to provide easy access to
amcat4 from R. Learn more
about AmCAT and amcat4r at https://amcat-book.netlify.app/.
You can install the development version of amcat4r from GitHub with:
# install.packages("devtools")
remotes::install_github("ccs-amsterdam/amcat4r")Before you can use AmCAT, you need to login:
amcat_login("https://amcat4.labs.vu.nl/amcat")Some examples of how to query an index:
query_documents(INDEX)
query_documents(INDEX, fields=list("publisher", "text"))
query_documents(INDEX, filters = list(publisher="Guardian"))
query_documents(INDEX, filters = list(date=list(lte="2024-06-01")))
query_documents(INDEX, queries = "hai*", fields = "text")Examples of creating an index, setting the fields, and uploading documents:
create_index(INDEX, name="Test index")
set_fields(INDEX, list(title='text', text='text', publisher='keyword', date='date'))
docs = tribble(
~publisher, ~date, ~title, ~text,
"Guardian", "2025-01-01", "This is an article", "With some text",
"NY Times", "2024-01-01", "Another article", "Haiku time: 古池や 蛙飛び込む 水の音",
)
upload_documents(INDEX, docs)