Re: [R-es] Cambiar formato fecha

2018-10-02 Thread Javier Marcuzzi
Estimada Miriam Alzate

Puede enviar un archivo con todas las fechas, y a partir de este probamos
crear un data.frame a partir de sus datos. Con solo la columna de fecha
alcanzaría.

Javier Rubén Marcuzzi

El mar., 2 oct. 2018 a las 11:26,  escribió:

> Es el 4 de mayo. Tengo 65000 filas... Los formatos son o bien: 04/05/2017
> o 4/05/17. Entonces las que tienen el último formato son las que me dan
> errores y no me las convierte ni reconoce. Intento cambiarlas en excel y
> tampoco lo consigo.
>
> El Mar, 2 de Octubre de 2018, 16:24, Jesús Para Fernández escribió:
> > Buenas
> >
> > Cuantas filas tienes?? Yo creo que el problema es la no homogeneidad de
> > las fechas.  Has probado a separar las q estan en um formato y en otro,
> > reconvertirlas con lubridate y volver a juntarlas??
> >
> > Si tienes una fecha q es 04/05/17 es que el el 4 de mayo o el 5 de
> abril??
> >
> > Un saludo
> > Jesús
> >
> > Obtener Outlook para Android
> >
> > 
> > From: R-help-es  on behalf of
> > miriam.alz...@unavarra.es 
> > Sent: Tuesday, October 2, 2018 4:18:26 PM
> > To: Carlos Ortega
> > Cc: Lista R; marcu...@unavarra.es
> > Subject: Re: [R-es] Cambiar formato fecha
> >
> > Hola Carlos,
> > He probado pero me da un aviso y me dice que muchas observaciones no se
> > pueden convertir. Veo que muchas no me las lee como fecha. Supongo que
> los
> > datos originales están mal...pero creía que había solución.
> >
> > Gracias y un saludo
> >
> > El Lun, 1 de Octubre de 2018, 22:05, Carlos Ortega escribió:
> >> Hola Miriam,
> >>
> >> ¿Has probado en cualquier caso?.
> >> "lubridate" es capaz de gestionar estas diferencias.
> >>
> >> Usa la función "dmy()", que entenderá esas pequeñas diferencias con
> >> respecto al día. Puede gestionar incluso diferencias mucho mayores...
> >>
> >> Saludos,
> >> Carlos Ortega
> >> www.qualityexcellence.es
> >>
> >> El lun., 1 oct. 2018 a las 19:05, Miriam Alzate
> >> ()
> >> escribió:
> >>
> >>> Hola,
> >>>
> >>> No  me sirve porque tengo dos tipos de formatos de fechas. En unos
> >>> tengo
> >>> 0 delante del día del mes cuando es entre el 1 y el 9 y en otros
> >>> no...No
> >>> sé como unificar eso para que todas tengan el formato por ejemplo:
> >>> 02/12/2017 y no 2/12/2017.
> >>>
> >>> Un saludo
> >>>
> >>>
> >>>
> >>> El 29/09/2018 a las 13:06, jose luis escribió:
> >>> > Hola
> >>> > efectivamente lubridate te podría servir
> >>> >
> >>> > library(lubridate)
> >>> >
> >>> > data$fecha_nueva<-dmy(data$ReviewData)
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > El Viernes 28 de septiembre de 2018 16:41, Javier Marcuzzi
> >>> >  escribió:
> >>> >
> >>> >
> >>> > Estimada Miriam
> >>> > Le respondo corto, estoy en el celular, escriba str(los datos), su
> >>> fecha
> >>> > puede ser en realidad texto. Hay varias formas, lubridate, pero yo
> >>> aprendí
> >>> > striptime y me siento cómodo con este comando.
> >>> > Javier Marcuzzi
> >>> >
> >>> > El vie., 28 de sep. de 2018 1:20 PM,  >>> > > escribió:
> >>> >
> >>> > > Buenas tardes,
> >>> > > Tengo un problema con una columna de formato fecha. Adjunto una
> >>> imagen
> >>> d
> >>> > > cómo tengo las fechas en la columna. ¿Cómo puedo ponerlas todas en
> >>> el
> >>> > > mismo formato?
> >>> > >
> >>> > >
> >>> > >
> >>> > > Muchas gracias
> >>> > > ___
> >>> > > 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
> >>> >
> >>> >
> >>>
> >>>
> >>> [[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
> >>
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
>
> ___
> 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] Polygon

2018-10-02 Thread Steven Yen
Thanks!!! It did wonders.
Steven

On 10/3/2018 9:39 AM, David Winsemius wrote:
>> On Oct 2, 2018, at 5:50 PM, Steven Yen  wrote:
>>
>> Great. Thanks! It did wonders.
>> 1. Is there a way to suppress the obvious tick stops (-3,-2,-1,0,1,2,3)
>> and mark only the ticks -1.96 and 1.96.
>> 2. Better yet, to draw vertical lines at x = -1.96 and x = 1.96.
>> Thanks.
> Read ?plot.default
>
> Then add xaxt="n" to the arguments to curve, ... and afterwards:
>
> axis( 1, at=c(-1.96, 1.96),lab=c(-1.96, 1.96) )
> abline( v= c(-1.96, 1.96) )
>
> --
>> Steven
>>
>> On 10/3/2018 12:51 AM, Rui Barradas wrote:
>>> Hello,
>>>
>>> Continue with
>>>
>>>
>>> polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')
>>>
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Às 17:25 de 02/10/2018, Steven Yen escreveu:
 Can someone help me with polygon. The following codes are self-runnable
 and mark a shaded area under the standard normal curve in the x-range
 (-3,-1).
 Is there a way to also mark the area in (1,3), at the same time.
 That is, I want shaded areas in both tails. Thank you...

 ===
 # Create data for the area to shade
 cord.x <- c(-3,seq(-3,-1,0.01),-1)
 cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)

 # Make a curve
 curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')

 # Add the shaded area.
 polygon(cord.x,cord.y,col='skyblue')

