MovieData R6 class
MovieData.RdManages a SQLite database connection for movie data, loads a joined dataset
from the omdb and tomatoes tables, and applies filter logic derived from
Shiny input values.
Details
On initialization the class opens a connection to the SQLite database at
db_path, joins the two tables via inner_join(), collects the result into
memory, and stores it in $all_movies. Call $filter() to obtain a
filtered data frame for rendering. Call $disconnect() to close the
connection explicitly; the private finalize() method also calls it when
the object is garbage collected.
Logging is handled via the logger package. Set the threshold with
logger::log_threshold() before initializing the class.
Methods
MovieData$new()
Connect to the SQLite database and load all movie data.
Usage
MovieData$new(db_path)MovieData$filter()
Filter the in-memory data frame using input values.
Arguments
reviewsMinimum number of Rotten Tomatoes reviews (default: 10).
oscarsMinimum number of Oscar wins (default: 0).
yearInteger vector of length 2:
c(min_year, max_year)(default:c(1940, 2014)).boxofficeNumeric vector of length 2: box-office range in millions (default:
c(0, 800)).genreGenre string;
"All"disables the filter (default:"All").directorPartial director name; empty string disables the filter (default:
"").castPartial cast name; empty string disables the filter (default:
"").
MovieData$disconnect()
Explicitly close the database connection.
Details
Call this from shiny::onStop() or in tests via on.exit().
The private finalize() method calls this automatically when the object
is garbage collected.