Re: [R-es] Encontrar la primera columna no NA

2016-10-27 Thread Javier Villacampa González
000:  10 Uno0.54640585
> > difftime( Sys.time(), t)
> Time difference of 1.060787 secs
>
>
> - Mensaje original -
> De: "Olivier Nuñez" <onu...@unex.es>
> Para: "Javier Villacampa González" <javier.villacampa.gonza...@gmail.com>
> CC: "R ayuda" <r-help-es@r-project.org>
> Enviados: Jueves, 27 de Octubre 2016 15:10:07
> Asunto: Re: [R-es] Encontrar la primera columna no NA
>
> Prueba lo siguiente, no es óptimo, pero creo va bastnate más rapido que
> los que mencionaste:
>
> t <- Sys.time()
> dat[,First_month := apply(.SD,1,function(x) colnames(.SD)[min(which(!is.na
> (x)))])]
> dat[,Value_First_month := apply(.SD,1,function(x) x[min(which(!is.na
> (x)))])]
> difftime( Sys.time(), t)
>
> Time difference of 3.478778 secs
>
>
> - Mensaje original -
> De: "Javier Villacampa González" <javier.villacampa.gonza...@gmail.com>
> Para: "R ayuda" <r-help-es@r-project.org>
> Enviados: Jueves, 27 de Octubre 2016 13:43:19
> Asunto: [R-es] Encontrar la primera columna no NA
>
> Imaginemos que tenemos una matriz con datos temporales por sujetos.
> Pongamos que numero de veces que ha jugado una carta en un juego online. Y
> que quiero saber cuantas veces jugo la carta el primer mes que estuvo en el
> juego.
>
> Pero claro mi matriz guarda los datos temporalmente de tal manera que:
>
> # data.table( Enero = c( 1, 4, NA , NA , NA) , Febrero = c( 2, 6, 1, NA, NA
> ) , Marzo = c( 8,6,7,3, NA) ,  Abril = c( NA, 15, 5, 6,6 ))
> #Enero Febrero Marzo Abril
> # 1: 1   2 8NA
> # 2: 4   6 615
> # 3:NA   1 7 5
> # 4:NA  NA 3 6
> # 5:NA  NANA 6
> # Suponiendo que cada fila es un jugador
> # En este caso la solucion debería ser
> # 1 para el primero que empezó en Enero
> # 4 para el segundo jugador  que empezó en Enero
> # 1 para el tercero  que empezó en Febrero
> # 3 Para el cuarto  que empezó en Marzo
> # 6 para el quinto  que empezó en Abril
>
>
> A alguno se os ocurre una solucion más eficiente que la siguiente. Esto
> seguro que con data table o dplyr se puede. Ya he quitados los pipes que
> facilitan la lectura pero que no se llevan bien con data.table. Pero estoy
> seguro que se puede mejorar más.
>
> #===
> # Como ejemplo de codigo
> #===
> # S Primera solucion --
> 
> # First not NA colum per subject
> library(data.table)
> library(dplyr)
> set.seed(123456)
> numero <- 1e5
> dat <-
>   data.table( Uno  = sample( c(runif(numero) , rep(NA , numero /2e0  )),
> size = numero ) ,
> dos= sample( c(runif(numero) , rep(NA , numero /1e1  )),
> size = numero ) ,
> tres   = sample( c(runif(numero) , rep(NA , numero /2e1 )) ,
> size = numero ) ,
> cuatro = sample( c(runif(numero) , rep(NA , numero /1e2 )) ,
> size = numero ) ,
> cinco  = sample( c(runif(numero) , rep(NA , numero /2e2 )) ,
> size = numero ) ,
> seis   = sample( c(runif(numero) , rep(NA , numero /1e3 )) ,
> size = numero )
> )
>
>
> t <- Sys.time()
> First_month <-
>   dat %>%
>   apply( MARGIN = 1, FUN =
>function(x){
>  which( !is.na(x)  ) %>%  min( na.rm = TRUE ) %>%  return()
>}
>   )
>
>
>
> First_month %>%  table %>%  prop.table
> dat[ , First_month := First_month]
> N_for <- length( unique(First_month ))
> for( j in 1:N_for){
>   x <- dat[  First_month == j,  j,  with = FALSE]
>   dat[ First_month == j , Value_First_month := x ]
> }
>
> dat %>%  print
> # dat %>%  summary
>
> cat( "===\n", difftime( Sys.time(), t, units =
> "min") , " minutos que cuesta \n===\n" )
> beepr::beep(3)
> # E Primera solucion --
> 
>
>
>
>
> # S comparativa --
> -
> library(microbenchmark)
> N <- 1e2
> tabla <-
>   microbenchmark(
> JVG_dplyr ={  dat %>%
> apply( MARGIN = 1, FUN =
>  function(x){
>which( !is.na(x)  ) %>%  min( na.rm = TRUE ) %>%
> return()
>}
> )
> },
> JVG ={
> apply(X = dat,  MARGIN = 1, FUN =
>  function(x){
>  

Re: [R-es] Encontrar la primera columna no NA

2016-10-27 Thread Javier Villacampa González
Pues parece que para este caso en particular es mejor la solucon con el for
vectorizado. Aunque la verdad que la tuyaes muy buena de cara compresion y
comprensión de codigo. Igual si tuviese mas columnas la solucin la tuya
sería más rápida. Tendré que mirarlo.

library(microbenchmark)
N <- 1e1
tabla <-
  microbenchmark(
JVG ={
apply(X = dat,  MARGIN = 1, FUN =
 function(x){
   return(   min(  which( !is.na(x)  ),  na.rm = TRUE ) )
 }
)
  dat[ , First_month := First_month]
  N_for <- length( unique(First_month ))
  for( j in 1:N_for){
x <- dat[  First_month == j,  j,  with = FALSE]
dat[ First_month == j , Value_First_month := x ]
  }
},
Olivier ={
  dat[,First_month   := apply(X = .SD,MARGIN = 1,FUN = function(x)
colnames(.SD)[min(which(!is.na(x)))])]
  dat[,Value_First_month := apply(X = .SD,MARGIN = 1,FUN = function(x)
x[min(which(!is.na(x)))])]
},
times = N, unit = "s")

tabla %>%  print
beepr::beep(3)

# Unit: seconds
#   expr  min   lq mean   median   uq  max neval
# JVG2.345127 2.440396 2.591505 2.509842 2.738680 3.01349810
# Olivier5.445869 5.454217 6.132737 6.212742 6.410948 7.00808510


El 27 de octubre de 2016, 15:10, Olivier Nuñez <onu...@unex.es> escribió:

> Prueba lo siguiente, no es óptimo, pero creo va bastnate más rapido que
> los que mencionaste:
>
> t <- Sys.time()
> dat[,First_month := apply(.SD,1,function(x) colnames(.SD)[min(which(!is.na
> (x)))])]
> dat[,Value_First_month := apply(.SD,1,function(x) x[min(which(!is.na
> (x)))])]
> difftime( Sys.time(), t)
>
> Time difference of 3.478778 secs
>
>
> - Mensaje original -
> De: "Javier Villacampa González" <javier.villacampa.gonza...@gmail.com>
> Para: "R ayuda" <r-help-es@r-project.org>
> Enviados: Jueves, 27 de Octubre 2016 13:43:19
> Asunto: [R-es] Encontrar la primera columna no NA
>
> Imaginemos que tenemos una matriz con datos temporales por sujetos.
> Pongamos que numero de veces que ha jugado una carta en un juego online. Y
> que quiero saber cuantas veces jugo la carta el primer mes que estuvo en el
> juego.
>
> Pero claro mi matriz guarda los datos temporalmente de tal manera que:
>
> # data.table( Enero = c( 1, 4, NA , NA , NA) , Febrero = c( 2, 6, 1, NA, NA
> ) , Marzo = c( 8,6,7,3, NA) ,  Abril = c( NA, 15, 5, 6,6 ))
> #Enero Febrero Marzo Abril
> # 1: 1   2 8NA
> # 2: 4   6 615
> # 3:NA   1 7 5
> # 4:NA  NA 3 6
> # 5:NA  NANA 6
> # Suponiendo que cada fila es un jugador
> # En este caso la solucion debería ser
> # 1 para el primero que empezó en Enero
> # 4 para el segundo jugador  que empezó en Enero
> # 1 para el tercero  que empezó en Febrero
> # 3 Para el cuarto  que empezó en Marzo
> # 6 para el quinto  que empezó en Abril
>
>
> A alguno se os ocurre una solucion más eficiente que la siguiente. Esto
> seguro que con data table o dplyr se puede. Ya he quitados los pipes que
> facilitan la lectura pero que no se llevan bien con data.table. Pero estoy
> seguro que se puede mejorar más.
>
> #===
> # Como ejemplo de codigo
> #===
> # S Primera solucion --
> 
> # First not NA colum per subject
> library(data.table)
> library(dplyr)
> set.seed(123456)
> numero <- 1e5
> dat <-
>   data.table( Uno  = sample( c(runif(numero) , rep(NA , numero /2e0  )),
> size = numero ) ,
> dos= sample( c(runif(numero) , rep(NA , numero /1e1  )),
> size = numero ) ,
> tres   = sample( c(runif(numero) , rep(NA , numero /2e1 )) ,
> size = numero ) ,
> cuatro = sample( c(runif(numero) , rep(NA , numero /1e2 )) ,
> size = numero ) ,
> cinco  = sample( c(runif(numero) , rep(NA , numero /2e2 )) ,
> size = numero ) ,
> seis   = sample( c(runif(numero) , rep(NA , numero /1e3 )) ,
> size = numero )
> )
>
>
> t <- Sys.time()
> First_month <-
>   dat %>%
>   apply( MARGIN = 1, FUN =
>function(x){
>  which( !is.na(x)  ) %>%  min( na.rm = TRUE ) %>%  return()
>}
>   )
>
>
>
> First_month %>%  table %>%  prop.table
> dat[ , First_month := First_month]
> N_for <- length( unique(First_month ))
> for( j in 1:N_for){
>   x <- dat[  First_month == j,  j,  with = FALSE]
>   dat[ First_month == j , Value_First_month := x ]
> }
>
> dat %>%  print
> # dat %>% 

[R-es] Encontrar la primera columna no NA

2016-10-27 Thread Javier Villacampa González
Imaginemos que tenemos una matriz con datos temporales por sujetos.
Pongamos que numero de veces que ha jugado una carta en un juego online. Y
que quiero saber cuantas veces jugo la carta el primer mes que estuvo en el
juego.

Pero claro mi matriz guarda los datos temporalmente de tal manera que:

# data.table( Enero = c( 1, 4, NA , NA , NA) , Febrero = c( 2, 6, 1, NA, NA
) , Marzo = c( 8,6,7,3, NA) ,  Abril = c( NA, 15, 5, 6,6 ))
#Enero Febrero Marzo Abril
# 1: 1   2 8NA
# 2: 4   6 615
# 3:NA   1 7 5
# 4:NA  NA 3 6
# 5:NA  NANA 6
# Suponiendo que cada fila es un jugador
# En este caso la solucion debería ser
# 1 para el primero que empezó en Enero
# 4 para el segundo jugador  que empezó en Enero
# 1 para el tercero  que empezó en Febrero
# 3 Para el cuarto  que empezó en Marzo
# 6 para el quinto  que empezó en Abril