>> -- 
>> st...@ntu.edu.tw (S.T. Yen)
>>
>>
>>  [[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.
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>
>

-- 
st...@ntu.edu.tw (S.T. Yen)


[[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.


Re: [R] Polygon

2018-10-02 Thread David Winsemius


> On Oct 2, 2018, at 5:50 PM, Steven Yen  wrote:
> 
> Great. Thanks! It did wonders.
> 1. Is there a way to suppress the obvious tick stops (-3,-2,-1,0,1,2,3) 
> and mark only the ticks -1.96 and 1.96.
> 2. Better yet, to draw vertical lines at x = -1.96 and x = 1.96.
> Thanks.

Read ?plot.default

Then add xaxt="n" to the arguments to curve, ... and afterwards:

axis( 1, at=c(-1.96, 1.96),lab=c(-1.96, 1.96) )
abline( v= c(-1.96, 1.96) )

--
> Steven
> 
> On 10/3/2018 12:51 AM, Rui Barradas wrote:
>> Hello,
>> 
>> Continue with
>> 
>> 
>> polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')
>> 
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> Às 17:25 de 02/10/2018, Steven Yen escreveu:
>>> Can someone help me with polygon. The following codes are self-runnable
>>> and mark a shaded area under the standard normal curve in the x-range
>>> (-3,-1).
>>> Is there a way to also mark the area in (1,3), at the same time.
>>> That is, I want shaded areas in both tails. Thank you...
>>> 
>>> ===
>>> # Create data for the area to shade
>>> cord.x <- c(-3,seq(-3,-1,0.01),-1)
>>> cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)
>>> 
>>> # Make a curve
>>> curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')
>>> 
>>> # Add the shaded area.
>>> polygon(cord.x,cord.y,col='skyblue')
>>> 
>> 
> 
> -- 
> st...@ntu.edu.tw (S.T. Yen)
> 
> 
>   [[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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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.


Re: [R] Polygon

2018-10-02 Thread Steven Yen
Great. Thanks! It did wonders.
1. Is there a way to suppress the obvious tick stops (-3,-2,-1,0,1,2,3) 
and mark only the ticks -1.96 and 1.96.
2. Better yet, to draw vertical lines at x = -1.96 and x = 1.96.
Thanks.
Steven

On 10/3/2018 12:51 AM, Rui Barradas wrote:
> Hello,
>
> Continue with
>
>
> polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 17:25 de 02/10/2018, Steven Yen escreveu:
>> Can someone help me with polygon. The following codes are self-runnable
>> and mark a shaded area under the standard normal curve in the x-range
>> (-3,-1).
>> Is there a way to also mark the area in (1,3), at the same time.
>> That is, I want shaded areas in both tails. Thank you...
>>
>> ===
>> # Create data for the area to shade
>> cord.x <- c(-3,seq(-3,-1,0.01),-1)
>> cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)
>>
>> # Make a curve
>> curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')
>>
>> # Add the shaded area.
>> polygon(cord.x,cord.y,col='skyblue')
>>
>

-- 
st...@ntu.edu.tw (S.T. Yen)


[[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.


Re: [R] Strange result for strptime with %p

2018-10-02 Thread David Winsemius


> On Oct 2, 2018, at 10:11 AM, David Winsemius  wrote:
> 
> 
>> On Oct 2, 2018, at 6:30 AM, Marc Girondot via R-help  
>> wrote:
>> 
>> Dear members... are these results normal ?
>> 
>> For the first one, no problem. I expected this:
>> 
>>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
>>> tz="Asia/Jayapura")
>> [1] "2018-05-01 01:00:00 WIT"
>> 
>> For this one, it is ok also:
>> 
>>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
>>> tz="Asia/Jayapura")-1
>> [1] "2018-05-01 00:59:59 WIT"
>> 
>> But how to explain this ???
>> 
>>> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
>>> tz="Asia/Jayapura")
>> [1] NA
> 
> I'm afraid this is "as documented":
> 
> %I
> Hours as decimal number (01–12).
> 
> I see no reason not to use "%H"

If you need to use %I and %p then you may need to pre-process with sub(" 00", " 
12", object_name)

 strptime("05/01/18 12:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
tz="Asia/Jayapura")
[1] "2018-05-01 00:59:59 WIT"


> 
> -- 
> David.
>> 
>> Thanks for your advices
>> Marc
>> __
>> 
>> R 3.5.1 on MacOS 10.14
>> 
>>> version
>>   _
>> platform   x86_64-apple-darwin15.6.0
>> arch   x86_64
>> os darwin15.6.0
>> system x86_64, darwin15.6.0
>> status
>> major  3
>> minor  5.1
>> year   2018
>> month  07
>> day02
>> svn rev74947
>> language   R
>> version.string R version 3.5.1 (2018-07-02)
>> nickname   Feather Spray
>> 
>> __
>> 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.
> 
> David Winsemius
> Alameda, CA, USA
> 
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
> 
> __
> 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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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.


Re: [R-es] Cambiar formato fecha

2018-10-02 Thread Juan Abasolo
Cada maestrillo su librillo. Y yo acá soy estudiantillo.

Probaría, y que me corrijan los maestros, primero trabajar con una porcion
muy chiquita pero representativa de tus datos, tipo datos[1:1000,
c(lacolumnaquetedaguerra, algunamasporsitehacefalta)]
y ahí mismo, si el problema es corregir todos los 1/ 2/ 3/ 4/ 5/ 6/ 7/ 8/
9/ a los mismo pero con cero adelante, pedirle que te localice la barra en
posición 2 (si es tres está bien) y ahí que le mande un 0 adelante.
La comento. Seguro que falla lo que yo escriba, pero haría la búsqueda por
ahí.

algo onda:
if(regexpr(pattern = "/", datos$columnapeleona)==2, cat(0, columnapeleona,
sep = "")

Me imagino que después vas a tener que pelearte en que entienda que eso es
una fecha y no una cadena de texto, que creo que es lo que te estoy
diciendo que hagás. Pero como decía, yo soy alumno en esto y me perdí las
primeras clases.

Suerte!



Mezu hau jaso duzu  helbidetik (2018 urr. 2, ar.
(16:26)):

> Es el 4 de mayo. Tengo 65000 filas... Los formatos son o bien: 04/05/2017
> o 4/05/17. Entonces las que tienen el último formato son las que me dan
> errores y no me las convierte ni reconoce. Intento cambiarlas en excel y
> tampoco lo consigo.
>
> El Mar, 2 de Octubre de 2018, 16:24, Jesús Para Fernández escribió:
> > Buenas
> >
> > Cuantas filas tienes?? Yo creo que el problema es la no homogeneidad de
> > las fechas.  Has probado a separar las q estan en um formato y en otro,
> > reconvertirlas con lubridate y volver a juntarlas??
> >
> > Si tienes una fecha q es 04/05/17 es que el el 4 de mayo o el 5 de
> abril??
> >
> > Un saludo
> > Jesús
> >
> > Obtener Outlook para Android
> >
> > 
> > From: R-help-es  on behalf of
> > miriam.alz...@unavarra.es 
> > Sent: Tuesday, October 2, 2018 4:18:26 PM
> > To: Carlos Ortega
> > Cc: Lista R; marcu...@unavarra.es
> > Subject: Re: [R-es] Cambiar formato fecha
> >
> > Hola Carlos,
> > He probado pero me da un aviso y me dice que muchas observaciones no se
> > pueden convertir. Veo que muchas no me las lee como fecha. Supongo que
> los
> > datos originales están mal...pero creía que había solución.
> >
> > Gracias y un saludo
> >
> > El Lun, 1 de Octubre de 2018, 22:05, Carlos Ortega escribió:
> >> Hola Miriam,
> >>
> >> ¿Has probado en cualquier caso?.
> >> "lubridate" es capaz de gestionar estas diferencias.
> >>
> >> Usa la función "dmy()", que entenderá esas pequeñas diferencias con
> >> respecto al día. Puede gestionar incluso diferencias mucho mayores...
> >>
> >> Saludos,
> >> Carlos Ortega
> >> www.qualityexcellence.es
> >>
> >> El lun., 1 oct. 2018 a las 19:05, Miriam Alzate
> >> ()
> >> escribió:
> >>
> >>> Hola,
> >>>
> >>> No  me sirve porque tengo dos tipos de formatos de fechas. En unos
> >>> tengo
> >>> 0 delante del día del mes cuando es entre el 1 y el 9 y en otros
> >>> no...No
> >>> sé como unificar eso para que todas tengan el formato por ejemplo:
> >>> 02/12/2017 y no 2/12/2017.
> >>>
> >>> Un saludo
> >>>
> >>>
> >>>
> >>> El 29/09/2018 a las 13:06, jose luis escribió:
> >>> > Hola
> >>> > efectivamente lubridate te podría servir
> >>> >
> >>> > library(lubridate)
> >>> >
> >>> > data$fecha_nueva<-dmy(data$ReviewData)
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > El Viernes 28 de septiembre de 2018 16:41, Javier Marcuzzi
> >>> >  escribió:
> >>> >
> >>> >
> >>> > Estimada Miriam
> >>> > Le respondo corto, estoy en el celular, escriba str(los datos), su
> >>> fecha
> >>> > puede ser en realidad texto. Hay varias formas, lubridate, pero yo
> >>> aprendí
> >>> > striptime y me siento cómodo con este comando.
> >>> > Javier Marcuzzi
> >>> >
> >>> > El vie., 28 de sep. de 2018 1:20 PM,  >>> > > escribió:
> >>> >
> >>> > > Buenas tardes,
> >>> > > Tengo un problema con una columna de formato fecha. Adjunto una
> >>> imagen
> >>> d
> >>> > > cómo tengo las fechas en la columna. ¿Cómo puedo ponerlas todas en
> >>> el
> >>> > > mismo formato?
> >>> > >
> >>> > >
> >>> > >
> >>> > > Muchas gracias
> >>> > > ___
> >>> > > 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
> >>> >
> >>> >
> >>>
> >>>
> >>> [[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
> >>
> >
> > 

Re: [R] Sp-package overlay

2018-10-02 Thread Ben Tupper
Hi,

I'm pretty sure that what you ask is likely not too hard to do.  On the other 
hand, I think you will do well to consider the following...

1. Join the mailing list; the folks there will know better what you are trying 
to do - see

https://stat.ethz.ch/mailman/listinfo/r-sig-geo 



2. Switch from the sf package to the sf package if you can - see  

https://cran.r-project.org/web/packages/sf/


3. Come up to speed with geospatial data handling in R starting here 

https://geocompr.robinlovelace.net/index.html


Cheers,
Ben


> On Oct 2, 2018, at 10:33 AM, Ivy Pieters  wrote:
> 
> Hey there, 
> 
> For my internship I have to work with R. I am working with R for the first
> time and I don't know much. 
> Somehow I don't manage to find the answer to my question in google. I think
> I don't search with the right words, or maybe I just don't understand
> enough. Anyways, I hope someone here can help me out. 
> 
> I have 2 datasets: 
> 
> a SpatialPolygonDataFrame, this dataset is called "field" (these are
> different fields of arable land) 
> and a SpatialPointsDataFrame, this dataset is called "odk" (these are
> different soil samples taken in each field) 
> 
> The field data set consists of 8 polygons and they have a slot with coords 
> 
> The odk data set consists of 537 features (soil samples), these features
> belong to the polygons but they are all mixed. This dataset also has a slot
> with coords 
> 
> They are both projected in the same coordinate system. 
> 
> Now I would like to create a new dataset with a table with the features of
> odk that belong to polygon 1 and a separate table for the features that
> belong to polygon 2 etc. The best is if they also get into the
> spatialpointsdataframe format. 
> 
> I really don't know how to do this. I hope someone here can help me out. I
> hope that I gave enough information for anyone to help me else let me know
> if I have to tell something more about my datasets. 
> 
> Thank you already a lot in advance, 
> 
> Hope to hear from anyone soon, 
> 
> Kind regards, 
> 
> Ivy
> 
> __
> 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.
> 

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/






[[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.


Re: [R] Strange result for strptime with %p

2018-10-02 Thread David Winsemius


> On Oct 2, 2018, at 6:30 AM, Marc Girondot via R-help  
> wrote:
> 
> Dear members... are these results normal ?
> 
> For the first one, no problem. I expected this:
> 
> > strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
> > tz="Asia/Jayapura")
> [1] "2018-05-01 01:00:00 WIT"
> 
> For this one, it is ok also:
> 
> > strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
> > tz="Asia/Jayapura")-1
> [1] "2018-05-01 00:59:59 WIT"
> 
> But how to explain this ???
> 
> > strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
> > tz="Asia/Jayapura")
> [1] NA

I'm afraid this is "as documented":

%I
Hours as decimal number (01–12).

I see no reason not to use "%H"

-- 
David.
> 
> Thanks for your advices
> Marc
> __
> 
> R 3.5.1 on MacOS 10.14
> 
> > version
>_
> platform   x86_64-apple-darwin15.6.0
> arch   x86_64
> os darwin15.6.0
> system x86_64, darwin15.6.0
> status
> major  3
> minor  5.1
> year   2018
> month  07
> day02
> svn rev74947
> language   R
> version.string R version 3.5.1 (2018-07-02)
> nickname   Feather Spray
> 
> __
> 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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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.


Re: [R] Polygon

2018-10-02 Thread Rui Barradas

Hello,

Continue with


polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')


Hope this helps,

Rui Barradas

Às 17:25 de 02/10/2018, Steven Yen escreveu:

Can someone help me with polygon. The following codes are self-runnable
and mark a shaded area under the standard normal curve in the x-range
(-3,-1).
Is there a way to also mark the area in (1,3), at the same time.
That is, I want shaded areas in both tails. Thank you...

===
# Create data for the area to shade
cord.x <- c(-3,seq(-3,-1,0.01),-1)
cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)

# Make a curve
curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')

# Add the shaded area.
polygon(cord.x,cord.y,col='skyblue')



__
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.


Re: [R] Why do two different calls to mgcv::gamm give different p-values?

2018-10-02 Thread Øystein Sørensen
Thanks a lot, Simon. That was a silly mistake on my part. After correcting,
there is still a slight difference between the p-values, but this is so
small that I guess it is just numerics.

Best,
Øystein

On Tue, Oct 2, 2018 at 2:26 PM Simon Wood  wrote:

> Dear Øystein,
>
> In your code 'id' is set up to be numeric. In your first gamm call it
> gets coerced to a factor (since nothing else would make sense). In  your
> second gamm call it is simply treated as numeric, since that could makes
> sense. To make the two models equivalent you just need to substitute:
>
> id <- as.factor(rep(1:ng, n/ng))
>
> into your loop.
>
> best,
> Simon
>
> On 01/10/18 08:15, Øystein Sørensen wrote:
> > I have longitudinal data where a response y_{ij} has been measured
> > repeatedly for i=1,...,n individuals, j=1,...,m times for each
> individual.
> > Let x_{ij} be the age of individual i at her/his jth measurement. I wish
> to
> > see how the response varies with age, and have reason to believe that a
> > nonlinear fit is needed. I hence wish to model the relationship using an
> > additive mixed model of the form y_{ij} = f(x_{ij}) + b_{i} +
> > \epsilon_{ij}, where f() is some smooth function to be estimated, b_{i}
> > \sim N(0, \sigma_{b}^{2}) is the random effect for individual i,
> > \epsilon_{ij} \sim N(0, \sigma^{2}) is the residual.
> >
> > Reading the documentation to the mgcv package, I see that such models can
> > be set up by calling the mgcv::gamm two different ways. One way shown to
> > set up such a model is with the call
> > b1 <- gamm(y ~ s(x), random = list(id =~ 1)),
> > where id is an indicator of the specific individual. In this way, the
> > random effect is specified in a list. The other way is to set up the
> random
> > effect with a smooth of the re:
> > b2 <- gamm(y ~ s(x) + s(id, bs = "re")).
> >
> > As far as I can understand, these two setups should create the same
> > underlying model matrices. However, when running them on my data, the
> > p-values for the smooth terms, as well as their estimated degrees of
> > freedom, are different.
> >
> > Below is a reproducible example on simulated data, which show that these
> > two types of specifying the models give different p-values and estimated
> > degrees of freedom. On my real data, these differences are sometimes even
> > more exaggerated.
> >
> > My question is: Are not these two calls to gamm suppose to estimate the
> > same model, or have I misunderstood?
> >
> > Here is a reproducible example:
> >
> > library(mgcv)
> > set.seed(100)
> > n_sim <- 100
> > df <- data.frame(
> >model1_pval = numeric(n_sim),
> >model1_edf = numeric(n_sim),
> >model2_pval = numeric(n_sim),
> >model2_edf = numeric(n_sim)
> > )
> >
> > # Number of observations
> > n <- 500
> > # Number of groups
> > ng <- 100
> >
> > for(i in 1:n_sim){
> ># Draw the fixed effect covariate
> >x <- rnorm(n)
> ># Set up the group
> >id <- rep(1:ng, n/ng)
> ># Draw the random effect
> >z <- rnorm(ng)
> ># Draw the response
> >y <- 0.1 * x + 0.2 * x^3 + z[id] + rnorm(n)
> >
> ># Fit the two different models
> >b1 <- gamm(y ~ s(x, k = 5), random = list(id =~ 1))
> >b2 <- gamm(y ~ s(x, k = 5) + s(id, bs = "re"))
> >
> >df[i, "model1_pval"] <- anova(b1$gam)$s.pv
> >df[i, "model1_edf"] <- anova(b1$gam)$edf
> >df[i, "model2_pval"] <- anova(b2$gam)$s.pv[[1]]
> >df[i, "model2_edf"] <- anova(b2$gam)$edf[[1]]
> > }
> >
> > # Differences between model 1 and model 2 p values
> > mean(df$model1_pval)
> > #> [1] 6.790546e-21
> > mean(df$model2_pval)
> > #> [1] 3.090694e-14
> > max(abs(df$model1_pval - df$model2_pval))
> > #> [1] 2.770545e-12
> >
> > # Differences between model1 and model 2 estimated degrees of freedom
> > mean(df$model1_edf)
> > #> [1] 3.829992
> > mean(df$model2_edf)
> > #> [1] 3.731438
> > max(abs(df$model1_edf - df$model2_edf))
> > #> [1] 0.6320281
> >
> >
> > Thanks in advance,
> > Øystein Sørensen
> >
> >   [[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.
>
>

[[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] Polygon

2018-10-02 Thread Steven Yen
Can someone help me with polygon. The following codes are self-runnable 
and mark a shaded area under the standard normal curve in the x-range 
(-3,-1).
Is there a way to also mark the area in (1,3), at the same time.
That is, I want shaded areas in both tails. Thank you...

===
# Create data for the area to shade
cord.x <- c(-3,seq(-3,-1,0.01),-1)
cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)

# Make a curve
curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')

# Add the shaded area.
polygon(cord.x,cord.y,col='skyblue')

-- 
st...@ntu.edu.tw (S.T. Yen)


[[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] Sp-package overlay

2018-10-02 Thread Ivy Pieters
Hey there, 

For my internship I have to work with R. I am working with R for the first
time and I don't know much. 
Somehow I don't manage to find the answer to my question in google. I think
I don't search with the right words, or maybe I just don't understand
enough. Anyways, I hope someone here can help me out. 

I have 2 datasets: 

a SpatialPolygonDataFrame, this dataset is called "field" (these are
different fields of arable land) 
and a SpatialPointsDataFrame, this dataset is called "odk" (these are
different soil samples taken in each field) 

The field data set consists of 8 polygons and they have a slot with coords 

The odk data set consists of 537 features (soil samples), these features
belong to the polygons but they are all mixed. This dataset also has a slot
with coords 

They are both projected in the same coordinate system. 

Now I would like to create a new dataset with a table with the features of
odk that belong to polygon 1 and a separate table for the features that
belong to polygon 2 etc. The best is if they also get into the
spatialpointsdataframe format. 

I really don't know how to do this. I hope someone here can help me out. I
hope that I gave enough information for anyone to help me else let me know
if I have to tell something more about my datasets. 

Thank you already a lot in advance, 

Hope to hear from anyone soon, 

Kind regards, 

Ivy

__
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.


Re: [R] Strange result for strptime with %p

2018-10-02 Thread Jeff Newmiller
... except that the %p is ignored or generates an error 
(implementation-dependent) if you use %H, so this may only address a few of the 
values you are processing and then only on some platforms.

On October 2, 2018 8:22:02 AM PDT, Rui Barradas  wrote:
>Hello,
>
>Or %H, it also works.
>
>strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %H:%M:%S %p"), 
>tz="Asia/Jayapura")
>#[1] "2018-05-01 00:59:59 WIT"
>
>
>Hope this helps,
>
>Rui Barradas
>
>Às 15:20 de 02/10/2018, PIKAL Petr escreveu:
>> Hi
>> 
>> Credit belongs to documentation. I picked it from it.
>> 
>> Cheers
>> Petr
>> 
>>> -Original Message-
>>> From: peter dalgaard 
>>> Sent: Tuesday, October 2, 2018 4:15 PM
>>> To: PIKAL Petr 
>>> Cc: Marc Girondot ; r-help mailing list
>>> project.org>
>>> Subject: Re: [R] Strange result for strptime with %p
>>>
>>> Nice catch, Petr:
>>>
 strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
 tz="Asia/Jayapura")
>>> [1] NA
 strptime("05/01/18 12:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
 tz="Asia/Jayapura")
>>> [1] "2018-05-01 00:59:59 WIT"
>>>
>>> -pd
>>>
 On 2 Oct 2018, at 15:39 , PIKAL Petr 
>wrote:

 Hi

 Maybe it is connected to
 %I
 Hours as decimal number (01–12).

 Your input has hour as 00

 Cheers
 Petr

> -Original Message-
> From: R-help  On Behalf Of Marc
> Girondot via R-help
> Sent: Tuesday, October 2, 2018 3:30 PM
> To: R-help Mailing List 
> Subject: [R] Strange result for strptime with %p
>
> Dear members... are these results normal ?
>
> For the first one, no problem. I expected this:
>
>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S
>%p"),
> tz="Asia/Jayapura")
> [1] "2018-05-01 01:00:00 WIT"
>
> For this one, it is ok also:
>
>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S
>%p"),
> tz="Asia/Jayapura")-1
> [1] "2018-05-01 00:59:59 WIT"
>
> But how to explain this ???
>
>> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S
>%p"),
> tz="Asia/Jayapura")
> [1] NA
>
> Thanks for your advices
> Marc
> __
>
> R 3.5.1 on MacOS 10.14
>
>> version
> _
> platform   x86_64-apple-darwin15.6.0
> arch   x86_64
> os darwin15.6.0
> system x86_64, darwin15.6.0
> status
> major  3
> minor  5.1
> year   2018
> month  07
> day02
> svn rev74947
> language   R
> version.string R version 3.5.1 (2018-07-02)
> nickname   Feather Spray
>
> __
> 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.
 Osobní údaje: Informace o zpracování a ochraně osobních údajů
 obchodních partnerů PRECHEZA a.s. jsou zveřejněny na:
 https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ |
>Information
 about processing and protection of business partner’s personal data
 are available on website:
 https://www.precheza.cz/en/personal-data-protection-principles/
 Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
 důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
 odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and
>any
 documents attached to it may be confidential and are subject to the
 legally binding disclaimer:
>https://www.precheza.cz/en/01-disclaimer/

 __
 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.
>>>
>>> --
>>> Peter Dalgaard, Professor,
>>> Center for Statistics, Copenhagen Business School Solbjerg Plads 3,
>2000
>>> Frederiksberg, Denmark
>>> Phone: (+45)38153501
>>> Office: A 4.23
>>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> 
>> Osobní údaje: Informace o zpracování a ochraně osobních údajů
>obchodních partnerů PRECHEZA a.s. jsou zveřejněny na:
>https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
>about processing and protection of business partner’s personal data are
>available on website:
>https://www.precheza.cz/en/personal-data-protection-principles/
>> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
>odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email 

Re: [R] Strange result for strptime with %p

2018-10-02 Thread Rui Barradas

Hello,

Or %H, it also works.

strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %H:%M:%S %p"), 
tz="Asia/Jayapura")

#[1] "2018-05-01 00:59:59 WIT"


Hope this helps,

Rui Barradas

Às 15:20 de 02/10/2018, PIKAL Petr escreveu:

Hi

Credit belongs to documentation. I picked it from it.

Cheers
Petr


-Original Message-
From: peter dalgaard 
Sent: Tuesday, October 2, 2018 4:15 PM
To: PIKAL Petr 
Cc: Marc Girondot ; r-help mailing list 
Subject: Re: [R] Strange result for strptime with %p

Nice catch, Petr:


strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
tz="Asia/Jayapura")

[1] NA

strptime("05/01/18 12:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
tz="Asia/Jayapura")

[1] "2018-05-01 00:59:59 WIT"

-pd


On 2 Oct 2018, at 15:39 , PIKAL Petr  wrote:

Hi

Maybe it is connected to
%I
Hours as decimal number (01–12).

Your input has hour as 00

Cheers
Petr


-Original Message-
From: R-help  On Behalf Of Marc
Girondot via R-help
Sent: Tuesday, October 2, 2018 3:30 PM
To: R-help Mailing List 
Subject: [R] Strange result for strptime with %p

Dear members... are these results normal ?

For the first one, no problem. I expected this:


strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),

