nested

Problems splitting data frame into a nested list

徘徊边缘 提交于 2019-12-02 04:56:52
I am a newbie to R and I have problem splitting a very large data frame into a nested list. I tried to look for help on the internet, but I was unsuccessful. I have a simplified example on how my data are organized: The headers are: 1 "station" (number) 2. "date.str" (date string) 3. "member" 4. "forecast time" 5. "data" I am not sure my data example will show up rightly, but if so, it look like this: 1. station date.str member forecast.time data1 2. 6019 20110805 mbr000 06 77 3. 6031 20110805 mbr000 06 28 4. 6071 20110805 mbr000 06 45 5. 6019 20110805 mbr001 12 22 6. 6019 20110806 mbr024 18

How to check if nested objects have children or not?

耗尽温柔 提交于 2019-12-02 04:37:36
I'm new to Javascript/React so I'm not sure how to implement this into my recursive function. I have a nested menu of json objects set up, and want to add little arrows indicating if there is another level to click to or not. Since my menu is made up of heavily nested json objects, I used recursion to go through all the objects and render them as a menu. I will include screenshots to visually explain what I'm trying to do as well. Does anyone have any ideas on how to check if that layer of objects has children, and if so add an arrow (or anything) to indicate this? Here is my code: class Menu

How to determine that all the files have been read and resolve a promise

大憨熊 提交于 2019-12-02 04:37:23
The following code is responsible for reading files. My requirement is how to find whether all files has been read so that I can return or resolve a promise from the parent function(readmultifiles). $.when(readmultifiles(files)) .then(function(){//all files uploaded})) Above code initiates the file read. What can be done so that upon reading of all files callback is done or a return can be made. function readmultifiles(files) { // Read first file setup_reader(files, 0); } function setup_reader(files, i) { var file = files[i]; var name = file.name; var reader = new FileReader(); reader.onload =

Extract values by key from a nested dictionary

六月ゝ 毕业季﹏ 提交于 2019-12-02 04:24:28
Given this nested dictionary, how could I print all the "phone" values using a for loop? people = { 'Alice': { 'phone': '2341', 'addr': '87 Eastlake Court' }, 'Beth': { 'phone': '9102', 'addr': '563 Hartford Drive' }, 'Randy': { 'phone': '4563', 'addr': '93 SW 43rd' } for d in people.values(): print d['phone'] Using a list comprehension >>> [people[i]['phone'] for i in people] ['9102', '2341', '4563'] Or if you'd like to use a for loop. l = [] for person in people: l.append(people[person]['phone']) >>> l ['9102', '2341', '4563'] Loop over the values and then use get() method, if you want to

Parsing a JSON file with GSON

心不动则不痛 提交于 2019-12-02 04:21:41
I'm having trouble reading a JSON file into a POJO. Let me give you a snippet of what my JSON file entails: { "Speidy": { "factionId": "2", "role": "ADMIN", "title": "", "power": 9.692296666666667, "powerBoost": 0.0, "lastPowerUpdateTime": 1337023306922, "lastLoginTime": 1337023306922, "chatMode": "PUBLIC" }, "ShadowSlayer272": { "factionId": "2", "role": "NORMAL", "title": "", "power": 0.8673466666666667, "powerBoost": 0.0, "lastPowerUpdateTime": 1336945426926, "lastLoginTime": 1336945426926, "chatMode": "PUBLIC" }, My issue is the first 'node' is completely random, i.e how can I make a POJO

Nested PCRE Regex Issue

北城以北 提交于 2019-12-02 03:18:59
问题 I have a custom template engine. It catch this : @function(argument1 argument2 ...) @get(param:name) @get(param:@get(sub:name)) And this : @function(argument1 argument2 ...) Some stuff @with(nested:tag) @foreach(arguments as value) More stuff : @get(value) @/foreach @function(other:args) Same function name (nested) @/function @/function With this pattern (PCRE / PHP) : # @ ([\w]+) \( ( (?: [^@\)] | (?R) )+ ) \) (?: ( (?> (?-2) ) ) @/\\1 )? #xms This regex catch almost all results. But when i

Creating nested master pages in ASP.NET Web Application

南楼画角 提交于 2019-12-02 03:12:39
问题 Is it possible to create nested master pages in an ASP.NET Web Application projects as one can do in ASP.NET Website projects? I am using Visual Studio 2008 and working on an ASP.NET Web Application. While creating a master page there is no option to choose another master page which if was available would have allowed me to create nested master pages. Have anyone faced similar issue? Is any sort of work around recommended? Thanks in advance for any help. Cheers. 回答1: Yes, from version 2 of

How do I map multiple lists with dapper

你。 提交于 2019-12-02 03:09:47
I've got three classes User, Order & Project which are stored in single tables. The orders and projects both have a n:n relation with the users. To implement that I've got two crosstables (UserOrders, UserProjects) which map these relations. public class User { public string UserID {get;set;} public List<string> Orders{get;set;} public List<string> Projects {get;set;} } public class Order { public string OrderID {get;set} ... } public class Project { public string ProjectID {get;set} ... } As you can see the User object contains a list of every related orderID/projectID. Now I want to query

storage problem in R. alternative to nested loop for creating array of matrices and then multiple plots

心不动则不痛 提交于 2019-12-02 03:05:28
问题 With the following pieces of information, I can easily create an array of matrices b0=data.frame(b0_1=c(11.41,11.36),b0_2=c(8.767,6.950)) b1=data.frame(b1_1=c(0.8539,0.9565),b1_2=c(-0.03179,0.06752)) b2=data.frame(b2_1=c(-0.013020 ,-0.016540),b2_2=c(-0.0002822,-0.0026720)) T.val=data.frame(T1=c(1,1),T2=c(1,2),T3=c(2,1)) dt_data=cbind(b0,b1,b2,T.val) fu.time=seq(0,50,by=0.8) pat=ncol(T.val) #number of T's nit=2 #no of rows pt.array1=array(NA, dim=c(nit,length(fu.time),pat)) for ( it.er in 1

JS: Reduce array to nested objects

老子叫甜甜 提交于 2019-12-02 02:56:58
问题 So I have this array var mapped = [[2016, "October", "Monday", {object}], [2017, "January", "Friday", {object}], [2017, "January", "Wednesday", {object}], [2017, "October", "Monday", {object}]] What I want to accomplish is something like this: [{ "2016": [{ "October": [{ "Monday": [{object}] }] }], }, { "2017": [{ "January": [{ "Friday": [{object}] }, { "Wednesday": [{object}] }] }, { "October": [{ "Monday": [{object}] }] }] }] I've been searching around for so long, and I can't find a