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道真实原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!