A alguno se os ocurre una solucion más eficiente que la siguiente. Esto
seguro que con data table o dplyr se puede. Ya he quitados los pipes que
facilitan la lectura pero que no se llevan bien con data.table. Pero estoy
seguro que se puede mejorar más.

#===
# Como ejemplo de codigo
#===
# S Primera solucion --
# First not NA colum per subject
library(data.table)
library(dplyr)
set.seed(123456)
numero <- 1e5
dat <-
  data.table( Uno  = sample( c(runif(numero) , rep(NA , numero /2e0  )),
size = numero ) ,
dos= sample( c(runif(numero) , rep(NA , numero /1e1  )),
size = numero ) ,
tres   = sample( c(runif(numero) , rep(NA , numero /2e1 )) ,
size = numero ) ,
cuatro = sample( c(runif(numero) , rep(NA , numero /1e2 )) ,
size = numero ) ,
cinco  = sample( c(runif(numero) , rep(NA , numero /2e2 )) ,
size = numero ) ,
seis   = sample( c(runif(numero) , rep(NA , numero /1e3 )) ,
size = numero )
)


t <- Sys.time()
First_month <-
  dat %>%
  apply( MARGIN = 1, FUN =
   function(x){
 which( !is.na(x)  ) %>%  min( na.rm = TRUE ) %>%  return()
   }
  )