tz="Asia/Jayapura")
[1] "2018-05-01 01:00:00 WIT"

For this one, it is ok also:


strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),

tz="Asia/Jayapura")-1
[1] "2018-05-01 00:59:59 WIT"

But how to explain this ???


strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),

tz="Asia/Jayapura")
[1] NA

Thanks for your advices
Marc
__

R 3.5.1 on MacOS 10.14


version

_
platform   x86_64-apple-darwin15.6.0
arch   x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major  3
minor  5.1
year   2018
month  07
day02
svn rev74947
language   R
version.string R version 3.5.1 (2018-07-02)
nickname   Feather Spray

__
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.

Osobní údaje: Informace o zpracování a ochraně osobních údajů
obchodních partnerů PRECHEZA a.s. jsou zveřejněny na:
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
about processing and protection of business partner’s personal data
are available on website:
https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
documents attached to it may be confidential and are subject to the
legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/

__
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.


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com










Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
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-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.


Re: [R-es] Cambiar formato fecha

2018-10-02 Thread miriam . alzate
Es el 4 de mayo. Tengo 65000 filas... Los formatos son o bien: 04/05/2017
o 4/05/17. Entonces las que tienen el último formato son las que me dan
errores y no me las convierte ni reconoce. Intento cambiarlas en excel y
tampoco lo consigo.

