nested

D3 nesting and object traversal

和自甴很熟 提交于 2019-12-25 09:14:36
问题 i have a json as shared below and I am trying to nest the data prior to visualization. I wish to plot under gov and non-gov how every vendor is distributed for high and low projects so trying to create a json object like [{v1: {Gov: {high:3, low:2}, {Non-Gov: {high:12, low:1}}}, {v2:{Gov: {high:3, low:2}, {Non-Gov: {high:12, low:1}}}, ...] I am able to nest the data but unable to get the respective counts. Any guidance is appreciated. Apologies if the question construct is vague. [ { "vendor"

Changing nested dictionary in VBA

人走茶凉 提交于 2019-12-25 08:58:29
问题 I was about to ask a question when the solution came in one test. So I'm posting anyway and answering, so others can benefit. The question was: I run the code below and get a runtime error 450 - Wrong number of arguments or invalid property assignment Dim data, tmpDict As Dictionary Set data = New Dictionary Set tmpDict = New Dictionary data.Add 123, tmpDict Set tmpDict = data.Item(123) tmpDict.Add "somekey", 100 data.Item(123) = tmpDict The error occur in last line. The code was simplified

Nested URLs, controllers and views in Ruby on Rails

主宰稳场 提交于 2019-12-25 08:46:47
问题 What I am trying to do is to nest my pages in Rails for example: www.mysite.com/fifa17/ps4 This way, once I am on the show.html.erb , I can use use the route to sell my product for specifically that game on that console platform.. At the moment, I have a Console model with has_many :games and a Game model with has_many :consoles , but I can't get the routing and views to work. Do I have just one controller or two? I have both the Games and Consoles seeded under ActiveRecords by name . I seem

Template function requires existence of inner class in non-templated class [duplicate]

天涯浪子 提交于 2019-12-25 08:03:16
问题 This question already has answers here : Where and why do I have to put the “template” and “typename” keywords? (6 answers) Closed 2 years ago . There's a template function f that requires its template parameter type T to have an inner class named Inner . Inside f the class T::Inner shall be instantiated. First try. // // "error: need 'typename' before 'T:: Inner' because 'T' is a dependent scope" // template <typename T> void f( void ) { T::Inner i; } I get that, so here comes the second try

python nested for-loop not executing beyond first

半世苍凉 提交于 2019-12-25 07:48:27
问题 This script is meant to read through a file and take in the number (numA) and the text next to it (sourceA). It then uses this and compares it to every other line in the file. If a match in "nums" is found but not in sources, it writes the num to a file along with the sources it appears in. with open(sortedNums, "r")as sor: for line in sor: NumsA, sourceA = line.split('####') for line in sor: if '####' in line: NumsB, sourceB = line.split('####') if (NumsA == NumsB) & (sourceA != sourceB):

Use list of nested indices to access list element

拈花ヽ惹草 提交于 2019-12-25 07:32:23
问题 How can a list of indices (called "indlst"), such as [[1,0], [3,1,2]] which corresponds to elements [1][0] and [3][1][2] of a given list (called "lst"), be used to access their respective elements? For example, given indlst = [[1,0], [3,1,2]] lst = ["a", ["b","c"], "d", ["e", ["f", "g", "h"]]] (required output) = [lst[1][0],lst[3][1][2]] The output should correspond to ["b","h"]. I have no idea where to start, let alone find an efficient way to do it (as I don't think parsing strings is the

Spark: Work around nested RDD

被刻印的时光 ゝ 提交于 2019-12-25 06:31:04
问题 There are two tables. First table has records with two fields book1 and book2 . These are id's of books that usualy are read together, in pairs. Second table has columns books and readers of these books, where books and readers are book and reader IDs, respectively. For every reader in the second table I need to find corresponding books in the pairs table. For example if reader read books 1,2,3 and we have pairs (1,7), (6,2), (4,10) the resulting list for this reader should have books 7,6. I

Nested For loops, X-mas tree in C

前提是你 提交于 2019-12-25 05:29:09
问题 So I have the task of creating a Christmas tree in C, I know this has been done to death but there are some conditions that have to be meet that leave me beyond confused, I don't even know where to start. So we ask the user for the number of levels(how many lines in the layer) and then the number of layers. Now, each line after the first in each layer will add 2 " * " one to each side of the first( which is just a line with one " * ".) And we do this until the number of levels in the layer is

Remove duplicates of array from another array, JavaScript

柔情痞子 提交于 2019-12-25 05:13:34
问题 How can i remove duplicated arrays in this data structure? I got this: ["5", "26", 300], ["7", "10", 20], ["3", "4", 30], ["5", "2", 52], ["9", "5", 300], ["3", "4", 30], ["5", "2", 52], ["5", "26", 300], ["1", "27", 250] with: var all = [].concat(jsonData['l'],jsonData['c'], jsonData['r']); for (e in all){ console.log([all[e].source, all[e].target, Number(all[e].link)]); } I need to reduce data, remove duplicated arrays and provide result to sankey graf. jsonData elements contain much more

avoiding nested for loops in MATLAB

北慕城南 提交于 2019-12-25 04:52:05
问题 I have a scenario in MATLAB where I would like to evaluate a function for certain parameter values. The parameters are extracted from an arbitrary number of arrays, and each array can have an arbitrary number of elements. I know the number of arrays and the number of elements in them before I call the function. For example, say I have arrays A = [a1 a2 ... aL] , B = [b1 b2 ... bM] and C = [c1 c2 ... cN] . for i = 1:length(A) for j = 1:length(B) for k = 1:length(C) myfunc(A(i), B(j), C(k)) end