Skip to content
This repository was archived by the owner on Oct 28, 2019. It is now read-only.

Commit d2dca90

Browse files
committed
Port help to roxygen. Add package level documentation. Add @Seealso and @family to functions. #3
1 parent 37a7dcc commit d2dca90

21 files changed

+624
-237
lines changed

pkg/DESCRIPTION

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ Maintainer: Microsoft <[email protected]>
88
Description: Functions and datasets to support Azure ML.
99
License: MIT + file LICENSE
1010
LazyData: TRUE
11-
Collate: protocol.R objects.R generic.R
12-
Imports: webapi, purrr, R6, foreign, stringi, uuid
11+
Imports: webapi,
12+
purrr,
13+
R6,
14+
foreign,
15+
stringi,
16+
uuid

pkg/NAMESPACE

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
S3method(`[[`, Datasets)
2-
S3method(`[[`, Experiments)
3-
S3method(as.data.frame, Dataset)
4-
S3method(as.list, Datasets)
5-
S3method(as.list, Experiments)
6-
S3method(length, Datasets)
7-
S3method(length, Experiments)
8-
S3method(names, Datasets)
9-
S3method(names, Experiments)
10-
S3method(update, Dataset)
1+
# Generated by roxygen2 (4.1.1): do not edit by hand
2+
3+
S3method("[[",Datasets)
4+
S3method("[[",Experiments)
5+
S3method(as.data.frame,Dataset)
6+
S3method(as.list,Datasets)
7+
S3method(as.list,Experiments)
8+
S3method(names,Datasets)
9+
S3method(names,Experiments)
1110
export(create)
1211
export(dataset)
1312
export(datasets)
1413
export(experiments)
1514
export(workspace)
1615
import(R6)
1716
import(purrr)
18-
import(webapi)
1917
import(stringi)
20-
importFrom(foreign, read.arff)
21-
importFrom(foreign, write.arff)
22-
importFrom(uuid, UUIDgenerate)
18+
import(webapi)
19+
importFrom(foreign,read.arff)
20+
importFrom(foreign,write.arff)
21+
importFrom(jsonlite,fromJSON)
22+
importFrom(uuid,UUIDgenerate)

pkg/R/azureml-package.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#' Interface to Azure ML Studio datasets and experiments.
2+
#'
3+
#' Allows you to work with Azure ML Studio datasets and experiments directly from R.
4+
#'
5+
#' @section Summary of functions:
6+
#'
7+
#' 1. Create a link to an Azure ML workspace
8+
#'
9+
#' \itemize{
10+
#' \item Link to workspace: \code{\link{workspace}}
11+
#' }
12+
#'
13+
#' 2. Datasets
14+
#'
15+
#' \itemize{
16+
#' \item Get datasets: \code{\link{datasets}}
17+
#' }
18+
#'
19+
#' 3. Experiments
20+
#'
21+
#' \itemize{
22+
#' \item Get experiments: \code{\link{experiments}}
23+
#' }
24+
#'
25+
#' @import R6
26+
#' @import purrr
27+
#' @import webapi
28+
#' @import stringi
29+
#' @importFrom foreign read.arff
30+
#' @importFrom foreign write.arff
31+
#' @importFrom uuid UUIDgenerate
32+
#' @importFrom jsonlite fromJSON
33+
#'
34+
#' @name azureml-package
35+
#' @aliases azureml
36+
#' @docType package
37+
#' @keywords package
38+
NULL

pkg/R/generic.R

Lines changed: 225 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,263 @@
1-
1+
#' Create an object representing an ML studio workspace
2+
#'
3+
#' Create an object that mediates access to a ML studio workspace. This does
4+
#' not actually create an ML studio workspace, it has to exist already.
5+
#'
6+
#' @param id Workspace id from ML studio -> settings -> workspace id
7+
#' @param authorization.token Authorization token from ML studio -> settings -> authorization.tokens
8+
#'
9+
#' @export
10+
#' @seealso \code{\link{datasets}}, \code{\link{experiments}}
11+
#'
12+
#' @return A Workspace object with the following user-accessible elements:
13+
#' \describe{
14+
#' \item{experiments, example.experiments, user.experiments}{Collection of experiments in workspace, optionally filtered for example or user experiments}
15+
#' \item{datasets, example.datasets, user.datasets}{Collection of datasets in workspace, optionally filtered for example or user datasets}
16+
#'}
17+
#' @examples
18+
#'
19+
#' \dontrun{
20+
#' # provide id and auth token from ML studio -> settings
21+
#' workspace(id, authorization.token)
22+
#' }
223
workspace =
324
function(id, authorization.token)
425
Workspace$new(id, authorization.token)
526