First_month %>%  table %>%  prop.table
dat[ , First_month := First_month]
N_for <- length( unique(First_month ))
for( j in 1:N_for){
  x <- dat[  First_month == j,  j,  with = FALSE]
  dat[ First_month == j , Value_First_month := x ]
}

dat %>%  print
# dat %>%  summary

cat( "===\n", difftime( Sys.time(), t, units =
"min") , " minutos que cuesta \n===\n" )
beepr::beep(3)
# E Primera solucion --




# S comparativa ---
library(microbenchmark)
N <- 1e2
tabla <-
  microbenchmark(
JVG_dplyr ={  dat %>%
apply( MARGIN = 1, FUN =
 function(x){
   which( !is.na(x)  ) %>%  min( na.rm = TRUE ) %>%
return()
   }
)
},
JVG ={
apply(X = dat,  MARGIN = 1, FUN =
 function(x){
   return(   min(  which( !is.na(x)  ),  na.rm = TRUE ) )
 }
)
},
times = N, unit = "s")

tabla %>%  print
beepr::beep(3)

# Unit: seconds
#   exprminlq   mean medianuq   max
neval
# JVG_dplyr 21.2321152 22.233428 22.9575357 22.5701781 23.32
26.64273010
# JVG0.7628928  0.843067  0.9260389  0.8495834  1.027036
1.29586810
# E comparativa ---

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] Hadoop

2016-06-15 Thread Javier Villacampa González
Hola buenas,

me preguntaba si alguno usa hadoop Spark en su día día y si me podíais
recomendar un buen curso para empezar. Estuve en la charla de meetup de
madrid hace unos meses de Rspark y estuvo bien, ahora me preguntaba si es
posible profundizar.

Pero me gustaría tener recomendaciones de cualquier material que podáis
recomendar, cursos de coursera que hayais hecho, libros que hayais leido,
charlas de youtube que hayais visto. Los objetivo son:

   1. que sea simple,  un poco para tontitos y si puede ser que usen R por
   no meterme con una cosa más.
   2. que lo hayáis mirado, la red esta llena de cosas de estas me gustaría
   que me dieses opinión. Estoy intentando hacer alguno a ciegas pero no es la
   mejor opción
   3. que sea simple y con R


Gracias por adelantado.

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] Codificacion de caracteres

2016-05-10 Thread Javier Villacampa González
imagino que te está guardando tu BD en UTF-8 y por lo que sea la necesitas
en latin1 (utilizas Windows?)

Esto lo deduzco de esta prueba
iconv(x = "España", from = "latin1", to = "UTF-8") # Pone españa con
enie.No sé si me hará la faena el email.

Lo que deberia hacer es esto.
df$col1 <- iconv(x = df$col1, from = "UTF-8", to = "latin1")

Y espero que funcione



--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] [help] Heatmaps con escala discreta con stat_bin2d y stat_density2d.

2016-02-08 Thread Javier Villacampa González
Hola buenas,

le estaba dando un par de vueltas a una cosa de mi blog de hacer heatmaps.
El problema es que como no puedo fijar la escala no puedo comparar los
gráficos para hacer una presentación visual. Lo cual es problema.

Basicamente quería hacer que el siguiente  dibujo con una modificación:
http://4.bp.blogspot.com/-vVpWzRWyupQ/VlEe-JxKZ_I/Ces/pZiycrBUv2g/s1600/Solution4.jpeg

La cosa es que mse gustaría saber i se puede fijar la escala por
intervalos. Algo así como lo que tienen en el siguiente ejemplo:
http://stackoverflow.com/questions/6793881/gradient-breaks-in-a-ggplot-stat-bin2d-plot

También me sería de ayuda si me dieseis una pista para la función
stat_density2d y algun manual o curso de ggplot2. Me vuelvo loco siempre
con el, ya que la ayuda del cran es bastante regular si estas acostumbrado
a usar las ayudas estandar.

Muchas gracias por adelantado. Como siempre.

Javier

PD: Para ver como se crea mirad esta entrada:
http://ncymat.blogspot.com.es/2015/11/representar-datos-de-eyetracker-parte-2.html
PD2: No es una promocion del blog ahora lo tengo bastanta muerto.

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Bootstrap data frame

2016-01-27 Thread Javier Villacampa González
Hola buenas


En principio a mí no me parece una mala aproximación. Tal vez se podría
intentar adaptar el problema a un modelo de supervivencia, pero tendría que
pensarlo.  ( https://vimeo.com/142732615 )



De todas maneras, creo que coges días al azar para calcular to "proxy".
Aunque yo personalmente cogería días consecutivos porque probablemente el
consumo en muchos productos no sea independiente temporalmente.

Por otro lado, de cara a la implementación no sé si sería mejor coger 6 o
siete días o comparar ambas distribuciones. Más que nada porque si se te
acaba el stock en la +1 después de que puedas hacer tu pedido entonces el
tiempo real serían 7 días.

Espero que te parezca bien el feedback. Estaría encantado de discutir esto
con los compañeros.

Un abrazo

Javier




--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] R in UNIX OS

2015-11-03 Thread Javier Villacampa González
Hello,

I have a silly questions:

