Using Graphite, I'm plotting some graph and the same with a time shift.
Eg:
aliasByNode(my.application.metric.$Continent.$DC.*, 4, 5, 3)
aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3)
But I'd like to be able to identify the graphs (they currently get the same name).
How to add a prefix or a suffix (or any marker) to a metric alias?
Eg:
-- EU.PAR.pokemonCaught
-- EU.PAR.pokemonCaught (last week)
Use regex with aliasSub to grab whole ( (.*) ) metric and change it - add desired text ( \1 last week ). E.g.
aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3)
should look like
aliasSub(aliasByNode(timeShift(my.application.metric.$Continent.$DC.*, "7d"), 4, 5, 3), "(.*)", "\1 last week")
You could just use alias() to rename it however you like.
Related
I have a very large array (RFO_2003; dim = c(360, 180, 13, 12)) of numeric data. I made the array using a for-loop that does some calculations based another array. I am trying to check some samples of data in this array to ensure I have generated it properly.
To do this, I want to apply a function that returns the index of the array where that element equals a specific value. For example, I want to start by looking at a few examples where the value == 100.
I tried
which(RFO_2003 == 100)
That returned (first line of results)
[1] 459766 460208 460212 1177802 1241374 1241498 1241499 1241711 1241736 1302164 1302165
match gave the same results. What I was expecting was something more like
[8, 20, 3, 6], [12, 150, 4, 7], [16, 170, 4, 8]
Is there a way to get the indices in that format?
My searches have found solutions in other languages, lots of stuff on vectors, or the index is never output, it is immediately fed into another part of a custom function so I can't see which part would output the index in a way I understand, such as this question, although that one also returns dimnames not an index.
I am looking to take a collection and slide a window of length 'w' and step size 's' over it to get many sub collections.
I have seen Base.Iterators.partition but that does not allow sliding by less than the window (or partition) length.
I have written something myself that works but I expect there is already a function that does this and I just haven't found it yet.
Assuming z is your Vector and s is your step size and w is window size simply do:
((#view z[i:i+w-1]) for i in 1:s:length(z)-w+1)
Example:
z = collect(1:10)
for e in ((#view z[i:i+4]) for i in 1:2:length(z)-4)
#do something, try display(e)
end
I just found IterTools.jl, it has a partition with custom step size.
julia> for i in partition(1:9, 3, 2)
#show i
end
i = (1, 2, 3)
i = (3, 4, 5)
i = (5, 6, 7)
i = (7, 8, 9)
Have you looked at RollingFunctions? It seems to me that it does what you're looking for, it has rolling and running functions which take a function, a vector, and a windows size as input and return the result of applying the function over successive windows.
I have the following csv:
https://github.com/antonio1695/Python/blob/master/nearBPO/facturasprueba.csv
With it I want to use the apriori function to find association rules. However, I get the error:
Error in asMethod(object) :
column(s) 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 not logical or a factor. Discretize the columns first.
I have already bumped into this error before, and what I did was:
dataframe$columnX <- discretize(df$columnX)
However, this only works if I select manually each column and discretize them one by one. I would like to do the same thing but for aprox 3k columns. The case I gave you has only 11, I'm guessing that 11 will do.
I found the answer, thanks for everyones help though. To select and discretize multiple columns:
for (i in 2:12){df[,i]<-discretize(df[,i])}
I have two undirected graphs.
require (igraph)
gsmall <- graph(c(1,3,5,8,3,5), directed = F)
gbig <- graph(c(3, 5, 3, 10, 4, 5, 4, 10, 5, 7, 5, 8, 5, 9, 7, 10, 8, 10, 9, 10), directed = F)
Now I want to know if gbig contains a subgraph which is isomorphic to gsmall. Or to put it precise I want one specific mapping (if it exists).
In the igraph R-package this can be done with the subgraph_isomorphisms function. The problem is that this function gives me all isomorphisms which is expensive already in this small example.
So I tried graph.subisomorphic.lad(gsmall, gbig, all.maps =F) which gives me
$iso
[1] TRUE
$map
[1] 3 1 10 6 9 8 4 5
$maps
NULL
as a result. Supposedly $map contains the information I need. But I don't know how to use these numbers to generate a renaming of nodes from gsmall such that the renamed version of gsmall is actually a subgraph of gbig. I have the same translation problem with the output of subgraph_isomorphisms which according to the help returns a 'list of vertex sequences, corresponding to all mappings from the first graph to the second' which I don't understand.
Can anyone tell me how to get that renaming I want? If I am right with the assumption that the $map entry of the result of graph.subisomorphic.lad(gsmall, gbig, all.maps =F) contains what I need how can I get that renaming from that point on? If not how to achieve it in another way?
Thanks in advance.
I need help with the replace() command
replace(c(3,2,2,1),1:3,4:6)
I was expecting an output of 6,5,5,4 but got 4,5,6,1
What am i doing wrong?
My understanding of what replace is this: it looks up index values of elements of the first argument in the second argument (e.g. 3 is the 3rd element in 1:3) and then replaces it with elements in the third argument with the same index (e.g. 3rd element in 4:6 is 6 thus the reason for me expecting the first element in the vector to be 6)
Thank you. (replace help file doesn't have example... need to ask for clarification here)
While replace doesn't give the behaviour your desired, to achieve what you were intending is quite easy to do using match:
new[match(x,i)]
It is all given in the description of replace(), just read carefully:
‘replace’ replaces the values in ‘x’ with indices given in ‘list’
by those given in ‘values’. If necessary, the values in ‘values’
are recycled.
x <- c(3, 2, 2, 1)
i <- 1:3
new <- 4:6
so this means in your case:
x[i] <- new
That command says to take the vector c(3, 2, 2, 1) and to replace the components with indices in 1:3 by the values given by the vector 4:6. This gives c(4, 5, 6, 1).