turning categorical data with 'from … to …' fields into a useable graph - graph

I have categorical data which are written every time there is a state change, the data in my case will have {state: ***, From: DateTime, To: DateTime}. The writing function also triggers every midnight, so no From-To will extend past midnight. My question is what is the most sensible way to graph this data? If possible I'd like to be able to graph it as shown in the attached image. If anyone has a better recommendation for graphing this or knows how to produce a graph like the one shown from a set of data I'd really appreciate the input.
For the language used to graph, if anyone knows of a C# extension, that would be ideal but for now any language that can give me something useable would be perfect.
Also I control the nature of the data, so if a solution requires fields to be added or changed, that's ok

Related

Conditional place data into a prebuilt report

It's quite an interesting challenge, and I can't say that I entirely know how/the best way to go about it.
Basically I have a data set, I have attached a few picture to try and show you what I am working with. The data was randomly generated but it similar to what I am working with.
I am wanting to take the data, then input the date and value into the report based on the category, and date. The even more challenging part of it is that I need to have to report be filled out for each unique id. So it will have to create many different reports, and then fill it out.
Any idea/questions? I have no idea how to go about it.
I am experienced in R, excel, some python and SQL (but very little).
If you have the dataset in R, you could write a function that takes the parameters needed, performs the aggregation, and writes the result to excel.
It is not clear to me what exactly the data aggregation part is. Without reproducible data it is hard to go into more detail.

How to auto restrict the view in rpivottable to be data protection compliant

I am starting a customer lifetime project at work and want to share how the data looks with the business, as I want to be able to identify the important variables with them. I plan to do this using the excellent rpivottable package and launch a shiny app to see where there are basic differences in groups to select my features.
This would mean I have my customer base of 4million customers and slice and dice them in a number of ways.
However, following GDPR we need to ensure no group is shown that has less than 7 customers in it. Therefore I need somekind of background calculation to ensure that less than 7 customers are never shown.
If I think logically about this, the only way I could see it working would be to make a change to the pivottable, have some form of submit button, so that the size of groups could be calculated, and then a filter (which needs to be hidden from the user so it cannot be switched off) is applied.
I know I should provide code, but I do not know where to start here. Has anyone had similar issues and has a potential solution to all or part of the problem?
Has anyone built a hidden filter into their rpivottable?
Has anyone been able to restrict their output to only show 90% of their data?
Thanks,
J
To be absolutely sure, you would need to load in a data frame that looks like "dim, dim, dim, count" where count is always greater than 7. Basically just a bit of preprocessing on your input data. Unfortunately, this means that you will be restricted to a small number of coarse dimensions, else you will end up filtering out everything.

Live Data Visualization using R and mongoDB

My aim is to create a visual data representation of Temperature data coming from a street light via sensors. I am picking that data from the mongoDB database. Basically in my knowledge and experience, I used Shiny And R to show static data graphs from the database, but I am unable to find any way of showing continuously updating data in a moving line chart. I hope you get the picture.
Please refer to this example using node.js(I want to achieve results similar to this but using R)
https://www.youtube.com/watch?v=nauRfoNNEQs
My questions is, is there a way to show real time data visualization in R or I have to necessarily use node.js with plotly?
I'm not sure how "live" you can get the stream, but you might want to look into this:
https://shiny.rstudio.com/reference/shiny/latest/reactivePoll.html
http://shiny.rstudio.com/gallery/reactive-poll-and-file-reader.html

Shinobi charts recreating every time

