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] "394151"
#>
#> $`1420`$`4`
#> [1] "344673"
#>
#> $`1420`$`3`
#> [1] "203699"
#>
#> $`1420`$`2`
#> [1] "54866"
#>
#> $`1420`$`1`
#> [1] "18472"
#>
#>
#> $`2767052`
#> $`2767052`$`5`
#> [1] "5211549"
#>
#> $`2767052`$`4`
#> [1] "2897542"
#>
#> $`2767052`$`3`
#> [1] "1064289"
#>
#> $`2767052`$`2`
#> [1] "233460"
#>
#> $`2767052`$`1`
#> [1] "128171"
#>
#>
#> $`10210`
#> $`10210`$`5`
#> [1] "1052401"
#>
#> $`10210`$`4`
#> [1] "699615"
#>
#> $`10210`$`3`
#> [1] "344152"
#>
#> $`10210`$`2`
#> [1] "99610"
#>
#> $`10210`$`1`
#> [1] "53624"
#>
#>
# Clean up: remove the temporary file
file.remove(temp_file)
#> [1] TRUE
# }