The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: A Simple Connection Between the 'FormShare App' and 'R' for Advanced Analytics
Version: 1.0.1
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 .
URL: https://github.com/qlands/formshare-R-package
BugReports: https://github.com/qlands/formshare-R-package/issues
Depends: R (≥ 3.0)
Imports: R6, httr, jsonlite
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.2
StagedInstall: yes
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2023-01-28 15:23:28 UTC; cquiros
Author: Carlos Quiros ORCID iD [aut, cre]
Maintainer: Carlos Quiros <cquiros@qlands.com>
Repository: CRAN
Date/Publication: 2023-01-28 15:40:02 UTC

An R6 Class Representing a connection to FormShare

Description

The main FormShare class.

Details

This class encapsulates all functions to execute analytics in FormShare.

Public fields

user_id

The user ID in FormShare.

api_key

The API key used to connect to FormShare.

api_secret

The API secret used to connect to FormShare

server_url

The FormShare server to connect to

logged_in

Whether the used has a valid connection

api_token

Token to use in other functions

token_url

FormShare URL to retrieve a valid token

Methods

Public methods


Method new()

Create a new FormShare object.

Usage
FormShare$new(
  server_url = "https://formshare.org",
  user_id = "",
  api_key = "",
  api_secret = ""
)
Arguments
server_url

Server URL. By default https://formshare.org

user_id

The user ID to use

api_key

The API Key to use.

api_secret

The API Secret to use.

Returns

A new FormShare object.


Method get_api_key()

Get the current API key.

Usage
FormShare$get_api_key()

Method set_api_key()

Sets the current API key.

Usage
FormShare$set_api_key(new_key)
Arguments
new_key

New API key


Method get_api_secret()

Get the current API secret

Usage
FormShare$get_api_secret()

Method set_api_secret()

Sets the current API secret.

Usage
FormShare$set_api_secret(new_secret)
Arguments
new_secret

New API secret


Method get_server_url()

Get the current server URL

Usage
FormShare$get_server_url()

Method set_server_url()

Sets the current server URL.

Usage
FormShare$set_server_url(new_url)
Arguments
new_url

New server URL


Method login()

Log-in to the FormShare server and stores a API token

Usage
FormShare$login()
Returns

True of False if the connection was successful.


Method get_repositories()

Return the repositories that the user has access to.

Usage
FormShare$get_repositories()
Returns

A data frame with repositories that the user has access to.


Method get_tables()

Get the tables in a repository.

Usage
FormShare$get_tables(repository)
Arguments
repository

The repository to use

Returns

A data frame with tables inside a repository.


Method get_fields()

Get the fields in a table of a repository.

Usage
FormShare$get_fields(repository, table)
Arguments
repository

The repository to use

table

The table to use

Returns

A data frame with fields inside a table.


Method execute()

Executes an SQL and returns it result.

Usage
FormShare$execute(repository, sql)
Arguments
repository

The repository to use

sql

SQL to execute

Returns

A data frame with the result of the execution.


Method get_table()

A convenient function to return the contents of a table.

Usage
FormShare$get_table(repository, table)
Arguments
repository

The repository to use

table

Table to retrieve

Returns

A data frame with data of the table


Method clone()

The objects of this class are cloneable with this method.

Usage
FormShare$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


# 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")

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.