is possilbe to install R in a AIX OS Machine?
Where can I found the download files?

Thank you in advance

Javier
--

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R-es] help: Rstudio no responde

2015-10-26 Thread Javier Villacampa González
Hola buenas,

hace unos días el Rstudio me dejó de funcionar en una de mis maquinas
Windows8. No puedo volver a un estado anterior así que mal y tampoco me
vale reinsatalarlo ( aunque reinstale ambos programas R y Rstudio) porque
sigue sin funcionar. No tengo muy claro que hacer. ¿Alguna ayuda? ¿Esto es
una duda de R?

Muchas gracias por adelantado

PD a continuación os muestro mis errores
Mi R
[image: Imágenes integradas 1]
Mi Rstudio

[image: Imágenes integradas 2]

--
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R-es] help Mapa de Calor con Google Maps de fondo

2015-10-21 Thread Javier Villacampa González
Como te comenta Alex te podría ser util la entreda de mi blog es con
imagenes pero la lógica es la misma (
http://ncymat.blogspot.com.es/2015/10/plotear-datos-de-eye-tracker.html).
Te puede interesar especialmente la última parte.
scale_fill_manual(values = Colors , breaks = Breaks, guide = F) + # We lost
the guide. Si quieres algo más por zonas Ahora estoy investigando esto
stat_binhex(bins = 10, colour = "gray", alpha = 0.5)
coord_fixed()
http://thedatagame.com.au/2015/09/27/how-to-create-nba-shot-charts-in-r/

Soy muy novel en esto, así que tal vez no seá lo que necesitas

Un cordial saludo y buean suerta.



--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] [Help] Oferta de trabajo en Valencia

2015-08-13 Thread Javier Villacampa González
Un excompañero de trabajo ofrece trabajo a expertos en machine learning y
geolocalización. Bueno, lo de expertos es un decir, basicamente lo que
quieres es un joven con ganas de aprender aunque no sepa mucho.

Os pongo el enlace por si a alguien le interesa.

Un abrazo

http://www.geoblink.com/jobsoffers/datascientist

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] help awk y shells en R

2015-06-09 Thread Javier Villacampa González
] foo4.sh: line 1: #!/bin/sh: No such file or directory


# [2] 753003840;1;26-MO-54;42000;1;1;1;41944;1;1;1


# [3] 753218504;2;2963 BFT;0;0;0;1;0;0;0;1


# [4] 751885448;11;82-17-UT;0;0;1;1;5104;0;1;1


# [5] 753053463;3;11-81-JP;0;0;0;1;0;0;0;1


# [6] 753053463;2;19-75-RB;0;0;0;1;0;0;0;1


# [7] ===


# [8]   1 [main] head (32500) C:\\Rtools\\bin\\head.exe: *** fatal
error - cygheap base mismatch detected - 0x612E1400/0x612A1970.

# [9] This problem is probably due to using incompatible versions of the
cygwin DLL.

# [10] Search for cygwin1.dll using the Windows Start-Find/Search
facility

# [11] and delete all but the most recent version.  The most recent
version *should*

# [12] reside in x:\\cygwin\\bin, where 'x' is the drive on which you
have


# [13] installed the cygwin distribution.  Rebooting is also suggested if
you

# [14] are unable to find another cygwin DLL.


# [15] ===@


# [16]   4 [main] head (7308) C:\\Rtools\\bin\\head.exe: *** fatal
error - cygheap base mismatch detected - 0x612E1400/0x612A1970.

# [17] This problem is probably due to using incompatible versions of the
cygwin DLL.

# [18] Search for cygwin1.dll using the Windows Start-Find/Search
facility

# [19] and delete all but the most recent version.  The most recent
version *should*

# [20] reside in x:\\cygwin\\bin, where 'x' is the drive on which you
have


# [21] installed the cygwin distribution.  Rebooting is also suggested if
you

# [22] are unable to find another cygwin DLL.






El 8 de junio de 2015, 21:32, javier.ruben.marcu...@gmail.com escribió:

  Estimado Javier Villacampa González

 Hace mucho que no uso awk o gawk, pero recuerdo cygwin y en lo personal no
 tuve inconvenientes con awk.

 No se como está esa tecnología hoy en día, pero yo evalué usar R con awk,
 al respecto hay una integración en
 http://www.inside-r.org/packages/cran/Kmisc/docs/awk

 Javier Rubén Marcuzzi
 Técnico en Industrias Lácteas
 Veterinario

 *De:* Javier Villacampa González javier.villacampa.gonza...@gmail.com
 *Enviado el:* ‎lunes‎, ‎08‎ de ‎junio‎ de ‎2015 ‎03‎:‎05‎ ‎p.m.
 *Para:* Carlos Ortega c...@qualityexcellence.es
 *CC:* R-help-es@r-project.org r-help-es@r-project.org

 Al final resulto más fácil de lo esperado. Hay que instalar cywin y
 utilizar los comandos de la siguiente manera

 system('C:/cygwin/bin/wc -l var_risco_2012.csv')
 Esto en principio funciona

 El 8 de junio de 2015, 17:41, Carlos Ortega c...@qualityexcellence.es
 escribió:

  Hola,
 
  Mira esto:
 
  http://stackoverflow.com/questions/18603984/using-system-with-windows
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
  El 8 de junio de 2015, 17:14, Javier Villacampa González 
  javier.villacampa.gonza...@gmail.com escribió:
 
  Hola buenas,
 
  a veces empleo desde R shells de unix, Existe alguna manera de utilizar
  estos shelss desde windows o el lenguaje awk.
 
  La idea es hacerlo siempre desde R, igual invoncando cygwin desde
 windows
  es posible. Pero no me queda claro
 
  Un abrazo y gracias por adelntado
 
  Javier
  #_
  # EJEMPLO, ¿Que habría que poner en
  # ¿¿???
  # suponiendoq que tengo cygwin instalado
  #_
 
  # Un ejemplo sería cambiar unos MËG por unos MEG ya que fread no me lee
  bien los Ë
 
  file.rename(from = Data/data.csv, to = Data/data_2.csv)
  switch(OS,
 WIN = system( ¿¿???),
 MAC = system( command =  awk \'{gsub( \M.?G\,\MEG\);
 print}\'
  Data/data_2.csv  Data/data_2_2.csv)
  )
  file.rename(from = Data/data.csv, to = Data/data_2.csv)
 
  --
 
  [[alternative HTML version deleted]]
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es
 
 
 
 
  --
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 



 --

  [[alternative HTML version deleted]]

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es




