Skip to content

Commit 0980221

Browse files
authored
Merge pull request #1 from datashield/v1.0.0-dev
first commit
2 parents cedd617 + 002967c commit 0980221

14 files changed

Lines changed: 539 additions & 1 deletion

DESCRIPTION

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Package: dsExampleClient
2+
Title: Provide an example of DataSHIELD Client-Side package
3+
Version: 1.0.0
4+
Authors@R:
5+
person("Tim", "Cadman", , "t.j.cadman@umcg.nl", role = c("aut", "cre"),
6+
comment = c(ORCID = "0000-0002-7682-5645"))
7+
Description: A complete DataSHIELD client-side package containing one exported function as an example how to create a DataSHIELD package.
8+
License: LGPL (>= 3)
9+
Encoding: UTF-8
10+
Roxygen: list(markdown = TRUE)
11+
RoxygenNote: 7.3.2
12+
Imports:
13+
DSI,
14+
cli
15+
Suggests:
16+
knitr,
17+
rmarkdown,
18+
testthat (>= 3.0.0),
19+
DSLite,
20+
devtools,
21+
dsBase
22+
Config/testthat/edition: 3
23+
VignetteBuilder: knitr

LICENSE.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
GNU Lesser General Public License
2+
=================================
3+
4+
_Version 3, 29 June 2007_
5+
_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
6+
7+
Everyone is permitted to copy and distribute verbatim copies
8+
of this license document, but changing it is not allowed.
9+
10+
11+
This version of the GNU Lesser General Public License incorporates
12+
the terms and conditions of version 3 of the GNU General Public
13+
License, supplemented by the additional permissions listed below.
14+
15+
### 0. Additional Definitions
16+
17+
As used herein, “this License” refers to version 3 of the GNU Lesser
18+
General Public License, and the “GNU GPL” refers to version 3 of the GNU
19+
General Public License.
20+
21+
“The Library” refers to a covered work governed by this License,
22+
other than an Application or a Combined Work as defined below.
23+
24+
An “Application” is any work that makes use of an interface provided
25+
by the Library, but which is not otherwise based on the Library.
26+
Defining a subclass of a class defined by the Library is deemed a mode
27+
of using an interface provided by the Library.
28+
29+
A “Combined Work” is a work produced by combining or linking an
30+
Application with the Library. The particular version of the Library
31+
with which the Combined Work was made is also called the “Linked
32+
Version”.
33+
34+
The “Minimal Corresponding Source” for a Combined Work means the
35+
Corresponding Source for the Combined Work, excluding any source code
36+
for portions of the Combined Work that, considered in isolation, are
37+
based on the Application, and not on the Linked Version.
38+
39+
The “Corresponding Application Code” for a Combined Work means the
40+
object code and/or source code for the Application, including any data
41+
and utility programs needed for reproducing the Combined Work from the
42+
Application, but excluding the System Libraries of the Combined Work.
43+
44+
### 1. Exception to Section 3 of the GNU GPL
45+
46+
You may convey a covered work under sections 3 and 4 of this License
47+
without being bound by section 3 of the GNU GPL.
48+
49+
### 2. Conveying Modified Versions
50+
51+
If you modify a copy of the Library, and, in your modifications, a
52+
facility refers to a function or data to be supplied by an Application
53+
that uses the facility (other than as an argument passed when the
54+
facility is invoked), then you may convey a copy of the modified
55+
version:
56+
57+
* **a)** under this License, provided that you make a good faith effort to
58+
ensure that, in the event an Application does not supply the
59+
function or data, the facility still operates, and performs
60+
whatever part of its purpose remains meaningful, or
61+
62+
* **b)** under the GNU GPL, with none of the additional permissions of
63+
this License applicable to that copy.
64+
65+
### 3. Object Code Incorporating Material from Library Header Files
66+
67+
The object code form of an Application may incorporate material from
68+
a header file that is part of the Library. You may convey such object
69+
code under terms of your choice, provided that, if the incorporated
70+
material is not limited to numerical parameters, data structure
71+
layouts and accessors, or small macros, inline functions and templates
72+
(ten or fewer lines in length), you do both of the following:
73+
74+
* **a)** Give prominent notice with each copy of the object code that the
75+
Library is used in it and that the Library and its use are
76+
covered by this License.
77+
* **b)** Accompany the object code with a copy of the GNU GPL and this license
78+
document.
79+
80+
### 4. Combined Works
81+
82+
You may convey a Combined Work under terms of your choice that,
83+
taken together, effectively do not restrict modification of the
84+
portions of the Library contained in the Combined Work and reverse
85+
engineering for debugging such modifications, if you also do each of
86+
the following:
87+
88+
* **a)** Give prominent notice with each copy of the Combined Work that
89+
the Library is used in it and that the Library and its use are
90+
covered by this License.
91+
92+
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
93+
document.
94+
95+
* **c)** For a Combined Work that displays copyright notices during
96+
execution, include the copyright notice for the Library among
97+
these notices, as well as a reference directing the user to the
98+
copies of the GNU GPL and this license document.
99+
100+
* **d)** Do one of the following:
101+
- **0)** Convey the Minimal Corresponding Source under the terms of this
102+
License, and the Corresponding Application Code in a form
103+
suitable for, and under terms that permit, the user to
104+
recombine or relink the Application with a modified version of
105+
the Linked Version to produce a modified Combined Work, in the
106+
manner specified by section 6 of the GNU GPL for conveying
107+
Corresponding Source.
108+
- **1)** Use a suitable shared library mechanism for linking with the
109+
Library. A suitable mechanism is one that **(a)** uses at run time
110+
a copy of the Library already present on the user's computer
111+
system, and **(b)** will operate properly with a modified version
112+
of the Library that is interface-compatible with the Linked
113+
Version.
114+
115+
* **e)** Provide Installation Information, but only if you would otherwise
116+
be required to provide such information under section 6 of the
117+
GNU GPL, and only to the extent that such information is
118+
necessary to install and execute a modified version of the
119+
Combined Work produced by recombining or relinking the
120+
Application with a modified version of the Linked Version. (If
121+
you use option **4d0**, the Installation Information must accompany
122+
the Minimal Corresponding Source and Corresponding Application
123+
Code. If you use option **4d1**, you must provide the Installation
124+
Information in the manner specified by section 6 of the GNU GPL
125+
for conveying Corresponding Source.)
126+
127+
### 5. Combined Libraries
128+
129+
You may place library facilities that are a work based on the
130+
Library side by side in a single library together with other library
131+
facilities that are not Applications and are not covered by this
132+
License, and convey such a combined library under terms of your
133+
choice, if you do both of the following:
134+
135+
* **a)** Accompany the combined library with a copy of the same work based
136+
on the Library, uncombined with any other library facilities,
137+
conveyed under the terms of this License.
138+
* **b)** Give prominent notice with the combined library that part of it
139+
is a work based on the Library, and explaining where to find the
140+
accompanying uncombined form of the same work.
141+
142+
### 6. Revised Versions of the GNU Lesser General Public License
143+
144+
The Free Software Foundation may publish revised and/or new versions
145+
of the GNU Lesser General Public License from time to time. Such new
146+
versions will be similar in spirit to the present version, but may
147+
differ in detail to address new problems or concerns.
148+
149+
Each version is given a distinguishing version number. If the
150+
Library as you received it specifies that a certain numbered version
151+
of the GNU Lesser General Public License “or any later version”
152+
applies to it, you have the option of following the terms and
153+
conditions either of that published version or of any later version
154+
published by the Free Software Foundation. If the Library as you
155+
received it does not specify a version number of the GNU Lesser
156+
General Public License, you may choose any version of the GNU Lesser
157+
General Public License ever published by the Free Software Foundation.
158+
159+
If the Library as you received it specifies that a proxy can decide
160+
whether future versions of the GNU Lesser General Public License shall
161+
apply, that proxy's public statement of acceptance of any version is
162+
permanent authorization for you to choose that version for the
163+
Library.

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(ds.funLevels)
4+
importFrom(DSI,datashield.aggregate)
5+
importFrom(DSI,datashield.connections_find)
6+
importFrom(cli,cli_abort)

