R & Power BI In this exercise, you will embed R into Power BI to analyze industry employment data. The following steps are the same as the previous exercise. Make sure you load the same data again: Step 1: Use Embedded SQL to Import Data Click Get Data, then choose MySQL. Enter the following connection details: Server: dadata.bensresearch.com Database: industry Click Advanced Options to embed custom SQL queries. Paste and run each of the queries below one at a time: SELECT TSE.DataYear, TSE.StateShort, SUM(HHI.Herf * ISE.Emp / TSE.Emp) AS WHHI FROM (SELECT StateShort, DataYear, SUM(ExpEmpValue) AS Emp FROM StateData WHERE IndustryCodeLength = 6 GROUP BY StateShort, DataYear) AS TSE JOIN (SELECT StateShort, DataYear, IndustryCode, ExpEmpValue AS Emp FROM StateData WHERE IndustryCodeLength = 6) AS ISE ON TSE.StateShort = ISE.StateShort AND TSE.DataYear = ISE.DataYear JOIN HHI ON ISE.DataYear = HHI.DataYear AND ISE.IndustryCode = HHI.IndustryCode GROUP BY TSE.DataYear, TSE.StateShort ORDER BY WHHI SELECT * FROM HHI SELECT * FROM StateData SELECT StateShort, DataYear, SUM(ExpEmpValue) AS Emp FROM StateData WHERE IndustryCodeLength = 6 GROUP BY StateShort, DataYear Rename your resulting tables as follows: WHHI (for the weighted HHI results) HHI StateData StateEmp (total employment by state) Step 2: Import NAICS Labels Click Get Data again. Browse for the file NAICS.csv and load it. Your result should look like this: Step 3: Using R Once you have these results. Select the R visualization. Drag only DataYear, ExpEmpValue and IndustryCodeLength to it. Then write the code below, which transforms and plot the data: library(sqldf) plot <- sqldf("SELECT DataYear, SUM(ExpEmpValue) AS Emp FROM dataset WHERE IndustryCodeLength = 6 GROUP BY DataYear") library(ggplot2) ggplot(plot, aes(x = DataYear, y = Emp)) + geom_line(color = "steelblue", size = 1) + geom_point(color = "steelblue", size = 2) + labs(title = "Employment Over Time", x = "Year", y = "Employment" ) + theme_minimal() Question: Inspect the resulting graph. Which year had the lowest number of manufacturing jobs nationwide? Ignore years not included in our dataset.数值题
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
What sort of chart could you create to compare data, where the data does not have to be in any specific order?
Lee needs to create a chart comparing sales for 21 regions. What sort of chart would be best?
When creating a dashboard for storytelling, which of the following is the best practice?
A large retail chain's quarterly report contains hundreds of pages of tables showing sales data by product, region, and store. Executives struggle to quickly grasp overall performance and identify key trends. Based on the sources, which benefit of data visualization would most directly address this challenge?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!