El Mar, 2 de Octubre de 2018, 16:24, Jesús Para Fernández escribió:
> Buenas
>
> Cuantas filas tienes?? Yo creo que el problema es la no homogeneidad de
> las fechas.  Has probado a separar las q estan en um formato y en otro,
> reconvertirlas con lubridate y volver a juntarlas??
>
> Si tienes una fecha q es 04/05/17 es que el el 4 de mayo o el 5 de abril??
>
> Un saludo
> Jesús
>
> Obtener Outlook para Android
>
> 
> From: R-help-es  on behalf of
> miriam.alz...@unavarra.es 
> Sent: Tuesday, October 2, 2018 4:18:26 PM
> To: Carlos Ortega
> Cc: Lista R; marcu...@unavarra.es
> Subject: Re: [R-es] Cambiar formato fecha
>
> Hola Carlos,
> He probado pero me da un aviso y me dice que muchas observaciones no se
> pueden convertir. Veo que muchas no me las lee como fecha. Supongo que los
> datos originales están mal...pero creía que había solución.
>
> Gracias y un saludo
>
> El Lun, 1 de Octubre de 2018, 22:05, Carlos Ortega escribió:
>> Hola Miriam,
>>
>> ¿Has probado en cualquier caso?.
>> "lubridate" es capaz de gestionar estas diferencias.
>>
>> Usa la función "dmy()", que entenderá esas pequeñas diferencias con
>> respecto al día. Puede gestionar incluso diferencias mucho mayores...
>>
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>> El lun., 1 oct. 2018 a las 19:05, Miriam Alzate
>> ()
>> escribió:
>>
>>> Hola,
>>>
>>> No  me sirve porque tengo dos tipos de formatos de fechas. En unos
>>> tengo
>>> 0 delante del día del mes cuando es entre el 1 y el 9 y en otros
>>> no...No
>>> sé como unificar eso para que todas tengan el formato por ejemplo:
>>> 02/12/2017 y no 2/12/2017.
>>>
>>> Un saludo
>>>
>>>
>>>
>>> El 29/09/2018 a las 13:06, jose luis escribió:
>>> > Hola
>>> > efectivamente lubridate te podría servir
>>> >
>>> > library(lubridate)
>>> >
>>> > data$fecha_nueva<-dmy(data$ReviewData)
>>> >
>>> >
>>> >
>>> >
>>> > El Viernes 28 de septiembre de 2018 16:41, Javier Marcuzzi
>>> >  escribió:
>>> >
>>> >
>>> > Estimada Miriam
>>> > Le respondo corto, estoy en el celular, escriba str(los datos), su
>>> fecha
>>> > puede ser en realidad texto. Hay varias formas, lubridate, pero yo
>>> aprendí
>>> > striptime y me siento cómodo con este comando.
>>> > Javier Marcuzzi
>>> >
>>> > El vie., 28 de sep. de 2018 1:20 PM, >> > > escribió:
>>> >
>>> > > Buenas tardes,
>>> > > Tengo un problema con una columna de formato fecha. Adjunto una
>>> imagen
>>> d
>>> > > cómo tengo las fechas en la columna. ¿Cómo puedo ponerlas todas en
>>> el
>>> > > mismo formato?
>>> > >
>>> > >
>>> > >
>>> > > Muchas gracias
>>> > > ___
>>> > > 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
>>> >
>>> >
>>>
>>>
>>> [[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
>>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

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


Re: [R-es] Cambiar formato fecha

2018-10-02 Thread Jesús Para Fernández
Buenas

Cuantas filas tienes?? Yo creo que el problema es la no homogeneidad de las 
fechas.  Has probado a separar las q estan en um formato y en otro, 
reconvertirlas con lubridate y volver a juntarlas??

Si tienes una fecha q es 04/05/17 es que el el 4 de mayo o el 5 de abril??

Un saludo
Jes�s

Obtener Outlook para Android


From: R-help-es  on behalf of 
miriam.alz...@unavarra.es 
Sent: Tuesday, October 2, 2018 4:18:26 PM
To: Carlos Ortega
Cc: Lista R; marcu...@unavarra.es
Subject: Re: [R-es] Cambiar formato fecha

Hola Carlos,
He probado pero me da un aviso y me dice que muchas observaciones no se
pueden convertir. Veo que muchas no me las lee como fecha. Supongo que los
datos originales est�n mal...pero cre�a que hab�a soluci�n.

Gracias y un saludo

El Lun, 1 de Octubre de 2018, 22:05, Carlos Ortega escribi�:
> Hola Miriam,
>
> �Has probado en cualquier caso?.
> "lubridate" es capaz de gestionar estas diferencias.
>
> Usa la funci�n "dmy()", que entender� esas peque�as diferencias con
> respecto al d�a. Puede gestionar incluso diferencias mucho mayores...
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> El lun., 1 oct. 2018 a las 19:05, Miriam Alzate
> ()
> escribi�:
>
>> Hola,
>>
>> No  me sirve porque tengo dos tipos de formatos de fechas. En unos tengo
>> 0 delante del d�a del mes cuando es entre el 1 y el 9 y en otros no...No
>> s� como unificar eso para que todas tengan el formato por ejemplo:
>> 02/12/2017 y no 2/12/2017.
>>
>> Un saludo
>>
>>
>>
>> El 29/09/2018 a las 13:06, jose luis escribi�:
>> > Hola
>> > efectivamente lubridate te podr�a servir
>> >
>> > library(lubridate)
>> >
>> > data$fecha_nueva<-dmy(data$ReviewData)
>> >
>> >
>> >
>> >
>> > El Viernes 28 de septiembre de 2018 16:41, Javier Marcuzzi
>> >  escribi�:
>> >
>> >
>> > Estimada Miriam
>> > Le respondo corto, estoy en el celular, escriba str(los datos), su
>> fecha
>> > puede ser en realidad texto. Hay varias formas, lubridate, pero yo
>> aprend�
>> > striptime y me siento c�modo con este comando.
>> > Javier Marcuzzi
>> >
>> > El vie., 28 de sep. de 2018 1:20 PM, > > > escribi�:
>> >
>> > > Buenas tardes,
>> > > Tengo un problema con una columna de formato fecha. Adjunto una
>> imagen
>> d
>> > > c�mo tengo las fechas en la columna. �C�mo puedo ponerlas todas en
>> el
>> > > mismo formato?
>> > >
>> > >
>> > >
>> > > Muchas gracias
>> > > ___
>> > > 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
>> >
>> >
>>
>>
>> [[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
>

___
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] Strange result for strptime with %p

2018-10-02 Thread PIKAL Petr
Hi

Credit belongs to documentation. I picked it from it.

Cheers
Petr

> -Original Message-
> From: peter dalgaard 
> Sent: Tuesday, October 2, 2018 4:15 PM
> To: PIKAL Petr 
> Cc: Marc Girondot ; r-help mailing list  project.org>
> Subject: Re: [R] Strange result for strptime with %p
>
> Nice catch, Petr:
>
> > strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> > tz="Asia/Jayapura")
> [1] NA
> > strptime("05/01/18 12:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> > tz="Asia/Jayapura")
> [1] "2018-05-01 00:59:59 WIT"
>
> -pd
>
> > On 2 Oct 2018, at 15:39 , PIKAL Petr  wrote:
> >
> > Hi
> >
> > Maybe it is connected to
> > %I
> > Hours as decimal number (01–12).
> >
> > Your input has hour as 00
> >
> > Cheers
> > Petr
> >
> >> -Original Message-
> >> From: R-help  On Behalf Of Marc
> >> Girondot via R-help
> >> Sent: Tuesday, October 2, 2018 3:30 PM
> >> To: R-help Mailing List 
> >> Subject: [R] Strange result for strptime with %p
> >>
> >> Dear members... are these results normal ?
> >>
> >> For the first one, no problem. I expected this:
> >>
> >>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> >> tz="Asia/Jayapura")
> >> [1] "2018-05-01 01:00:00 WIT"
> >>
> >> For this one, it is ok also:
> >>
> >>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> >> tz="Asia/Jayapura")-1
> >> [1] "2018-05-01 00:59:59 WIT"
> >>
> >> But how to explain this ???
> >>
> >>> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> >> tz="Asia/Jayapura")
> >> [1] NA
> >>
> >> Thanks for your advices
> >> Marc
> >> __
> >>
> >> R 3.5.1 on MacOS 10.14
> >>
> >>> version
> >>_
> >> platform   x86_64-apple-darwin15.6.0
> >> arch   x86_64
> >> os darwin15.6.0
> >> system x86_64, darwin15.6.0
> >> status
> >> major  3
> >> minor  5.1
> >> year   2018
> >> month  07
> >> day02
> >> svn rev74947
> >> language   R
> >> version.string R version 3.5.1 (2018-07-02)
> >> nickname   Feather Spray
> >>
> >> __
> >> 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.
> > Osobní údaje: Informace o zpracování a ochraně osobních údajů
> > obchodních partnerů PRECHEZA a.s. jsou zveřejněny na:
> > https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
> > about processing and protection of business partner’s personal data
> > are available on website:
> > https://www.precheza.cz/en/personal-data-protection-principles/
> > Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> > důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
> > odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> > documents attached to it may be confidential and are subject to the
> > legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
> >
> > __
> > 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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
> Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>

Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
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.


