We saw an instance of plotting using GGPLOT before inward the RGUI.
Herein nosotros role ggplot inward Power BI.
We connect to Northwind database on an instance of SQL Server 2016 Developer. We charge information from Products together with OrderDetails tabular array into Power BI.
We drib the R Script Visual from the Visualizations onto the designer.
ggplot2
The R script editor opens upwards every bit shown
ggplot_03
Add the next code every bit shown:
-------------------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y + geom_point(aes(color="red"))
-------------------------
If y'all run this code using the R script
You drib dead an error:
Now alter the inward a higher house to this:
---------------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y+geom_point(aes(color="red"))
y=y+geom_point(aes(size=Quantity))
y
---------------------
Now run the script. You volition run across the plot every bit shown. The size shows the value of "Quantity" together with the color=red is supposed to drib dead inward red.
The right code for aes is modified to this:
-------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y+geom_point(aes(size=Quantity, color="red"))
y
-------------------
Run this code again. You drib dead the next visualization.
Herein nosotros role ggplot inward Power BI.
We connect to Northwind database on an instance of SQL Server 2016 Developer. We charge information from Products together with OrderDetails tabular array into Power BI.
We drib the R Script Visual from the Visualizations onto the designer.
ggplot2
The R script editor opens upwards every bit shown
ggplot_03
Add the next code every bit shown:
-------------------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y + geom_point(aes(color="red"))
-------------------------
If y'all run this code using the R script
You drib dead an error:
Now alter the inward a higher house to this:
---------------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y+geom_point(aes(color="red"))
y=y+geom_point(aes(size=Quantity))
y
---------------------
Now run the script. You volition run across the plot every bit shown. The size shows the value of "Quantity" together with the color=red is supposed to drib dead inward red.
The right code for aes is modified to this:
-------------------
library(ggplot2)
y=ggplot(data=dataset, aes(x=ProductName, y=Quantity))
y=y+geom_point(aes(size=Quantity, color="red"))
y
-------------------
Run this code again. You drib dead the next visualization.
Looks similar in that place may to a greater extent than or less mistake inward rendering of the color. Changing it to bluish makes it nevertheless 'red'.
Komentar
Posting Komentar