Title: | R Interface to Experigen |
---|---|
Description: | Provides convenience functions to communicate with an Experigen server: Experigen (<http://github.com/aquincum/experigen>) is an online framework for creating linguistic experiments, and it stores the results on a dedicated server. This package can be used to retrieve the results from the server, and it is especially helpful with registered experiments, as authentication with the server has to happen. |
Authors: | Daniel Szeredi [aut, cre] |
Maintainer: | Daniel Szeredi <[email protected]> |
License: | GPL-3 |
Version: | 0.2.1 |
Built: | 2025-02-04 02:37:29 UTC |
Source: | https://github.com/aquincum/rexperigen |
Run a request to the API
API.request(server = getOption("Rexperigen.server"), request = "version", params = list(), auth = FALSE, method = "GET")
API.request(server = getOption("Rexperigen.server"), request = "version", params = list(), auth = FALSE, method = "GET")
server |
The server name (no need to be clean) |
request |
The request verb to the server |
params |
A list of |
auth |
Do we send authentication? If this is |
method |
The HTTP method to use ( |
Other development: checkAuthentication
,
create.API.request.URL
,
prepare.server.URL
,
server.version
Checks whether the authentication is supported by the server and handles the different POST request routes.
checkAuthentication(request, auth, version.needed = 1)
checkAuthentication(request, auth, version.needed = 1)
request |
The needed request to be made (without |
auth |
Whether authentication is requested in R. |
version.needed |
The minimum version of the request. If it is
|
A list:
request
: the request to send
auth
: whether to still send an authenticated request.
Other development: API.request
,
create.API.request.URL
,
prepare.server.URL
,
server.version
checkAuthentication("makecsv", TRUE) checkAuthentication("registration", TRUE, 2)
checkAuthentication("makecsv", TRUE) checkAuthentication("registration", TRUE, 2)
Checks whether the user is logged in. It also throws an exception if the server is of an old version and logging in is not supported.
checkLogin()
checkLogin()
The experimenter login user name
options(Rexperigen.server.version="2.0.0") setExperigenCredentials("my", "credentials", check = FALSE) checkLogin()
options(Rexperigen.server.version="2.0.0") setExperigenCredentials("my", "credentials", check = FALSE) checkLogin()
Experigen has been using some URL cleaning since version 1. This function asks the server (if version >= 2) to return how it would clean the given URL. For older versions, you still have to replace /'s and stuff by .'s by yourself, sorry!
cleanURL(sourceURL)
cleanURL(sourceURL)
sourceURL |
The source URL to clean |
The cleaned URL
## Not run: cleanURL("https://s3.amazonaws.com/myexperiment/index.html") ## End(Not run)
## Not run: cleanURL("https://s3.amazonaws.com/myexperiment/index.html") ## End(Not run)
Create an URL for a request to the Experigen API.
create.API.request.URL(server, request, params = list())
create.API.request.URL(server, request, params = list())
server |
The server name (no need to be clean) |
request |
The request verb to the server |
params |
A list of name=value pairs that will be passed to the server |
A URL that can be queried.
Other development: API.request
,
checkAuthentication
,
prepare.server.URL
,
server.version
create.API.request.URL("db.phonologist.org", "users", list(sourceurl="x.y", experimentName="z"))
create.API.request.URL("db.phonologist.org", "users", list(sourceurl="x.y", experimentName="z"))
Create a login for yourself using this function
createExperimenter(experimenter, password)
createExperimenter(experimenter, password)
experimenter |
The username. |
password |
Your password. |
A string that the server returns ("done"
if success)
This function downloads the results of an experiment.
downloadExperiment(sourceURL, experimentName, destination = "default.csv", auth = FALSE)
downloadExperiment(sourceURL, experimentName, destination = "default.csv", auth = FALSE)
sourceURL |
The source URL for the experiment |
experimentName |
The experiment name as set in |
destination |
The file to download. By default, all uploaded results are
saved in |
auth |
Whether authentication is needed |
The downloaded data set as data frame
Other download: getDestinations
,
getUsers
## Not run: downloadExperiment("https...s3.amazonaws.com.myexperiment.index.html", "testing1") downloadExperiment("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
## Not run: downloadExperiment("https...s3.amazonaws.com.myexperiment.index.html", "testing1") downloadExperiment("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
Returns the list of destination files for an experiment.
getDestinations(sourceURL, experimentName, auth = FALSE)
getDestinations(sourceURL, experimentName, auth = FALSE)
sourceURL |
The source URL for the experiment |
experimentName |
The experiment name as set in |
auth |
Whether authentication is needed |
The list of destinations
Other download: downloadExperiment
,
getUsers
## Not run: getDestinations("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
## Not run: getDestinations("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
Returns a list of the registered experiments for the logged in experimenter.
getRegisteredExperiments()
getRegisteredExperiments()
The parsed list of experiments
Other registration: registerExperiment
,
removeRegistration
## Not run: getRegisteredExperiments() ## End(Not run)
## Not run: getRegisteredExperiments() ## End(Not run)
Requests the table of users from the server.
getUsers(sourceURL, experimentName, auth = FALSE)
getUsers(sourceURL, experimentName, auth = FALSE)
sourceURL |
The source URL for the experiment |
experimentName |
The experiment name as set in |
auth |
Whether authentication is needed |
The table of users
Other download: downloadExperiment
,
getDestinations
## Not run: getUsers("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
## Not run: getUsers("https...s3.amazonaws.com.myexperiment.index.html", "running", auth = TRUE) ## End(Not run)
Simply removes the stored credentials, so following requests will be unauthenticated.
logoutExperigen()
logoutExperigen()
Error string returned when no server is found
NO_SERVER_ERROR
NO_SERVER_ERROR
An object of class character
of length 1.
Prepares the server URL by checking for the presence of a protocol
prefix, and prefixing http://
if there is none. Also, returns
the URL with a trailing /
if that was not present either.
prepare.server.URL(server)
prepare.server.URL(server)
server |
A server name. |
A clean URL with protocol prefix and trailing slash.
Other development: API.request
,
checkAuthentication
,
create.API.request.URL
,
server.version
prepare.server.URL("db.phonologist.org") prepare.server.URL("https://myserver.com/")
prepare.server.URL("db.phonologist.org") prepare.server.URL("https://myserver.com/")
Registers the given experiment to the experimenter. Returns the server's response. Do provide the credentials before calling this function
registerExperiment(sourceURL, experimentName)
registerExperiment(sourceURL, experimentName)
sourceURL |
The source URL for the experiment |
experimentName |
The experiment name as set in |
The server response.
Other registration: getRegisteredExperiments
,
removeRegistration
## Not run: registerExperiment("https...s3.amazonaws.com.myexperiment.index.html", "running") ## End(Not run)
## Not run: registerExperiment("https...s3.amazonaws.com.myexperiment.index.html", "running") ## End(Not run)
Removes the registration of the experiment to the logged in experimenter. Does not remove any data though! All of the data will be available to anyone.
removeRegistration(sourceURL, experimentName)
removeRegistration(sourceURL, experimentName)
sourceURL |
The source URL for the experiment |
experimentName |
The experiment name as set in |
The server response.
Other registration: getRegisteredExperiments
,
registerExperiment
## Not run: removeRegistration("https...s3.amazonaws.com.myexperiment.index.html", "running") ## End(Not run)
## Not run: removeRegistration("https...s3.amazonaws.com.myexperiment.index.html", "running") ## End(Not run)
An R interface for downloading results from an Experigen server.
Works with the "classic" server that is currently running on
db.experigen.org
as well, but its main advantage is that it helps
a lot with the new functions of the newer version of the Experigen
server. Most importantly, it helps with registration of experimenters,
registration of experiments and accessing their data.
setExperigenServer
, setExperigenCredentials
registerExperiment
, removeRegistration
, getRegisteredExperiments
The main function is downloadExperiment
. Further information
about the experiment can be inquired with getUsers
and
getDestinations
Returns the version of an Experigen server
server.version(server = getOption("Rexperigen.server"))
server.version(server = getOption("Rexperigen.server"))
server |
The server name |
A string with the Experigen server version
Other development: API.request
,
checkAuthentication
,
create.API.request.URL
,
prepare.server.URL
server.version("db.phonologist.org")
server.version("db.phonologist.org")
Sets up the experimenter credentials for the further requests. It can also check whether the authentication is successful.
setExperigenCredentials(experimenter, password, check = TRUE, quiet = FALSE)
setExperigenCredentials(experimenter, password, check = TRUE, quiet = FALSE)
experimenter |
The experimenter username |
password |
The password for the experimenter |
check |
Whether to check if the experimenter is registered. |
quiet |
If |
Whether the existence check is successful. If check = FALSE
,
it will return TRUE
by default
Other setup: setExperigenServer
## Not run: setExperigenCredentials("joesmith", "1234") ## End(Not run) setExperigenCredentials("janemiller", "passdrow", check = FALSE)
## Not run: setExperigenCredentials("joesmith", "1234") ## End(Not run) setExperigenCredentials("janemiller", "passdrow", check = FALSE)
Rexperigen.server.version
option based on
the response of the server. If check = FALSE
, set
the version by yourself!Sets the Experigen server address for further operations.
By default, it checks the existence of the server and
sets the Rexperigen.server.version
option based on
the response of the server. If check = FALSE
, set
the version by yourself!
setExperigenServer(server, check = TRUE)
setExperigenServer(server, check = TRUE)
server |
The server's URL |
check |
Whether to check the server's existence |
Other setup: setExperigenCredentials
setExperigenServer("db.phonologist.org") setExperigenServer("localhost:3000", FALSE)
setExperigenServer("db.phonologist.org") setExperigenServer("localhost:3000", FALSE)
Returns the main version number of the server.
versionMain()
versionMain()
The main version number as a numeric