why can not get the same web interface while running coding from Rstudio and open from browser

Dear all

I meet a very strange problem that I have the following coding which runs normally in Rstudio,

p <- plot_ly(
  data = pca.df, 
  x =~pca.df[,paste0('Axis',sel.xaxis)], 
  y =  ~pca.df[,paste0('Axis',sel.yaxis)], 
  mode = "markers",
  color = ~popnames,
  marker= ~list(size=8,color=color),
  text=~paste0('Ind. name= ',ind.names,"\n ,Pop:", popnames)

But error appears when I open the URL link as following: error:unique() applies only to vectors

If I change the above code to : (delete the symbol ~)

p <- plot_ly(
  data = pca.df, 
  x =pca.df[,paste0('Axis',sel.xaxis)], 
  y =  pca.df[,paste0('Axis',sel.yaxis)], 
  mode = "markers",
  color = popnames,
  marker=list(size=8,color=color),
  text=paste0('Ind. name= ',ind.names,"\n ,Pop:", popnames))

It runs normally in URL link instead, but error appears when runs in Rstudio like following: error: object color not find.

I have no idea about it. May I ask if any of you know how to solve it?

Thank you in advance

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.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.