--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] help awk y shells en R

2015-06-08 Thread Javier Villacampa González
Al final resulto más fácil de lo esperado. Hay que instalar cywin y
utilizar los comandos de la siguiente manera

system('C:/cygwin/bin/wc -l var_risco_2012.csv')
Esto en principio funciona

El 8 de junio de 2015, 17:41, Carlos Ortega c...@qualityexcellence.es
escribió:

 Hola,

 Mira esto:

 http://stackoverflow.com/questions/18603984/using-system-with-windows

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es

 El 8 de junio de 2015, 17:14, Javier Villacampa González 
 javier.villacampa.gonza...@gmail.com escribió:

 Hola buenas,

 a veces empleo desde R shells de unix, Existe alguna manera de utilizar
 estos shelss desde windows o el lenguaje awk.

 La idea es hacerlo siempre desde R, igual invoncando cygwin desde windows
 es posible. Pero no me queda claro

 Un abrazo y gracias por adelntado

 Javier
 #_
 # EJEMPLO, ¿Que habría que poner en
 # ¿¿???
 # suponiendoq que tengo cygwin instalado
 #_

 # Un ejemplo sería cambiar unos MËG por unos MEG ya que fread no me lee
 bien los Ë

 file.rename(from = Data/data.csv, to = Data/data_2.csv)
 switch(OS,
WIN = system( ¿¿???),
MAC = system( command =  awk \'{gsub( \M.?G\,\MEG\); print}\'
 Data/data_2.csv  Data/data_2_2.csv)
 )
 file.rename(from = Data/data.csv, to = Data/data_2.csv)

 --

 [[alternative HTML version deleted]]

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es




 --
 Saludos,
 Carlos Ortega
 www.qualityexcellence.es




--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] help awk y shells en R

2015-06-08 Thread Javier Villacampa González
Hola buenas,

a veces empleo desde R shells de unix, Existe alguna manera de utilizar
estos shelss desde windows o el lenguaje awk.

La idea es hacerlo siempre desde R, igual invoncando cygwin desde windows
es posible. Pero no me queda claro

Un abrazo y gracias por adelntado

Javier
#_
# EJEMPLO, ¿Que habría que poner en
# ¿¿???
# suponiendoq que tengo cygwin instalado
#_

# Un ejemplo sería cambiar unos MËG por unos MEG ya que fread no me lee
bien los Ë

file.rename(from = Data/data.csv, to = Data/data_2.csv)
switch(OS,
   WIN = system( ¿¿???),
   MAC = system( command =  awk \'{gsub( \M.?G\,\MEG\); print}\'
Data/data_2.csv  Data/data_2_2.csv)
)
file.rename(from = Data/data.csv, to = Data/data_2.csv)

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Comparaciones múltiples

2015-03-30 Thread Javier Villacampa González
Hola Miguel yo tengo una función para hacer comparaciones multiples ( muy
util si hacer medidas repetidas, ya que en el otro caso tienes la función
HSD)

t.test.Comparison.Function.Ch - function( data, StringResponse,
StringFactor){
  
  # Factor
  
  data[,StringFactor ] - factor(data[,StringFactor ] )

  
  # Create data.frame
  
  T.Test - data.frame(Name = NA, LevelOne =NA, LevelTwo= NA,statistic =
NA, df = NA, df = NA, p.value = NA )
  T.Test - T.Test[-1,]
  NumberOfFactors - length(levels(data[, StringFactor]) )

  
  # t.test computation
  
  for(i in 1:(  NumberOfFactors - 1 ) ){
LevelOne - levels(data[, StringFactor])[i]
for(j in (i+1):( NumberOfFactors) ){
  LevelTwo - levels(data[, StringFactor])[j]
  x -t.test( x =data[data[, StringFactor] == LevelOne, StringResponse]
,
  y =data[data[, StringFactor] == LevelTwo, StringResponse]
)

  T.Test - rbind( T.Test,
   data.frame(Name = paste(LevelOne,LevelTwo, sep= .),
  LevelOne = LevelOne,
  LevelTwo= LevelTwo,
  statistic = x$statistic, df =
x$parameter, p.value = x$p.value )
  )
}
  }

  
  # Significacion
  
  T.Test$Sign - n.s.
  if(dim( T.Test[  T.Test$p.value = 0.1  T.Test$p.value  0.05 ,] )[1] 
0 ){
T.Test[  T.Test$p.value = 0.1  T.Test$p.value  0.05 ,]$Sign - ·
  }

  if(dim( T.Test[  T.Test$p.value = 0.05  T.Test$p.value  0.01 ,] )[1] 
0 ){
T.Test[  T.Test$p.value = 0.05  T.Test$p.value  0.01 ,]$Sign - *
  }

  if(dim( T.Test[  T.Test$p.value = 0.01  T.Test$p.value  0.001 ,] )[1]
 0 ){
T.Test[  T.Test$p.value = 0.01  T.Test$p.value  0.001 ,]$Sign - **
  }

  if(dim( T.Test[  T.Test$p.value = 0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value = 0.001  ,]$Sign - ***
  }

  
  # Bonferroni p.value
  
  T.Test$p.value.Adjusted - p.adjust(T.Test$p.value, method = bonferroni)

  
  # Significacion
  
  T.Test$Sign.Adjusted - n.s.
  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.1  T.Test$p.value.Adjusted
 0.05 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.1  T.Test$p.value.Adjusted 
0.05 ,]$Sign.Adjusted - ·
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.05 
T.Test$p.value.Adjusted  0.01 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.05  T.Test$p.value.Adjusted 
0.01 ,]$Sign.Adjusted - *
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.01 
T.Test$p.value.Adjusted  0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.01  T.Test$p.value.Adjusted 
0.001 ,]$Sign.Adjusted - **
  }

  if(dim( T.Test[  T.Test$p.value.Adjusted = 0.001 ,] )[1]  0 ){
T.Test[  T.Test$p.value.Adjusted = 0.001  ,]$Sign.Adjusted - ***
  }


  
  # Effect Size
  
  t - T.Test$statistic
  df -T.Test$df
  T.Test$Effect.Size - sqrt( t^2/(t^2+df) )

  T.Test$statistic - round( T.Test$statistic, digits = 3)
  T.Test$df - round( T.Test$df, digits = 3)
  T.Test$p.value - round( T.Test$p.value, digits = 3)
  T.Test$p.value.Adjusted - round( T.Test$p.value.Adjusted, digits = 3)
  T.Test$Effect.Size - round( T.Test$Effect.Size, digits = 3)


  return(T.Test)


}


