带R的SQL 2016-错误HRESULT 0x80004004 [英] SQL 2016 with R - Error HRESULT 0x80004004

查看:110
本文介绍了带R的SQL 2016-错误HRESULT 0x80004004的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究许多有关使用SQL和R的教程.但是,当我尝试运行R脚本以获取"ggplot"库时,出现以下错误

I am working through a number of tutorials on using SQL and R. But when I am trying to Run the R Script to obtain the 'ggplot' library I am getting the following error

Msg 39004, Level 16, State 20, Line 1
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 1, Line 1
An external script error occurred: 
Error in library("ggplot2") : there is no package called 'ggplot2'
Calls: source -> withVisible -> eval -> eval -> library

Error in ScaleR.  Check the output for more information.
Error in eval(expr, envir, enclos) : 
Error in ScaleR.  Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted

(0 row(s) affected)

原始脚本是

INSERT INTO chartBinary (binData)
EXEC sp_execute_external_script
@language = N'R',
@script = N'
library("ggplot2");
img <- inputDataSet;
image_file = tempfile();
png(filename = image_file, width=800, height=600);
print(ggplot(img, aes(x = AirportID, y = WindSpeed)) +
labs(x = "Airport ID", y = "Wind Speed") +
theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0)) +
geom_point(stat = "identity") +
geom_smooth(method = "loess", aes(group = 1)) +
geom_text(aes(label = AirportID), size = 3, vjust = 1.0) +
geom_text(aes(label = round(WindSpeed, digits = 2)), size = 3, vjust = 2.0));
dev.off();
OutputDataset <- data.frame(data=readBin(file(image_file,"rb"),what=raw(),n=1e6));',
@input_data_1 = N'SELECT AirportID, AVG(CONVERT(float, WindSpeed)) as   WindSpeed 
FROM
[Weather_Sample] GROUP BY AirportID ORDER BY AirportID;',
@input_data_1_name = N'inputDataSet',
@output_data_1_name = N'OutputDataset';

系统具有SQL 2016,SSMS 2017,MS R Open 3.4.0 与R的集成可与Visual Studio 2015很好地配合,并且没有错误.可以下载库包并运行脚本而不会出现错误.只有当我开始使用SMSS时,我才无法下载软件包

The system has SQL 2016, SSMS 2017, MS R Open 3.4.0 The integration with R works well with Visual Studio 2015 and has no errors. Can download library packages and run the scripts with no errors. Only when I start using SMSS I am unable to download packages

推荐答案

您将需要将 ggplot2 软件包安装到SQL Server实例. 有多种方法可以将不可用的R软件包安装到SQL Server实例.

You will need to install the ggplot2 package to the SQL Server instance. There are various ways to install unavailable R packages to the SQL Server instance.

根据设置,您将选择适合您的方法.

You will choose the method suitable for you depending on your setup.

如果在本地计算机上工作,则需要下载软件包的 Windows Binaries (zip文件)并使用T-SQL安装.

If you are working on a local machine then you would want to download the Windows Binaries (zip file) of the package and install using T-SQL.

在这里检查: 在SQL Server上安装其他R软件包

这篇关于带R的SQL 2016-错误HRESULT 0x80004004的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