The datapubliclu R package provides a convenient interface for
accessing datasets from data.public.lu, the
open data portal of Luxembourg. It simplifies the process of downloading
and importing data directly into your R environment.
You can install the development version of datapubliclu from GitHub
using remotes.
# install.packages("remotes")
remotes::install_github("cavrilionis/datapubliclu")The package provides functions to list available datasets, download specific datasets, and import them into R.
Use the list_datasets() function to retrieve a list of available
datasets.
library(datapubliclu)
datasets <- list_datasets()
print(datasets)To download and import a specific dataset, use the get_dataset()
function, providing the dataset ID.
# Example: Downloading the "Population par commune" dataset
population_data <- get_dataset("population-par-commune")
head(population_data)Use the search_datasets() function to search for datasets based on
keywords.
# Example: Searching for datasets related to "housing"
housing_datasets <- search_datasets("housing")
print(housing_datasets)Use the get_dataset_metadata() function to retrieve metadata for a
specific dataset.
# Example: Retrieving metadata for the
# "Prix de vente des appartements par commune" dataset
metadata <- get_dataset_metadata("prix-de-vente-des-appartements-par-commune")
print(metadata)get_dataset() automatically detects and handles common file formats
(e.g., CSV, XLSX, JSON). You can also specify the file format
explicitly.
# Example: Importing a CSV file
csv_data <- get_dataset("some-dataset-id", format = "csv")
# Example: Importing an Excel file
excel_data <- get_dataset("another-dataset-id", format = "xlsx")library(datapubliclu)
library(dplyr)
library(ggplot2)
population_data <- get_dataset("population-par-commune")
population_summary <- population_data |>
group_by(Commune) |>
summarise(Total_Population = sum(Population)) |>
arrange(desc(Total_Population))
print(head(population_summary))
ggplot(head(population_summary, 10),
aes(x = reorder(Commune, Total_Population), y = Total_Population)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "Top 10 Communes by Population",
x = "Commune",
y = "Total Population")Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request.
Please ensure that your code follows the package’s style guidelines and includes appropriate tests.
Please note that the datapubliclu project is released with a
Contributor Code of
Conduct.
By contributing to this project, you agree to abide by its terms.
This package is licensed under the MIT License.
If you encounter any issues or have questions, please open an issue.
