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] "381373"
#>
#> $`1420`$`4`
#> [1] "332458"
#>
#> $`1420`$`3`
#> [1] "197118"
#>
#> $`1420`$`2`
#> [1] "53370"
#>
#> $`1420`$`1`
#> [1] "18099"
#>
#>
#> $`2767052`
#> $`2767052`$`5`
#> [1] "4889869"
#>
#> $`2767052`$`4`
#> [1] "2737370"
#>
#> $`2767052`$`3`
#> [1] "1022233"
#>
#> $`2767052`$`2`
#> [1] "226158"
#>
#> $`2767052`$`1`
#> [1] "124005"
#>
#>
#> $`10210`
#> $`10210`$`5`
#> [1] "1005880"
#>
#> $`10210`$`4`
#> [1] "668556"
#>
#> $`10210`$`3`
#> [1] "330967"
#>
#> $`10210`$`2`
#> [1] "96512"
#>
#> $`10210`$`1`
#> [1] "52117"
#>
#>
# Clean up: remove the temporary file
file.remove(temp_file)
#> [1] TRUE
# }