Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
suvamdey17
Participant
R Visualization is generally being used to create those charts which are not directly available in SAP Analytics Cloud. In this blog I am going to explain how to create a chart in SAP Analytics Cloud using R Visualization.

Below are the steps being used to create a gauge chart in SAP Analytics Cloud using R Visualization:

 

Step-1: Either create a new Story or open an existing story in edit mode. Navigate to “Insert” and click on “+” button. Click on “R Visualization”.

 



 

Step-2: Add the Model as Input Data in Builder.


 


 

Step-3: Click on “Add Script” in Builder.


Step-4: Expand the window.


 

Step-5: There are 4 panes in the window i.e. Editor, Environment, Console and Preview. Write R code in Editor. After that execute the code by clicking on “Execute” button. If there is no error message in Console and the gauge chart is being displayed in Preview, then click on “Apply” button.

 

R Code:

gg.gauge <- function(pos,pos1,breaks=c(0,70,100),values=c(1,3,4)) {

require(ggplot2)

get.poly <- function(a,b,r1=0.5,r2=1.0) {

th.start <- pi*(1-a/100)

th.end   <- pi*(1-b/100)

th       <- seq(th.start,th.end,length=100)

x        <- c(r1*cos(th),rev(r2*cos(th)))

y        <- c(r1*sin(th),rev(r2*sin(th)))

return(data.frame(x,y))

}

ggplot()+

geom_polygon(data=get.poly(breaks[1],breaks[2]),aes(x,y),fill="#0A3264")+

geom_polygon(data=get.poly(breaks[2],breaks[3]),aes(x,y),fill="#B2D4F5")+

geom_polygon(data=get.poly(pos-1,pos+1,0.2),aes(x,y),fill="Red")+

annotate("text",x=0,y=0,label=round(pos1),vjust=0,size=16,fontface="bold")+

coord_fixed()+

theme_bw()+

theme(axis.text=element_blank(),

axis.title=element_blank(),

axis.ticks=element_blank(),

panel.grid=element_blank(),

panel.border=element_blank())

}

meas1 = 1

meas2 = Sample_Model$`Marks Obtained`

meter = (meas2/meas1)

gg.gauge(meter,meas2,breaks=c(0,meter,100),values=c(0,meas2,meas1))

 


 


 

Step-6: The gauge chart is being displayed in the story.


 

In this way we can create other charts also in SAP Analytics Cloud using R Visualization.

 

Conclusion: R Visualization is the very powerful feature of SAP Analytics Cloud where we can do coding using R. Using R Visualization feature we can create those charts which are not directly available in SAP Analytics Cloud.
2 Comments
Labels in this area