27+
28+
29+
#' Extract datasets from experiments
30+
#'
31+
#' Extract datasets from experiments
32+
#'
33+
#' @param workspace workspace object, as returned by \code{\link{workspace}}
34+
#'
35+
#' @param x Experiment from which to extract a dataset
36+
#' @param node Node id
37+
#' @param port Port name
38+
#' @param data.type Format of intermediate data set
39+
#'
40+
#' @return A remote dataset
41+
#' @export
42+
#'
43+
#' @family dataset functions
44+
645
datasets = function(workspace) private(workspace)$datasets
46+
47+
48+
49+
50+
#' Extract experiments from Azure ML studio
51+
#'
52+
#' @inheritParams datasets
53+
#'
54+
#' @export
55+
#' @family experiment functions
756
experiments = function(workspace) private(workspace)$experiments
857

58+
59+
60+
#' Convert Dataset to data.frame
61+
#'
62+
#' @param x Dataset to convert
63+
#' @param row.names Unused for now, needed for consistency with generic
64+
#' @param optional Unused for now, needed for consistency with generic
65+
#' @param \dots Unused for now, needed for consistency with generic
66+
#'
67+
#' @export
68+
#' @family dataset functions
69+
#'
70+
#' @return A data frame with the same contents as the dataset
71+
#'
72+
#' @examples
73+
#'
74+
#' \dontrun{
75+
#' ws = workspace(id, authorization.token)
76+
#' as.data.frame(ws$datasets[[1]])
77+
#' }
78+
979
as.data.frame.Dataset = function(x, row.names = NULL, optional = FALSE, ...) private(x)$as.data.frame()
1080

81+
82+
83+
84+
#' Access experiment or dataset by index or name/id
85+
#'
86+
#' Access individual experiments or datasets in a workspace by index or by name for datasets, id for experiments
87+
#'
88+
#' Both names and ids can be obtained with the function names applied to the experiments or datasets, which are elements of the a workspace object.
89+
90+
#' @param x The experiments or datasets slots of a Workspace object
91+
#' @param i The index of the dataset or experiment
92+
#' @param name The name of the dataset
93+
#' @param id The id of the experiment
94+
95+
#' @export
96+
#' @family dataset functions
97+
98+
#' @return A dataset or experiment object
99+
100+
#' @examples
101+
#' \dontrun{
102+
#' # provide id and auth token from ML studio -> settings
103+
#' ws = workspace(id, authorization.token)
104+
#' experiments(ws)[[1]]
105+
#' datasets(ws)[[1]]
106+
#' # name from ML studio ->datasets -> my datasets or samples -> name or
107+
#' # names(ws$datsets)
108+
#' datasets(ws)[[name]]
109+
#' # id from ML studio -> experiments -> my datasets or samples -> name
110+
#' experiments(ws)[[id]]
111+
#' }
112+
11113
`[[.Datasets` = function(x, i) private(x)$get.item(i)
12114

115+
116+
#' Convert Datsets object to list
117+
#'
118+
#' @export
119+
#' @family dataset functions
120+
#'
121+
#' @return A list of datasets
13122
as.list.Datasets =
14123
function(x, ...) {
15124
y = private(x)$get.datasets()
16125
setNames(y, unlist(map(as.list(y), "Name")))}
17126

127+
128+
#' Return the names of available experiments or datasets.
129+
#'
130+
#' %% ~~ A concise (1-5 lines) description of what the function does. ~~
131+
#'
132+
#' In the case of Experiments, the names are actually experiment ids.
133+
#'
134+
#' @param x Collection of experiments or datasets to extract names from
135+
#'
136+
#' @export
137+
#' @family dataset functions
138+
#' @return A character vector.
139+
#'
140+
#' @examples
141+
#'
142+
#' \dontrun{
143+
#' ws = workspace(id, authorization.token)
144+
#' names(experiments(ws))
145+
#' names(datasets(ws))
146+
#' }
147+
18148
names.Datasets = function(x) names(as.list(x))
19149

150+
151+
152+
#' @export
153+
#' @family dataset functions
20154
`[[.Experiments` = function(x, i) private(x)$get.item(i)
21155

