diff --git a/DESCRIPTION b/DESCRIPTION index e497a14..49f0d07 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,12 +17,16 @@ Imports: ggplot2, purrr, tibble, - curl + curl, + rlang, + stringr, + tidyr, + wordcloud2 Suggests: testthat (>= 3.0.0), rmarkdown, knitr -URL: https://github.com/rOpenGov/finna +URL: https://ropengov.github.io/finna/ BugReports: https://github.com/rOpenGov/finna/issues Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index 3c8f6ec..f7ed2dd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,12 +8,21 @@ export(refine_metadata) export(search_finna) export(visualize_author_distribution) export(visualize_format_distribution) +export(visualize_format_distribution_pie) +export(visualize_format_library_correlation) export(visualize_library_distribution) export(visualize_subject_distribution) +export(visualize_title_year_heatmap) export(visualize_top_20_titles) +export(visualize_word_cloud) export(visualize_year_distribution) +export(visualize_year_distribution_line) import(dplyr) import(ggplot2) +import(rlang) +import(stringr) +import(tidyr) +import(wordcloud2) importFrom(curl,curl_download) importFrom(httr,GET) importFrom(httr,content) diff --git a/R/search_finna.R b/R/search_finna.R index 938c3c6..4ee9fb7 100644 --- a/R/search_finna.R +++ b/R/search_finna.R @@ -57,6 +57,9 @@ search_finna <- function(query = NULL,#lookfor page <- 1 records_per_page <- 100 # Fetch 100 records per page for efficiency + # Initialize resultCount + result_count <- 0 + while (total_fetched < limit) { # Calculate the remaining number of records to fetch remaining_to_fetch <- min(records_per_page, limit - total_fetched) @@ -66,7 +69,7 @@ search_finna <- function(query = NULL,#lookfor lookfor = query, type = type, `field[]` = fields, - `filter[]` = filters, + # `filter[]` = filters, `facet[]` = facets, `facetFilter[]` = facetFilters, sort = sort, @@ -76,6 +79,13 @@ search_finna <- function(query = NULL,#lookfor prettyPrint = prettyPrint ) + # Add filters to the query parameters (handle each filter as filter[]) + if (!is.null(filters)) { + for (i in seq_along(filters)) { + query_params[[paste0('filter[', i, ']')]] <- filters[i] + } + } + # Execute the GET request and handle potential errors response <- tryCatch( httr::GET(base_url, query = query_params), @@ -90,6 +100,11 @@ search_finna <- function(query = NULL,#lookfor # Parse the JSON content of the response search_results <- httr::content(response, "parsed") + # Extract resultCount only from the first page + if (page == 1) { + result_count <- search_results$resultCount + } + # Extract and structure relevant data from the search results records <- search_results$records if (is.null(records) || length(records) == 0) { @@ -163,5 +178,8 @@ search_finna <- function(query = NULL,#lookfor # Attach the language attribute to the tibble attr(tibble_results, "language") <- lng #cat("Data retrieved from Finna API (https://www.finna.fi) - metadata licensed under CC0.\n") + #return(tibble_results) + attr(tibble_results, "result_count") <- result_count return(tibble_results) + } diff --git a/R/visualizeFinna.R b/R/visualizeFinna.R index 796658a..ee745d9 100644 --- a/R/visualizeFinna.R +++ b/R/visualizeFinna.R @@ -23,6 +23,41 @@ visualize_year_distribution <- function(year_data) { ) } +#' Visualize Year Distribution (Line Plot) +#' +#' Creates a line plot showing the distribution of records by year. +#' +#' @param metadata A tibble containing refined Finna metadata, with a "Year" column. +#' @return A ggplot2 object representing the line plot. +#' @import ggplot2 +#' @import dplyr +#' @export +#' @examples +#' library(finna) +#' sibelius_data <- search_finna("sibelius") +#' refined_data <- refine_metadata(sibelius_data) +#' visualize_year_distribution_line(refined_data) +visualize_year_distribution_line <- function(metadata) { + # Convert the Year to numeric + metadata <- metadata %>% + mutate(Year = as.numeric(Year)) %>% + filter(!is.na(Year)) + + # Count the number of records by year + year_distribution <- metadata %>% + count(Year, sort = TRUE) + + # Plot the year distribution as a line plot + ggplot(year_distribution, aes(x = Year, y = n)) + + geom_line(color = "steelblue", size = 1) + + theme_minimal() + + labs( + title = "Yearly Distribution of Records", + x = "Year", + y = "Number of Records" + ) +} + #' Visualize Top-20 Titles by Count #' #' Creates a bar plot showing the top-20 most frequent titles and their counts. @@ -31,6 +66,7 @@ visualize_year_distribution <- function(year_data) { #' @return A ggplot2 object showing the bar plot of the top-20 titles. #' @import ggplot2 #' @import dplyr +#' @import stringr #' @export #' @examples #' library(finna) @@ -38,9 +74,12 @@ visualize_year_distribution <- function(year_data) { #' refined_data <- refine_metadata(sibelius_data) #' visualize_top_20_titles(refined_data) visualize_top_20_titles <- function(metadata) { - # Convert titles to lowercase for case-insensitive comparison + # Clean the titles: Convert to lowercase, remove punctuation, and trim whitespace metadata <- metadata %>% - mutate(Title = tolower(Title)) + mutate(Title = tolower(Title), # Convert to lowercase + Title = stringr::str_trim(Title), # Trim leading and trailing whitespace + Title = stringr::str_squish(Title), # Remove extra spaces between words + Title = stringr::str_replace_all(Title, "[[:punct:]]", "")) # Remove punctuation # Calculate the top-20 titles top_titles <- metadata %>% @@ -59,6 +98,52 @@ visualize_top_20_titles <- function(metadata) { ) } +#' Visualize Heatmap of Titles by Year +#' +#' Creates a heatmap showing the most frequent titles and their occurrence over time. +#' +#' @param metadata A tibble containing refined Finna metadata, with "Title" and "Year" columns. +#' @return A ggplot2 object showing the heatmap of title frequency by year. +#' @import ggplot2 +#' @import dplyr +#' @export +#' @examples +#' library(finna) +#' sibelius_data <- search_finna("sibelius") +#' refined_data <- refine_metadata(sibelius_data) +#' visualize_title_year_heatmap(refined_data) +visualize_title_year_heatmap <- function(metadata) { + # Clean the data + metadata <- metadata %>% + mutate(Title = tolower(Title), # Convert to lowercase + Title = stringr::str_trim(Title), # Trim leading/trailing whitespace + Year = as.numeric(Year)) %>% # Convert year to numeric + filter(!is.na(Year), !is.na(Title)) %>% + count(Title, Year) + + # Filter top 20 titles by total count + top_titles <- metadata %>% + group_by(Title) %>% + summarise(total = sum(n)) %>% + top_n(20, total) %>% + pull(Title) + + # Filter metadata to include only top titles + metadata_filtered <- metadata %>% filter(Title %in% top_titles) + + # Plot the heatmap + ggplot(metadata_filtered, aes(x = Year, y = reorder(Title, n), fill = n)) + + geom_tile() + + scale_fill_gradient(low = "white", high = "steelblue") + + theme_minimal() + + labs( + title = "Heatmap of Top 20 Titles by Year", + x = "Year", + y = "Title", + fill = "Count" + ) +} + #' Visualize Distribution by Formats #' @@ -95,6 +180,41 @@ visualize_format_distribution <- function(metadata) { ) } +#' Visualize Correlation Between Formats and Libraries +#' +#' Creates a heatmap showing the correlation between formats and libraries. +#' +#' @param metadata A tibble containing refined Finna metadata, with "Formats" and "Library" columns. +#' @return A ggplot2 object showing the heatmap of format-library correlation. +#' @import ggplot2 +#' @import dplyr +#' @export +#' @examples +#' library(finna) +#' sibelius_data <- search_finna("sibelius") +#' refined_data <- refine_metadata(sibelius_data) +#' visualize_format_library_correlation(refined_data) +visualize_format_library_correlation <- function(metadata) { + # Clean and count format-library combinations + format_library_dist <- metadata %>% + mutate(Formats = tolower(Formats), + Library = tolower(Library)) %>% + count(Formats, Library) %>% + filter(!is.na(Formats), !is.na(Library)) + + # Plot the heatmap + ggplot(format_library_dist, aes(x = Formats, y = Library, fill = n)) + + geom_tile() + + scale_fill_gradient(low = "white", high = "darkorange") + + theme_minimal() + + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + # Rotate x-axis labels + labs( + title = "Correlation Between Formats and Libraries", + x = "Format", + y = "Library", + fill = "Count" + ) +} #' Visualize Distribution by Libraries #' @@ -234,5 +354,72 @@ visualize_subject_distribution <- function(metadata) { ) } +#' Visualize Word Cloud of Titles or Subjects +#' +#' Creates a word cloud showing the frequency of words in titles or subjects. +#' +#' @param metadata A tibble containing refined Finna metadata, with "Title" or "Subjects" column. +#' @param column The column to visualize as a word cloud (e.g., "Title" or "Subjects"). +#' @return A word cloud plot of the most frequent words. +#' @import wordcloud2 +#' @import dplyr +#' @import tidyr +#' @import rlang +#' @export +#' @examples +#' library(finna) +#' music_data <- search_finna("music") +#' refined_data <- refine_metadata(music_data) +#' visualize_word_cloud(refined_data, "Title") +visualize_word_cloud <- function(metadata, column = "Title") { + # Convert the column name to symbol + column <- rlang::ensym(column) + + # Clean and split words + words <- metadata %>% + select(!!column) %>% + mutate(!!column := tolower(!!column)) %>% + tidyr::separate_rows(!!column, sep = " ") %>% + count(!!column, sort = TRUE) %>% + filter(!is.na(!!column), nchar(!!column) > 1) # Remove NA and short words + + # Create word cloud + wordcloud2::wordcloud2(data = words) +} + + + +#' Visualize Format Distribution as Pie Chart +#' +#' Creates a pie chart showing the distribution of records by formats. +#' +#' @param metadata A tibble containing refined Finna metadata, with a "Formats" column. +#' @return A ggplot2 object showing the pie chart of format distribution. +#' @import ggplot2 +#' @import dplyr +#' @export +#' @examples +#' library(finna) +#' sibelius_data <- search_finna("sibelius") +#' refined_data <- refine_metadata(sibelius_data) +#' visualize_format_distribution_pie(refined_data) +visualize_format_distribution_pie <- function(metadata) { + # Clean and count the format distribution + format_distribution <- metadata %>% + mutate(Formats = tolower(Formats)) %>% + count(Formats, sort = TRUE) + + # Plot the pie chart + ggplot(format_distribution, aes(x = "", y = n, fill = Formats)) + + geom_bar(stat = "identity", width = 1) + + coord_polar("y") + + theme_void() + # Remove background and axis + labs( + title = "Distribution of Formats", + fill = "Formats" + ) +} + + diff --git a/custom.css b/custom.css deleted file mode 100644 index 5e21ff2..0000000 --- a/custom.css +++ /dev/null @@ -1,52 +0,0 @@ -# Define the custom CSS -css_content <- " -/* Make sure the table takes up the full width and content wraps */ -table { - width: 100%; - border-collapse: collapse; /* Ensures that borders are collapsed into a single border */ - word-wrap: break-word; /* Ensure long words are wrapped */ -} - -th, td { - padding: 10px; /* Add padding to table cells */ - text-align: left; /* Align text to the left */ - vertical-align: top; /* Align text to the top for multi-line cells */ - border-bottom: 1px solid #ddd; /* Add a border under each cell */ - word-break: break-word; /* Break long words to fit in the cell */ -} - -/* Add some space between the columns */ -th, td { - padding: 8px 12px; -} - -/* Make the header row stand out */ -th { - background-color: #f2f2f2; /* Light gray background for headers */ - font-weight: bold; -} - -/* Add a hover effect for table rows */ -tr:hover { - background-color: #f5f5f5; /* Light gray background on hover */ -} - -/* Make the table responsive by allowing horizontal scrolling */ -.table-wrapper { - overflow-x: auto; - -webkit-overflow-scrolling: touch; /* For smooth scrolling on mobile devices */ -} - -/* Ensure long URLs or text don't overflow */ -td { - white-space: pre-wrap; /* Preserve spaces and wrap text */ -} - -/* Optional: add some color to every other row for readability */ -tr:nth-child(even) { - background-color: #f9f9f9; -} -" - -# Write the CSS content to a file -writeLines(css_content, "pkgdown/assets/custom.css") diff --git a/FinnaR.Rproj b/finna.Rproj similarity index 100% rename from FinnaR.Rproj rename to finna.Rproj diff --git a/man/visualize_format_distribution_pie.Rd b/man/visualize_format_distribution_pie.Rd new file mode 100644 index 0000000..0ab3e51 --- /dev/null +++ b/man/visualize_format_distribution_pie.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualizeFinna.R +\name{visualize_format_distribution_pie} +\alias{visualize_format_distribution_pie} +\title{Visualize Format Distribution as Pie Chart} +\usage{ +visualize_format_distribution_pie(metadata) +} +\arguments{ +\item{metadata}{A tibble containing refined Finna metadata, with a "Formats" column.} +} +\value{ +A ggplot2 object showing the pie chart of format distribution. +} +\description{ +Creates a pie chart showing the distribution of records by formats. +} +\examples{ +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_format_distribution_pie(refined_data) +} diff --git a/man/visualize_format_library_correlation.Rd b/man/visualize_format_library_correlation.Rd new file mode 100644 index 0000000..fed48d2 --- /dev/null +++ b/man/visualize_format_library_correlation.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualizeFinna.R +\name{visualize_format_library_correlation} +\alias{visualize_format_library_correlation} +\title{Visualize Correlation Between Formats and Libraries} +\usage{ +visualize_format_library_correlation(metadata) +} +\arguments{ +\item{metadata}{A tibble containing refined Finna metadata, with "Formats" and "Library" columns.} +} +\value{ +A ggplot2 object showing the heatmap of format-library correlation. +} +\description{ +Creates a heatmap showing the correlation between formats and libraries. +} +\examples{ +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_format_library_correlation(refined_data) +} diff --git a/man/visualize_title_year_heatmap.Rd b/man/visualize_title_year_heatmap.Rd new file mode 100644 index 0000000..08a8ee8 --- /dev/null +++ b/man/visualize_title_year_heatmap.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualizeFinna.R +\name{visualize_title_year_heatmap} +\alias{visualize_title_year_heatmap} +\title{Visualize Heatmap of Titles by Year} +\usage{ +visualize_title_year_heatmap(metadata) +} +\arguments{ +\item{metadata}{A tibble containing refined Finna metadata, with "Title" and "Year" columns.} +} +\value{ +A ggplot2 object showing the heatmap of title frequency by year. +} +\description{ +Creates a heatmap showing the most frequent titles and their occurrence over time. +} +\examples{ +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_title_year_heatmap(refined_data) +} diff --git a/man/visualize_word_cloud.Rd b/man/visualize_word_cloud.Rd new file mode 100644 index 0000000..e65b41b --- /dev/null +++ b/man/visualize_word_cloud.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualizeFinna.R +\name{visualize_word_cloud} +\alias{visualize_word_cloud} +\title{Visualize Word Cloud of Titles or Subjects} +\usage{ +visualize_word_cloud(metadata, column = "Title") +} +\arguments{ +\item{metadata}{A tibble containing refined Finna metadata, with "Title" or "Subjects" column.} + +\item{column}{The column to visualize as a word cloud (e.g., "Title" or "Subjects").} +} +\value{ +A word cloud plot of the most frequent words. +} +\description{ +Creates a word cloud showing the frequency of words in titles or subjects. +} +\examples{ +library(finna) +music_data <- search_finna("music") +refined_data <- refine_metadata(music_data) +visualize_word_cloud(refined_data, "Title") +} diff --git a/man/visualize_year_distribution_line.Rd b/man/visualize_year_distribution_line.Rd new file mode 100644 index 0000000..9210ba9 --- /dev/null +++ b/man/visualize_year_distribution_line.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visualizeFinna.R +\name{visualize_year_distribution_line} +\alias{visualize_year_distribution_line} +\title{Visualize Year Distribution (Line Plot)} +\usage{ +visualize_year_distribution_line(metadata) +} +\arguments{ +\item{metadata}{A tibble containing refined Finna metadata, with a "Year" column.} +} +\value{ +A ggplot2 object representing the line plot. +} +\description{ +Creates a line plot showing the distribution of records by year. +} +\examples{ +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_year_distribution_line(refined_data) +} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index ad2ce3f..c80fdd8 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -1,4 +1,4 @@ -url: ~ +url: https://ropengov.github.io/finna/ template: # Use Bootstrap 5 for the site styling diff --git a/vignettes/articles/Fennica.Rmd b/vignettes/articles/Fennica.Rmd new file mode 100644 index 0000000..597172a --- /dev/null +++ b/vignettes/articles/Fennica.Rmd @@ -0,0 +1,59 @@ +--- +title: "Fennica in Finna" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Fennica in Finna} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +## Fennica + +To search Fennica data in Finna + +```{r} +library(finna) +fennica <- search_finna("*",filters=c('collection:"FEN"')) +print(fennica) +``` + +## Bulk data + +In order to download the whole data we can add the parameter `limit = Inf` +as `search_finna("*",filters=c('collection:"FEN"'), limit = Inf)` + +## Checking the total counts + +search the whole data and it total search of counts in the the interval between +some years for example between the years 1809-1917 as follows: + +```{r} +library(finna) +fennica <- search_finna("*",filters = c('collection:"FEN"', 'search_daterange_mv:"[1809 TO 1918]"')) +print(fennica) +``` + +we can check the whole data count + +```{r} +library(finna) +fennica <- search_finna("*",filters = c('collection:"FEN"', 'search_daterange_mv:"[1809 TO 1918]"')) +result_count <- attr(fennica, "result_count") +print(result_count) +``` + +## Visualization for fennica + +We can use any of the functions provided to visualize the data +```{r} +library(finna) +fennica <- search_finna("*",filters = c('collection:"FEN"', 'search_daterange_mv:"[1809 TO 1918]"')) +refined_data <- refine_metadata(fennica) +visualize_author_distribution(refined_data) +``` + +```{r} +fennica <- search_finna("*",filters = c('collection:"FEN"', 'search_daterange_mv:"[1809 TO 1918]"')) +refined_data <- refine_metadata(fennica) +visualize_word_cloud(refined_data, "Title") +``` diff --git a/vignettes/articles/refinemetadata.Rmd b/vignettes/articles/refinemetadata.Rmd index 350bb8c..de6c9e7 100644 --- a/vignettes/articles/refinemetadata.Rmd +++ b/vignettes/articles/refinemetadata.Rmd @@ -2,7 +2,7 @@ title: "Refine, integrate and analyse Finna metadata" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Introduction to finna} + %\VignetteIndexEntry{Refine, integrate and analyse Finna metadata} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -52,6 +52,13 @@ analysis_results <- analyze_metadata(refined_data) visualize_year_distribution(analysis_results$year_distribution) ``` +#### 1.1 Line plot of yearly distribution +```{r} +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_year_distribution_line(refined_data) +``` ### 2. **Applying the `visualize_top_20_titles()` Function** @@ -65,6 +72,14 @@ top_20_titles_plot <- visualize_top_20_titles(refined_data) print(top_20_titles_plot) ``` +#### 2.1 Visualize Heatmap of Titles by Year +```{r warning=FALSE} +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_title_year_heatmap(refined_data) +``` + ### 3. **Applying the `visualize_format_distribution()` Function** This function visualizes the distribution of the records by format. @@ -76,6 +91,13 @@ format_distribution_plot <- visualize_format_distribution(refined_data) # To display the plot print(format_distribution_plot) ``` +#### 3.1 Visualize Format Distribution as Pie Chart +```{r} +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_format_distribution_pie(refined_data) +``` ### 4. **Applying the `visualize_library_distribution()` Function** @@ -88,6 +110,17 @@ library_distribution_plot <- visualize_library_distribution(refined_data) # To display the plot print(library_distribution_plot) ``` +#### 4.1 **Visualize Correlation Between Formats and Libraries** + +This function shows the distribution of the records by library. + +```{r} +library(finna) +sibelius_data <- search_finna("sibelius") +refined_data <- refine_metadata(sibelius_data) +visualize_format_library_correlation(refined_data) +``` + ### 5. **Applying the `visualize_author_distribution()` Function** @@ -112,4 +145,12 @@ subject_distribution_plot <- visualize_subject_distribution(refined_data) # To display the plot print(subject_distribution_plot) ``` +#### 6.1 **Visualize Word Cloud of Titles or Subjects** +This function visualizes the distribution of the records by subject. + +```{r} +music_data <- search_finna("music") +refined_data <- refine_metadata(music_data) +visualize_word_cloud(refined_data, "Title") +``` diff --git a/vignettes/vignette.Rmd b/vignettes/vignette.Rmd index af6e4f2..c3e6038 100644 --- a/vignettes/vignette.Rmd +++ b/vignettes/vignette.Rmd @@ -11,14 +11,18 @@ vignette: > This vignette provides an overview of how to use the finna package. -To make a simple search use the following code. I we need a bulk download we use -`search_finna("sibelius", limit = Inf)` where we add the term `limit = Inf`. +To make a simple search use the following code. ```{r} library(finna) record <- search_finna("sibelius") print(record) ``` + +## Bulk search + + I we need a bulk download we use +`search_finna("sibelius", limit = Inf)` where we add the term `limit = Inf`. ## Free text search ```{r} @@ -257,20 +261,14 @@ print(record) ### Narrowing the search -When narrowing search do not use codes as a combination as follows - -`search_finna("trump", filters = c('{!geofilt sfield=location_geo pt=61.663987171517796,24.17263895273209 d=212.53603751769646}',author_facet:"Häkkinen, Hannu"')) -` -or - -`search_finna("trump", filters = c('{!geofilt sfield=location_geo pt=61.663987171517796,24.17263895273209 d=100}'), facetFilters = c('author_facet:"Häkkinen, Hannu"')) -` -rather use specific search as follows +When narrowing search you can use codes as a combination as follows ```{r} -record <- search_finna("trump", filters = c('~author_facet:"Häkkinen, Hannu"')) +record <- search_finna("trump", filters = c('{!geofilt sfield=location_geo pt=61.663987171517796,24.17263895273209 d=212.53603751769646},author_facet:"Häkkinen,Hannu"')) print(record) ``` + + ### specific search ```{r} @@ -281,14 +279,32 @@ record <- search_finna("era:'2010-luku'", filters = c('building:"0/3AMK/"')) ### search without removing duplication In order to search data without removing duplication -[example](https://www.finna.fi/Search/Results?filter%5B%5D=finna.deduplication%3A%220%22&dfApplied=1&lookfor=era%3A%222010-luku%22&type=AllFields) +[example](https://www.finna.fi/Search/Results?dfApplied=1&lookfor=era%3A%222010-luku%22&type=AllFields&filter[]=~building%3A%220%2F3AMK%2F%22&filter[]=finna.deduplication:%220%22) + ```{r} -record <- search_finna("era:'2010-luku'", filters = c('finna.deduplication:"0"')) +record <- search_finna('era:"2010-luku"', filters = c('~building:"0/3AMK/"', 'finna.deduplication:"1"')) print(record) ``` -removing duplication can be done as follows +We can confirm this as follows by checking the count + +```{r} +record <- search_finna('era:"2010-luku"', filters = c('~building:"0/3AMK/"', 'finna.deduplication:"1"')) +result_count <- attr(record, "result_count") +print(result_count) +``` + +Removing duplication can be done as follows + ```{r} -record <- search_finna("era:'2010-luku'", filters = c('finna.deduplication:"1"')) +record <- search_finna('era:"2010-luku"', filters = c('~building:"0/3AMK/"', 'finna.deduplication:"0"')) print(record) ``` +To confirm this we can check the count + +```{r} +record <- search_finna('era:"2010-luku"', filters = c('~building:"0/3AMK/"', 'finna.deduplication:"0"')) +result_count <- attr(record, "result_count") +print(result_count) +``` +