Get Rating Distribution from Goodreads
Source:R/get_rating_distribution.R
get_rating_distribution.Rd
This function takes a file path containing Goodreads book IDs and retrieves the rating distribution for each book.
Examples
# \donttest{
# Create a temporary file with sample book IDs
temp_file <- tempfile(fileext = ".txt")
writeLines(c("1420", "2767052", "10210"), temp_file)
# Run the function
rating_distributions <- get_rating_distribution(temp_file)
print(rating_distributions)
#> $`1420`
#> $`1420`$`5`
#> [1] "378727"
#>
#> $`1420`$`4`
#> [1] "330018"
#>
#> $`1420`$`3`
#> [1] "195852"
#>
#> $`1420`$`2`
#> [1] "53043"
#>
#> $`1420`$`1`
#> [1] "18002"
#>
#>
#> $`2767052`
#> $`2767052`$`5`
#> [1] "4846692"
#>
#> $`2767052`$`4`
#> [1] "2713313"
#>
#> $`2767052`$`3`
#> [1] "1014588"
#>
#> $`2767052`$`2`
#> [1] "224700"
#>
#> $`2767052`$`1`
#> [1] "123286"
#>
#>
#> $`10210`
#> $`10210`$`5`
#> [1] "996690"
#>
#> $`10210`$`4`
#> [1] "662611"
#>
#> $`10210`$`3`
#> [1] "328467"
#>
#> $`10210`$`2`
#> [1] "95870"
#>
#> $`10210`$`1`
#> [1] "51851"
#>
#>
# Clean up: remove the temporary file
file.remove(temp_file)
#> [1] TRUE
# }