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] "391926"
#>
#> $`1420`$`4`
#> [1] "342714"
#>
#> $`1420`$`3`
#> [1] "202608"
#>
#> $`1420`$`2`
#> [1] "54597"
#>
#> $`1420`$`1`
#> [1] "18400"
#>
#>
#> $`2767052`
#> $`2767052`$`5`
#> [1] "5145698"
#>
#> $`2767052`$`4`
#> [1] "2866397"
#>
#> $`2767052`$`3`
#> [1] "1057129"
#>
#> $`2767052`$`2`
#> [1] "232332"
#>
#> $`2767052`$`1`
#> [1] "127317"
#>
#>
#> $`10210`
#> $`10210`$`5`
#> [1] "1044103"
#>
#> $`10210`$`4`
#> [1] "694122"
#>
#> $`10210`$`3`
#> [1] "341711"
#>
#> $`10210`$`2`
#> [1] "98976"
#>
#> $`10210`$`1`
#> [1] "53289"
#>
#>
# Clean up: remove the temporary file
file.remove(temp_file)
#> [1] TRUE
# }