简体   繁体   English

Power BI 中的数据操作

[英]Data manipulation in Power BI

I am new to Power BI and have recently been exploring its potential use as a data visualization tool.我是 Power BI 的新手,最近一直在探索它作为数据可视化工具的潜在用途。 I currently add my data through Get Data -> "R Script" where I use read.csv and the dplyr package to import and sort through the messy data.我目前通过 Get Data -> "R Script" 添加我的数据,我使用 read.csv 和 dplyr package 导入和排序杂乱的数据。 I currently haven't found a way to edit the import scripts so any new changes I make to the script result in me having to re-import the data and reconnecting all the app links.我目前还没有找到编辑导入脚本的方法,因此我对脚本所做的任何新更改都会导致我不得不重新导入数据并重新连接所有应用程序链接。

My potential new approach is to import the data into Power BI with read.csv and modifying the contents via Transform Data -> Transform -> R Script.我潜在的新方法是使用 read.csv 将数据导入 Power BI 并通过 Transform Data -> Transform -> R 脚本修改内容。 My issue is that when I run the following script Power BI's output is an empty table:我的问题是,当我运行以下脚本时,Power BI 的 output 是一个空表:

i.e:# 'dataset' holds the input data for this script

library(dplyr)

dataset <- dataset %>%
select(2,3,4) %>%
rename(First= A) %>%
rename(Last= B) %>%
rename(Extra= C)

Said script runs on RStudio, any suggestions?所述脚本在 RStudio 上运行,有什么建议吗?

Your second approach sounds about right which is to load data first in Power BI and then transform it in R.您的第二种方法听起来很正确,即首先在 Power BI 中加载数据,然后在 R 中对其进行转换。

Load the output of your R script to a new variable which should fix the problem.将 R 脚本的 output 加载到应该可以解决问题的新变量中。 Updated script is below:更新的脚本如下:

library(dplyr)

output <- dataset %>%
select(2,3,4) %>%
rename(First= A) %>%
rename(Last= B) %>%
rename(Extra= C)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM