I would guess you don't have the dependent library active, try adding this on line 6 before it loads the Matrix library as it seems to depend on the methods library:
library (methods);
Sometimes on default, R will load this automatically but in Omniscope you have to make sure you state every library being used. It's probably a similar issue to this:
Does Omniscope look into R_DEFAULT_PACKAGES and .Rprofiles? If so you follow the post below to have default libraries always being added in Omniscope based on your settings in your own version of R.