-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 21.7 KB
/
.Rhistory
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
return(data.frame(lon=c(h1, h2), lat=c(k1, k2)))
}
return(NULL)
}
yup2 <- data.frame(lon=c(-77.2858, -77.2850),lat=c(1.2059, 1.2050),score=c(1))
centers = calculateDisk(-77.2858, 1.2059, -77.2850, 1.2050)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1) %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1) %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1) %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*1000)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1) %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*100000)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1) %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*1000000)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*999999) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*999500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*990500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*590500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*790500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*890500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*899500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.5, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.75, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=yup2$lon, lat=yup2$lat, radius = 0.1)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=1, fillOpacity=0.75, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=points$lon, lat=points$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=2, fillOpacity=0.75, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=points$lon, lat=points$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=2, fillOpacity=0.05, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=points$lon, lat=points$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=2, fillOpacity=0.25, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=points$lon, lat=points$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lon, lat=centers$lat, weight=2, fillOpacity=0.35, color="red", radius = epsilon*950500) %>%
addCircleMarkers(lng=points$lon, lat=points$lat, radius = 0.1)
points <- data.frame(lng=as.numeric(c(-77.2858, -77.2850)),
lat=as.numeric(c(1.2059, 1.2050)))
d <- SpatialPointsDataFrame(coords = points, data = points, proj4string = CRS("+init=epsg:4326"))
library(sp)
d <- SpatialPointsDataFrame(coords = points, data = points, proj4string = CRS("+init=epsg:4326"))
d_mrc <- spTransform(d, CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"))
d_mrc
coordinates(d_mrc)
coordinates(d_mrc)$lng
coordinates(d_mrc)[1,1]
coordinates(d_mrc)[1,2]
class(coordinates(d_mrc)[1,2])
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
centers
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
centers
c_merc <- SpatialPointsDataFrame(coords = centers, data = centers, proj4string = CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"))
c <- spTransform(c_merc, CRS("+init=epsg:4326"))
c_merc
c
coordinates(c)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
as.data.frame(coordinates(c))
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lng, lat=centers$lat, weight=2, fillOpacity=0.35, color="red", radius = epsilon) %>%
addCircleMarkers(lng=points$lng, lat=points$lat, radius = 0.1)
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lng, lat=centers$lat, weight=2, fillOpacity=0.35, color="red", radius = epsilon/2) %>%
addCircleMarkers(lng=points$lng, lat=points$lat, radius = 0.1)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
leaflet() %>% addProviderTiles("Esri.WorldStreetMap") %>%
addCircles(lng=centers$lng, lat=centers$lat, weight=2, fillOpacity=0.35, color="red", radius = epsilon/2) %>%
addCircleMarkers(lng=points$lng, lat=points$lat, radius = 0.1)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
library(SparkR)
# sparkR.session(master = "local[*]", sparkConfig = list(spark.driver.memory = "2g"))
sc <- sparkR.init("local[4]", "SparkR", sparkPackages="com.databricks:spark-csv_2.10:1.5.0")
sqlContext <- sparkRSQL.init(sc)
dataRDD = SparkR:::textFile(sc,"/home/and/notebooks/sample_small.csv")
dataRDD
dataRDD_splitted = SparkR:::map(dataRDD, function(x){print(x)})
head(dataRDD_splitted)
r = "898,40.3586583,116.5952766"
strsplit(r, ",")
strsplit(r, ",")[1]
strsplit(r, ",")[[1]][1]
strsplit(r, ",")[[1]][2]
strsplit(r, ",")[[1]]
library(sp)
pts = cbind(1:5, 1:5)
pts
point = strsplit(r, ",")[[1]]
point
strsplit(r, ",")
as.matrix(strsplit(r, ","))
as.data.frame(strsplit(r, ","))
as.data.frame(t(strsplit(r, ",")))
as.matrix(t(strsplit(r, ",")))
as.data.frame(t(strsplit(r, ",")[[1]]))
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
coordinates(p) = ~V2+V3
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p$V2 <- as.numeric(p$V2)
p$V3 <- as.numeric(p$V3)
coordinates(p) = ~V2+V3
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p
p$V2 <- as.numeric(p$V2)
p
as.double("40.25")
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V2+V3
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p$V2 <- as.double(p$V2)
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p$lng <- as.double(p$V2)
p$lat <- as.double(p$V3)
coordinates(p) = ~lng+lat
p
p = as.data.frame(t(strsplit(r, ",")[[1]]))
p$lng <- as.double(p$V2)
p
class(p$V2)
?as.data.frame
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$lng <- as.double(p$V2)
p$lat <- as.double(p$V3)
coordinates(p) = ~lng+lat
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~lng+lat
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V2+V3
p
data(meuse)
meuse.xy = meuse[c("x", "y")]
View(meuse.xy)
class(meuse)
class(meuse.xy)
coordinates(meuse.xy) <- ~x+y
class(meuse.xy)
p
class(p)
proj4string(p) = CRS("+proj=longlat +datum=WGS84")
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = CRS("+proj=longlat +datum=WGS84")
p
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
wgs84 = CRS("+init=epsg:4326")
mercator = CRS("+init=epsg:3857")
proj4string(p) = wgs84
p
p2 = spTransform(p, mercator)
p2
r = "898,40.3586583,116.5952766"
p = as.data.frame(t(strsplit(r, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = wgs84
p = spTransform(p, mercator)
p
p$coords
p$coordinates
p@coords
cbind(p$V1,p@coords)
c(p$V1,p@coords)
len(c(p$V1,p@coords))
length(c(p$V1,p@coords))
transformCoords <- function(line){
p = as.data.frame(t(strsplit(line, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = wgs84
p = spTransform(p, mercator)
return(c(p$V1,p@coords))
}
r = "898,40.3586583,116.5952766"
print(transformCoords(r))
dataRDD = SparkR:::textFile(sc,"/home/and/notebooks/sample_small.csv")
dataRDD_splitted = SparkR:::map(dataRDD, transformCoords)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/transformCoords.R')
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/transformCoords.R')
head(dataRDD)
dataRDD_splitted
sdf <- createDataFrame(sqlContext, dataRDD_splitted)
head(sdf)
?as.double
?as.numeric
as.numeric(c("-.1"," 2.7 ","B"))
as.numeric(c("-.1","2.7154613","B"))
as.double(c("-.1","2.7154613","B"))
r
transformCoords(r)
transformCoords <- function(line){
library(sp)
p = as.data.frame(t(strsplit(line, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = wgs84
p = spTransform(p, mercator)
return(as.double(c(p$V1,p@coords)))
}
r = "898,40.3586583,116.5952766"
transformCoords(r)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/transformCoords.R')
r = "898,40.3586583,116.5952766"
transformCoords(r)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/transformCoords.R')
r = "898,40.3586583,116.5952766"
transformCoords(r)
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/transformCoords.R')
r = "898,40.3586583,116.5952766"
transformCoords(r)
rr = transformCoords(r)
rr
rr[1]
as.integer(rr[1])
as.double(rr[2])
as.numeric(rr[2])
class(rr[2])
options(digits=15)
as.numeric(rr[2])
source('~/.active-rstudio-document')
head(points)
nrow(points)
p = c(2,3,6)
p
poinst[points$ID == p,]
points[points$ID == p,]
points[p,]
source('~/.active-rstudio-document')
?rect
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
plot(NA)
rect(c(3,4),c(1,0),c(5,9),c(6,5))
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
View(data)
source('~/.active-rstudio-document')
data
data[1]
data[1,1]
class(data[1,1])
data = read.table('/home/and/notebooks/sample_small.csv', header = F)
data = read.table('/home/and/notebooks/sample_small.csv', header = F, stringsAsFactors = F)
data[1,1]
class(data[1,1])
lapply(data, transformCoords)
library("rgdal", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
library("rgdal", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.3")
lapply(data, transformCoords)
data
lapply(data, transformCoords)
lapply(data, 1, transformCoords)
lapply(data, 2, transformCoords)
tapply(data, 2, transformCoords)
tapply(data, 1, transformCoords)
tapply(data, transformCoords)
mapply(data, transformCoords)
apply(data, 1, transformCoords)
mapply(data, 1, transformCoords)
apply(t(data), 1, transformCoords)
apply(t(data), 2, transformCoords)
t(apply(data, 1, transformCoords))
write.csv(lapply(data, transformCoords), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
write.csv(t(lapply(data, transformCoords)), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
t(apply(data, 1, transformCoords))
write.csv(t(apply(data, 1, transformCoords)), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
write.csv(t(apply(data, 1, transformCoords)), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, header = F)
?writer.csv
?write.csv
write.csv(t(apply(data, 1, transformCoords)), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
class(t(apply(data, 1, transformCoords)))
class(as.data.frame(t(apply(data, 1, transformCoords))))
class(data)
class(t(data))
write.csv(apply(t(data), 1, transformCoords)), '/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
write.csv(as.data.frame(t(apply(data, 1, transformCoords))),
'/home/and/notebooks/sample_small_EPGS-4799.csv',row.names = F, col.names = F)
write.csv(as.data.frame(t(apply(data, 1, transformCoords))),
'/home/and/notebooks/sample_small_EPGS-4799.csv', row.names = F, col.names = F)
write.table(as.data.frame(t(apply(data, 1, transformCoords))),
'/home/and/notebooks/sample_small_EPGS-4799.csv', sep = ',', row.names = F, col.names = F)
install.packages(c("colorspace", "ggplot2", "htmlwidgets", "knitr", "plotly", "rgdal", "scales"))
install.packages(c("colorspace", "ggplot2", "htmlwidgets", "knitr",
)
).
install.packages(c("colorspace", "ggplot2", "htmlwidgets", "knitr", "plotly", "rgdal", "scales"))
data = read.table('/home/and/notebooks/sample_small.csv', header = F)
data[1,1]
line = "0,39.537542,116.694663"
p = as.data.frame(t(strsplit(line, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
library(sp)
p = as.data.frame(t(strsplit(line, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = wgs84
p = spTransform(p, mercator)
p
line = "0,39.990010,116.317406"
p = as.data.frame(t(strsplit(line, ",")[[1]]),stringsAsFactors=F)
p$V2 <- as.double(p$V2)
p$V3 <- as.double(p$V3)
coordinates(p) = ~V3+V2
proj4string(p) = wgs84
p = spTransform(p, mercator)
p
line
install.packages("yaml")
source('~/Documents/PhD/Code/Y2Q1/SDB/Project/Code/Leaflet_example.R')
map
library(SparkR)
# sparkR.session(master = "local[*]", sparkConfig = list(spark.driver.memory = "2g"))
sc <- sparkR.init("local[4]", "SparkR", sparkPackages="com.databricks:spark-csv_2.10:1.5.0")
library(SparkR)
# sparkR.session(master = "local[*]", sparkConfig = list(spark.driver.memory = "2g"))
sc <- sparkR.init("local[4]", "SparkR", sparkPackages="com.databricks:spark-csv_2.10:1.5.0")
library(SparkR)
# sparkR.session(master = "local[*]", sparkConfig = list(spark.driver.memory = "2g"))
sc <- sparkR.init("local[4]", "SparkR", sparkPackages="com.databricks:spark-csv_2.10:1.5.0")
sqlContext <- sparkRSQL.init(sc)
schema <- structType(structField("tag", "string"), structField("x", "double"), structField("y", "double"))
points <- read.df(sqlContext, "/home/and/Documents/PhD/Code/Y2Q1/SDB/Project/Code/points.txt", source = "com.databricks.spark.csv", schema = schema)
# points = as.DataFrame(sqlContext = sqlContext, data=points)
registerTempTable(points, "points")
sql = "SELECT * FROM points WHERE POINT(x, y) IN CIRCLERANGE(POINT(4.5, 4.5), 2)"
print(collect(sql(sqlContext,sql)))
capabilities()
q()
if (!require("pacman")) install.packages("pacman")
pacman::p_load(ggplot2, data.table)
filename = 'Beijing_N10K-50K_E10.0-50.0_1496421767449.csv'
data = mydat <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
names(data) = c('Epsilon', 'Dataset', 'Time', 'Implementation')
temp_title = paste("(radius of disk in mts) in Beijing dataset.")
title = substitute(paste("Execution time by ",epsilon) ~temp_title, list(temp_title = temp_title))
if (!require("pacman")) install.packages("pacman")
pacman::p_load(ggplot2, data.table)
filename = 'Beijing_N10K-50K_E10.0-50.0_1496421767449.csv'
data = mydat <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
filename = 'Beijing_N10K-50K_E10.0-50.0_1496421767449.csv'
data <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
filename = 'Beijing_N10K-50K_E10.0-50.0_1496421767449.csv'
data <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
View(data)
names(data) = c('Epsilon', 'Dataset', 'Time', 'Implementation')
temp_title = paste("(radius of disk in mts) in Beijing dataset.")
title = substitute(paste("Execution time by ",epsilon) ~temp_title, list(temp_title = temp_title))
g = ggplot(data=data, aes(x=factor(Dataset), y=Time, group=Implementation, colour=Implementation, shape=Implementation)) +
geom_line(aes(linetype=Implementation)) +
geom_point(size=2) +
labs(title=title,y="Time (sec)") +
## scale_x_discrete("Number of points", breaks = paste0(seq(20,100,20),"K")) +
scale_x_discrete("Number of points") +
theme(axis.text.x=element_text(size=8, angle=90),axis.text.y=element_text(size=8)) +
facet_wrap(~Epsilon) +
scale_colour_discrete() +
scale_shape_discrete() +
scale_linetype_discrete()
pdf(paste0(filename, ".pdf"), width = 10.5, height = 7.5)
plot(g)
dev.off()
setwd("~/Documents/PhD/Code/Y2Q3/Scripts")
source('~/Documents/PhD/Code/Y2Q3/Scripts/plotBenchmarks.R')
source('~/Documents/PhD/Code/Y2Q3/Scripts/plotBenchmarks.R')
filename
strsplit(filename, '.')
filename
strsplit(filename, '\.')
strsplit(filename, '\\.')
strsplit(filename, '\\.')[1:-1]
strsplit(filename, '\\.')[1:3]
strsplit(filename, '\\.')[[1]][1:3]
strsplit(filename, '\\.')[[1]][1:4]
length(strsplit(filename, '\\.'))
length(strsplit(filename, '\\.')[[1]])
length(strsplit(filename, '\\.')[[1]]) - 1
strsplit(filename, '\\.')[[1]][1:length(strsplit(filename, '\\.')[[1]]) - 1]
paste0(strsplit(filename, '\\.')[[1]][1:length(strsplit(filename, '\\.')[[1]]) - 1], collapse = '.')
if (!require("pacman")) install.packages("pacman")
if (!require("pacman")) install.packages("pacman")
pacman::p_load(ggplot2, data.table)
args = commandArgs(trailingOnly=TRUE)
filename = args[1]
filename = "Beijing_N60K-100K_E30.0-50.0_1496879439.csv"
data <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
names(data) = c('Epsilon', 'Dataset', 'Time', 'Implementation')
temp_title = paste("(radius of disk in mts) in Beijing dataset.")
title = substitute(paste("Execution time by ",epsilon) ~temp_title, list(temp_title = temp_title))
paste0(seq(20,100,20),"K")
data
g = ggplot(data=data, aes(x=factor(Dataset), y=Time, group=Implementation, colour=Implementation, shape=Implementation)) +
geom_line(aes(linetype=Implementation)) +
geom_point(size=2) +
labs(title=title,y="Time (sec)") +
scale_x_discrete("Number of points", breaks = paste0(seq(20,100,20),"K")) +
## scale_x_discrete("Number of points") +
theme(axis.text.x=element_text(size=8, angle=90),axis.text.y=element_text(size=8)) +
facet_wrap(~Epsilon) +
scale_colour_discrete() +
scale_shape_discrete() +
scale_linetype_discrete()
filename = paste0(strsplit(filename, '\\.')[[1]][1:length(strsplit(filename, '\\.')[[1]]) - 1], collapse = '.')
plot(g)
data <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
filename = "Beijing_N60K-100K_E30.0-50.0_1496879439.csv"
data <- fread(paste0('http://www.cs.ucr.edu/~acald013/public/Results/', filename))
data = data[, c(2, 3, 5, 1)]
names(data) = c('Epsilon', 'Dataset', 'Time', 'Implementation')
data$Dataset <- factor(data$Dataset, levels = paste0(seq(10,100,10),"K"))
data
summary(data$Dataset)
temp_title = paste("(radius of disk in mts) in Beijing dataset.")
title = substitute(paste("Execution time by ",epsilon) ~temp_title, list(temp_title = temp_title))
g = ggplot(data=data, aes(x=factor(Dataset), y=Time, group=Implementation, colour=Implementation, shape=Implementation)) +
geom_line(aes(linetype=Implementation)) +
geom_point(size=2) +
labs(title=title,y="Time (sec)") +
scale_x_discrete("Number of points", breaks = paste0(seq(20,100,20),"K")) +
## scale_x_discrete("Number of points") +
theme(axis.text.x=element_text(size=8, angle=90),axis.text.y=element_text(size=8)) +
facet_wrap(~Epsilon) +
scale_colour_discrete() +
scale_shape_discrete() +
scale_linetype_discrete()
plot(g)
devtools::install_github("rstudio/addinexamples", type = "source")
addinexamples:::reformatAddin()
addinexamples:::reformatAddin()
system("git status", wait=TRUE)
setwd("~/Documents/PhD/Code")
getwd()