| Title: | A Simple Connection Between the 'FormShare App' and 'R' for Advanced Analytics |
|---|---|
| Description: | Provides analytics directly from 'R'. It requires: 'FormShare App': <https://github.com/qlands/FormShare >= 2.22.0> . Analytics plugin: <https://github.com/qlands/formshare_analytics_plugin> . Remote SQL plugin: <https://github.com/qlands/formshare_sql_plugin> . |
| Authors: | Carlos Quiros [aut, cre] (ORCID: <https://orcid.org/0000-0002-9485-9961>) |
| Maintainer: | Carlos Quiros <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.1 |
| Built: | 2026-05-15 06:24:20 UTC |
| Source: | https://github.com/qlands/formshare-r-package |
The main FormShare class.
This class encapsulates all functions to execute analytics in FormShare.
user_idThe user ID in FormShare.
api_keyThe API key used to connect to FormShare.
api_secretThe API secret used to connect to FormShare
server_urlThe FormShare server to connect to
logged_inWhether the used has a valid connection
api_tokenToken to use in other functions
token_urlFormShare URL to retrieve a valid token
new()
Create a new FormShare object.
FormShare$new( server_url = "https://formshare.org", user_id = "", api_key = "", api_secret = "" )
server_urlServer URL. By default https://formshare.org
user_idThe user ID to use
api_keyThe API Key to use.
api_secretThe API Secret to use.
A new FormShare object.
get_api_key()
Get the current API key.
FormShare$get_api_key()
set_api_key()
Sets the current API key.
FormShare$set_api_key(new_key)
new_keyNew API key
get_api_secret()
Get the current API secret
FormShare$get_api_secret()
set_api_secret()
Sets the current API secret.
FormShare$set_api_secret(new_secret)
new_secretNew API secret
get_server_url()
Get the current server URL
FormShare$get_server_url()
set_server_url()
Sets the current server URL.
FormShare$set_server_url(new_url)
new_urlNew server URL
login()
Log-in to the FormShare server and stores a API token
FormShare$login()
True of False if the connection was successful.
get_repositories()
Return the repositories that the user has access to.
FormShare$get_repositories()
A data frame with repositories that the user has access to.
get_tables()
Get the tables in a repository.
FormShare$get_tables(repository)
repositoryThe repository to use
A data frame with tables inside a repository.
get_fields()
Get the fields in a table of a repository.
FormShare$get_fields(repository, table)
repositoryThe repository to use
tableThe table to use
A data frame with fields inside a table.
execute()
Executes an SQL and returns it result.
FormShare$execute(repository, sql)
repositoryThe repository to use
sqlSQL to execute
A data frame with the result of the execution.
get_table()
A convenient function to return the contents of a table.
FormShare$get_table(repository, table)
repositoryThe repository to use
tableTable to retrieve
A data frame with data of the table
clone()
The objects of this class are cloneable with this method.
FormShare$clone(deep = FALSE)
deepWhether to make a deep clone.
# This class requires an API key and secret # you can get one at https://formshare.org/ # # Create a new connection to FormShare my_connection = FormShare$new(server_url = "https://formshare.org", user_id = "my_user",api_key = "my_api_key",api_secret = "my_api_secret") # Log in with your account credentials my_connection$login() # Get the repositories that your account has access to repositories = my_connection$get_repositories() # Get the tables in a repository tables = my_connection$get_tables("a_repository") # Get the fields in a table fields = my_connection$get_fields("a_repository", "a_table") # Execute a SQL data = my_connection$execute("a_repository", "SELECT * FROM maintable") # Get the data from a table data = my_connection$get_table("a_repository", "a_table")# This class requires an API key and secret # you can get one at https://formshare.org/ # # Create a new connection to FormShare my_connection = FormShare$new(server_url = "https://formshare.org", user_id = "my_user",api_key = "my_api_key",api_secret = "my_api_secret") # Log in with your account credentials my_connection$login() # Get the repositories that your account has access to repositories = my_connection$get_repositories() # Get the tables in a repository tables = my_connection$get_tables("a_repository") # Get the fields in a table fields = my_connection$get_fields("a_repository", "a_table") # Execute a SQL data = my_connection$execute("a_repository", "SELECT * FROM maintable") # Get the data from a table data = my_connection$get_table("a_repository", "a_table")