I am using shinobicharts ChartFragment. I have scenario that each time I have to load the chart with different data within same activity i.e I am not recreating that activity. But I am failed to do this. It not recreating and not clearing the series which I previously set to that chart.
Can anybody help, how can I remove old series in that chart and load new series each time? I tried shinobiChart().removeSeries() but it didn't work.
Thanks
If you wish to dynamically load new data, you do not necessarily need to remove the series. Instead you can simply add data points to your data adapter. You will find the following methods useful:
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#add(int, com.shinobicontrols.charts.Data)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#add(com.shinobicontrols.charts.Data)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#addAll(int, java.util.Collection>)
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#addAll(java.util.Collection>)
In these api docs you will also find similar methods to remove data points.
One thing to bear in mind is that adding or removing a data point to / from a SimpleDataAdapter class instance which is set on a series will trigger a redraw of that series. If you are working with large numbers of data points, this might not be performant. In this case a more suitable approach might be to temporarily remove the data adapter from the series, perform the modification to the data and then re add the data adapter back to the series. Alternatively you might like to implement your own DataAdapter and control when you instruct the chart to redraw that series (via the fireUpdateHandler method).
You can of course remove the series itself and add a new one, but this approach is potentially inefficient. That said, if you wish to remove a series from a chart you need to use the following method:
https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.html#removeSeries(com.shinobicontrols.charts.Series)
In order for this method to be successful you will first need to obtain a reference to the correct series, which you must pass to this method as a parameter.
I hope that you find this information useful. If you need any further help please if possible post any relevant code, such as that which you use to create your fragments and set up your chart.
Thanks and kind regards,
Kai.
Disclaimer - I work for ShinobiControls.

Array calculation in Tableau, maxif routine

I'm fairly new to Tableau, and I'm struggling in building some routines that could be easily implemented in Excel (though it would take forever for big sets of data).
So here is the deal, consider a dataset with the following fields:
int [id_order] -> id of the sales order (deepest level, there are only unique entries of id_order)
int [id_client] -> as I want to know who bought it
date [purchase_date] -> when the customer bought the product
What I want to know is, for each order, when was the last time (if ever) the client has bought something. In order words, what is the highest purchase_date for that user that is smaller than current purchase_date.
In excel, approach is simple (but again, not efficient)
{=max(if(id_client=B1,if(purchase_order
Is there a way to do this kind of calculation in Tableau?
You can do this in Tableau using table calculations. They take a little time to understand how to use well, but are very powerful and flexible. I posted a sample Tableau workbook for a similar question in an answer for SO question Find first time a condition is met
Your situation is similar, but with the extra complication that you want to repeat the analysis for each client id, so you might want to try a recursive approach using the Previous_Value() function instead of the approach used in that example - though I'm not certain that previous_value() will fit your situation.
Still, it might be helpful to download the example workbook I mentioned to get an idea how table calculations can address similar problems.
Just to register the solution, in case someone has the same doubt.
So, basically the solution I found use table calculation, which is not calculated until it's called on a sheet (and is only calculated on the context of the sheet). That's a little bit limiting, so what I do is create a sheet with all the fields I need (+ what is necessary for the table calculation) then export the data (to mdb) and connect to this new file.
So, for my example, the right table calculation is (let's name it last_order_date):
LOOKUP(MAX([purchase_date]),-1)
Explanations. The MAX() is necessary because Lookup (and all table calculations) does not work with data directly, only with aggregations. You can use sum, avg, max, attr, whatever suits you. As in my case there will be only 1 correspondence, any function will do just fine and return the same value.
The -1 indicates that I'm looking for the element immediately before the current entry (of the table, as you define it). If it were FIRST(), it would go for the first entry of the table, and LAST() would go for the last.
Now, I have to put it on a sheet. So I'll bring the fields id_client, id_order, purchase_date and last_order_date.
Then I have to define the parameters of my table calculation last_order_date (Edit Table Calculation). I'll go to Compute using and choose advanced. Now I'll do Partitioning: id_client, and addressing all the rest. What will that do? This mean Tableau will create temporary tables for each id_client, and table calculations will use those tables as parameter.
Additionally, I will Sort by field purchase_date, Max (again the aggregation issue) and ascending, to guarantee my entries are in chronological order.
Now, what will it do? For each entry it will access the table of the id_client, and check what was the purchase_date that is immediately before the current entry (that is being assessed), exactly what I need.
To avoid spending Tableau processing in Visualization, I often put all the fields in details (and leave nothing on screen), use Bar chart (it's good because it allows me to see the data). Then I export it to mdb, then connect to it again. Unfortunately Tableau doesn't directly export to tde.

Resources