Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of PowerBI and R language

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you the sample analysis of PowerBI and R language, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

As the latest business intelligence office system of Microsoft, PowerBI has attracted a lot of attention since it was released last year.

His update frequency is quite high, and the iteration of function update is very fast.

Friends who probably dabble in the field of visualization understand the reason. Big data and the trend of cloud computing are sweeping the world, and massive data processing has become a constraint restricting the development of various industries. Subject to the threshold of programming tools, most data processing business personnel may have to rely heavily on Excel and other visual self-service software that does not require programming.

The above requirements are also known as self-service BI tools, that is, business intelligence tools that do not need to be led by IT personnel and can be operated by business people.

At present, in this field, the successful commercialization of Tableau has won the first opportunity, the vast user base and multiple functional iterations, both in the visual presentation form and the quality of the report.

The Microsoft empire must show the must-kill skill (why does not Gates' software lag behind in everything, mobile operating system, search, smart terminal). In the early office2013 version, four high-quality plug-ins such as PowerQuery, PowerPivot, PowerView and PowerMap have been launched.

In the latest version of Excel2016, it is packaged as a built-in program (so that you do not have to configure your own environment), and the four-piece set is integrated to establish PowerBI's online platform and desktop tool PowerBI Desktop.

Although the visual chart type and quality of PowerBI (limited by development cycle and market experience) is not perfect, it is free (Tableau is said to cost thousands of dollars). This one is enough.

Of course, PowerBI contains a golden spoon from birth, and the map library is a docking BingMap. Relying on the support of PowerQuery, it has a strong ability to obtain data sources, and relies on the support of PowerPivot to add powerful data modeling and processing capabilities. The combination of PowerView and PowerMap can basically solve most of the visualization forms.

In addition, PowerBI's online community allows developers to contribute high-quality, dazzling new visual objects. Do you think PowerBI has only a few built-in chart objects? go to his community and have a look. You can find a lot of good things in it.

Third-party visualization library website:

Https://app.powerbi.com/visuals/

These visual objects are divided into two categories in the community:

Custom visuals

R-powered visuals

What I'm going to share with you today is only R scripts in built-in visual objects and R-style visual objects in the online community.

Here is some practical information.

Recently, the R language scripting object function of PowerBI was tried, and although it was poorly used, it was a meaningful step as Microsoft's business intelligence system began to try to interface with mainstream statistical programming languages.

Next, I would like to share with you about my experience (in fact, I still complain a lot):

There are two types of R-related charts supported in PowerBI:

One is the form in which the script code needs to be built and executed in R and the R graphic object is inserted to display the output.

The other is the PowerBI visual objects encapsulated by the PowerBI online community and the official platform that reference and draw lessons from the excellent R language visualization package.

The first one requires you to have a R basis and be able to write graphic code. After importing the dataset, enter and run the R code to generate an R-style visual chart on the PowerBI page. (of course, since you are running R code, you must install R's Gui program in advance on PC. If there is Rstudio, PowerBI also supports calling. )

This approach is basically equivalent to using PowerBI as the third-party IDE of R, but it is too early to call it the third-party IDE of R, because.

Its code efficiency and operating experience can't be worse, not to mention RStudio, even R's official Gui interface is several times easier to use.

The code aging speed is super slow.

The dataset needs to be imported in advance

Graphic objects can only be displayed in data objects, but text information cannot be displayed

Next I'll run a few programs as a case demonstration:

The self-built R script needs to insert the RScript object at the beginning-- get the data--

Get the data in the form of R code in the pop-up input box of execute R script:

Data (mtcars)

After the connection is successful, import the dataset:

After the data model is loaded, all available fields of the dataset are listed in the field list on the right side of the PowerBI, and the entire data observations can be displayed and previewed in the table column in the upper left corner.

After the dataset is imported, select the R script in the visual chart object, insert it, and drag the fields you need in the list of fields on the right into the value area.

You will find that after inserting the R script object, all mouse actions performed are recorded as R code in the R script Editor (very similar to the recording macro in Excel).

Now you are free to write and execute code in the R script editor. (the code is the same as in R, after writing a sentence of code, select and click the editor's operation button)

Library (ggplot2)

Library (RColorBrewer)

Library (ggthemes)

Ggplot (mtcars,aes (qsec,disp,colour=factor (cyl) + geom_point () + theme_economist () + scale_colour_economist () + guides (colour=guide_legend (title=NULL))

Ggplot (mtcars,aes (qsec,disp,size=mpg,colour=factor (cyl) + geom_point () + scale_size_area () + theme_economist () + scale_colour_economist () + guides (colour=guide_legend (title=NULL))

Next I use the diamonds dataset (from the ggplot2 package)

Library (ggplot2)

Library (ggthemes)

Ggplot (diamonds,aes (depth,fill=color)) + geom_histogram () + theme_economist () + scale_fill_economist () + guides (fill=guide_legend (title=NULL)) + scale_x_discrete (limits=c (50 and 70))

Although the above charts output the results perfectly, the process is still very difficult. PowerBI is not as convenient as calling the dataset in R, and every time you want to change a data, you have to create a new RScript object.

The following is to introduce the second column of R visual objects about PowerBI, which is also a category recommended by individuals.

Because these visual objects have been modified by developers, there is basically no need for you to write code to output beautiful charts (because it is a R program called in the background, you still need to install R software in advance).

This type of chart object can be downloaded from PowerBI's online developer community to the chart plug-in and case demo.

Each R chart object provides plug-in downloads and Sample exclusive references.

After downloading, import the visual object in the visualization menu.

Insert the correlation visualization chart object you just imported, and drag the fields of the correlation you want to render into the Values field box.

After that, you will find that the chart object will automatically correlate the thermal matrix diagram. (color depth represents correlation, positive blue, negative red)

The chart object calls the corrplot function in R. We use this function in RStudio to generate a similar case diagram.

Library (corrplot)

Data (mtcars)

Corr

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report