-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
121 lines (90 loc) · 3.33 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ucimlrepo <img src="man/figures/logo-ucimlrepo.png" align ="right" alt="A hexagonal logo of the ucimlrepo R package that shows data being downloaded from a repository" width ="150"/>
<!-- badges: start -->
[![R-CMD-check](https://github.com/coatless-rpkg/ucimlrepo/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/coatless-rpkg/ucimlrepo/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of `ucimlrepo` is to download and import data sets directly into R
from the [UCI Machine Learning Repository](https://archive.ics.uci.edu/).
> [!IMPORTANT]
>
> This package is an unoffical port of the [Python `ucimlrepo` package](https://github.com/uci-ml-repo/ucimlrepo).
> [!NOTE]
>
> Want to have datasets alongside a help documentation entry?
>
> Check out the [`{ucidata}`](https://github.com/coatless-rpkg/ucidata) R package!
> The package provides a small selection of data sets from the
> UC Irvine Machine Learning Repository alongside of help entries.
## Installation
You can install the development version of ucimlrepo from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("coatless-rpkg/ucimlrepo")
```
## Usage
To use `ucimlrepo`, load the package using:
```{r}
#| label: load-pkg
library(ucimlrepo)
```
With the package now loaded, we can download a dataset using the `fetch_ucirepo()` function
or use the `list_available_datasets()` function to view a list of available datasets.
### Download data
For example, to download the `iris` dataset, we can use:
```{r}
#| label: download dataset
# Fetch a dataset by name
iris_by_name <- fetch_ucirepo(name = "iris")
names(iris_by_name)
```
There are many levels to the data returned. For example, we can extract the
original data frame containing the `iris` dataset using:
```{r}
iris_uci <- iris_by_name$data$original
head(iris_uci)
```
Alternatively, we could retrieve two data frames, one for the features and one for the targets:
```{r}
iris_features <- iris_by_name$data$features
iris_targets <- iris_by_name$data$targets
```
We can then view the first few rows of each data frame:
```{r}
head(iris_features)
head(iris_targets)
```
Alternatively, you can also directly query by using an ID found by using
`list_available_datasets()` or by looking up the dataset on the UCI ML Repo website:
```{r}
#| label: download dataset by id
#| eval: false
# Fetch a dataset by id
iris_by_id <- fetch_ucirepo(id = 53)
```
### View list of data sets
We can also view a list of data sets available for download
using the `list_available_datasets()` function:
```{r}
#| label: list-packages
#| eval: false
# List available datasets
list_available_datasets()
```
> [!NOTE]
>
> Not all 600+ datasets on UCI ML Repo are available for download using the package.
> The current list of available datasets can be viewed [here](https://archive.ics.uci.edu/datasets?Python=true&skip=0&take=25&sort=desc&orderBy=NumHits).
>
> If you would like to see a specific dataset added, please submit a comment
> on an [issue ticket in the upstream repository](https://github.com/uci-ml-repo/ucimlrepo/issues/9).