CoConUT_import.R 1.17 KB
Newer Older
Stephanie's avatar
Stephanie committed
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

Sys.setenv(LANG = "en")  

library(ggplot2) 
library(jsonlite) 
require(GGally) 
library(dplyr) 
library(rgl) 
library(knitr)
library(scales) 
library(stringi) 
library(RHRV) 
library(anytime)

basedir <-"D:\\Dropbox\\UNI\\BAK\\Daten\\CoConUT\\"

datadir <- paste(basedir, 'data/', sep = "")
plotdir <- paste(basedir, 'plots/', sep = "")

#loading data
json_file <- paste(basedir, "g3.json", sep="") 
json_data_coco <- fromJSON(paste(json_file, sep = ""), flatten = TRUE) 
coconut.df <- json_data_coco[["data"]]

#parsing timestamp into actual time
coconut.df$unix_timestamp <- as.numeric(coconut.df$timestamp)/1000
time <- anytime(coconut.df$unix_timestamp)

# optional
coconut.df$second_counter = (coconut.df$unix_timestamp - min(coconut.df$unix_timestamp))

#extracting everything into variables
lux <- as.numeric(coconut.df$light.lux)
latitude <- as.numeric(coconut.df$gps.latitude)
longitude <- as.numeric(coconut.df$gps.longitude)
bluetooth <- as.numeric(coconut.df$bluetooth.numOfBTDevices)

#print everything
print(coconut.df)
print(time)
print(longitude)
print(latitude)
print(lux)
print(bluetooth)

# getting coordinate-tuples
coordinates<-cbind(latitude,longitude)
print(coordinates)