This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowThe Fabric community is upgrading! Read all of the details including the timeline and what you can expect. Learn more
Hi,
I can't figure out what I'm doing wrong... No matter what I try, I can't get a custom visual to keep my data as strings, it always does some weird index conversion...
This is my (simply) script.R:
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly")
####################################################
################### Actual code ####################
fig <- plot_ly(
type = 'table',
cells = list(
values = rbind(Values$id, Values$string)
))
####################################################
############# Create and save widget ###############
p = ggplotly(fig);
internalSaveWidget(p, 'out.html');
####################################################
If I give it a table:
id,string
1,Test1
2,test
3,Test1
4,test
5,not test
I get a visual table:
1,3
2,2
3,3
4,2
5,1
This is driving me nuts and it's probably a really simple answer!
PS I used the defaults generated by:
pbiviz new no_strings -t rhtml
Solved! Go to Solution.
Hey @jschne ,
I assume you are facing the implicit string to factor conversion, this R: rbind string to factor column - Stack Overflow provides two approaches to tackle this challenge.
Hopefully, this provides what you are looking for.
Regards,
Tom
Hey @jschne ,
I assume you are facing the implicit string to factor conversion, this R: rbind string to factor column - Stack Overflow provides two approaches to tackle this challenge.
Hopefully, this provides what you are looking for.
Regards,
Tom
You saved my Friday!
For some reason the code worked in RStudio, but it needed that stringsasFactors to work in the custom viz.
Thanks again!
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
| User | Count |
|---|---|
| 24 | |
| 22 | |
| 20 | |
| 18 | |
| 14 |
| User | Count |
|---|---|
| 45 | |
| 38 | |
| 24 | |
| 22 | |
| 20 |