This doesn't sound like an RStudio or shiny issue (it was initially placed in the shiny category).
That error message "error: object color not find." seems to be referring to the "color" object in the marker
argument. R is looking for an object named 'color', which hasn't been defined for it yet. I'd guess why it works in one environment but not another is that it was defined in one environment, but not the other.
A good way to get help diagnosing a problem like this is to offer it up as a minimal reproducible example. Give us the minimum code to reproduce your error. For example now, the code refers to data and other variables we don't have, and so I can't reproduce the issue you're having and help fix it, we're just giving a best guess. (How do you make a good minimal reproducible example? that's a great question, I'm glad you asked: FAQ: What's a reproducible example (`reprex`) and how do I do one?)
I suspect that minimal reprex will help diagnose the "unique() applies only to vectors" errorm, which I don't have a guess for quite yet.