--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] help:ELIMINAR FILAS DUPLICADAS DENTRO DE UNA MATRIZ

2015-03-18 Thread Javier Villacampa González
Lo que quires hacer es algo así

d - rbind( mtcars , mtcars[1:3,] )
duplicated(d)

d - d[ !duplicated(d) ,]

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] ELIMINAR FILAS DUPLICADAS DENTRO DE UNA MATRIZ

2015-03-18 Thread Javier Villacampa González
Lo que quires hacer es algo así

d - rbind( mtcars , mtcars[1:3,] )
duplicated(d)

d - d[ !duplicated(d) ,]


--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 70, Envío 3

2014-12-04 Thread Javier Villacampa González
Felicidades, la charla es sublime. Muy util. Estoy deseando echarle un
diente al código.



El 4 de diciembre de 2014, 12:00, r-help-es-requ...@r-project.org
escribió:

 Envíe los mensajes para la lista R-help-es a
 r-help-es@r-project.org

 Para subscribirse o anular su subscripción a través de la WEB
 https://stat.ethz.ch/mailman/listinfo/r-help-es

 O por correo electrónico, enviando un mensaje con el texto help en
 el asunto (subject) o en el cuerpo a:
 r-help-es-requ...@r-project.org

 Puede contactar con el responsable de la lista escribiendo a:
 r-help-es-ow...@r-project.org

 Si responde a algún contenido de este mensaje, por favor, edite la
 linea del asunto (subject) para que el texto sea mas especifico que:
 Re: Contents of R-help-es digest Además, por favor, incluya en
 la respuesta sólo aquellas partes del mensaje a las que está
 respondiendo.

 Asuntos del día:

1. R en OpenAnalytics - 2014... (Video Disponible). (Carlos Ortega)


 -- Mensaje reenviado --
 From: Carlos Ortega c...@qualityexcellence.es
 To: Lista R r-help-es@r-project.org
 Cc:
 Date: Wed, 3 Dec 2014 14:23:48 +0100
 Subject: [R-es] R en OpenAnalytics - 2014... (Video Disponible).
 Hola,

 Ya está disponible el video de la presentación que hizo Jorge Ayuso en el
 OpenAnalytics-2014 de Madrid:

 http://madrid.r-es.org/r-en-el-openanalytics-2014/

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es

 [[alternative HTML version deleted]]



 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es




--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] help: Shiny y denisty plots en R maps

2014-11-25 Thread Javier Villacampa González
Hola buenas,

estoy en una época convulsa de de dudas, ya que ando pegandome con shiny y
los mapas. Quería pegar un heatmap dinámico (mapa de paises) en una
aplicación shiny.
El problema es que no termino de hayar la manera. Os paso las apps. A ver
si alguien sabe algo. La idea es poder mostrar el heatmap por distintos
subgrupos seleccionados en la app. Pero estoy bastante perdido.

Muchas gracias por adelantado como siempre.

#-
# heatmap.R
#-

# require(devtools)
# install_github('ramnathv/rCharts')
# install_github('ramnathv/rMaps')
library(rCharts)
library(rMaps)
L2 - Leaflet$new()
L2$setView(c(29.7632836,  -95.3632715), 10)
L2$tileLayer(provider = MapQuestOpen.OSM)

data(crime, package = 'ggmap')
library(plyr)
crime_dat = ddply(crime, .(lat, lon), summarise, count = length(address))
crime_dat = toJSONArray2(na.omit(crime_dat), json = F, names = F)
cat(rjson::toJSON(crime_dat[1:2]))
# Add leaflet-heat plugin. Thanks to Vladimir Agafonkin
L2$addAssets(jshead = c(
  http://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js;
))

# Add javascript to modify underlying chart
L2$setTemplate(afterScript = sprintf(
script
  var addressPoints = %s
  var heat = L.heatLayer(addressPoints).addTo(map)
/script
, rjson::toJSON(crime_dat)
))

L2


#-
# ui.R
#-

library(rCharts)
library(rMaps)
library(leaflet)


shinyUI(fluidPage(
  tags$head(tags$link(rel='stylesheet', type='text/css',
href='styles.css')),
  leafletMap(
map, 100%, 400,
initialTileLayer = //{s}.
tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png,
initialTileLayerAttribution = HTML('Maps by a href=
http://www.mapbox.com/;Mapbox/a'),
options=list(
  center = c(29.7632836,  -95.3632715),
  zoom = 10
)
  ),

  hr(),
  fluidRow(

  )
))


#-
# server.R
#-
library(leaflet)
library(ggplot2)
library(maps)
library(rCharts)
library(rMaps)

data(uspop2000)



shinyServer(function(input, output, session) {

  map - createLeafletMap(session = session, outputId = 'map')

})
--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] help:Problemas compatibllidad Windows Mac

