data-management

R: create a data frame out of a rolling window

北城余情 提交于 2020-01-21 03:23:10
问题 Lets say I have a data frame with the following structure: DF <- data.frame(x = 0:4, y = 5:9) > DF x y 1 0 5 2 1 6 3 2 7 4 3 8 5 4 9 what is the most efficient way to turn 'DF' into a data frame with the following structure: w x y 1 0 5 1 1 6 2 1 6 2 2 7 3 2 7 3 3 8 4 3 8 4 4 9 Where w is a length 2 window rolling through the dataframe 'DF.' The length of the window should be arbitrary, i.e a length of 3 yields w x y 1 0 5 1 1 6 1 2 7 2 1 6 2 2 7 2 3 8 3 2 7 3 3 8 3 4 9 I am a bit stumped by

Access 2010 Date Data Management

蓝咒 提交于 2020-01-06 19:46:30
问题 I'm making a database that tracks equipment availability and how a question on how to approach data management. Currently I have it such that equipment may be entered when it is under maintaince and I have a table to track that data. What I need to come of this data is reports that contain weekly, month to date, and year to date availability. My initial thoughts were to use this one table to calculate everything that was down during the timeframe and just use the inverse to get the

Where to put data management rules for complex data validation in ASP.NET MVC?

纵饮孤独 提交于 2020-01-03 19:16:32
问题 I am currently working on an ASP.NET MVC2 project. This is the first time I am working on a real MVC web application. The ASP.NET MVC website really helped me to get started really fast, but I still have some obscure knowledge concerning datamodel validation. My problem is that I do not really know where to manage my filled datamodel when it comes to complex validation rules. For example, validating a string field with a Regex is quite easy and I know that I just have to decorate my field

How to reshape long to wide data in Stata?

空扰寡人 提交于 2020-01-02 08:59:05
问题 I have the following data: id tests testvalue 1 A 4 1 B 5 1 C 3 1 D 3 2 A 3 2 B 3 3 C 3 3 D 4 4 A 3 4 B 5 4 A 1 4 B 3 I would like to change the above long data format into following wide data. id testA testB testC testD index 1 4 5 3 3 1 2 3 3 . . 2 3 . . 3 4 3 4 3 5 . . 4 4 1 3 . . 5 I am trying reshape wide testvalue, i(id) j(tests) It gives error because there are no unique values within tests . What would be the solution to this problem? 回答1: You need to create an extra identifier to

Collapse data frame by group using different functions on each variable

不羁岁月 提交于 2019-12-24 10:28:00
问题 Define df<-read.table(textConnection('egg 1 20 a egg 2 30 a jap 3 50 b jap 1 60 b')) s.t. > df V1 V2 V3 V4 1 egg 1 20 a 2 egg 2 30 a 3 jap 3 50 b 4 jap 1 60 b My data has no factors so I convert factors to characters: > df$V1 <- as.character(df$V1) > df$V4 <- as.character(df$V4) I would like to "collapse" the data frame by V1 keeping: The max of V2 The mean of V3 The mode of V4 (this value does not actually change within V1 groups, so first, last, etc might do also.) Please note this is a

Reading plist file. iOS Programming

我的梦境 提交于 2019-12-23 02:45:12
问题 I have this code and can't figure out what I'm doing wrong. As you can see in the code below I have a plist file called shifts.plist which is in my supporting files folder. Here is my plist structure. NSString *path = [[NSBundle mainBundle] pathForResource:@"shifts" ofType:@"plist"]; dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:path]; cell.textLabel.text = [secondTableInfo objectAtIndex:indexPath.row]; NSLog(@"%@",[[dictionary objectForKey:@"name"]objectAtIndex:0]); I would

What is the best way to manage metadata in R? [duplicate]

半世苍凉 提交于 2019-12-21 05:21:37
问题 This question already has answers here : How to create, structure, maintain and update data codebooks in R? (4 answers) Closed last year . In analyzing data the metadata about variables is extremely important. How do you manage this information in R? For example, is there a way to specify a label that will be printed instead of the variable name? What facilities are there in R for this? 回答1: Quick suggestions that come to mind are attributes to store data along with an object (as Frank

Assign data frame name to list elements using name vector

大兔子大兔子 提交于 2019-12-18 08:59:03
问题 I have a data frame, 'mydata': head(mydata) ID MDC 000001 21A 000002 5 000003 8 ... I've split my data frame by one of it's column values, namely 'MDC'. This created a list, subdivided into further lists by the column value 'MDC': mylist <- split(mydata, mydata$MDC, drop=TRUE) summary(mylist) Length Class Mode 0 75 data.frame list 1 75 data.frame list 10 75 data.frame list 11 75 data.frame list 12 75 data.frame list 21A 75 data.frame list ... I now want to create a data frame for each MDC

how to insert missing observations on a data frame

岁酱吖の 提交于 2019-12-17 16:53:43
问题 I have a data that are observations over time. Unfortunately, some large gaps of time points are missing on a treatment. They are not coded as NA and if I make a plot out of them it becomes apparent. My data frame looks like this. The number of samples per time points are irregular. (edit: sorry for not making the example reproducible)s structure(list(A = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,

Make dummy target that checks the age of an existing file?

我是研究僧i 提交于 2019-12-11 17:45:57
问题 I'm using make to control the data flow in a statistical analysis. If have my raw data in a directory ./data/raw_data_files , and I've got a data manipulation script that creates cleaned data cache at ./cache/clean_data . The make rule is something like: cache/clean_data: scripts/clean_data I do not want to touch the data in ./data/ , either with make, or any of my data munging scripts. Is there any way in make to create a dependency for the cache/clean_data that just checks whether specific