forked from HackerEarth/indiahacks-ml-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadfiles.R
30 lines (23 loc) · 882 Bytes
/
readfiles.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(data.table)
library(jsonlite)
#### Train
train <- fromJSON("train_data.json")
train_data <- data.table(ID = unlist(names(train)))
train_data[, `:=` (genres = unlist(lapply(train, '[',1)),
titles = unlist(lapply(train, '[',2)),
cities = unlist(lapply(train, '[', 3)),
segment = unlist(lapply(train, '[',4)),
dow = unlist(lapply(train, '[',5)),
tod = unlist(lapply(train, '[', 6))
)]
#### Test
test <- fromJSON("test_data.json")
test_data <- data.table(ID = unlist(names(test)))
test_data[,`:=` (genres = unlist(lapply(test, '[',1)),
titles = unlist(lapply(test, '[',2)),
tod = unlist(lapply(test, '[', 3)),
cities = unlist(lapply(test, '[',4)),
dow = unlist(lapply(test, '[',5))
)]
str(train)
str(test)