2014-11-21 Thread Javier Villacampa González
Muchas gracias a todos, con la dodificacion UTF-8 todo queda solucionado.
Una pena que en pleo año 2014 aun existan estas incompatibilidades y más
para gente como yo que acabamos utilizando los tres principales OS.

Muchas gracias de nuevo.

El 18 de noviembre de 2014, 17:05, Carlos J. Gil Bellosta 
c...@datanalytics.com escribió:

 Hola, ¿qué tal?

 Si tu aplicación está leyendo ficheros externos, asegúrate de que
 especificas el _encoding_ adecuadamente. Mira lo que escribí al
 respecto en

 http://www.datanalytics.com/2011/09/08/codigos-de-caracteres-en-r/

 Si tienes texto en español (y con caracteres no ASCII en el código)
 asegúrate de guardar el fichero (o ficheros) .R con un _encoding_
 predeterminado. Te recomiendo UTF-8, que no es el que usa Windows por
 defecto, pero es el que espera Mac.

 Un saludo,

 Carlos J. Gil Bellosta
 http://www.datanalytics.com

 El día 18 de noviembre de 2014, 16:36, Javier Villacampa González
 javier.villacampa.gonza...@gmail.com escribió:
  Hola buenas,
 
  lo primero pedir perdon porque llevo tiempo desconectado. Estaba haciendo
  una app de shiny y me he encontrado que lo que funciona perfectamente en
 un
  PC no funciona en un mac. Imagino que son los caracteres. Pero no lo
 tengo
  muy claro.
 
  Alguna solucón de como guardar los ficheros Rdata y los R para que no
  ocurra este problema. Imagino que va por ahí...
  Lo curioso es que R lo abre bien, así que no tengo claro porque es.
 
  El error de shiny es el siguiente:
 
  ERROR: unable to find an inherited method for function ‘span’ for
  signature ‘character’
 
  Por  los de ‘span†supongo que es el pais
 
  Gracias por adelantado ( por enesima vez)
 
  Javier
 
 
  --
 
  [[alternative HTML version deleted]]
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es




--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] help: shiny leer ficheros desde google drive

2014-08-30 Thread Javier Villacampa González
Hola buenas,

Un compañero y yo estamos haciendo una aplicación shiny. Nos ha quedado
bastante aparente y en sevidor local (con R) funciona bastante bien. El
problema es que cuando cargamos los ficheros en la web deja de fucionar
¿Por qué? Pues porque al principio de la aplicacion cargamos unos datos de
nuestro ordenador y esto no es posible a la hora de poner los datos
ShinyApps.io (una de las multiples soluciones que se nos ofrece en la red)
[1, 2,a p 3]

Una de las posibles soluciones que se nos había ocurrido era subir los
datos en formato csv a goolge drive y una vez permitido a cualquiera
acceder a ellos leerlos con un read table a través del link.

La pregunta es ¿Alguien sabe como leer unos datos colgados en csv desde
google drive? ¿Podría poner un ejemplo práctico? los que hemos encontrado
no hemos sabido reproducirlos.

Otra pregunta es ¿alguna otra solución gratuita para leer datos colgados
on-line?


Como siempre, gracias por adelantado y un cordial saludo

Javier

Bibliografía
[1] https://github.com/rstudio/shinyapps/blob/master/guide/guide.md
[2] http://shiny.rstudio.com/tutorial/lesson7/
[3] https://www.shinyapps.io/


--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] outliers (Marta valdes lopez)

2014-07-14 Thread Javier Villacampa González
Hola Marta,

si observas cualquier artículo de psicología esto es una práctica típica.
Te digo psicología porque creo que tus datos son de ese tipo. Tienes
bibiligrafía de artículos cientificos en las que se quitan valores
siguiendo los criterios que te he dicho solo has de buscar bibliografía del
campo en el que te mueces. Osea que nos quitarlos por que sí, aunque en
cada area de ciencia tienes una serie de criterios para acabar con los
ouliers. Yo personalmente me fio más de mi buena intuición(y validación)
que de un test. De todas maneras seguro que tienes un informe de como
recogiste los datos y puedes trazar el origen de este dato en concreto.
Creo que eso es mejor que cualquier test. De todas maneras a mi el test me
sale:

 setwd(dir=c:/Users/usuario/Desktop/) library(outliers) 
 filename-timediff.csv time-read.csv(filename, 
 sep=;,header=TRUE,dec=.) # Esto es lo que has de cambiar 
 chisq.out.test(time$TimeDiff)
chi-squared test for outlier

data:  time$TimeDiff
X-squared = 73260.07, p-value  2.2e-16
alternative hypothesis: highest value 14478.4 is an outlier


No se si te he sido de mucha ayuda.

Un saludo







