how to remove "Modal state sequence" field from seqmsplot - r

Hi I would like to make a plot of the sequence of modal states (seqmsplot in TraMineR) but because I am making a figure which consists some other plots I would like to remove the in-build subtitle which says "Modal state sequence ..." because this is affecting the heights of y-axis. Does anyone know how I can remove this in seqmsplot and use main="Modal state sequence" instead?
Below is a picture (from TraMineR website) which shows which part I would like to remove.

Up to TraMineR v 2.2-2, the display of the info about the frequency of the sequence of modal states was hard coded.
The development version 2.3-3 (available on R-Forge), which will eventually become 2.2-3 on the CRAN, offers a new attribute info in the plot method plot.stslist.modst invoked by seqmsplot.
With this new version, you can suppress the info with seqmsplot(..., info=FALSE). For example, using the mvad data:
data(mvad)
m.seq <- seqdef(mvad[,17:86], xtstep=3)
seqmsplot(m.seq, info=FALSE)

Related

SpotifyR get_artist_audio_features() doesn't filter by market, is_uri() not found when editing

I'm trying to obtain audio features of an artist's tracks with spotifyr:
test <- get_artist_audio_features("california honeydrops", include_groups = c("album", "single", "appears_on", "compilation"), market = "US")
A quick check of the results reveals several repeats of the same track and album names with slightly different audio features, and unique(test$available_markets reveals that these duplications are because the function did not properly filter by market = "US". Replacing "US" with other country codes yields the same result. However, if include_groups is left as the default, which only returns tracks from albums, then the market filter does work as expected.
I thought I might make a quick fix by editing the source code for get_artist_audio_features() to force market = "US" in RStudio, but I get an error when copy-pasting and then trying to run the original function's code because R insists one of the functions used to make get_artist_audio_features(), spotify::is_uri(), is not part of the spotifyr package. However, it can be found in the package's help section, is part of the original function, and works fine when calling the original function.
Of course, I can filter these duplicates out after the fact, but for edification's sake, what gives? Can anyone provide a fix to the original function or explain why R can't find the is_uri() when I try to run a copy of the original function?

R View gt table in window from script message box three buttons

Ultimate goal: Display gt table in pop-out window with 3 buttons to control script action
Minimum goal: Display a gt table in pop-out viewer window
Full detail:
I am creating a table using the gt package in R. I want to display the table with three options for how to proceed: OK (script continues), Edit (allow the user to make minor modifications to a specific column), Cancel (something has gone wrong and the process needs to be terminated). My plan is to allow a quick QC of the data before it gets saved. My issue is that I have no idea how to display a gt table in a viewer window or with tk_messageBox and that's about the only package I know of that might do this.
Any ideas?
Here's an example gt table:
table <- gt(mtcars) %>%
tab_header(
title = md("**2014 - 2019 Salary and Playoff Appearances**⚽"),
subtitle = "I am a boss")
you could achieve such an effect with shiny/miniUI specifically runGadget()
see this answer I gave yesterday which is an example where the user is shown two checkboxes to interact with that are returned as data into the calling environment
Is it possible to create a check box to record a user's input without resorting to Shiny in R?

How to modify the DataLabel fill (using a solid fill color)?

I'm trying to edit the data labels for a chart I'm writing on the slide. I can access the text of the datalabel using the methods available but as of yet the datalabel.fill is not existent. Any workarounds welcome if this is not planned on being added to the library in the future.
I've already gone through the source code in the github (https://github.com/scanny/python-pptx) but the datalabel class only has the font, has_text_frame, position, text_frame, _dLbl, _get_or_add_dLbl, _get_or_add_rich, _get_or_add_tx_rich, _get_or_add_txPr, and _remove_tx_rich methods. No fill or line fill methods is available.
The script I'm running does something similar for cells in a table:
cell.fill.solid()
cell.fill.fore_color.rgb = color_list[((col>0)*1)][i%2]
I'm looking at replicating the functionality on datalabels for chart series, with code that looks like this:
label.fill.solid()
label.fill.rgb = RGBColor(0x9B,0xBB,0x59)
label.fill.alpha = Alpha(.2)
label.line.fill.solid()
label.line.rgb = RGBColor(0xF0,0xF0,0x00)
The expected output xml should put the following for data labels:
<c:spPr>
<a:solidFill>
<a:srgbClr val="9BBB59">
<a:alpha val="80000"/>
</a:srgbClr>
</a:solidFill>
<a:ln>
<a:solidFill>
<a:schemeClr val="F0F000"/>
</a:solidFill>
</a:ln>
</c:spPr>
Actual output is non-existent as there is no method to do this directly.
This feature is not yet implemented, but if it was implemented it would be a .format property on the DataLabel object.
Typically users will work around an API gap like this by adding what we typically call a "workaround function" to the client code that manipulates the underlying XML directly, in this case, to add an <c:spPr> subtree in the right place.
python-pptx can generally get you close as far as a parent element is concerned. In this case, it can get you to the <c:dLbl> element like this:
data_label = chart.series[0].points[0].data_label
dLbl = data_label._dLbl
print(dLbl.xml)
The leading underscore in ._dLbl is your hint that you're getting into internals and if things don't go well it's something you're doing wrong, not an issue to be reported.
The dLbl object is an lxml.etree._Element object and can be manipulated with that API. If you have a search on "python-pptx workaround function" you'll find some examples for how to create new elements and put them where you want them.
The .xml property available on any python-pptx XML element object is handy for inspecting the results along the way. opc-diag can also be handy for inspecting PPTX files generated by PowerPoint or python-pptx for analysis or diagnostic purposes.

retrieve information from activities in processMapR

I have a problem with "ProcessmapR" .
Take the eventlog "patients" from package "eventdataR" , as an example .
We can get a plot from Business Process via "process_map(patients)".
Now I want to find out which patient-ID has passed through a node just by selecting the node in "Viewer" .
How can I do it ?
library(eventdataR)
library(processmapR)
process_map(patients)
click here to see the plot
The graph generated by process_map is static and you can't get much information from it;
There are ways to add any tooltip that you want on any of the nodes of the graph, though:
You need to do the process_map with render=FALSE option and save it to a variable, and then you can change it as you wish; for instance:
gr <- process_map(patients, render=FALSE)
gr$nodes_df$tooltip[1] <- "Just a test!"
render_graph(gr)
The code segment above is just for illustration, and by no means is supposed to be considered as a good way of doing this job.

How to set a "formatted value" in googleVis?

I am using googleVis and shiny to (automatically) create a Organizational Chart.
Similar to this question:
Google Visualization: Organizational Chart with fields named the same, I want to use formatted values in googleVis to be able to create fields in an organizational chart, which have the same name. I suspect it has something to do with roles but I cannot figure the correct syntax out.
The help page for gvisOrgChart mentiones formatted values but does not say how to set them:
"You can specify a formatted value to show on the chart instead, but the unformatted value is still used as the ID."
## modified example from help page
library(googleVis)
Regions[7,1] = Regions[8,1] # artificially create duplicated name in another parent node
Org <- gvisOrgChart(Regions)
plot(Org)
In the above example the duplicated name (Mexico) is only shown once in the chart. I want both of them to be drawn (One in the Europe and one in the America parent node).
Thank you for your help
cateraner
After talking to one of the developers of the googleVis package I got the solution to the problem now. The formatted value contains extra speak marks, which have to be removed before the text is usable as HTML.
## modified example from help page
library(googleVis)
# add new entry
levels(Regions$Region) = c(levels(Regions$Region), "{v: 'Germany.2', f: 'Germany'}")
Regions[8,1] = "{v: 'Germany.2', f: 'Germany'}"
Org <- gvisOrgChart(Regions)
# remove extra speak marks
Org$html$chart <- gsub("\"\\{v", "\\{v", Org$html$chart)
Org$html$chart <- gsub("\\}\"", "\\}", Org$html$chart)
plot(Org)
In the resulting graph you have two times "Germany", one under node "America" and one under "Europe". The same way you could add HTML formations to your text (color, font, etc.).
Thanks too Markus Gesmann for helping me on that.

Resources