Re: [R] Strange result for strptime with %p

2018-10-02 Thread peter dalgaard
Nice catch, Petr:

> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
> tz="Asia/Jayapura")
[1] NA
> strptime("05/01/18 12:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
> tz="Asia/Jayapura")
[1] "2018-05-01 00:59:59 WIT"

-pd

> On 2 Oct 2018, at 15:39 , PIKAL Petr  wrote:
> 
> Hi
> 
> Maybe it is connected to
> %I
> Hours as decimal number (01–12).
> 
> Your input has hour as 00
> 
> Cheers
> Petr
> 
>> -Original Message-
>> From: R-help  On Behalf Of Marc Girondot via
>> R-help
>> Sent: Tuesday, October 2, 2018 3:30 PM
>> To: R-help Mailing List 
>> Subject: [R] Strange result for strptime with %p
>> 
>> Dear members... are these results normal ?
>> 
>> For the first one, no problem. I expected this:
>> 
>>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
>> tz="Asia/Jayapura")
>> [1] "2018-05-01 01:00:00 WIT"
>> 
>> For this one, it is ok also:
>> 
>>> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
>> tz="Asia/Jayapura")-1
>> [1] "2018-05-01 00:59:59 WIT"
>> 
>> But how to explain this ???
>> 
>>> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
>> tz="Asia/Jayapura")
>> [1] NA
>> 
>> Thanks for your advices
>> Marc
>> __
>> 
>> R 3.5.1 on MacOS 10.14
>> 
>>> version
>>_
>> platform   x86_64-apple-darwin15.6.0
>> arch   x86_64
>> os darwin15.6.0
>> system x86_64, darwin15.6.0
>> status
>> major  3
>> minor  5.1
>> year   2018
>> month  07
>> day02
>> svn rev74947
>> language   R
>> version.string R version 3.5.1 (2018-07-02)
>> nickname   Feather Spray
>> 
>> __
>> 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.
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
> partnerů PRECHEZA a.s. jsou zveřejněny na: 
> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
> processing and protection of business partner’s personal data are available 
> on website: https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
> podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
> https://www.precheza.cz/01-dovetek/ | This email and any documents attached 
> to it may be confidential and are subject to the legally binding disclaimer: 
> https://www.precheza.cz/en/01-disclaimer/
> 
> __
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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.


