用到的包
{rgl}和{plot3Drgl}、{emdbook}
{rgl}的下载比较麻烦,先是在R窗口中下载:
install.packages("rgl",dependencies=TRUE,repos="http://cran.rstudio.com")
下了一堆,在加载{rgl}是,提示
Error: package or namespace load failed for ‘rgl’:
package ‘htmltools’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
移除htmltools,然后重新安装后,又提示mime、jsonlite同样的问题。于是全部卸载重装
remove.packages("html", "mime", "jsonlite", "rgl")
install.packages("html", "mime", "jsonlite", "rgl", dependencies=TRUE, repos="http://cran.rstudio.com")
最后安装{plot3Drgl}, {emdbook},比较顺利。
示例
library(rgl)
x <- y <- seq(-5,5,length=1000)
f <- functio