R/ds.funLevels.R

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#' @title Returns levels of a factor variable with fun message
2+
#' @description Retrieves the number of columns in a dataset and provides a motivational message
3+
#' @param x a character string providing the name of the input data frame or matrix.
4+
#' @param fun_message a character string with the motivational message
5+
#' @param datasources a list of \code{\link{DSConnection-class}} objects obtained after login.
6+
#' If the \code{datasources} argument is not specified
7+
#' the default set of connections will be used: see \code{\link{datashield.connections_default}}.
8+
#' @return \code{ds.funLevels} returns the levels prefixed by a fun message
9+
#' @author Tim Cadman
10+
#' @importFrom DSI datashield.aggregate datashield.connections_find
11+
#' @examples
12+
#' \dontrun{
13+
#' ds.funLevels(
14+
#' df.name = "iris$Species",
15+
#' fun_message = "This is a fun message ,",
16+
#' dataources = conns
17+
#' )
18+
#' }
19+
#' @export
20+
ds.funLevels <- function(x=NULL, fun_message=NULL, datasources=NULL) {
21+
22+
if(is.null(datasources)){
23+
datasources <- datashield.connections_find()
24+
}
25+
26+
.check_args(x, fun_message)
27+
fun_message_no_spaces <- gsub(" ", "", fun_message)
28+
cally <- call("funLevelsDS", x, fun_message_no_spaces)
29+
fun_levels <- DSI::datashield.aggregate(datasources, cally)
30+
31+
return(fun_levels)
32+
33+
}
34+
35+
#' Validate Arguments
36+
#'
37+
#' This function checks whether the provided arguments meet the expected conditions.
38+
#' It ensures that `x` and `fun_message` are not `NULL` and that both are character vectors.
39+
#'
40+
#' @param x A character vector. Must not be `NULL`.
41+
#' @param fun_message A character vector. Must not be `NULL`.
42+
#' @return This function does not return a value. It throws an error if any of the conditions are not met.
43+
#' @importFrom cli cli_abort
44+
.check_args <- function(x, fun_message) {
45+
46+
if(is.null(x)) {
47+
cli_abort("`x` must not be NULL")
48+
}
49+
50+
if(is.null(fun_message)) {
51+
cli_abort("`fun_message` must not be NULL")
52+
}
53+
54+
x_class <- class(x)
55+
message_class <- class(fun_message)
56+
57+
if(x_class != "character") {
58+
cli_abort(
59+
c(
60+
"x" = "`x` must be a character vector",
61+
"i" = "You have provided an input with class {x_class}")
62+
)
63+
}
64+
65+
if(message_class != "character") {
66+
cli_abort(
67+
c(
68+
"x" = "`fun_message` must be a character vector",
69+
"i" = "You have provided an input with class {message_class}")
70+
)
71+
}
72+
73+
}

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1+
12
# dsExampleClient
2-
DataSHIELD Example Client
3+
4+
The goal of dsExampleClient is to show how to write a basic DataSHIELD client-side package.
5+
6+
## Installation
7+
8+
Clone this repository by opening the terminal in R and typing:
9+
10+
```
11+
git clone https://github.com/timcadman/dsExample my/target/path
12+
```
13+
14+
To use this package as a template for your new DataSHIELD package, perform the following steps:
15+
- Log in to Github and create a github repository for your new package
16+
- Create a local folder for your new package and copy this repository to that folder
17+
- Open the terminal in R, navigate to the folder of your new package and type:
18+
```
19+
git init
20+
```
21+
22+
## Link this package with your new repository by typing in the terminal:
23+
```
24+
git remote add origin https://github.com/myGithubUsername/myNewPackageClient
25+
```
26+

dsExampleClient.Rproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: No
4+
SaveWorkspace: No
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
LineEndingConversion: Posix
18+
19+
BuildType: Package
20+
PackageUseDevtools: Yes
21+
PackageInstallArgs: --no-multiarch --with-keep.source
22+
PackageRoxygenize: rd,collate,namespace

man/dot-check_args.Rd

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ds.funLevels.Rd

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is part of the standard setup for testthat.
2+
# It is recommended that you do not modify it.
3+
#
4+
# Where should you do additional test configuration?
5+
# Learn more about the roles of various files in:
6+
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
7+
# * https://testthat.r-lib.org/articles/special-files.html
8+
9+
library(testthat)
10+
library(dsExampleClient)
11+
12+
test_check("dsExampleClient")

0 commit comments

Comments
 (0)