如何使用R语言在SAP Analytics Cloud里绘制各种统计图表
更新:HHH   时间:2023-1-7


这期内容当中小编将会给大家带来有关如何使用R语言在SAP Analytics Cloud里绘制各种统计图表,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

插入一个R visualization:

一定要确保图形出现这个model的小图标,代表这个R visualization的模型数据成功绑定之后才能进行下一步操作:

模型绑定成功后,在R script编辑器Environment标签页的Data下拉菜单里能看到模型数据。

使用这个SAP Analytics Cloud官方教程里提供的excel文件作为数据源:

https://www.rial-r-visualization/https://www.ontent/uploads/2019/09/R-Script-Plot.txt

# Discription:
# Creating a histogram of the log returns, adding the kernel density of the log returns
# and the normal density as reference distribution 
#
# Requirements: 
# ggplot requires a data frame
# 
# Output:
# Histogram Plot
# 
library(ggplot2)
Simulated_data <- data.frame(Simulated_data)
histgg <- ggplot(data = Simulated_data, aes(logreturns))
histgg + geom_histogram(aes(y = ..density..),fill = "lightblue",color = "black", alpha = 0.8, position = "identity") +
  geom_density(aes(color = "Kernel Density"), size = 1) +
  stat_function(aes(color = "Normal Distribution"), fun = dnorm, args = list(mean = mean(Simulated_data$logreturns), sd = sd(Simulated_data$logreturns)), size = 1) +
  ggtitle("Histogram") +
  theme(panel.grid = element_line(linetype = "dashed", color = "lightgrey"), panel.background = element_rect(fill = "white"),
        panel.border = element_rect(colour = "black", fill=NA),
        plot.title = element_text(hjust = 0.5)) +
  scale_colour_manual("Density", values = c("red", "darkgreen")) +
  xlab(" ")+
  ylab("Frequency")

点击Execute按钮,就可以看到R脚本绘制出来的图形了:

上述就是小编为大家分享的如何使用R语言在SAP Analytics Cloud里绘制各种统计图表了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注天达云行业资讯频道。

返回大数据教程...