crosstab - R table (xtab?) -


my data in below format:

 out reg.   task date   task state name task state time  a6ere  01-03-2014  manual  23:09:48  a6ere  01-03-2014  manual  23:10:05  a6ere  01-03-2014  assign  23:24:44  a6ere  01-03-2014  confrm  23:25:15  a6ere  01-03-2014  arr     23:45:07  a6ere  01-03-2014  started 00:20:00  a6ere  01-03-2014  finish  00:39:00  a6eed  01-03-2014  free    22:42:28  a6eed  01-03-2014  manual  23:37:37  a6eed  01-03-2014  assign  23:37:41  a6eed  01-03-2014  confrm  23:37:58  a6eed  01-03-2014  arr     00:34:26  a6eed  01-03-2014  started 01:04:00 

i want summarize below:

out reg.task date   arr          assign     confrm       finish     free        manual    started  a6ere   01-03-2014  23:45:07    23:24:44    23:25:15    00:39:00                23:10:05    00:20:00 a6eed   01-03-2014  00:34:26    23:37:41    23:37:58    01:41:00    22:42:28    23:37:37   01:04:00 

i used pivot in excel , dcast in r (creating pivot table). both output count of timestamps instead of time stamps.

cross-tab in ms-access able give above required output.

is there anyway can acheive same in r? pls advise.

thank you.

it looks want use last value duplicated values:

df <- read.table(text="a6ere  01-03-2014  manual  23:09:48  a6ere  01-03-2014  manual  23:10:05  a6ere  01-03-2014  assign  23:24:44  a6ere  01-03-2014  confrm  23:25:15  a6ere  01-03-2014  arr     23:45:07  a6ere  01-03-2014  started 00:20:00  a6ere  01-03-2014  finish  00:39:00  a6eed  01-03-2014  free    22:42:28  a6eed  01-03-2014  manual  23:37:37  a6eed  01-03-2014  assign  23:37:41  a6eed  01-03-2014  confrm  23:37:58  a6eed  01-03-2014  arr     00:34:26  a6eed  01-03-2014  started 01:04:00")  dcast(df, v1+v2~v3, value.var="v4",         fun.aggregate=function(x) tail(as.character(x), 1), fill="")  #     v1         v2      arr   assign   confrm   finish     free   manual  started #1 a6eed 01-03-2014 00:34:26 23:37:41 23:37:58          22:42:28 23:37:37 01:04:00 #2 a6ere 01-03-2014 23:45:07 23:24:44 23:25:15 00:39:00          23:10:05 00:20:00 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -