Pie chart from flags in quicksight - amazon-quicksight

I have data in the folling format
ID
Day
Error_A_Happened
Error_B_Happened
Error_C_Happened
0
0
0
0
1
1
0
1
1
0
0
1
1
0
1
1
1
0
0
0
I want to create a pie chart that shows the errors by error category (A, B, C) in AWS Quicksight.
If I just drag a column to the chart it shows between 0 and 1, I tried creating another field with the sums of the column but I can't use it as a value in the chart.
I also tried something like
sum({Error_A_Happened}), sum({Error_B_Happened}), sum({Error_C_Happened})
But it gives me a syntax error.
I have no ideia what to do now, any help os welcomed.

Related

Set-up animation time in paraview from one column

I have a .txt file containing columns of data. At each row, i have 5 columns, containing object id, time, x position, y position, z position.
Example:
ID Time X Y Z
0 0 0 0 0
1 0 1 0 0
3 0 0 1 0
0 1 0 0 0
1 1 0 1 0
I don't know how to set up Paraview to read the column Time as the Time in the animation.
I know it's possible with multiple files (one for each time step), but is it possible with one single file containing all the time steps as shown above ?
Thanks for advice
Not supported in ParaView (last release 5.6.0) by default, but it should be quite easy to do it with a live programmable source.

Sorting Data, Getting Rid of Rows

Hi I'm trying to sort data by creating a new matrix from my current matrix data, that leaves out rows when a condition are met. For example, if I only want to keep the rows that have column 17's value as < 2, then I wrote:
B=[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
count=0
for n = 1:19709
if abs(G(n,17)) < 2
B(n,:)=G(n,:)
end
count=count+1
if count>19709
break
end
end
But this code instead returns a row of zeros when the conditions are not met, rather than just leaving out the row, but I'm not sure whats wrong with the code. Thank you!

Connected component labeling in matrix

I'm trying to do the following
Given the following matrix (where 1's are empty cells and 0's are obstacles):
0 0 1 1
1 0 0 0
1 0 1 1
1 1 0 0
I want it to become like this:
0 0 1 1
2 0 0 0
2 0 2 2
2 2 0 0
What I need to do is to label all connected components (free spaces).
What I already tried to do is to write a function called isConnected() which takes indexes of two cells and checks if there is a connected path between them. And by repeating this function n^2 times on every empty cell on the matrix I can label all connected spaces. But as this algorithm has a bad time complexity (n^2*n^2*O(isConnected())) I prefer to use something else.
I hope these pictures will explain better what I'm trying to accomplish:

Create a Matrix with conditions

I am struggling to create two matrix in SAS based on certain conditions.
trying to create a 12x12 matrix in the format below:
col1 col2 col3 col4 ............col12
1 0 0 0 ............ 0
1 1 0 0 ............ 0
1 1 1
0 1 1
0 0 1
1 0 0
1 1 0
1 1 1
0 1 1
0 0 1
0 0 0
0 0 0
and so on.
and this-
col1 col2 col3 col4 ............col12
1 0 0 0 ............ 0
1 2 0 0 ............ 0
1 2 3
0 2 3
0 0 3
1 0 0
1 2 0
1 2 3
0 2 3
0 0 3
0 0 0
0 0 0
and so on. Basically displays the col# instead of 1's.
I read a couple of articles online and tried Proc IML but i got an error that the procedure doesn't exist.
I tried the code below to start with but nothing. I am confused as to how should I enter the conditions.
data test_matrices ;
array col(12) col1-col12;
do i=1 to 12;
j=i-1;
col(i)=ifn(i le 5 , 1, 0,0);
output;
end;
run;
Please help.
Thanks.
Jay
What you need to start with:
Arrays have to have a name, and unless they're temporary arrays they also need variable names (they'll take the name concatenated with the array index if you don't provide it). So:
array (*) 1-12;
needs to be
array myVars(12) col1-col12;
You need two loops, one to define your 'rows' and one to work on your columns, nested. IE, for row 1, do something 12 times, for row 2, do something 12 times.
So this:
do i=1 to 12;
do j=1 to 12;
... do stuff ...
end;
output; *you had this right! It goes in the outer loop since it defines rows.;
end;
Now, you have something that lets you work on just one cell. So you're on cell (i,j); what rule defines what should go there? Figure out that logic, and then set myvars[j] to that value. You can't operate on the 'i' parameter, but instead that's going to just define how often you output.
Ie, this:
myvars[j] = i;
That's not correct, but figure out what is correct and assign that to myvars[j].

Plotting multiple matrices gnuplot

I'm fairly new to gnuplot and I'm trying to see how my array varies with iterations of my program to debug, I would ideally like to be able to make an animation of the data.
Here's what my data looks like:
'q=0'
1 0 0
0 1 1
1 1 0
'q=1'
1 0 0
0 1 1
0 1 0
and so on.
I tried using: plot "matrix.dat" index 0 matrix with image, just to plot the first matrix but I got "Warning matrix contains missing or undefined values, Matrix does not represent a grid".
I think the problem may be the comment lines. When I used this version of your data file
1 0 0
0 1 1
1 1 0
1 0 0
0 1 1
0 1 0
plotting with index works. To make an animation, you could create a series of .png files and stitch them together with another application. An example of the gnuplot code to make the .pngs would be:
set terminal png
do for [i=0:100] {
set output sprintf('matrix%03.0f.png',i)
plot 'data.dat' index i matrix with image
}

Resources