Re: [R-es] Cambiar formato fecha

2018-10-02 Thread miriam . alzate
Hola Carlos,
He probado pero me da un aviso y me dice que muchas observaciones no se
pueden convertir. Veo que muchas no me las lee como fecha. Supongo que los
datos originales están mal...pero creía que había solución.

Gracias y un saludo

El Lun, 1 de Octubre de 2018, 22:05, Carlos Ortega escribió:
> Hola Miriam,
>
> ¿Has probado en cualquier caso?.
> "lubridate" es capaz de gestionar estas diferencias.
>
> Usa la función "dmy()", que entenderá esas pequeñas diferencias con
> respecto al día. Puede gestionar incluso diferencias mucho mayores...
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> El lun., 1 oct. 2018 a las 19:05, Miriam Alzate
> ()
> escribió:
>
>> Hola,
>>
>> No  me sirve porque tengo dos tipos de formatos de fechas. En unos tengo
>> 0 delante del día del mes cuando es entre el 1 y el 9 y en otros no...No
>> sé como unificar eso para que todas tengan el formato por ejemplo:
>> 02/12/2017 y no 2/12/2017.
>>
>> Un saludo
>>
>>
>>
>> El 29/09/2018 a las 13:06, jose luis escribió:
>> > Hola
>> > efectivamente lubridate te podría servir
>> >
>> > library(lubridate)
>> >
>> > data$fecha_nueva<-dmy(data$ReviewData)
>> >
>> >
>> >
>> >
>> > El Viernes 28 de septiembre de 2018 16:41, Javier Marcuzzi
>> >  escribió:
>> >
>> >
>> > Estimada Miriam
>> > Le respondo corto, estoy en el celular, escriba str(los datos), su
>> fecha
>> > puede ser en realidad texto. Hay varias formas, lubridate, pero yo
>> aprendí
>> > striptime y me siento cómodo con este comando.
>> > Javier Marcuzzi
>> >
>> > El vie., 28 de sep. de 2018 1:20 PM, > > > escribió:
>> >
>> > > Buenas tardes,
>> > > Tengo un problema con una columna de formato fecha. Adjunto una
>> imagen
>> d
>> > > cómo tengo las fechas en la columna. ¿Cómo puedo ponerlas todas en
>> el
>> > > mismo formato?
>> > >
>> > >
>> > >
>> > > Muchas gracias
>> > > ___
>> > > 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
>> >
>> >
>>
>>
>> [[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
>

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


[R] Book: Spatial, Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA. Volume II: GAM and Zero-Inflated Models

2018-10-02 Thread Highland Statistics Ltd
We are pleased to announce the following book:

Spatial, Temporal and Spatial-Temporal Ecological Data Analysis with 
R-INLA. Volume II: GAM and Zero-Inflated Models
Authors: Zuur and Ieno

Book website: www.highstat.com
Paperback or EBook can be order (exclusively) from www.highstat.com
TOC: http://highstat.com/Books/BGS/SpatialTempVII/TOC_SpatTempII_Online.pdf

Summary: In Volume II we apply zero-inflated models and generalised 
additive (mixed-effects) models to spatial and spatial-temporal data. 
Data and all R code is available.


Outline:

In Chapter 18 we will explain how to deal with zero-inflated data. We 
introduce so-called zero-inflated Poisson (ZIP) models, zero-inflated 
negative binomial (ZINB) models, zero-altered Poisson (ZAP) models and 
zero-altered negative binomial (ZINB) models.

In Chapter 19 we extend the ZIP, ZINB, ZAP and ZANB models with spatial 
correlation. Both these chapters use a skate data set from South 
America. In the appendix accompanying Chapter 19 we also explain how to 
manipulate maps and create spatial polygons (e.g. for coastlines).

In Chapter 20 we revisit a data set with which we have been battling 
since 2006. It is about begging behaviour of owl nestlings. In Zuur 
(2009a) we applied linear mixed-effects models on it, and in Zuur et al. 
(2012a) we analysed it with a zero-inflated GLMM. Thanks to R-INLA we 
finally cracked this data set and apply a zero-inflated GAMM.

In Chapter 21 we analyse sandeel count data. This work came out of a 
consultancy project that we carried out for Wageningen Marine Research 
(The Netherlands) in 2017. Although the setup of the experiment is 
simple (approximately 400 sites sampled once per year, for 4 years), 
analysing these data and writing this chapter took about 30 days. This 
should give you an idea about the complexity of the statistical tools 
(zero-inflated GAMMs + spatial-temporal correlation) that we discuss in 
this book.

Chapter 22 is about zero-inflated bird densities sampled in the Labrador 
Sea, located between the Labrador Peninsula (Eastern Canada) and 
Greenland. This chapter is about the analysis of zero-inflated 
continuous data with spatial correlation. A zero-altered gamma model 
with spatial correlation is used.

In Chapter 23 we analyse coral reef data sampled around an island. A lot 
of misery comes together in this chapter: smoothers, zero-inflation and 
spatial dependency that should not cross land as benthic species that 
live in a coral reef do not walk over land! We will discuss barrier 
models (Bakka et al. 2018) which ensure that spatial correlation seeps 
around a barrier (in this case an island).

Up to Chapter 23 all data sets analysed were geostatistical data and not 
areal or lattice data. The reason for this is that most ecological data 
is geostatistical. In Chapter 24 we analyse aggregated tornado data in 
102 counties in Illinois. This is areal data. We will use various CAR 
models (e.g. iCAR, BYM, BYM2) for zero-inflated spatial and 
spatial-temporal correlated data.


-- 

Dr. Alain F. Zuur
Highland Statistics Ltd.
9 St Clair Wynd
AB41 6DZ Newburgh, UK
Email: highs...@highstat.com
URL:   www.highstat.com

And:
NIOZ Royal Netherlands Institute for Sea Research,
Department of Coastal Systems, and Utrecht University,
P.O. Box 59, 1790 AB Den Burg,
Texel, The Netherlands



Author of:
1. Beginner's Guide to Spatial, Temporal and Spatial-Temporal Ecological Data 
Analysis with R-INLA. (2017).
2. Beginner's Guide to Zero-Inflated Models with R (2016).
3. Beginner's Guide to Data Exploration and Visualisation with R (2015).
4. Beginner's Guide to GAMM with R (2014).
5. Beginner's Guide to GLM and GLMM with R (2013).
6. Beginner's Guide to GAM with R (2012).
7. Zero Inflated Models and GLMM with R (2012).
8. A Beginner's Guide to R (2009).
9. Mixed effects models and extensions in ecology with R (2009).
10. Analysing Ecological Data (2007).


[[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.


Re: [R] Strange result for strptime with %p

2018-10-02 Thread PIKAL Petr
Hi

Maybe it is connected to
%I
Hours as decimal number (01–12).

Your input has hour as 00

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Marc Girondot via
> R-help
> Sent: Tuesday, October 2, 2018 3:30 PM
> To: R-help Mailing List 
> Subject: [R] Strange result for strptime with %p
>
> Dear members... are these results normal ?
>
> For the first one, no problem. I expected this:
>
>  > strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> tz="Asia/Jayapura")
> [1] "2018-05-01 01:00:00 WIT"
>
> For this one, it is ok also:
>
>  > strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> tz="Asia/Jayapura")-1
> [1] "2018-05-01 00:59:59 WIT"
>
> But how to explain this ???
>
>  > strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"),
> tz="Asia/Jayapura")
> [1] NA
>
> Thanks for your advices
> Marc
> __
>
> R 3.5.1 on MacOS 10.14
>
>  > version
> _
> platform   x86_64-apple-darwin15.6.0
> arch   x86_64
> os darwin15.6.0
> system x86_64, darwin15.6.0
> status
> major  3
> minor  5.1
> year   2018
> month  07
> day02
> svn rev74947
> language   R
> version.string R version 3.5.1 (2018-07-02)
> nickname   Feather Spray
>
> __
> 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
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] Strange result for strptime with %p