156+
157+
158+
#' Extract datasets from experiments
159+
#'
160+
#' Extract datasets from experiments
161+
#'
162+
#'
163+
#' @param x Experiment from which to extract a dataset
164+
#' @param node Node id
165+
#' @param port Port name
166+
#' @param data.type Format of intermediate data set
167+
#' @return A remote dataset
168+
#'
169+
#' @export dataset
170+
#' @family experiment functions
171+
22172
dataset =
23173
function(x, node, port, data.type) {
24174
private(x)$get.intermediate.dataset(node, port, data.type)}
25175

176+
177+
#' Convert Collection of Datasets and Experiments to lists
178+
#'
179+
#'
180+
#'
181+
#' @param x The object to convert to a list
182+
#' @param \dots Unused, just for compatibility with generic
183+
#'
184+
#' @export
185+
#' @return A Dataset or Experiment object
186+
#' @family experiment functions
187+
188+
#' @examples
189+
#'
190+
#' \dontrun{
191+
#' ws = workspace(id, authorization.token)
192+
#' as.list(experiments(ws))
193+
#' as.list(datasets(ws))
194+
#' }
195+
26196
as.list.Experiments =
27197
function(x, ...) {
28198
y = private(x)$get.experiments()
29199
setNames(y, unlist(map(as.list(y), "ExperimentId")))}
30200

201+
#' @export
202+
#' @family experiment functions
31203
names.Experiments = function(x) names(as.list(x))
32204

205+
206+
207+
208+
209+
210+
211+
212+
213+
214+
215+
216+
217+
#' Create new remote dataset
218+
#'
219+
#' Create a new remote dataset from a dataframe or serialized data/
220+
#'
221+
#'
222+
#' @param data Either a data frame or serialized data.
223+
#' @param workspace The workspace where to create the remote dataset
224+
#' @param data.type The format of \code{data} or to be used to serialize it.
225+
#' @param name A unique name for the data set within a workspace
226+
#' @param description An extended description for the dataset
227+
#' @return A remote dataset object. Can be transformed into a data frame with
228+
#' \code{as.data.frame} or updated with \code{update}
229+
#' @examples
230+
#'
231+
#' \dontrun{
232+
#' ws = workspace(workspace, authorization.token)
233+
#' create(iris3, ws, "GenericCSV", "iris3", "Iris three class data set")
234+
#' }
235+
#' @export create
33236
create =
34237
function(data, workspace, data.type, name, description)
35238
workspace$datasets$add(data, data.type, name, description)
36239

240+
241+
242+
243+
244+
#' Update and existing remote data set
245+
#'
246+
#'
247+
#' Arguments set to NULL are construed as "leave unchanged".
248+
#'
249+
#' @param x A remote dataset object as returned by \code{create} or extracted
250+
#' from a workspace experiments field with the bracket operator/
251+
#' @param data A data frame or serialized data
252+
#' @param data.type The format of \code{data} or to be used to serialize it.
253+
#' @param name A unique name for the dataset
254+
#' @param description An extended description for the dataset
255+
#' @examples
256+
#'
257+
#' \dontrun{
258+
#' ws = workspace(workspace, authorization.token)
259+
#' update(ws$user.datasets[[1]], iris3)
260+
#' }
37261
update.Dataset =
38262
function(
39263
x,

pkg/man/as.data.frame.Dataset.Rd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/generic.R
3+
\name{as.data.frame.Dataset}
4+
\alias{as.data.frame.Dataset}
5+
\title{Convert Dataset to data.frame}
6+
\usage{
7+
\method{as.data.frame}{Dataset}(x, row.names = NULL, optional = FALSE, ...)
8+
}
9+
\arguments{
10+
\item{x}{Dataset to convert}
11+
12+
\item{row.names}{Unused for now, needed for consistency with generic}
13+
14+
\item{optional}{Unused for now, needed for consistency with generic}
15+
16+
\item{\dots}{Unused for now, needed for consistency with generic}
17+
}
18+
\value{
19+
A data frame with the same contents as the dataset
20+
}
21+
\description{
22+
Convert Dataset to data.frame
23+
}
24+
\examples{
25+
\dontrun{
26+
ws = workspace(id, authorization.token)
27+
as.data.frame(ws$datasets[[1]])
28+
}
29+
}
30+
\seealso{
31+
Other dataset functions: \code{\link{[[.Datasets}};
32+
\code{\link{as.list.Datasets}}; \code{\link{datasets}};
33+
\code{\link{names.Datasets}}
34+
}
35+

0 commit comments

Comments
 (0)