Using Rstudio to create Graph - rstudio

i want to make Bar graph from attached data in Rstudio i want to show that what ip used what protocol and how many times
Protocol
Source DNS FTP HTTP IMF LLC SMTP TCP TELNET
172.16.112.100 306 0 0 0 0 0 0 0
172.16.112.50 0 0 0 0 0 0 0 24
172.16.113.168 0 0 0 0 0 0 0 15
172.16.113.204 1 0 0 0 0 0 0 0
172.16.114.50 1 0 0 0 0 0 0 0
172.16.115.20 158 0 0 0 0 0 0 2
192.168.1.20 3 0 0 0 0 0 0 0
194.7.248.153 0 0 0 0 0 0 0 2
197.218.177.69 0 0 0 0 0 0 0 0
HP_ed:9b:2d 0 0 0 0 0 0 0 0

Simple way to build one plot for each IP:
After loading data as a data.frame with colnames and rownames.
par(mfrow=c(4,3))
for (i in 1:nrow(data)) {
barplot(as.numeric(data[i,]), main=rownames(data)[i], names.arg=colnames(data))
}
Your data is very poor, which makes the graphs have only one or no bar at all. If you want stacked or grouped bars you should have a look at the pakages ggplot2 or lattice.

Related

Find 4-neighbors using J

I'm trying to find the 4-neighbors of all 1's in a matrix of 0's and 1's using the J programming language. I have a method worked out, but am trying to find a method that is more compact.
To illustrate, let's say I have the matrix M—
] M=. 4 4$0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0
0 0 1 0
0 0 0 0
0 0 0 0
and I want to generate—
0 0 1 0
0 1 0 1
0 0 1 0
0 0 0 0
I've sorted something close (which I owe to this little gem: https://www.reddit.com/r/cellular_automata/comments/9kw21u/i_made_a_34byte_implementation_of_conways_game_of/)—
] +/+/(|:i:1*(2 2)$1 0 0 1)&|.M
0 0 1 0
0 1 2 1
0 0 1 0
0 0 0 0
which is fine because I'll be weighting the initial 1's anyway (and the actual numbers aren't really that important for my application anyway). But I feel like this could be more compact and I've just hit a wall. And the compactness of the expression actually is important to my application.
Building on #Eelvex comment solution, if you are willing to make the verb dyadic it becomes pretty simple. The left argument can be the rotation matrix and then the result is composed with +./ which is a logical or and can be weighted however you want.
] M0=. 4 4$0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0
0 0 1 0
0 0 0 0
0 0 0 0
] m =.2,\5$0,i:1
0 _1
_1 0
0 1
1 0
m +./#:|. M0
0 0 1 0
0 1 0 1
0 0 1 0
0 0 0 0
There is still an issue with the edges (which wrap) around, but that also occurs with your original solution, so I am hoping that you are not concerned with that.
] M1=. 4 4$1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
m +./#:|. M1
0 1 0 1
1 0 0 0
0 0 0 0
1 0 0 0
If you did want to clean that up, you can use the slightly longer m +./#:(|.!.0), which fills the rotation with 0's.
] M2=. 4 4$ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1
m +./#:(|.!.0) M2
0 0 0 0
0 0 0 0
0 0 0 1
0 0 1 0
m +./#:(|.!.0) M1
0 1 0 0
1 0 0 0
0 0 0 0
0 0 0 0

Elassandra single node cluster not starting. Stuck in Mutation Stage

I have a single node Elassandra cluster running on a box.
It crashed light night. The following was the last line systemctl status output:
Main process exited, code=killed, status=6/ABRT
Upon restart however, it got stuck in mutation stage with similar lines appearing in the logs(/var/log/cassandra/system.log) repeatedly:
2020-09-14 12:53:38,048 TRACE [MutationStage-31] ElasticSecondaryIndex.java:2158 readCellValue indexer=730313363 name=value kind=REGULAR type=text value={"dw1":{"6":{"total_weight":"72664168.50","total_count":"5979710.00","product_name":"Masala 12g","target_weight":"12","mean_weight":"12.15","th_packed_weight":"71756520.00","ega":"907648.50","ega_per":"1.26"}},"dw2":{"6":{"total_weight":"72654813.00","total_count":"5979710.00","product_name":"Masala 12g","target_weight":"12","mean_weight":"12.15","th_packed_weight":"71756520.00","ega":"898293.00","ega_per":"1.25"}}}
tpstats output:
Pool Name Active Pending Completed Blocked All time blocked
ReadStage 0 0 0 0 0
MiscStage 0 0 0 0 0
CompactionExecutor 0 0 9 0 0
MutationStage 32 920 5808076 0 0
MemtableReclaimMemory 0 0 8 0 0
GossipStage 0 0 0 0 0
SecondaryIndexManagement 0 0 0 0 0
RequestResponseStage 0 0 0 0 0
ReadRepairStage 0 0 0 0 0
CounterMutationStage 0 0 0 0 0
MigrationStage 0 0 0 0 0
MemtablePostFlush 0 0 8 0 0
PerDiskMemtableFlushWriter_0 0 0 8 0 0
ValidationExecutor 0 0 0 0 0
Sampler 0 0 0 0 0
MemtableFlushWriter 0 0 8 0 0
InternalResponseStage 0 0 0 0 0
ViewMutationStage 0 0 0 0 0
AntiEntropyStage 0 0 0 0 0
CacheCleanupExecutor 0 0 0 0 0
Message type Dropped
READ 0
RANGE_SLICE 0
_TRACE 0
HINT 0
MUTATION 0
COUNTER_MUTATION 0
BATCH_STORE 0
BATCH_REMOVE 0
REQUEST_RESPONSE 0
PAGED_RANGE 0
READ_REPAIR 0
the pending count under MutationStage never goes to zero. Its been in this state for a long time. There are no other nodes in this cluster and no data is being written on it right now.
To me the symptoms you described indicate that mutations are getting replayed from the commitlog.
You can workaround it by:
Shutting C* down temporarily.
Move the contents of the commitlog/ to another directory.
Start Cassandra.

