Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Error in rChart$copy() : could not find function "new" 'when using Rscript #727

Open
52teth opened this issue Jun 12, 2017 · 1 comment

Comments

@52teth
Copy link

52teth commented Jun 12, 2017

Hi,
Recently I try to use hPlot fuction for pie plot. When I run in the R platform, it plots successfully. But when I write my script in an R scirpt "pie.R" and run by Rscript pie.R, the following error appears:
Error in rChart$copy() : could not find function "new"
Calls: hPlot ->
Execution halted

The following is the pie.data used to plot:
type value label
1 O 133 O:20.7%
2 A 78 A:12.1%
3 B 69 B:10.7%
4 C 7 C:1.1%
5 D 73 D:11.3%
6 Other 284 Other:44.1%

Here is my script from "pie.R" :
pie1<-hPlot(x = "label", y = "value", data = pie.data, type = "pie",title=opt$title)
pie1$colors(rep(col,length=nrow(pie.data)))
pie1$legend(align = 'right', verticalAlign = 'top', layout = 'vertical',showInLegend='true')
out=paste(opt$outfile,".html",sep = "")
pie1$save(out,standalone=TRUE)

How can I deal with this problem? Can the rCharts be used in Rscript?
Thanks a lot for any suggestion!

@ghost
Copy link

ghost commented Oct 21, 2017

Well, I read somewhere that --default-packages=methods,utils needs to be passed to Rscript to work around this: stan-dev/rstan#190

Also, it seems, Rscript being missing the load of the methods package. This can also be fixed by calling library('methods') at the beginning of your script: dhimmel/elevcan#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant