Aquí os dejo los nuevos scripts y como queadarían bien representadas las solucioens.
En el resto de scripts bastaría cambiar lo siguiente :
annotation_custom(grob = image_1, # Image
xmin= 0, # Coordinates to represent the image
xmax= 1000,
ymin= 0,
ymax= 700 # Ahora ya ajustará bien
) +
En este script solo hay que fijarse en las dos últimas lineas donde hago el cambio de coordenas para que ajuste correctamente en las gráficas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
needed <- list("dplyr", "data.table", # Libraries for data mining | |
"jpeg", "ggplot2", "png", "grid", "geoR", "rgl", # Libraries for | |
"repmis" # Libraries for web scrapping [3] | |
) | |
if(FALSE){ # If you want to install change for TRUE | |
lapply(X = needed ,FUN = | |
function(x){ | |
if(!require(x, character.only = T)){ | |
install.packages(x) | |
} | |
library(x,character.only = T) | |
}) | |
}else{ | |
lapply(X = needed ,FUN = | |
function(x){ | |
library(x,character.only = T) | |
}) | |
} | |
dir <- # "C:/Users/Javier Villacampa/Dropbox/Chabi/Blog/Eye track/" | |
"C:/Users/usuario/Dropbox/Chabi/Blog/5 Eye track/" # Put your dir | |
setwd(dir) | |
dir.create(path = "Results") | |
dir.create(path = "Data") | |
rm(list = ls()); gc() | |
# S read data ------------------------------------------------------------- | |
# Download the image | |
url <- "http://2.bp.blogspot.com/-Qo8JF_ux808/VlEAanXvltI/AAAAAAAACds/TkzNkifUK4M/s1600/Imagen1.jpeg" | |
download.file(url = url, destfile = "Data/Imagen1.jpeg", mode = "wb") | |
image_1 <- readJPEG( source = "Data/Imagen1.jpeg") | |
image_1 <- rasterGrob(image = image_1, interpolate=TRUE) | |
# Download the csv from dropbox | |
# https://www.dropbox.com/s/1s4uo7u340snqtv/sample-1.txt?dl=0 | |
d <- repmis::source_DropboxData(file = "sample-1.txt", key = "1s4uo7u340snqtv", sep ="\t") %>% data.table() | |
# E read data ------------------------------------------------------------- | |
# S Clean data ------------------------------------------------------------ | |
d[ , TRIAL_INDEX := factor(TRIAL_INDEX)] | |
d[ , Subject := factor(Subject)] | |
d <- d[ d$CURRENT_FIX_X <= 1000 & d$CURRENT_FIX_X >= 0 & | |
d$CURRENT_FIX_Y <= 700 & d$CURRENT_FIX_Y >= 0, ] | |
# S Clean data ------------------------------------------------------------ | |
# S Plot ------------------------------------------------------------------ | |
d <- d %>% data.frame() | |
d2 <- copy(d) # Save a copy from the old data | |
d <- d2[, c("CURRENT_FIX_X", "CURRENT_FIX_Y")] | |
d$CURRENT_FIX_Y_2 <- d$CURRENT_FIX_Y | |
d$CURRENT_FIX_Y <- | |
-d$CURRENT_FIX_Y + 700 | |
# E Plot ------------------------------------------------------------------ | |
No hay comentarios:
Publicar un comentario