2014-07-14 12:03 GMT+02:00 Marta valdes lopez martavalde...@gmail.com:

 Hola!

 Muchas gracias por la ayuda, pero lo que quiero hacer es que yo se cual es
 el outlier, es el numero 14478 puede ser un error de transcripcion o lo que
 sea pero lo que me gustaria hacer seria que a traves de algun tipo de test
 me dijera que esse es el outlier y poder borrarlo de la base de datos
 porque no puedo borrarlo porque si; no se si me explico.

 Y cuando hago la chi cuadrado me sale esto pero no es el numero que quiero

  chisq.out.test(as.numeric(time$TimeDiff))
 chi-squared test for outlier
 data:  as.numeric(time$TimeDiff)
 X-squared = 24.9399, p-value = 5.915e-07
 alternative hypothesis: highest value 435 is an outlier

 Entonces no se como podria hacer para poder borrarlo de forma logica.

 Muchas gracias, un saludo


 2014-07-11 18:23 GMT+00:00 Javier Villacampa González 
 javier.villacampa.gonza...@gmail.com:

 Tu fichero tiene los decimales como puntos y no como comas como tu le
 indicas. Te dejo un ejemplo


 #-
 setwd(dir=c:/Users/usuario/Desktop/)
 library(outliers)
 filename-timediff.csv
 time-read.csv(filename, sep=;,header=TRUE,dec=.) # Esto es lo que
 has de cambiar
 chisq.out.test(time$TimeDiff)


 # Ayuda adicional
 #-
 # Si no supones normalidad
 #-
 time.without.outs - data.frame(row.names= 1:dim(time)[1], dif = time )


 x - boxplot(time.without.outs$TimeDiff,range= 1.5) # Quita los outliers
 que se van más de 1.5 rangos itercuartilicios. Puedes poner otro criterio
 pero este es el habitual

 time.without.outs$out.rg - F
 time.without.outs[ time.without.outs$TimeDiff %in% x$out,]$out.rg - T #
 Localizamos los outliers con la condición elegida

 time.without.outs$TimeDiff.without.out.rg - time.without.outs$TimeDiff
 time.without.outs[ time.without.outs$out.rg,]$TimeDiff.without.out.rg -
 NA # Borramos los outliers

 #-
 # Si supones normalidad bien lo puedes hacer así también
 #-


 time.without.outs$out.rg.norm - F
 time.without.outs[ time.without.outs$TimeDiff %in% x$out,]$out.rg.norm -
 T
 x - abs(scale(time.without.outs$TimeDiff)) # Normalizamos la variable

 time.without.outs$out.rg.norm - F
 time.without.outs[ x = qnorm(0.995),]$out.rg.norm - T # Quitmos los
 datos que estén alejados 99.5 % en la distro (suponiedo normalidad)

 time.without.outs$TimeDiff.without.out.norm - time.without.outs$TimeDiff
 time.without.outs[
 time.without.outs$out.rg.norm,]$TimeDiff.without.out.norm - NA


 #-
 # Si quieres quitar ambos
 #-

 time.without.outs$TimeDiff.without.out.norm.rg -
 time.without.outs$TimeDiff
 time.without.outs[ time.without.outs$out.rg |
 time.without.outs$out.rg.norm,]$TimeDiff.without.out.norm.rg - NA

 summary(time.without.outs)

 # Donde

 # TimeDiff.without.out.rg Son los datos sin outliers utilizando un
 criterio típico cuando no se sabe la distribución de tus datos
 # TimeDiff.without.out.norm Son los datos sin outliers asumiendo la
 normalidad de tus datos
 qqnorm(time.without.outs$TimeDiff.without.out.rg);
 qqline(time.without.outs$TimeDiff.without.out.rg, col = 2, lwd = 2)
 qqnorm(time.without.outs$TimeDiff.without.out.norm);
 qqline(time.without.outs$TimeDiff.without.out.norm, col = 2, lwd =2)

 hist(time.without.outs$TimeDiff.without.out.rg)
 hist(time.without.outs$TimeDiff.without.out.norm)
 ks.test(x= 

Re: [R-es] outliers (Marta valdes lopez)

2014-07-11 Thread Javier Villacampa González
Tu fichero tiene los decimales como puntos y no como comas como tu le
indicas. Te dejo un ejemplo

#-
setwd(dir=c:/Users/usuario/Desktop/)
library(outliers)
filename-timediff.csv
time-read.csv(filename, sep=;,header=TRUE,dec=.) # Esto es lo que has
de cambiar
chisq.out.test(time$TimeDiff)


# Ayuda adicional
#-
# Si no supones normalidad
#-
time.without.outs - data.frame(row.names= 1:dim(time)[1], dif = time )


x - boxplot(time.without.outs$TimeDiff,range= 1.5) # Quita los outliers
que se van más de 1.5 rangos itercuartilicios. Puedes poner otro criterio
pero este es el habitual

time.without.outs$out.rg - F
time.without.outs[ time.without.outs$TimeDiff %in% x$out,]$out.rg - T #
Localizamos los outliers con la condición elegida

time.without.outs$TimeDiff.without.out.rg - time.without.outs$TimeDiff
time.without.outs[ time.without.outs$out.rg,]$TimeDiff.without.out.rg - NA
# Borramos los outliers

#-
# Si supones normalidad bien lo puedes hacer así también
#-


time.without.outs$out.rg.norm - F
time.without.outs[ time.without.outs$TimeDiff %in% x$out,]$out.rg.norm - T
x - abs(scale(time.without.outs$TimeDiff)) # Normalizamos la variable

time.without.outs$out.rg.norm - F
time.without.outs[ x = qnorm(0.995),]$out.rg.norm - T # Quitmos los datos
que estén alejados 99.5 % en la distro (suponiedo normalidad)

time.without.outs$TimeDiff.without.out.norm - time.without.outs$TimeDiff
time.without.outs[
time.without.outs$out.rg.norm,]$TimeDiff.without.out.norm - NA


#-
# Si quieres quitar ambos
#-

time.without.outs$TimeDiff.without.out.norm.rg - time.without.outs$TimeDiff
time.without.outs[ time.without.outs$out.rg |
time.without.outs$out.rg.norm,]$TimeDiff.without.out.norm.rg - NA

summary(time.without.outs)

# Donde

# TimeDiff.without.out.rg Son los datos sin outliers utilizando un criterio
típico cuando no se sabe la distribución de tus datos
# TimeDiff.without.out.norm Son los datos sin outliers asumiendo la
normalidad de tus datos
qqnorm(time.without.outs$TimeDiff.without.out.rg);
qqline(time.without.outs$TimeDiff.without.out.rg, col = 2, lwd = 2)
qqnorm(time.without.outs$TimeDiff.without.out.norm);
qqline(time.without.outs$TimeDiff.without.out.norm, col = 2, lwd =2)

hist(time.without.outs$TimeDiff.without.out.rg)
hist(time.without.outs$TimeDiff.without.out.norm)
ks.test(x= time$TimeDiff, pnorm, mean(time$TimeDiff), sd(time$TimeDiff))
# A la vista de estos exploratorios yo no lo supondría.
# TimeDiff.without.out.norm.rg  son los datos sin outliers según los dos
criterios

# De todas maneras tienes un valor que yo creo que has introducido mal
max(time.without.outs$TimeDiff) # Este valor es claramente un error de
transcripción de datos.

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es