2018-10-02 Thread Marc Girondot via R-help

Dear members... are these results normal ?

For the first one, no problem. I expected this:

> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
tz="Asia/Jayapura")

[1] "2018-05-01 01:00:00 WIT"

For this one, it is ok also:

> strptime("05/01/18 01:00:00 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
tz="Asia/Jayapura")-1

[1] "2018-05-01 00:59:59 WIT"

But how to explain this ???

> strptime("05/01/18 00:59:59 AM", format = ("%m/%d/%y %I:%M:%S %p"), 
tz="Asia/Jayapura")

[1] NA

Thanks for your advices
Marc
__

R 3.5.1 on MacOS 10.14

> version
   _
platform   x86_64-apple-darwin15.6.0
arch   x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major  3
minor  5.1
year   2018
month  07
day    02
svn rev    74947
language   R
version.string R version 3.5.1 (2018-07-02)
nickname   Feather Spray

__
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.


Re: [R] Why do two different calls to mgcv::gamm give different p-values?

2018-10-02 Thread Simon Wood

Dear Øystein,

In your code 'id' is set up to be numeric. In your first gamm call it 
gets coerced to a factor (since nothing else would make sense). In  your 
second gamm call it is simply treated as numeric, since that could makes 
sense. To make the two models equivalent you just need to substitute:


id <- as.factor(rep(1:ng, n/ng))

into your loop.

best,
Simon

On 01/10/18 08:15, Øystein Sørensen wrote:

I have longitudinal data where a response y_{ij} has been measured
repeatedly for i=1,...,n individuals, j=1,...,m times for each individual.
Let x_{ij} be the age of individual i at her/his jth measurement. I wish to
see how the response varies with age, and have reason to believe that a
nonlinear fit is needed. I hence wish to model the relationship using an
additive mixed model of the form y_{ij} = f(x_{ij}) + b_{i} +
\epsilon_{ij}, where f() is some smooth function to be estimated, b_{i}
\sim N(0, \sigma_{b}^{2}) is the random effect for individual i,
\epsilon_{ij} \sim N(0, \sigma^{2}) is the residual.

Reading the documentation to the mgcv package, I see that such models can
be set up by calling the mgcv::gamm two different ways. One way shown to
set up such a model is with the call
b1 <- gamm(y ~ s(x), random = list(id =~ 1)),
where id is an indicator of the specific individual. In this way, the
random effect is specified in a list. The other way is to set up the random
effect with a smooth of the re:
b2 <- gamm(y ~ s(x) + s(id, bs = "re")).

As far as I can understand, these two setups should create the same
underlying model matrices. However, when running them on my data, the
p-values for the smooth terms, as well as their estimated degrees of
freedom, are different.

Below is a reproducible example on simulated data, which show that these
two types of specifying the models give different p-values and estimated
degrees of freedom. On my real data, these differences are sometimes even
more exaggerated.

My question is: Are not these two calls to gamm suppose to estimate the
same model, or have I misunderstood?

Here is a reproducible example:

library(mgcv)
set.seed(100)
n_sim <- 100
df <- data.frame(
   model1_pval = numeric(n_sim),
   model1_edf = numeric(n_sim),
   model2_pval = numeric(n_sim),
   model2_edf = numeric(n_sim)
)

# Number of observations
n <- 500
# Number of groups
ng <- 100

for(i in 1:n_sim){
   # Draw the fixed effect covariate
   x <- rnorm(n)
   # Set up the group
   id <- rep(1:ng, n/ng)
   # Draw the random effect
   z <- rnorm(ng)
   # Draw the response
   y <- 0.1 * x + 0.2 * x^3 + z[id] + rnorm(n)

   # Fit the two different models
   b1 <- gamm(y ~ s(x, k = 5), random = list(id =~ 1))
   b2 <- gamm(y ~ s(x, k = 5) + s(id, bs = "re"))

   df[i, "model1_pval"] <- anova(b1$gam)$s.pv
   df[i, "model1_edf"] <- anova(b1$gam)$edf
   df[i, "model2_pval"] <- anova(b2$gam)$s.pv[[1]]
   df[i, "model2_edf"] <- anova(b2$gam)$edf[[1]]
}

# Differences between model 1 and model 2 p values
mean(df$model1_pval)
#> [1] 6.790546e-21
mean(df$model2_pval)
#> [1] 3.090694e-14
max(abs(df$model1_pval - df$model2_pval))
#> [1] 2.770545e-12

# Differences between model1 and model 2 estimated degrees of freedom
mean(df$model1_edf)
#> [1] 3.829992
mean(df$model2_edf)
#> [1] 3.731438
max(abs(df$model1_edf - df$model2_edf))
#> [1] 0.6320281


Thanks in advance,
Øystein Sørensen

[[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-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] confiidence limits in Binom package

2018-10-02 Thread Adeela Munawar
Dear List,

I am using your package binom in R version 3.4.4 but i have to display
lower and upper confidence limts in binom.confint and binom.length function
but unable to dispaly them. Could you suggest any improvement?
for example,
Binom<-binom.length(p=0.01, n=40, conf.level = 0.95, method = "all")
Output:
print(Binom)
  method n   p  length
1  agresti-coull  400.01 0.13136905
2 asymptotic 400.01 0.03458699
3  bayes400.010.06453984
4cloglog400.010.09751737
5  exact 400.010.10443801
6  logit   400.010.11075339
7 probit  400.010.10233802
8profile  400.010.08961691
9lrt 400.010.06806841
10 prop.test   400.010.12318140
11wilson 400.010.10159667
Regards,
Adeela Munawar
Lecturer Statistics

[[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.