Grundy Number For a Matrix [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How to calculate the Grundy number for states of a 4*4 matrix. A valid move consists of transforming the 1s into 0s of a submatrix having all 1s.
Example:
1010
0011
0000
0000
Grundy Number = 2
I checked for smaller cases and calculated the Grundy number for that, but couldn't extend it for any binary 4*4 matrix. So, please help me to calculate this.
Note: Can convert 1 to 0 only in submatrix.
The Grundy number is calculated recursively through the reachable positions:
Start with the final position (all zeros) which is a loss (0).
0 0 0 0
0 0 0 0 = 0
0 0 0 0
0 0 0 0
Proceed to add ones to the matrix to get the values for the other configurations. Some examples with exactly one 1.
1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 = 0 0 0 0 = 0 0 1 0 = 0 0 0 1 = 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
For two 1s we have to distinguish if the 1s are adjacent and can be removed in one move or not.
1 0 1 0 1 0 0 0 1 0 0 0* 0 0 1 0
0 0 0 0 = 0 0 1 0 = 0 0 0 1 = 0 0 0 1 = 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 = 0 0 1 1 = 2
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
The same for three and more 1s.
1 0 1 0*
0 0 0 1 = 1
0 0 0 0
0 0 0 0
1 0 1 0* 1 0 0 0* 0 0 1 0*
0 0 1 0 = 0 0 1 1 = 0 0 1 1 = 3
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Finally we can evaluate the given matrix. Reachable positions from the example are marked with a star *. So we can easily see that the number we are looking for is mex(0, 1, 3) = 2.
1 0 1 0
0 0 1 1 = 2
0 0 0 0
0 0 0 0
A pseudo program could look as simple as this (the grundy function has to support scalar state and arrays or vectors of states for this to work):
grundy(0) = 0
grundy(state) = mex(grundy(reachableStates(state)))

Gnuplot set matrix dimension

I have a datafile contains two 101*101 matrix of float numbers, one is data and the other is error.
It looks like this
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
10381.8 0 0 3462.03 10341 0 6889.64
6919.26 6916.64 3459.49 10349.8 13781.3 6887.57 24157.2
3459.66 0 24158.9 13792.6 3433.65 27579.4 24117.4
0 0 0 0 0 0 0
0 0 0 0 0 0 0
# Errors [Positon_sample/samp_psd.txt] I_err:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
4892.66 4890.8 3459.49 5975.49 6890.64 4870.25 9130.63
3459.66 0 9131.25 6896.32 3433.65 9750.84 9115.54
3464.99 4888.97 5972.77 11419.1 7713.44 8438.29 9093.38
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Now I would like to only plot the first matrix.
I use "plot 'E:\samp_psd.txt' matrix with image"
But the program corrupt...
It seems that I should set the dimension of the matrix,
My case is a little similar like this
Gnuplot plot Matrix over Matrix
I would separate the two matrices with two empty lines like this:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
10381.8 0 0 3462.03 10341 0 6889.64
6919.26 6916.64 3459.49 10349.8 13781.3 6887.57 24157.2
3459.66 0 24158.9 13792.6 3433.65 27579.4 24117.4
0 0 0 0 0 0 0
0 0 0 0 0 0 0
# Errors [Positon_sample/samp_psd.txt] I_err:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
4892.66 4890.8 3459.49 5975.49 6890.64 4870.25 9130.63
3459.66 0 9131.25 6896.32 3433.65 9750.84 9115.54
3464.99 4888.97 5972.77 11419.1 7713.44 8438.29 9093.38
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Then you can access a single matrix with the index command like this:
plot "samp_psd.txt" index 0 matrix with image

Can`t plot matrix in Gnuplot

I have a matrix of 1s and 0s saved in file. It looks like this:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 0 0 0 0 1 1 0 0 0
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
I am trying to plot in gnuplot using command:
plot 'data.rtf' matrix with image
but when I do that I get an error:
warning: matrix contains missing or undefined values
Matrix does not represent a grid
I think I should get an image where 0 is white space and 1 is black space. I am new to gnuplot so i have no idea what might be wrong nor if i am using correct way to do it. I will be grateful for any help. Thanks.
Your file is an rtf (rich text format) file which is a markup language format, which gnuplot will not understand. You will need to create the file in a text editor (not a word processor) in order to be able to use it.
The file that you provided looks like:
{\rtf1\ansi\ansicpg1250\cocoartf1404\cocoasubrtf340
{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\f0\fs22 \cf0 \CocoaLigature0 0 0 0 0 0 0 0 0 0 0\
0 0 0 0 0 0 0 0 0 0\
0 0 0 0 0 0 0 0 0 1\
0 0 0 0 0 0 0 0 0 0\
0 0 0 0 0 0 0 1 1 0\
0 0 0 0 0 1 1 0 0 0\
1 1 1 1 1 0 0 0 0 0\
0 0 0 0 0 0 0 0 0 0\
0 0 0 0 0 0 0 0 0 0\
0 0 0 0 0 0 0 0 0 0
Notice that it starts with a bunch of markup text. Gnuplot is designed to work with text files and not formatted text or binary files (with some limited exceptions).
Creating a text file containing your designed matrix will work just fine.
Color plots are surface-like plots, thus you have to use splot not plot
set pm3d map
set palette gray
splot 'test.txt' matrix w image

Resources