switch out if-else return statements for just if-statements. Because you're returning, you don't need to ensure an "else" - if the object evaluation in condition 2 wasn't distinct from condition 1, it'd not have hit condition 2, it would've returned. This also simplifies the if-checks (e.g. you don't need to ensure !scale_vals after checking for scale_vals: if it wasn't !scale_vals, we wouldn't be here).
Add a check that 'bins' is numeric too.
switch out unnecessary x and y assignments, and use seq_along(x) instead of 1:x, since in the case that x is 0, 1:x produces some weird stuff.
Miscellaneous cleanup and tweaks: