[R] max size of a file that R can open to work

2019-06-05 Thread Ricardo Lopez
Hello, I´d like to ask you if the max size of a file that R can open  or
import to work depends of the memory RAM??  or has other restriction???

Thank you very much

[[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-es] Incluir un rango de varias variables explicativas a un modelo

2019-06-05 Thread Jorge I Velez
Hola Rolando,

Quizás subset() sea tu amigo en este caso.  Intenta:

## selecciona la variable dependiente y las variables independientes
d0 <- subset(wageszm14, select = c(lwage, SEXO:marr, pot23:pot317)

## ajusta el modelo
fit <- qregspiv(lwage ~ ., shpfile = zm15, tau = 0.5, nboot = 70, data = d0)

## resultados
summary(fit)

Saludos,
Jorge.-



On Sun, Jun 2, 2019 at 6:00 PM Rolando Valdez  wrote:

> Hola,
>
> Quiero especificar una ecuación con varias variables explicativas de una
> manera eficiente sin necesidad de escribir todas y cada una. Tengo un
> conjunto de variables (junto con otras) dentro de una base de datos que se
> llaman pot23 pot311 pot312 pot 316 pot317... pot80. No
> necesariamente están secuenciadas. Quisiera saber cómo indicar que incluya
> todas las variables de pot23 a pot80 en una ecuación.
>
> He intentado lo siguiente, pero no funciona:
>
> > pots <- paste("pot",23:321, sep="")
> > eqreg2 <- lwage~SEXO+EDAD+HLENGUA+ESCOACUM+marr+wageszm14[,pots]
> > fit <- qregspiv(eqreg2, shpfile = zm15, tau = 0.5, nboot = 70, data =
> wageszm14)
> Error: Can't find columns `pot24`, `pot25`, `pot26`, `pot27`, `pot28`, ...
> (and 273 more) in `.data`.
>
> De igual forma, después estaría interesado en obtener el logaritmo de todas
> esas variables pot~
>
> Gracias de antemano por cualquier tipo de ayuda.
>
> --
> Rol~
>
> [[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] Incluir un rango de varias variables explicativas a un modelo

2019-06-05 Thread Carlos Ortega
Hola,

Mira este código para construir tu fórmula a partir de los nombres de tus
variables...

#---

library(dplyr)
library(randNames)

set.seed(1234)

# Creo unos nombres aletaorios como nombres de variables
# Esto lo tendrías de tu data.frame con "names(tu_data_frame)"
my_names <- 25 %>%
  rand_names(nationality = 'ES') %>%
  select(name.first)

mynam_vec <- as.vector(my_names$name.first)
mynam_vec

# Construyo una formula con los nombres de las variables
myformula <- vector()
for(i in 1:length(mynam_vec)) {
  tmp <- mynam_vec[i]
  if(i != length(mynam_vec)) {
  myformula <- paste0(myformula, tmp, sep=" + ", collapse = "")
  } else {
  myformula <- paste0(myformula, tmp, sep= '' )
  }
}
myform_end <- paste("lweg ~ ", myformula, sep = " ")
myform_end
class(myform_end)

# Y con la cadena la transformo en una formula
como_formula <- as.formula(myform_end)
como_formula
class(como_formula)
#---

Que produce este resultado:

> library(dplyr)
> library(randNames)
>
> set.seed(1234)
>
> # Creo unos nombres aletaorios como nombres de variables
> # Esto lo tendrías de tu data.frame con "names(tu_data_frame)"
> my_names <- 25 %>%
+   rand_names(nationality = 'ES') %>%
+   select(name.first)
>
> mynam_vec <- as.vector(my_names$name.first)
> mynam_vec
 [1] "sonia" "elisa" "adrian""irene" "laura" "joaquin"
  "raquel"
 [8] "eva"   "rodrigo"   "carmelo"   "vicenta"   "jordi" "nuria"
  "enrique"
[15] "luz"   "mohamed"   "alfredo"   "nieves""fatima""santiago"
 "francisco"
[22] "joaquin"   "jose"  "manuel""andrea"
>
> # Construyo una formula con los nombres de las variables
> myformula <- vector()
> for(i in 1:length(mynam_vec)) {
+   tmp <- mynam_vec[i]
+   if(i != length(mynam_vec)) {
+   myformula <- paste0(myformula, tmp, sep=" + ", collapse = "")
+   } else {
+   myformula <- paste0(myformula, tmp, sep= '' )
+   }
+ }
> myform_end <- paste("lweg ~ ", myformula, sep = " ")
> myform_end
[1] "lweg ~  sonia + elisa + adrian + irene + laura + joaquin + raquel +
eva + rodrigo + carmelo + vicenta + jordi + nuria + enrique + luz + mohamed
+ alfredo + nieves + fatima + santiago + francisco + joaquin + jose +
manuel + andrea"
> class(myform_end)
[1] "character"
>
> # Y con la cadena la transformo en una formula
> como_formula <- as.formula(myform_end)
> como_formula
lweg ~ sonia + elisa + adrian + irene + laura + joaquin + raquel +
eva + rodrigo + carmelo + vicenta + jordi + nuria + enrique +
luz + mohamed + alfredo + nieves + fatima + santiago + francisco +
joaquin + jose + manuel + andrea
> class(como_formula)
[1] "formula"

#-


Saludos,
Carlos Ortega
www.qualityexcellence.es


El mar., 4 jun. 2019 a las 5:43, Rolando Valdez ()
escribió:

> Hola, gracias por la respuesta,
>
> No me funcionó debido a que los nombres de las variables no están
> seriadas, es decir, los nombres de las variables son del tipo: x23 x25 x30,
> x301 x320, x80. Entonces me da este error:
> Error in eval(predvars, data, env) : object 'pot24' not found. Debido a
> que pot24 no existe, ya que de pot23 se brinca a pot30.
>
> En Stata es algo muy simple de hacer, solo tengo que especificar gl
> indepvars "x23-x80" y ya. En R no logro hacerlo.
>
> ¿Alguna otra sugerencia?
>
> Gracias de antemano.
>
> El lun., 3 de jun. de 2019 a la(s) 04:50, Carlos Ortega (
> c...@qualityexcellence.es) escribió:
>
>> Hola,
>>
>> Mira la función "*as.formula()*".
>> Incluye un ejemplo muy parecido a lo que estás queriendo hacer.
>>
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>> El lun., 3 jun. 2019 a las 1:00, Rolando Valdez ()
>> escribió:
>>
>>> Hola,
>>>
>>> Quiero especificar una ecuación con varias variables explicativas de una
>>> manera eficiente sin necesidad de escribir todas y cada una. Tengo un
>>> conjunto de variables (junto con otras) dentro de una base de datos que
>>> se
>>> llaman pot23 pot311 pot312 pot 316 pot317... pot80. No
>>> necesariamente están secuenciadas. Quisiera saber cómo indicar que
>>> incluya
>>> todas las variables de pot23 a pot80 en una ecuación.
>>>
>>> He intentado lo siguiente, pero no funciona:
>>>
>>> > pots <- paste("pot",23:321, sep="")
>>> > eqreg2 <- lwage~SEXO+EDAD+HLENGUA+ESCOACUM+marr+wageszm14[,pots]
>>> > fit <- qregspiv(eqreg2, shpfile = zm15, tau = 0.5, nboot = 70, data =
>>> wageszm14)
>>> Error: Can't find columns `pot24`, `pot25`, `pot26`, `pot27`, `pot28`,
>>> ...
>>> (and 273 more) in `.data`.
>>>
>>> De igual forma, después estaría interesado en obtener el logaritmo de
>>> todas
>>> esas variables pot~
>>>
>>> Gracias de antemano por cualquier tipo de ayuda.
>>>
>>> --
>>> Rol~
>>>
>>> [[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
>> 

Re: [R] Parallel processes collapse into one

2019-06-05 Thread Abby Spurdle
> I have written an R package to collect some functions to run simulations
> for a research project. Main functions are written in C and make use of
> BLAS routines, such as dsymm, dgemm, and ddot. I run simulations in
> parallel by using mclapply and the problem is that after some point all R
> instances collapse into one: R seems to be running, but simulations do not
> progress further. If I run simulations on 16 cores I end up having an R
> instance with CPU usage about 1600%, never experienced such a behaviour.

This is outside my area.
However, my suggestion is that you provide a *minimal reproducible* example.
I think you're more likely to get responses.

Also note that there's an R mailing list for high performance computing,
however, it doesn't appear to be very active, so I'm not sure which is the
best mailing list to use.
Maybe someone else can comment on this...?

[[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] Plotting more than one regression line in ggplot

2019-06-05 Thread rain1290--- via R-help
Hi Rui (and everyone),

Thank you so much for your response! Much appreciated!
What if I wanted I create several regression lines and scatter plots in the 
same ggplot using a "melted" dataset? I would like to create a scatter plot and 
regression line for both the objects of "onepctCO2MEDIAN" and "RCP8.5MEDIANThis 
melted dataset looks like this:

>NewestdataUltra
 x variable   value  L1
1   0.0y  0. onepctCO2MEDIAN
2   0.006794447y  4.90024902 onepctCO2MEDIAN
3   0.014288058y  0.1607 onepctCO2MEDIAN
4   0.022087920y  6.63491326 onepctCO2MEDIAN
5   0.030797357y -1.24295056 onepctCO2MEDIAN
6   0.038451072y  1.56433744 onepctCO2MEDIAN
7   0.048087904y -2.26590352 onepctCO2MEDIAN
8   0.058677729y  2.20700446 onepctCO2MEDIAN
9   0.069261406y -2.36770013 onepctCO2MEDIAN
10  0.080524530y -1.09135062 onepctCO2MEDIAN
11  0.092760246y  0.40999399 onepctCO2MEDIAN
12  0.103789609y -0.12597268 onepctCO2MEDIAN
13  0.116953168y -2.41382534 onepctCO2MEDIAN
14  0.129253298y  7.08902570 onepctCO2MEDIAN
15  0.141710050y -0.75935388 onepctCO2MEDIAN
16  0.156002052y  0.04544160 onepctCO2MEDIAN
17  0.170648172y -1.53496826 onepctCO2MEDIAN
18  0.185318425y  6.55242014 onepctCO2MEDIAN
19  0.199463055y -0.83125628 onepctCO2MEDIAN
20  0.213513337y -2.50991826 onepctCO2MEDIAN
21  0.228839271y  0.13659682 onepctCO2MEDIAN
22  0.246981293y -1.37198445 onepctCO2MEDIAN
23  0.263012767y -0.87129883 onepctCO2MEDIAN
24  0.278505564y  0.66325836 onepctCO2MEDIAN
25  0.293658361y  0.79380363 onepctCO2MEDIAN
26  0.310747266y  3.48806374 onepctCO2MEDIAN
27  0.325990349y -4.46122081 onepctCO2MEDIAN
28  0.342517540y  0.08717340 onepctCO2MEDIAN
29  0.362751633y -1.41715777 onepctCO2MEDIAN
30  0.380199537y -0.99565082 onepctCO2MEDIAN
31  0.394992948y  0.32155262 onepctCO2MEDIAN
32  0.414373398y  3.14038657 onepctCO2MEDIAN
33  0.430690214y -0.73760988 onepctCO2MEDIAN
34  0.449738145y -2.48605407 onepctCO2MEDIAN
35  0.470167458y -3.42358584 onepctCO2MEDIAN
36  0.489019871y  0.48247475 onepctCO2MEDIAN
37  0.507242471y -0.97853863 onepctCO2MEDIAN
38  0.524314284y  8.53596838 onepctCO2MEDIAN
39  0.543750525y  5.48447420 onepctCO2MEDIAN
40  0.564234197y  3.21493666 onepctCO2MEDIAN
41  0.583679616y  3.91689160 onepctCO2MEDIAN
42  0.601459444y  4.49070196 onepctCO2MEDIAN
43  0.619924664y  6.54104103 onepctCO2MEDIAN
44  0.639932007y  4.80686500 onepctCO2MEDIAN
45  0.661347181y  8.15101701 onepctCO2MEDIAN
46  0.684117317y  0.26974132 onepctCO2MEDIAN
47  0.704829752y -0.18075007 onepctCO2MEDIAN
48  0.725045770y  9.71812491 onepctCO2MEDIAN
49  0.745165825y  1.54064657 onepctCO2MEDIAN
50  0.765016139y -1.64760409 onepctCO2MEDIAN
51  0.783461511y  4.80246029 onepctCO2MEDIAN
52  0.806382924y  4.04215160 onepctCO2MEDIAN
53  0.829241335y  9.37565122 onepctCO2MEDIAN
54  0.849924415y  5.33050497 onepctCO2MEDIAN
55  0.871352434y  7.54458026 onepctCO2MEDIAN
56  0.893632233y  6.46795471 onepctCO2MEDIAN
57  0.916052133y  2.80960651 onepctCO2MEDIAN
58  0.938579470y  5.39216613 onepctCO2MEDIAN
59  0.959907651y  7.20436888 onepctCO2MEDIAN
60  0.981643587y  3.33508065 onepctCO2MEDIAN
61  1.004116774y  8.86907070 onepctCO2MEDIAN
62  1.028363466y  1.78612989 onepctCO2MEDIAN
63  1.054009140y  6.25550382 onepctCO2MEDIAN
64  1.072440803y  7.60792365 onepctCO2MEDIAN
65  1.094457805y  7.68714831 onepctCO2MEDIAN
66  1.123176277y  4.77877639 onepctCO2MEDIAN
67  1.149430871y 12.71105018 onepctCO2MEDIAN
68  1.170912921y -0.71562844 onepctCO2MEDIAN
69  1.196743071y  1.64908992 onepctCO2MEDIAN
70  1.218625903y  3.03630241 onepctCO2MEDIAN
71  1.241868377y  4.29747688 onepctCO2MEDIAN
72  1.267941594y  1.95437781 onepctCO2MEDIAN
73  1.290708780y  3.99869637 onepctCO2MEDIAN
74  1.31389y  4.51794725 onepctCO2MEDIAN
75  1.339045882y  0.93379048 onepctCO2MEDIAN
76  1.362803459y  3.30507700 onepctCO2MEDIAN
77  1.384450197y  3.54229702 onepctCO2MEDIAN
78  1.409720302y  5.99736597 onepctCO2MEDIAN
79  1.435851157y  0.50818686 onepctCO2MEDIAN
80  1.455592215y  7.96616301 onepctCO2MEDIAN
81  1.479495347y  9.94604963 onepctCO2MEDIAN
82  1.506051958y  3.79083717 onepctCO2MEDIAN
83  1.525728464y  2.57358469 onepctCO2MEDIAN
84  1.549362063y 10.14049742 onepctCO2MEDIAN
85  1.573440671y 13.74083036 onepctCO2MEDIAN
86  1.600278735y  0.93357712 onepctCO2MEDIAN
87  1.623879492y  

Re: [R-es] Incluir un rango de varias variables explicativas a un modelo

2019-06-05 Thread Juan Abasolo
Meto cuchara y disculpen si es una tontería:
Y si creás un objeto con los nombres de las variables? y si solamente te
interesan las que cumplan no sé qué característica en el nombre, pedirlo.

pabuscar <- sort(names(tudataframe))
pabuscar[grep('x', pabuscar)]

Los que saben seguro que lo hacen más lindo, pero yo creo que eso te
funcionaría y no es difacil. Suerte

Hau idatzi du Rolando Valdez (rvald...@gmail.com) erabiltzaileak (2019 eka.
4, ar. (05:43)):

> Hola, gracias por la respuesta,
>
> No me funcionó debido a que los nombres de las variables no están seriadas,
> es decir, los nombres de las variables son del tipo: x23 x25 x30, x301
> x320, x80. Entonces me da este error:
> Error in eval(predvars, data, env) : object 'pot24' not found. Debido a que
> pot24 no existe, ya que de pot23 se brinca a pot30.
>
> En Stata es algo muy simple de hacer, solo tengo que especificar gl
> indepvars "x23-x80" y ya. En R no logro hacerlo.
>
> ¿Alguna otra sugerencia?
>
> Gracias de antemano.
>
> El lun., 3 de jun. de 2019 a la(s) 04:50, Carlos Ortega (
> c...@qualityexcellence.es) escribió:
>
> > Hola,
> >
> > Mira la función "*as.formula()*".
> > Incluye un ejemplo muy parecido a lo que estás queriendo hacer.
> >
> > Saludos,
> > Carlos Ortega
> > www.qualityexcellence.es
> >
> > El lun., 3 jun. 2019 a las 1:00, Rolando Valdez ()
> > escribió:
> >
> >> Hola,
> >>
> >> Quiero especificar una ecuación con varias variables explicativas de una
> >> manera eficiente sin necesidad de escribir todas y cada una. Tengo un
> >> conjunto de variables (junto con otras) dentro de una base de datos que
> se
> >> llaman pot23 pot311 pot312 pot 316 pot317... pot80. No
> >> necesariamente están secuenciadas. Quisiera saber cómo indicar que
> incluya
> >> todas las variables de pot23 a pot80 en una ecuación.
> >>
> >> He intentado lo siguiente, pero no funciona:
> >>
> >> > pots <- paste("pot",23:321, sep="")
> >> > eqreg2 <- lwage~SEXO+EDAD+HLENGUA+ESCOACUM+marr+wageszm14[,pots]
> >> > fit <- qregspiv(eqreg2, shpfile = zm15, tau = 0.5, nboot = 70, data =
> >> wageszm14)
> >> Error: Can't find columns `pot24`, `pot25`, `pot26`, `pot27`, `pot28`,
> ...
> >> (and 273 more) in `.data`.
> >>
> >> De igual forma, después estaría interesado en obtener el logaritmo de
> >> todas
> >> esas variables pot~
> >>
> >> Gracias de antemano por cualquier tipo de ayuda.
> >>
> >> --
> >> Rol~
> >>
> >> [[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
> >
>
>
> --
> Rol~
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Juan Abasolo

Hizkuntzaren eta Literaturaren Didaktika Saila | EUDIA ikerketa taldea
Bilboko Hezkuntza Fakultatea
Euskal Herriko Unibertsitatea
UPV/EHU

Sarriena auzoa z/g 48940 - Leioa (Bizkaia)

T: (+34) 94 601 7567
Telegram: @JuanAbasolo
Skype: abasolo72

Tutoretza ordutegia 

[[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] Mac/PC differences in lmer results

2019-06-05 Thread John via R-help
On Wed, 29 May 2019 18:44:26 +0200
Nicolas Schuck  wrote:

> Dear fellow R coders, 
> 
> I am observing differences in results obtained using glmer when using
> a Mac or Linux computer versus a PC 

Just as an aside and point of information, both the Mac and the Linux
systems are PCs, just as much so as one running Windows.  The
designation "PC" refers to hardware.  Your question demands the extra
steps of thinking about what other operating system might be in use.
There are others though I doubt R is implemented on any of them.

JWDougherty

__
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] Open a file which name contains a tilde

2019-06-05 Thread Frank Schwidom
On 2019-06-05 20:32:07, Enrico Schumann wrote:
> > "FS" == Frank Schwidom  writes:
>
> FS> Hi,
> FS> As I can see via path.expand a filename which contains a tilde 
> anywhere gets automatically crippled.
>
> FS> +> path.expand("a ~ b")
> FS> [1] "a /home/user b"
>
> FS> +> path.expand("a ~ b ~")
> FS> [1] "a /home/user b /home/user"
>
> FS> I want to open a file regardless whether its name contains any 
> character unless 0.
>
> FS> The unix filesystem allow the creation of such files, it sould be 
> possible to open these.
>
> FS> How can I switch off any file crippling activity?
>
> FS> Kind regards,
> FS> Frank
>
> Do you need 'path.expand'? For example,
>
> readLines("~/Desktop/a ~ b")
>
> reads just fine the content of a file named
> 'a ~ b' on my desktop.
>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>

Appendix:

I found out in the meantime that I can use 'R --no-readline' but I want to use 
readline and I found no possible readline configuration /etc/inputrc).

And maybe it works as Rscript.

But that should be more consistent because it is in fact very basic.

Kind regards,
Frank

__
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] Open a file which name contains a tilde

2019-06-05 Thread Frank Schwidom
On 2019-06-05 20:32:07, Enrico Schumann wrote:
> > "FS" == Frank Schwidom  writes:
>
> FS> Hi,
> FS> As I can see via path.expand a filename which contains a tilde 
> anywhere gets automatically crippled.
>
> FS> +> path.expand("a ~ b")
> FS> [1] "a /home/user b"
>
> FS> +> path.expand("a ~ b ~")
> FS> [1] "a /home/user b /home/user"
>
> FS> I want to open a file regardless whether its name contains any 
> character unless 0.
>
> FS> The unix filesystem allow the creation of such files, it sould be 
> possible to open these.
>
> FS> How can I switch off any file crippling activity?
>
> FS> Kind regards,
> FS> Frank
>
> Do you need 'path.expand'? For example,
>
> readLines("~/Desktop/a ~ b")
>
> reads just fine the content of a file named
> 'a ~ b' on my desktop.
>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>

Thanks for yor answer.

$ echo 123 > ~/'a ~ b'.txt

ls ~/'a ~ b'.txt

/home/user/a ~ b.txt

+> readLines("~/a ~ b.txt")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/home/user/a /home/user b.txt': No such file or directory

+> version
   _
platform   x86_64-pc-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  3
minor  1.1
year   2014
month  07
day10
svn rev66115
language   R
version.string R version 3.1.1 (2014-07-10)
nickname   Sock it to Me

Kind regards,
Frank

__
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] Open a file which name contains a tilde

2019-06-05 Thread Enrico Schumann
> "FS" == Frank Schwidom  writes:

FS> Hi,
FS> As I can see via path.expand a filename which contains a tilde anywhere 
gets automatically crippled.

FS> +> path.expand("a ~ b")
FS> [1] "a /home/user b"

FS> +> path.expand("a ~ b ~")
FS> [1] "a /home/user b /home/user"

FS> I want to open a file regardless whether its name contains any 
character unless 0.

FS> The unix filesystem allow the creation of such files, it sould be 
possible to open these.

FS> How can I switch off any file crippling activity?

FS> Kind regards,
FS> Frank

Do you need 'path.expand'? For example,

readLines("~/Desktop/a ~ b")

reads just fine the content of a file named
'a ~ b' on my desktop.


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] Sample function and prob argument

2019-06-05 Thread Duncan Murdoch

On 05/06/2019 4:34 a.m., le Gleut, Ronan wrote:

Dear R-help mailing list,

  


First of all, many many thanks for your great work on the R project!

  


I have a very small issue regarding the sample function. Depending if we
specify values for the prob argument, we don't get the same result for a
random sampling with replacement and with equal probabilities. See the
attached R code for a minimal example with the R version 3.6.0.

  


With a previous R version (3.5.x), the result was just a permutation
between the possible realizations. They are now totally different with the
latest R version.

  


I understand that if we specify or not the prob argument, two different
internal functions are used: .Internal(sample()) or .Internal(sample2()).
Indeed, the algorithm used to draw a sample may not be the same if by
default we assume equal probabilities (without the prob argument) or if
the user defines himself the probabilities (even if they are equal).

  


I found this post on stackoverflow which explains the reasons of this
difference (answer by Matthew Lundberg):

https://stackoverflow.com/questions/23316729/r-sample-probabilities-defaul
t-is-equal-weight-why-does-specifying-equal-weigh

  


I was wondering whether the solution proposed by PatrickT could solve this
issue? He proposed to have something like if(all.equal(prob, prob,
tolerance = .Machine$double.eps) prob = NULL inside the sample.int routine
in order to replicate prob=NULL with prob=rep(1, length(x)).



R has never promised that these will be the same, so I doubt if R will 
change the sample() function.  However, it's very easy for you to adopt 
something like PatrickT's solution for yourself.  Just use this function:


PatrickTsample <- function(x, size, replace = FALSE, prob = NULL) {
  if (!is.null(prob) && max(prob) == min(prob))
prob <- NULL
  sample(x = x, size = size, replace = replace, prob = prob)
}

You might want a looser tolerance on the vector of probabilities 
depending on your context.


Duncan Murdoch

__
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] Plotting more than one regression line in ggplot

2019-06-05 Thread David Winsemius



On 6/5/19 9:57 AM, David Winsemius wrote:

On 6/5/19 9:37 AM, rain1...@aim.com wrote:

Hi David (and everyone),

Thank you for your response. I changed the column names to x and y,
but the error/warning persists:

Warning message: Computation failed in `stat_smooth()`: 'what' must be
a function or character string

It is quite baffling as to why this is happening. Why would it work
for the scatter plot and not the regression line?



I'll add that I can reproduce a similar error but not the one you reported:


> lm <- ggplot(onepctCO2MEDIAN) +
+ geom_point(aes(x,y),
+ colour="blue") + geom_smooth(aes(x,y), method=lm)
> lm
Warning message:
Computation failed in `stat_smooth()`:
'what' must be a function or character string

Rerunning after removing the `lm` data object allows successful execution:

 rm(lm)
 ggplot(onepctCO2MEDIAN) +
 geom_point(aes(x,y),
 colour="blue") + geom_smooth(aes(x,y), method=lm)


So it's probably related to the non-standard evaluation where a function 
or a function name can be used and if there is a function name offered, 
the ggplot evaluation model first turns it into a character string and 
then accesses a data object instead of a function.


I'm guessing this would be seen by the package maintainer in due course, 
but I'm copying him.


--

David



Since it works perfectly well on my machine, that means we are now
lacking the required information (from you)  that is generally delivered
via `sessionInfo()`. I get:

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
   [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C LC_TIME=en_US.UTF-8
   [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
   [7] LC_PAPER=en_US.UTF-8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

other attached packages:
[1] ggplot2_3.1.1 zoo_1.8-5

loaded via a namespace (and not attached):
   [1] Rcpp_1.0.1   lattice_0.20-38  withr_2.1.2 assertthat_0.2.1
dplyr_0.8.0.1
   [6] crayon_1.3.4 R6_2.4.0 grid_3.5.2 plyr_1.8.4
gtable_0.3.0
[11] magrittr_1.5 scales_1.0.0 pillar_1.3.1 rlang_0.3.4
lazyeval_0.2.2
[16] rstudioapi_0.10  labeling_0.3 tools_3.5.2 glue_1.3.1
purrr_0.3.2
[21] munsell_0.5.0    yaml_2.2.0   compiler_3.5.2 pkgconfig_2.0.2
colorspace_1.4-1
[26] tidyselect_0.2.5 tibble_2.1.1

I'm also running:

RStudio
Version 1.1.463 – © 2009-2018 RStudio, Inc.


You should now restart a clean session, try again with just the required
packages and report back with full code and data.


Best;

David




-Original Message-
From: David Winsemius 
To: r-help 
Sent: Wed, Jun 5, 2019 12:00 pm
Subject: Re: [R] Plotting more than one regression line in ggplot


On 6/5/19 8:04 AM, rain1290--- via R-help wrote:

Hi Jeff (and everyone),

Thank you for your response and feedback. Yes, I know what you mean

- it was a blind and quick choice to use "lm" as my object name.
Unfortunately, changing the object name to something else does not
eliminate that error/warning message. As a result, the same
error/warning appears when running it. Oddly enough, the scatter plot
is just fine - it's the regression line that struggles to appear.
Could there be another reason for that?

Thanks, again,


TRhe error came because you did not reference the column names
correctly. This succeeds with the data you offered:


ggplot(onepctCO2MEDIAN) +
  geom_jitter(aes(x,y),
  colour="blue") + geom_smooth(aes(x,y), method=lm)


# At some point you changed the column names from
(RCP1pctCO2cumulativeMedian, departurea) to (x,y) , but didn't adjust
your code.


Best;

David.


-Original Message-
From: Jeff Newmiller 
To: rain1290 ; rain1290--- via R-help

; r-help ; r-sig-geo


Sent: Wed, Jun 5, 2019 10:49 am
Subject: Re: [R] Plotting more than one regression line in ggplot

Please read the Posting Guide... posting HTML on a plain text

mailing list really interferes with clear communication.

If you had spent even a small amount of time working with R

tutorials then you would know that "lm" is the name of a very basic,
very important R function. However, you are defining your own object
called "lm" that is very different indeed than the usual "lm"
function. I would guess that in a clean new R workspace where you had
not already run your ggplot function and assigned the result to your
own "lm" object then this code might run. However, once you have run
it once and try to run it again, your "method" argument gives the
wrong version of "lm" to geom_smooth and you confuse it.

As the doctor said to the man pounding his own head against the

wall, "If it hurts, don't do that." 

Re: [R] Mac/PC differences in lmer results

2019-06-05 Thread Alexandra Thorn
To check whether the data are being read in appropriately, what happens
when you plot the distribution of each of the independent variables on
the respective systems?

-A

On Wed, 5 Jun 2019 12:32:28 +0200
Olivier Crouzet  wrote:

> Hi,
> 
> 32bit vs. 64bit systems? 
> 
> Another thing I would look at would be how the windows machine will
> read the data file. Though issues should probably only arise with
> respect to text data, I've often experienced problems with reading
> unicode csv files on windows computers compared with unix-based
> computers. No guarantee though, just suggestions...
> 
> Olivier.
> 
> On Wed, 5 Jun 2019 12:15:53 +0200
> Nicolas Schuck  wrote:
> 
> > bert: you are right, sorry for not cc-ing the list. thanks also for
> > the hint. 
> > 
> > I wanted to bring this up here again, emphasising that we do find in
> > at least one case *a very large difference* in the p value, using
> > the same scripts and data on a windows versus mac machine (see
> > reproducible example in the gitlab link posted below). I have now
> > come across several instances in which results of (g)lmer models
> > don’t agree on windows vs unix-based machines, which I find a bit
> > disturbing. any ideas where non-negligible differences could come
> > from? 
> > 
> > thanks, 
> > nico 
> > 
> >   
> > > On 30. May 2019, at 16:58, Bert Gunter 
> > > wrote:
> > > 
> > > 
> > > Unless there us good reason not to, always cc the list. I have
> > > done so here.
> > > 
> > > The R Installation manual has some info on how to use different
> > > BLASes I believe, but someone with expertise (I have none) needs
> > > to respond to your queries.
> > > 
> > > On Thu, May 30, 2019 at 7:50 AM Nicolas Schuck
> > > mailto:nico.sch...@gmail.com>> wrote: I
> > > know that it is in use on the Mac, see sessionInfo below. I have
> > > to check on the Win system. Why would that make such a difference
> > > and how could I make the Win get the same results as the Unix
> > > Systems? 
> > > 
> > > R version 3.6.0 (2019-04-26) 
> > > Platform: x86_64-apple-darwin15.6.0 (64-bit) 
> > > Running under: macOS Mojave 10.14.5 
> > > Matrix products: default 
> > > BLAS:  
> > > /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
> > >  
> > > LAPACK: 
> > > /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
> > >  
> > > Random number generation: 
> > > RNG:  Mersenne-Twister 
> > > Normal:  Inversion Sample:  Rounding 
> > > locale: [1]
> > > en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> > > attached base packages: [1] stats  graphics  grDevices utils
> > > datasets  methods  base Thanks, Nico On 30. May 2019, at 16:34,
> > > Bert Gunter  > > > wrote:
> > >   
> > >> The BLAS in use on each?
> > >> 
> > >> Bert Gunter
> > >> 
> > >> "The trouble with having an open mind is that people keep coming
> > >> along and sticking things into it."
> > >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip
> > >> )
> > >> 
> > >> 
> > >> On Thu, May 30, 2019 at 5:27 AM Nicolas Schuck
> > >> mailto:nico.sch...@gmail.com>> wrote:
> > >> Dear fellow R coders, 
> > >> 
> > >> I am observing differences in results obtained using glmer when
> > >> using a Mac or Linux computer versus a PC. Specifically, I am
> > >> talking about a relatively complex glmer model with a nested
> > >> random effects structure. The model is set up in the following
> > >> way: gcctrl = glmerControl(optimizer=c('nloptwrap'), optCtrl =
> > >> list (maxfun = 50), calc.derivs = FALSE)
> > >> 
> > >> glmer_pre_instr1 = glmer(
> > >>   formula = cbind(FREQ, NSAMP-FREQ) ~ FDIST_minz + poly
> > >> (RFREQ,2) + ROI + (1 + FDIST_minz + RFREQ + ROI|ID/COL), data =
> > >> cdf_pre_instr, family = binomial, 
> > >>   control = gcctrl)
> > >> 
> > >> Code and data of an example for which I find reproducible,
> > >> non-negligible differences between Mac/Win can be found here:
> > >> https://gitlab.com/nschuck/glmer_sandbox/tree/master
> > >> 
> > >>  > >> > The
> > >> differences between the fitted models seem to be most pronounced
> > >> regarding the estimated correlation structure of the random
> > >> effects terms. Mac and Linux yield very similar results, but
> > >> Windows deviates quite a bit in some cases. This has a large
> > >> impact on p values obtained when performing model comparisons. I
> > >> have tried this on Mac OS 10.14, Windows 10 and Ubuntu and
> > >> Debian. All systems I have tried are using lme 1.1.21 and R
> > >> 3.5+. 
> > >> 
> > >> Does anyone have an idea what the underlying cause might be? 
> > >> 
> > >> Thanks, 
> > >> Nico 
> > >> 
> > >> 
> > >> 
> > >> 
> > >> [[alternative HTML version deleted]]
> > >> 
> > >> __
> > >> 

[R] Sample function and prob argument

2019-06-05 Thread le Gleut, Ronan
Dear R-help mailing list,

 

First of all, many many thanks for your great work on the R project!

 

I have a very small issue regarding the sample function. Depending if we
specify values for the prob argument, we don't get the same result for a
random sampling with replacement and with equal probabilities. See the
attached R code for a minimal example with the R version 3.6.0.

 

With a previous R version (3.5.x), the result was just a permutation
between the possible realizations. They are now totally different with the
latest R version.

 

I understand that if we specify or not the prob argument, two different
internal functions are used: .Internal(sample()) or .Internal(sample2()).
Indeed, the algorithm used to draw a sample may not be the same if by
default we assume equal probabilities (without the prob argument) or if
the user defines himself the probabilities (even if they are equal).

 

I found this post on stackoverflow which explains the reasons of this
difference (answer by Matthew Lundberg):

https://stackoverflow.com/questions/23316729/r-sample-probabilities-defaul
t-is-equal-weight-why-does-specifying-equal-weigh

 

I was wondering whether the solution proposed by PatrickT could solve this
issue? He proposed to have something like if(all.equal(prob, prob,
tolerance = .Machine$double.eps) prob = NULL inside the sample.int routine
in order to replicate prob=NULL with prob=rep(1, length(x)).

 

Thanks you in advance for your response.

 

Best regards,

Ronan Le Gleut

 


 
Helmholtz Zentrum Muenchen
Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
Ingolstaedter Landstr. 1
85764 Neuherberg
www.helmholtz-muenchen.de
Stellv. Aufsichtsratsvorsitzender: MinDirig. Dr. Manfred Wolter
Geschaeftsfuehrung: Prof. Dr. med. Dr. h.c. Matthias Tschoep, Heinrich Bassler, 
Kerstin Guenther
Registergericht: Amtsgericht Muenchen HRB 6466
USt-IdNr: DE 129521671
__
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] Plotting more than one regression line in ggplot

2019-06-05 Thread David Winsemius


On 6/5/19 9:37 AM, rain1...@aim.com wrote:
> Hi David (and everyone),
>
> Thank you for your response. I changed the column names to x and y, 
> but the error/warning persists:
>
> Warning message: Computation failed in `stat_smooth()`: 'what' must be 
> a function or character string
>
> It is quite baffling as to why this is happening. Why would it work 
> for the scatter plot and not the regression line?


Since it works perfectly well on my machine, that means we are now 
lacking the required information (from you)  that is generally delivered 
via `sessionInfo()`. I get:

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C LC_TIME=en_US.UTF-8
  [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 
LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

other attached packages:
[1] ggplot2_3.1.1 zoo_1.8-5

loaded via a namespace (and not attached):
  [1] Rcpp_1.0.1   lattice_0.20-38  withr_2.1.2 assertthat_0.2.1 
dplyr_0.8.0.1
  [6] crayon_1.3.4 R6_2.4.0 grid_3.5.2 plyr_1.8.4   
gtable_0.3.0
[11] magrittr_1.5 scales_1.0.0 pillar_1.3.1 rlang_0.3.4  
lazyeval_0.2.2
[16] rstudioapi_0.10  labeling_0.3 tools_3.5.2 glue_1.3.1   
purrr_0.3.2
[21] munsell_0.5.0    yaml_2.2.0   compiler_3.5.2 pkgconfig_2.0.2  
colorspace_1.4-1
[26] tidyselect_0.2.5 tibble_2.1.1

I'm also running:

RStudio
Version 1.1.463 – © 2009-2018 RStudio, Inc.


You should now restart a clean session, try again with just the required 
packages and report back with full code and data.


Best;

David


>
>
> -Original Message-
> From: David Winsemius 
> To: r-help 
> Sent: Wed, Jun 5, 2019 12:00 pm
> Subject: Re: [R] Plotting more than one regression line in ggplot
>
>
> On 6/5/19 8:04 AM, rain1290--- via R-help wrote:
> > Hi Jeff (and everyone),
> >
> > Thank you for your response and feedback. Yes, I know what you mean 
> - it was a blind and quick choice to use "lm" as my object name. 
> Unfortunately, changing the object name to something else does not 
> eliminate that error/warning message. As a result, the same 
> error/warning appears when running it. Oddly enough, the scatter plot 
> is just fine - it's the regression line that struggles to appear. 
> Could there be another reason for that?
> > Thanks, again,
>
>
> TRhe error came because you did not reference the column names
> correctly. This succeeds with the data you offered:
>
>
> ggplot(onepctCO2MEDIAN) +
>  geom_jitter(aes(x,y),
>  colour="blue") + geom_smooth(aes(x,y), method=lm)
>
>
> # At some point you changed the column names from
> (RCP1pctCO2cumulativeMedian, departurea) to (x,y) , but didn't adjust
> your code.
>
>
> Best;
>
> David.
>
> >
> > -Original Message-
> > From: Jeff Newmiller 
> > To: rain1290 ; rain1290--- via R-help 
> ; r-help ; r-sig-geo 
> 
> > Sent: Wed, Jun 5, 2019 10:49 am
> > Subject: Re: [R] Plotting more than one regression line in ggplot
> >
> > Please read the Posting Guide... posting HTML on a plain text 
> mailing list really interferes with clear communication.
> >
> > If you had spent even a small amount of time working with R 
> tutorials then you would know that "lm" is the name of a very basic, 
> very important R function. However, you are defining your own object 
> called "lm" that is very different indeed than the usual "lm" 
> function. I would guess that in a clean new R workspace where you had 
> not already run your ggplot function and assigned the result to your 
> own "lm" object then this code might run. However, once you have run 
> it once and try to run it again, your "method" argument gives the 
> wrong version of "lm" to geom_smooth and you confuse it.
> >
> > As the doctor said to the man pounding his own head against the 
> wall, "If it hurts, don't do that." Avoid re-using important object 
> names in R... some common names I see abused this way are df, data, c, 
> t, T, and F. Your choice was unusual, but quite effective at 
> illustrating the problem.
> >
> > On June 5, 2019 7:21:57 AM PDT, rain1290--- via R-help 
>  wrote:
> >> I am trying to plot, using ggplot, a series of scatter plots with
> >> regression lines for several datasets. I started with the following
> >> dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
> >>      onepctCO2MEDIAN
> >>      x  y
> >>      layer.1   0.0  0.000
> >>      layer.2   0.006794447  4.9002490
> >>      layer.3   0.014288058  0.1608000
> >>      layer.4   0.022087920  6.6349133
> >>      layer.5   0.030797357 

Re: [R] Plotting more than one regression line in ggplot

2019-06-05 Thread rain1290--- via R-help
Hi David (and everyone),

Thank you for your response. I changed the column names to x and y, but the 
error/warning persists:
Warning message:
Computation failed in `stat_smooth()`:
'what' must be a function or character string 
It is quite baffling as to why this is happening. Why would it work for the 
scatter plot and not the regression line?

-Original Message-
From: David Winsemius 
To: r-help 
Sent: Wed, Jun 5, 2019 12:00 pm
Subject: Re: [R] Plotting more than one regression line in ggplot


On 6/5/19 8:04 AM, rain1290--- via R-help wrote:
> Hi Jeff (and everyone),
>
> Thank you for your response and feedback. Yes, I know what you mean - it was 
> a blind and quick choice to use "lm" as my object name. Unfortunately, 
> changing the object name to something else does not eliminate that 
> error/warning message. As a result, the same error/warning appears when 
> running it. Oddly enough, the scatter plot is just fine - it's the regression 
> line that struggles to appear. Could there be another reason for that?
> Thanks, again,


TRhe error came because you did not reference the column names 
correctly. This succeeds with the data you offered:


ggplot(onepctCO2MEDIAN) +
  geom_jitter(aes(x,y),
  colour="blue") + geom_smooth(aes(x,y), method=lm)


# At some point you changed the column names from 
(RCP1pctCO2cumulativeMedian, departurea) to (x,y) , but didn't adjust 
your code.


Best;

David.

>
> -Original Message-
> From: Jeff Newmiller 
> To: rain1290 ; rain1290--- via R-help 
> ; r-help ; r-sig-geo 
> 
> Sent: Wed, Jun 5, 2019 10:49 am
> Subject: Re: [R] Plotting more than one regression line in ggplot
>
> Please read the Posting Guide... posting HTML on a plain text mailing list 
> really interferes with clear communication.
>
> If you had spent even a small amount of time working with R tutorials then 
> you would know that "lm" is the name of a very basic, very important R 
> function. However, you are defining your own object called "lm" that is very 
> different indeed than the usual "lm" function. I would guess that in a clean 
> new R workspace where you had not already run your ggplot function and 
> assigned the result to your own "lm" object then this code might run. 
> However, once you have run it once and try to run it again, your "method" 
> argument gives the wrong version of "lm" to geom_smooth and you confuse it.
>
> As the doctor said to the man pounding his own head against the wall, "If it 
> hurts, don't do that." Avoid re-using important object names in R... some 
> common names I see abused this way are df, data, c, t, T, and F. Your choice 
> was unusual, but quite effective at illustrating the problem.
>
> On June 5, 2019 7:21:57 AM PDT, rain1290--- via R-help  
> wrote:
>> I am trying to plot, using ggplot, a series of scatter plots with
>> regression lines for several datasets. I started with the following
>> dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
>>      onepctCO2MEDIAN
>>      x  y
>>      layer.1   0.0  0.000
>>      layer.2   0.006794447  4.9002490
>>      layer.3   0.014288058  0.1608000
>>      layer.4   0.022087920  6.6349133
>>      layer.5   0.030797357 -1.2429506
>>      layer.6   0.038451072  1.5643374
>>      layer.7   0.048087904 -2.2659035
>>      layer.8   0.058677729  2.2070045
>>      layer.9   0.069261406 -2.3677001
>>      layer.10  0.080524530 -1.0913506
>>      layer.11  0.092760246  0.4099940
>>      layer.12  0.103789609 -0.1259727
>>      layer.13  0.116953168 -2.4138253
>>      layer.14  0.129253298  7.0890257
>>      layer.15  0.141710050 -0.7593539
>>      layer.16  0.156002052  0.0454416
>>      layer.17  0.170648172 -1.5349683
>>      layer.18  0.185318425  6.5524201
>>      layer.19  0.199463055 -0.8312563
>>      layer.20  0.213513337 -2.5099183
>>      layer.21  0.228839271  0.1365968
>>      layer.22  0.246981293 -1.3719845
>>      layer.23  0.263012767 -0.8712988
>>      layer.24  0.278505564  0.6632584
>>      layer.25  0.293658361  0.7938036
>>      layer.26  0.310747266  3.4880637
>>      layer.27  0.325990349 -4.4612208
>>      layer.28  0.342517540  0.0871734
>>      layer.29  0.362751633 -1.4171578
>>      layer.30  0.380199537 -0.9956508
>>      layer.31  0.394992948  0.3215526
>>      layer.32  0.414373398  3.1403866
>>      layer.33  0.430690214 -0.7376099
>>      layer.34  0.449738145 -2.4860541
>>      layer.35  0.470167458 -3.4235858
>>      layer.36  0.489019871  0.4824748
>>      layer.37  0.507242471 -0.9785386
>>      layer.38  0.524314284  8.5359684
>>      layer.39  0.543750525  5.4844742
>>      layer.40  0.564234197  3.2149367
>>      layer.41  0.583679616  3.9168916
>>      layer.42  0.601459444  4.4907020
>>      layer.43  0.619924664  6.5410410
>>      layer.44  0.639932007  4.8068650
>>      layer.45  0.661347181  8.1510170
>>      layer.46  0.684117317  0.2697413
>>      layer.47  0.704829752 -0.1807501
>>   

[R] Open a file which name contains a tilde

2019-06-05 Thread Frank Schwidom
Hi,

As I can see via path.expand a filename which contains a tilde anywhere gets 
automatically crippled.

+> path.expand("a ~ b")
[1] "a /home/user b"

+> path.expand("a ~ b ~")
[1] "a /home/user b /home/user"

I want to open a file regardless whether its name contains any character unless 
0.

The unix filesystem allow the creation of such files, it sould be possible to 
open these.

How can I switch off any file crippling activity?

Kind regards,
Frank

__
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] Plotting more than one regression line in ggplot

2019-06-05 Thread David Winsemius



On 6/5/19 8:04 AM, rain1290--- via R-help wrote:

Hi Jeff (and everyone),

Thank you for your response and feedback. Yes, I know what you mean - it was a blind and 
quick choice to use "lm" as my object name. Unfortunately, changing the object 
name to something else does not eliminate that error/warning message. As a result, the 
same error/warning appears when running it. Oddly enough, the scatter plot is just fine - 
it's the regression line that struggles to appear. Could there be another reason for that?
Thanks, again,



TRhe error came because you did not reference the column names 
correctly. This succeeds with the data you offered:



ggplot(onepctCO2MEDIAN) +
 geom_jitter(aes(x,y),
 colour="blue") + geom_smooth(aes(x,y), method=lm)


# At some point you changed the column names from 
(RCP1pctCO2cumulativeMedian, departurea) to (x,y) , but didn't adjust 
your code.



Best;

David.



-Original Message-
From: Jeff Newmiller 
To: rain1290 ; rain1290--- via R-help ; r-help 
; r-sig-geo 
Sent: Wed, Jun 5, 2019 10:49 am
Subject: Re: [R] Plotting more than one regression line in ggplot

Please read the Posting Guide... posting HTML on a plain text mailing list 
really interferes with clear communication.

If you had spent even a small amount of time working with R tutorials then you would know that "lm" is the name of a very basic, 
very important R function. However, you are defining your own object called "lm" that is very different indeed than the usual 
"lm" function. I would guess that in a clean new R workspace where you had not already run your ggplot function and assigned the 
result to your own "lm" object then this code might run. However, once you have run it once and try to run it again, your 
"method" argument gives the wrong version of "lm" to geom_smooth and you confuse it.

As the doctor said to the man pounding his own head against the wall, "If it hurts, 
don't do that." Avoid re-using important object names in R... some common names I 
see abused this way are df, data, c, t, T, and F. Your choice was unusual, but quite 
effective at illustrating the problem.

On June 5, 2019 7:21:57 AM PDT, rain1290--- via R-help  
wrote:

I am trying to plot, using ggplot, a series of scatter plots with
regression lines for several datasets. I started with the following
dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
     onepctCO2MEDIAN
     x  y
     layer.1   0.0  0.000
     layer.2   0.006794447  4.9002490
     layer.3   0.014288058  0.1608000
     layer.4   0.022087920  6.6349133
     layer.5   0.030797357 -1.2429506
     layer.6   0.038451072  1.5643374
     layer.7   0.048087904 -2.2659035
     layer.8   0.058677729  2.2070045
     layer.9   0.069261406 -2.3677001
     layer.10  0.080524530 -1.0913506
     layer.11  0.092760246  0.4099940
     layer.12  0.103789609 -0.1259727
     layer.13  0.116953168 -2.4138253
     layer.14  0.129253298  7.0890257
     layer.15  0.141710050 -0.7593539
     layer.16  0.156002052  0.0454416
     layer.17  0.170648172 -1.5349683
     layer.18  0.185318425  6.5524201
     layer.19  0.199463055 -0.8312563
     layer.20  0.213513337 -2.5099183
     layer.21  0.228839271  0.1365968
     layer.22  0.246981293 -1.3719845
     layer.23  0.263012767 -0.8712988
     layer.24  0.278505564  0.6632584
     layer.25  0.293658361  0.7938036
     layer.26  0.310747266  3.4880637
     layer.27  0.325990349 -4.4612208
     layer.28  0.342517540  0.0871734
     layer.29  0.362751633 -1.4171578
     layer.30  0.380199537 -0.9956508
     layer.31  0.394992948  0.3215526
     layer.32  0.414373398  3.1403866
     layer.33  0.430690214 -0.7376099
     layer.34  0.449738145 -2.4860541
     layer.35  0.470167458 -3.4235858
     layer.36  0.489019871  0.4824748
     layer.37  0.507242471 -0.9785386
     layer.38  0.524314284  8.5359684
     layer.39  0.543750525  5.4844742
     layer.40  0.564234197  3.2149367
     layer.41  0.583679616  3.9168916
     layer.42  0.601459444  4.4907020
     layer.43  0.619924664  6.5410410
     layer.44  0.639932007  4.8068650
     layer.45  0.661347181  8.1510170
     layer.46  0.684117317  0.2697413
     layer.47  0.704829752 -0.1807501
     layer.48  0.725045770  9.7181249
     layer.49  0.745165825  1.5406466
     layer.50  0.765016139 -1.6476041
     layer.51  0.783461511  4.8024603
     layer.52  0.806382924  4.0421516
     layer.53  0.829241335  9.3756512
     layer.54  0.849924415  5.3305050
     layer.55  0.871352434  7.5445803
     layer.56  0.893632233  6.4679547
     layer.57  0.916052133  2.8096065
     layer.58  0.938579470  5.3921661
     layer.59  0.959907651  7.2043689
     layer.60  0.981643587  3.3350806
     layer.61  1.004116774  8.8690707
     layer.62  1.028363466  1.7861299
     layer.63  1.054009140  6.2555038
     layer.64  1.072440803  7.6079236
     layer.65  1.094457805  7.6871483
     layer.66  1.123176277  4.7787764
     layer.67  

Re: [R] Plotting more than one regression line in ggplot

2019-06-05 Thread Rui Barradas

Hello,

And please don't cross post. You have asked both

r-help@r-project.org and
r-sig-...@r-project.org

when you should have asked just one of them.

This is a question for r-help@r-project.org

Rui Barradas

Às 15:52 de 05/06/19, Rui Barradas escreveu:

Hello,

This is pretty basic ggplot.


lm1 <- ggplot(onepctCO2MEDIAN, aes(x, y)) +
   geom_point(colour = 'blue') +
   geom_smooth(method = 'lm')

lm1


If you want to combine several datasets, you will have to have a 
variable telling which dataset is which. In the example below, this is 
column 'id'.



onepctCO2MEDIAN2 <- onepctCO2MEDIAN
onepctCO2MEDIAN2$y <- jitter(onepctCO2MEDIAN2$y) + 2
onepctCO2MEDIAN$id <- 1
onepctCO2MEDIAN2$id <- 2
df2 <- rbind(onepctCO2MEDIAN, onepctCO2MEDIAN2)

ggplot(df2, aes(x, y, group = id, colour = factor(id))) +
   geom_point() +
   geom_smooth(method = 'lm')


Hope this helps,

Rui Barradas

Às 15:21 de 05/06/19, rain1290--- via R-help escreveu:
I am trying to plot, using ggplot, a series of scatter plots with 
regression lines for several datasets. I started with the following 
dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:

 onepctCO2MEDIAN
 x  y
 layer.1   0.0  0.000
 layer.2   0.006794447  4.9002490
 layer.3   0.014288058  0.1608000
 layer.4   0.022087920  6.6349133
 layer.5   0.030797357 -1.2429506
 layer.6   0.038451072  1.5643374
 layer.7   0.048087904 -2.2659035
 layer.8   0.058677729  2.2070045
 layer.9   0.069261406 -2.3677001
 layer.10  0.080524530 -1.0913506
 layer.11  0.092760246  0.4099940
 layer.12  0.103789609 -0.1259727
 layer.13  0.116953168 -2.4138253
 layer.14  0.129253298  7.0890257
 layer.15  0.141710050 -0.7593539
 layer.16  0.156002052  0.0454416
 layer.17  0.170648172 -1.5349683
 layer.18  0.185318425  6.5524201
 layer.19  0.199463055 -0.8312563
 layer.20  0.213513337 -2.5099183
 layer.21  0.228839271  0.1365968
 layer.22  0.246981293 -1.3719845
 layer.23  0.263012767 -0.8712988
 layer.24  0.278505564  0.6632584
 layer.25  0.293658361  0.7938036
 layer.26  0.310747266  3.4880637
 layer.27  0.325990349 -4.4612208
 layer.28  0.342517540  0.0871734
 layer.29  0.362751633 -1.4171578
 layer.30  0.380199537 -0.9956508
 layer.31  0.394992948  0.3215526
 layer.32  0.414373398  3.1403866
 layer.33  0.430690214 -0.7376099
 layer.34  0.449738145 -2.4860541
 layer.35  0.470167458 -3.4235858
 layer.36  0.489019871  0.4824748
 layer.37  0.507242471 -0.9785386
 layer.38  0.524314284  8.5359684
 layer.39  0.543750525  5.4844742
 layer.40  0.564234197  3.2149367
 layer.41  0.583679616  3.9168916
 layer.42  0.601459444  4.4907020
 layer.43  0.619924664  6.5410410
 layer.44  0.639932007  4.8068650
 layer.45  0.661347181  8.1510170
 layer.46  0.684117317  0.2697413
 layer.47  0.704829752 -0.1807501
 layer.48  0.725045770  9.7181249
 layer.49  0.745165825  1.5406466
 layer.50  0.765016139 -1.6476041
 layer.51  0.783461511  4.8024603
 layer.52  0.806382924  4.0421516
 layer.53  0.829241335  9.3756512
 layer.54  0.849924415  5.3305050
 layer.55  0.871352434  7.5445803
 layer.56  0.893632233  6.4679547
 layer.57  0.916052133  2.8096065
 layer.58  0.938579470  5.3921661
 layer.59  0.959907651  7.2043689
 layer.60  0.981643587  3.3350806
 layer.61  1.004116774  8.8690707
 layer.62  1.028363466  1.7861299
 layer.63  1.054009140  6.2555038
 layer.64  1.072440803  7.6079236
 layer.65  1.094457805  7.6871483
 layer.66  1.123176277  4.7787764
 layer.67  1.149430871 12.7110502
 layer.68  1.170912921 -0.7156284
 layer.69  1.196743071  1.6490899
 layer.70  1.218625903  3.0363024
 layer.71  1.241868377  4.2974769
 layer.72  1.267941594  1.9543778
 layer.73  1.290708780  3.9986964
 layer.74  1.31389  4.5179472
 layer.75  1.339045882  0.9337905
 layer.76  1.362803459  3.3050770
 layer.77  1.384450197  3.5422970
 layer.78  1.409720302  5.9973660
 layer.79  1.435851157  0.5081869
 layer.80  1.455592215  7.9661630
 layer.81  1.479495347  9.9460496
 layer.82  1.506051958  3.7908372
 layer.83  1.525728464  2.5735847
 layer.84  1.549362063 10.1404974
 layer.85  1.573440671 13.7408304
 layer.86  1.600278735  0.9335771
 layer.87  1.623879492  9.7588742
 layer.88  1.650029302  1.2769395
 layer.89  1.672362328 13.4970906
 layer.90  1.700221121 10.2087502
 layer.91  1.724793375  1.6811275
 layer.92  1.751070559  6.1178992
 layer.93  1.778022110 -0.1567626
 layer.94  1.803022087  3.8237479
 layer.95  1.830668867  4.4331468
 layer.96  1.855736911  5.9790707
 layer.97  1.882615030 11.3104333
 layer.98  1.909218490  8.2142607
 layer.99  1.938130021 15.3209674
 layer.100 

Re: [R] Plotting more than one regression line in ggplot

2019-06-05 Thread rain1290--- via R-help
Hi Jeff (and everyone),

Thank you for your response and feedback. Yes, I know what you mean - it was a 
blind and quick choice to use "lm" as my object name. Unfortunately, changing 
the object name to something else does not eliminate that error/warning 
message. As a result, the same error/warning appears when running it. Oddly 
enough, the scatter plot is just fine - it's the regression line that struggles 
to appear. Could there be another reason for that?
Thanks, again,


-Original Message-
From: Jeff Newmiller 
To: rain1290 ; rain1290--- via R-help ; 
r-help ; r-sig-geo 
Sent: Wed, Jun 5, 2019 10:49 am
Subject: Re: [R] Plotting more than one regression line in ggplot

Please read the Posting Guide... posting HTML on a plain text mailing list 
really interferes with clear communication.

If you had spent even a small amount of time working with R tutorials then you 
would know that "lm" is the name of a very basic, very important R function. 
However, you are defining your own object called "lm" that is very different 
indeed than the usual "lm" function. I would guess that in a clean new R 
workspace where you had not already run your ggplot function and assigned the 
result to your own "lm" object then this code might run. However, once you have 
run it once and try to run it again, your "method" argument gives the wrong 
version of "lm" to geom_smooth and you confuse it.

As the doctor said to the man pounding his own head against the wall, "If it 
hurts, don't do that." Avoid re-using important object names in R... some 
common names I see abused this way are df, data, c, t, T, and F. Your choice 
was unusual, but quite effective at illustrating the problem.

On June 5, 2019 7:21:57 AM PDT, rain1290--- via R-help  
wrote:
>I am trying to plot, using ggplot, a series of scatter plots with
>regression lines for several datasets. I started with the following
>dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
>    onepctCO2MEDIAN
>    x  y
>    layer.1   0.0  0.000
>    layer.2   0.006794447  4.9002490
>    layer.3   0.014288058  0.1608000
>    layer.4   0.022087920  6.6349133
>    layer.5   0.030797357 -1.2429506
>    layer.6   0.038451072  1.5643374
>    layer.7   0.048087904 -2.2659035
>    layer.8   0.058677729  2.2070045
>    layer.9   0.069261406 -2.3677001
>    layer.10  0.080524530 -1.0913506
>    layer.11  0.092760246  0.4099940
>    layer.12  0.103789609 -0.1259727
>    layer.13  0.116953168 -2.4138253
>    layer.14  0.129253298  7.0890257
>    layer.15  0.141710050 -0.7593539
>    layer.16  0.156002052  0.0454416
>    layer.17  0.170648172 -1.5349683
>    layer.18  0.185318425  6.5524201
>    layer.19  0.199463055 -0.8312563
>    layer.20  0.213513337 -2.5099183
>    layer.21  0.228839271  0.1365968
>    layer.22  0.246981293 -1.3719845
>    layer.23  0.263012767 -0.8712988
>    layer.24  0.278505564  0.6632584
>    layer.25  0.293658361  0.7938036
>    layer.26  0.310747266  3.4880637
>    layer.27  0.325990349 -4.4612208
>    layer.28  0.342517540  0.0871734
>    layer.29  0.362751633 -1.4171578
>    layer.30  0.380199537 -0.9956508
>    layer.31  0.394992948  0.3215526
>    layer.32  0.414373398  3.1403866
>    layer.33  0.430690214 -0.7376099
>    layer.34  0.449738145 -2.4860541
>    layer.35  0.470167458 -3.4235858
>    layer.36  0.489019871  0.4824748
>    layer.37  0.507242471 -0.9785386
>    layer.38  0.524314284  8.5359684
>    layer.39  0.543750525  5.4844742
>    layer.40  0.564234197  3.2149367
>    layer.41  0.583679616  3.9168916 
>    layer.42  0.601459444  4.4907020
>    layer.43  0.619924664  6.5410410
>    layer.44  0.639932007  4.8068650
>    layer.45  0.661347181  8.1510170
>    layer.46  0.684117317  0.2697413
>    layer.47  0.704829752 -0.1807501
>    layer.48  0.725045770  9.7181249
>    layer.49  0.745165825  1.5406466
>    layer.50  0.765016139 -1.6476041
>    layer.51  0.783461511  4.8024603
>    layer.52  0.806382924  4.0421516
>    layer.53  0.829241335  9.3756512
>    layer.54  0.849924415  5.3305050
>    layer.55  0.871352434  7.5445803
>    layer.56  0.893632233  6.4679547
>    layer.57  0.916052133  2.8096065
>    layer.58  0.938579470  5.3921661
>    layer.59  0.959907651  7.2043689
>    layer.60  0.981643587  3.3350806
>    layer.61  1.004116774  8.8690707
>    layer.62  1.028363466  1.7861299
>    layer.63  1.054009140  6.2555038
>    layer.64  1.072440803  7.6079236
>    layer.65  1.094457805  7.6871483
>    layer.66  1.123176277  4.7787764
>    layer.67  1.149430871 12.7110502
>    layer.68  1.170912921 -0.7156284
>    layer.69  1.196743071  1.6490899
>    layer.70  1.218625903  3.0363024
>    layer.71  1.241868377  4.2974769
>    layer.72  1.267941594  1.9543778
>    layer.73  1.290708780  3.9986964
>    layer.74  1.31389  4.5179472
>    layer.75  1.339045882  0.9337905
>    layer.76  1.362803459  3.3050770
>    layer.77  1.384450197  3.5422970
>    layer.78  1.409720302  5.9973660
> 

Re: [R] Plotting more than one regression line in ggplot

2019-06-05 Thread Rui Barradas

Hello,

This is pretty basic ggplot.


lm1 <- ggplot(onepctCO2MEDIAN, aes(x, y)) +
  geom_point(colour = 'blue') +
  geom_smooth(method = 'lm')

lm1


If you want to combine several datasets, you will have to have a 
variable telling which dataset is which. In the example below, this is 
column 'id'.



onepctCO2MEDIAN2 <- onepctCO2MEDIAN
onepctCO2MEDIAN2$y <- jitter(onepctCO2MEDIAN2$y) + 2
onepctCO2MEDIAN$id <- 1
onepctCO2MEDIAN2$id <- 2
df2 <- rbind(onepctCO2MEDIAN, onepctCO2MEDIAN2)

ggplot(df2, aes(x, y, group = id, colour = factor(id))) +
  geom_point() +
  geom_smooth(method = 'lm')


Hope this helps,

Rui Barradas

Às 15:21 de 05/06/19, rain1290--- via R-help escreveu:

I am trying to plot, using ggplot, a series of scatter plots with regression lines for 
several datasets. I started with the following dataset, "onepectCO2MEDIAN". The 
data for this dataset is as follows:
     onepctCO2MEDIAN
     x  y
     layer.1   0.0  0.000
     layer.2   0.006794447  4.9002490
     layer.3   0.014288058  0.1608000
     layer.4   0.022087920  6.6349133
     layer.5   0.030797357 -1.2429506
     layer.6   0.038451072  1.5643374
     layer.7   0.048087904 -2.2659035
     layer.8   0.058677729  2.2070045
     layer.9   0.069261406 -2.3677001
     layer.10  0.080524530 -1.0913506
     layer.11  0.092760246  0.4099940
     layer.12  0.103789609 -0.1259727
     layer.13  0.116953168 -2.4138253
     layer.14  0.129253298  7.0890257
     layer.15  0.141710050 -0.7593539
     layer.16  0.156002052  0.0454416
     layer.17  0.170648172 -1.5349683
     layer.18  0.185318425  6.5524201
     layer.19  0.199463055 -0.8312563
     layer.20  0.213513337 -2.5099183
     layer.21  0.228839271  0.1365968
     layer.22  0.246981293 -1.3719845
     layer.23  0.263012767 -0.8712988
     layer.24  0.278505564  0.6632584
     layer.25  0.293658361  0.7938036
     layer.26  0.310747266  3.4880637
     layer.27  0.325990349 -4.4612208
     layer.28  0.342517540  0.0871734
     layer.29  0.362751633 -1.4171578
     layer.30  0.380199537 -0.9956508
     layer.31  0.394992948  0.3215526
     layer.32  0.414373398  3.1403866
     layer.33  0.430690214 -0.7376099
     layer.34  0.449738145 -2.4860541
     layer.35  0.470167458 -3.4235858
     layer.36  0.489019871  0.4824748
     layer.37  0.507242471 -0.9785386
     layer.38  0.524314284  8.5359684
     layer.39  0.543750525  5.4844742
     layer.40  0.564234197  3.2149367
     layer.41  0.583679616  3.9168916
     layer.42  0.601459444  4.4907020
     layer.43  0.619924664  6.5410410
     layer.44  0.639932007  4.8068650
     layer.45  0.661347181  8.1510170
     layer.46  0.684117317  0.2697413
     layer.47  0.704829752 -0.1807501
     layer.48  0.725045770  9.7181249
     layer.49  0.745165825  1.5406466
     layer.50  0.765016139 -1.6476041
     layer.51  0.783461511  4.8024603
     layer.52  0.806382924  4.0421516
     layer.53  0.829241335  9.3756512
     layer.54  0.849924415  5.3305050
     layer.55  0.871352434  7.5445803
     layer.56  0.893632233  6.4679547
     layer.57  0.916052133  2.8096065
     layer.58  0.938579470  5.3921661
     layer.59  0.959907651  7.2043689
     layer.60  0.981643587  3.3350806
     layer.61  1.004116774  8.8690707
     layer.62  1.028363466  1.7861299
     layer.63  1.054009140  6.2555038
     layer.64  1.072440803  7.6079236
     layer.65  1.094457805  7.6871483
     layer.66  1.123176277  4.7787764
     layer.67  1.149430871 12.7110502
     layer.68  1.170912921 -0.7156284
     layer.69  1.196743071  1.6490899
     layer.70  1.218625903  3.0363024
     layer.71  1.241868377  4.2974769
     layer.72  1.267941594  1.9543778
     layer.73  1.290708780  3.9986964
     layer.74  1.31389  4.5179472
     layer.75  1.339045882  0.9337905
     layer.76  1.362803459  3.3050770
     layer.77  1.384450197  3.5422970
     layer.78  1.409720302  5.9973660
     layer.79  1.435851157  0.5081869
     layer.80  1.455592215  7.9661630
     layer.81  1.479495347  9.9460496
     layer.82  1.506051958  3.7908372
     layer.83  1.525728464  2.5735847
     layer.84  1.549362063 10.1404974
     layer.85  1.573440671 13.7408304
     layer.86  1.600278735  0.9335771
     layer.87  1.623879492  9.7588742
     layer.88  1.650029302  1.2769395
     layer.89  1.672362328 13.4970906
     layer.90  1.700221121 10.2087502
     layer.91  1.724793375  1.6811275
     layer.92  1.751070559  6.1178992
     layer.93  1.778022110 -0.1567626
     layer.94  1.803022087  3.8237479
     layer.95  1.830668867  4.4331468
     layer.96  1.855736911  5.9790707
     layer.97  1.882615030 11.3104333
     layer.98  1.909218490  8.2142607
     layer.99  1.938130021 15.3209674
     layer.100 1.963727593  5.8178217
     layer.101 1.993271947  9.6004907
     layer.102 2.022548139  3.4063646
     layer.103 2.050679922  4.7375010
     layer.104 2.078064442  3.0133019
     layer.105 2.104113460  5.5659522
     layer.106 2.133597612 12.0346333
     layer.107 

Re: [R] Plotting more than one regression line in ggplot

2019-06-05 Thread Jeff Newmiller
Please read the Posting Guide... posting HTML on a plain text mailing list 
really interferes with clear communication.

If you had spent even a small amount of time working with R tutorials then you 
would know that "lm" is the name of a very basic, very important R function. 
However, you are defining your own object called "lm" that is very different 
indeed than the usual "lm" function. I would guess that in a clean new R 
workspace where you had not already run your ggplot function and assigned the 
result to your own "lm" object then this code might run. However, once you have 
run it once and try to run it again, your "method" argument gives the wrong 
version of "lm" to geom_smooth and you confuse it.

As the doctor said to the man pounding his own head against the wall, "If it 
hurts, don't do that." Avoid re-using important object names in R... some 
common names I see abused this way are df, data, c, t, T, and F. Your choice 
was unusual, but quite effective at illustrating the problem.

On June 5, 2019 7:21:57 AM PDT, rain1290--- via R-help  
wrote:
>I am trying to plot, using ggplot, a series of scatter plots with
>regression lines for several datasets. I started with the following
>dataset, "onepectCO2MEDIAN". The data for this dataset is as follows:
>    onepctCO2MEDIAN
>    x  y
>    layer.1   0.0  0.000
>    layer.2   0.006794447  4.9002490
>    layer.3   0.014288058  0.1608000
>    layer.4   0.022087920  6.6349133
>    layer.5   0.030797357 -1.2429506
>    layer.6   0.038451072  1.5643374
>    layer.7   0.048087904 -2.2659035
>    layer.8   0.058677729  2.2070045
>    layer.9   0.069261406 -2.3677001
>    layer.10  0.080524530 -1.0913506
>    layer.11  0.092760246  0.4099940
>    layer.12  0.103789609 -0.1259727
>    layer.13  0.116953168 -2.4138253
>    layer.14  0.129253298  7.0890257
>    layer.15  0.141710050 -0.7593539
>    layer.16  0.156002052  0.0454416
>    layer.17  0.170648172 -1.5349683
>    layer.18  0.185318425  6.5524201
>    layer.19  0.199463055 -0.8312563
>    layer.20  0.213513337 -2.5099183
>    layer.21  0.228839271  0.1365968
>    layer.22  0.246981293 -1.3719845
>    layer.23  0.263012767 -0.8712988
>    layer.24  0.278505564  0.6632584
>    layer.25  0.293658361  0.7938036
>    layer.26  0.310747266  3.4880637
>    layer.27  0.325990349 -4.4612208
>    layer.28  0.342517540  0.0871734
>    layer.29  0.362751633 -1.4171578
>    layer.30  0.380199537 -0.9956508
>    layer.31  0.394992948  0.3215526
>    layer.32  0.414373398  3.1403866
>    layer.33  0.430690214 -0.7376099
>    layer.34  0.449738145 -2.4860541
>    layer.35  0.470167458 -3.4235858
>    layer.36  0.489019871  0.4824748
>    layer.37  0.507242471 -0.9785386
>    layer.38  0.524314284  8.5359684
>    layer.39  0.543750525  5.4844742
>    layer.40  0.564234197  3.2149367
>    layer.41  0.583679616  3.9168916 
>    layer.42  0.601459444  4.4907020
>    layer.43  0.619924664  6.5410410
>    layer.44  0.639932007  4.8068650
>    layer.45  0.661347181  8.1510170
>    layer.46  0.684117317  0.2697413
>    layer.47  0.704829752 -0.1807501
>    layer.48  0.725045770  9.7181249
>    layer.49  0.745165825  1.5406466
>    layer.50  0.765016139 -1.6476041
>    layer.51  0.783461511  4.8024603
>    layer.52  0.806382924  4.0421516
>    layer.53  0.829241335  9.3756512
>    layer.54  0.849924415  5.3305050
>    layer.55  0.871352434  7.5445803
>    layer.56  0.893632233  6.4679547
>    layer.57  0.916052133  2.8096065
>    layer.58  0.938579470  5.3921661
>    layer.59  0.959907651  7.2043689
>    layer.60  0.981643587  3.3350806
>    layer.61  1.004116774  8.8690707
>    layer.62  1.028363466  1.7861299
>    layer.63  1.054009140  6.2555038
>    layer.64  1.072440803  7.6079236
>    layer.65  1.094457805  7.6871483
>    layer.66  1.123176277  4.7787764
>    layer.67  1.149430871 12.7110502
>    layer.68  1.170912921 -0.7156284
>    layer.69  1.196743071  1.6490899
>    layer.70  1.218625903  3.0363024
>    layer.71  1.241868377  4.2974769
>    layer.72  1.267941594  1.9543778
>    layer.73  1.290708780  3.9986964
>    layer.74  1.31389  4.5179472
>    layer.75  1.339045882  0.9337905
>    layer.76  1.362803459  3.3050770
>    layer.77  1.384450197  3.5422970
>    layer.78  1.409720302  5.9973660
>    layer.79  1.435851157  0.5081869
>    layer.80  1.455592215  7.9661630
>    layer.81  1.479495347  9.9460496
>    layer.82  1.506051958  3.7908372
>    layer.83  1.525728464  2.5735847
>    layer.84  1.549362063 10.1404974
>    layer.85  1.573440671 13.7408304
>    layer.86  1.600278735  0.9335771
>    layer.87  1.623879492  9.7588742
>    layer.88  1.650029302  1.2769395
>    layer.89  1.672362328 13.4970906
>    layer.90  1.700221121 10.2087502
>    layer.91  1.724793375  1.6811275
>    layer.92  1.751070559  6.1178992
>    layer.93  1.778022110 -0.1567626
>    layer.94  1.803022087  3.8237479
>    layer.95  1.830668867  4.4331468
>    layer.96  1.855736911  5.9790707
>    

[R] Plotting more than one regression line in ggplot

2019-06-05 Thread rain1290--- via R-help
I am trying to plot, using ggplot, a series of scatter plots with regression 
lines for several datasets. I started with the following dataset, 
"onepectCO2MEDIAN". The data for this dataset is as follows:
    onepctCO2MEDIAN
    x  y
    layer.1   0.0  0.000
    layer.2   0.006794447  4.9002490
    layer.3   0.014288058  0.1608000
    layer.4   0.022087920  6.6349133
    layer.5   0.030797357 -1.2429506
    layer.6   0.038451072  1.5643374
    layer.7   0.048087904 -2.2659035
    layer.8   0.058677729  2.2070045
    layer.9   0.069261406 -2.3677001
    layer.10  0.080524530 -1.0913506
    layer.11  0.092760246  0.4099940
    layer.12  0.103789609 -0.1259727
    layer.13  0.116953168 -2.4138253
    layer.14  0.129253298  7.0890257
    layer.15  0.141710050 -0.7593539
    layer.16  0.156002052  0.0454416
    layer.17  0.170648172 -1.5349683
    layer.18  0.185318425  6.5524201
    layer.19  0.199463055 -0.8312563
    layer.20  0.213513337 -2.5099183
    layer.21  0.228839271  0.1365968
    layer.22  0.246981293 -1.3719845
    layer.23  0.263012767 -0.8712988
    layer.24  0.278505564  0.6632584
    layer.25  0.293658361  0.7938036
    layer.26  0.310747266  3.4880637
    layer.27  0.325990349 -4.4612208
    layer.28  0.342517540  0.0871734
    layer.29  0.362751633 -1.4171578
    layer.30  0.380199537 -0.9956508
    layer.31  0.394992948  0.3215526
    layer.32  0.414373398  3.1403866
    layer.33  0.430690214 -0.7376099
    layer.34  0.449738145 -2.4860541
    layer.35  0.470167458 -3.4235858
    layer.36  0.489019871  0.4824748
    layer.37  0.507242471 -0.9785386
    layer.38  0.524314284  8.5359684
    layer.39  0.543750525  5.4844742
    layer.40  0.564234197  3.2149367
    layer.41  0.583679616  3.9168916 
    layer.42  0.601459444  4.4907020
    layer.43  0.619924664  6.5410410
    layer.44  0.639932007  4.8068650
    layer.45  0.661347181  8.1510170
    layer.46  0.684117317  0.2697413
    layer.47  0.704829752 -0.1807501
    layer.48  0.725045770  9.7181249
    layer.49  0.745165825  1.5406466
    layer.50  0.765016139 -1.6476041
    layer.51  0.783461511  4.8024603
    layer.52  0.806382924  4.0421516
    layer.53  0.829241335  9.3756512
    layer.54  0.849924415  5.3305050
    layer.55  0.871352434  7.5445803
    layer.56  0.893632233  6.4679547
    layer.57  0.916052133  2.8096065
    layer.58  0.938579470  5.3921661
    layer.59  0.959907651  7.2043689
    layer.60  0.981643587  3.3350806
    layer.61  1.004116774  8.8690707
    layer.62  1.028363466  1.7861299
    layer.63  1.054009140  6.2555038
    layer.64  1.072440803  7.6079236
    layer.65  1.094457805  7.6871483
    layer.66  1.123176277  4.7787764
    layer.67  1.149430871 12.7110502
    layer.68  1.170912921 -0.7156284
    layer.69  1.196743071  1.6490899
    layer.70  1.218625903  3.0363024
    layer.71  1.241868377  4.2974769
    layer.72  1.267941594  1.9543778
    layer.73  1.290708780  3.9986964
    layer.74  1.31389  4.5179472
    layer.75  1.339045882  0.9337905
    layer.76  1.362803459  3.3050770
    layer.77  1.384450197  3.5422970
    layer.78  1.409720302  5.9973660
    layer.79  1.435851157  0.5081869
    layer.80  1.455592215  7.9661630
    layer.81  1.479495347  9.9460496
    layer.82  1.506051958  3.7908372
    layer.83  1.525728464  2.5735847
    layer.84  1.549362063 10.1404974
    layer.85  1.573440671 13.7408304
    layer.86  1.600278735  0.9335771
    layer.87  1.623879492  9.7588742
    layer.88  1.650029302  1.2769395
    layer.89  1.672362328 13.4970906
    layer.90  1.700221121 10.2087502
    layer.91  1.724793375  1.6811275
    layer.92  1.751070559  6.1178992
    layer.93  1.778022110 -0.1567626
    layer.94  1.803022087  3.8237479
    layer.95  1.830668867  4.4331468
    layer.96  1.855736911  5.9790707
    layer.97  1.882615030 11.3104333
    layer.98  1.909218490  8.2142607
    layer.99  1.938130021 15.3209674
    layer.100 1.963727593  5.8178217
    layer.101 1.993271947  9.6004907
    layer.102 2.022548139  3.4063646
    layer.103 2.050679922  4.7375010
    layer.104 2.078064442  3.0133019
    layer.105 2.104113460  5.5659522
    layer.106 2.133597612 12.0346333
    layer.107 2.164026260 -0.4028320
    layer.108 2.194852829 10.5996780
    layer.109 2.224257946  5.4479584
    layer.110 2.252194643  4.7052374
    layer.111 2.277335048 14.0962019
    layer.112 2.304058313  5.7149016
    layer.113 2.330930233  3.7780072
    layer.114 2.357022762  4.4120620
    layer.115 2.386489272  4.1866085
    layer.116 2.417503953  6.9078802
    layer.117 2.448524356  2.7825739
    layer.118 2.478698969  7.6171786
    layer.119 2.510175705 10.2410603
    layer.120 2.539697886  8.1820711
    layer.121 2.567915559  4.8275494
    layer.122 2.597463250 19.1624883
    layer.123 2.627518773 16.0677109
    layer.124 2.658759236 12.5897081
    layer.125 2.692401528  9.2907988
    layer.126 2.721903205  7.4262502
    layer.127 2.753021359  9.3902518
    layer.128 2.786313415 12.6193550
   

Re: [R-es] Identificar por coordenadas geográficas una calle de una ciudad

2019-06-05 Thread Diego Martín
Gracias a vuestra ayuda implementé fácilmente esta función:

id_geocode <- geocode(locate,
  output = "all",
  source = "dsk",
  messaging = FALSE,
  force = FALSE,
  sensor = FALSE,
  override_limit = FALSE,
  client = "",
  signature = "",
  nameType = "long")

Y como los casos de la variable "locate" no parecieron muy complicados,
encontró casi el 100% y resolvió mi necesidad. Ahora bien, en cuestión de
precisión es mejor Google y pasar a la opción profesional, aunque tenga un
coste.

Gracias una vez más.

Diego Martín.
Geógrafo.

El jue., 16 may. 2019 a las 7:22, Diego Martín ()
escribió:

> Muchísimas gracias a todos. Voy a echar un vistazo y, sí, os contaré qué
> tal.
> Un abrazo.
>
> El jue., 16 may. 2019 a las 0:31, Javier Marcuzzi (<
> javier.ruben.marcu...@gmail.com>) escribió:
>
>> Estimados
>>
>> Sobre como obtener la geolocalización, aparte de lo aportado por Rubén
>> Casal, también existe el api de Microsoft, lo que yo descartaría es tomar
>> una base de datos con geolocalización, teóricamente andarían pero si uno
>> por casualidad conoce la geografía real, se da cuenta de errores, salvo que
>> en España los datos estén correctos.
>>
>> Javier Rubén Marcuzzi
>>
>> El mié., 15 may. 2019 a las 8:50, rubenfcasal ()
>> escribió:
>>
>>> Hola a todos,
>>>
>>> Yo tengo empleado herramientas de este tipo hace tiempo. Básicamente
>>> hacían consultas a google maps sobre direcciones y devolvían la
>>> posición. El número de consultas tenía restricciones y había que darse
>>> de alta en la api de google:
>>> https://developers.google.com/maps/documentation/geocoding/start?csw=1
>>>
>>> Buscando ahora esas herramientas me encontré con la función geocode de
>>> ggmap:
>>>
>>> https://www.rdocumentation.org/packages/ggmap/versions/2.6.1/topics/geocode
>>> https://www.jessesadler.com/post/geocoding-with-r
>>> podrías comenzar por esta...
>>>
>>> Como a mi gustan bastante las herramientas de OpenStreetMap (para cargar
>>> rutas en R, ...),
>>> y para no depender de google, miré también ahora si había novedades
>>> sobre esto y encontré varias:
>>>
>>> https://datascienceplus.com/osm-nominatim-with-r-getting-locations-geo-coordinates-by-its-address
>>> https://rud.is/b/2015/07/29/introducing-the-nominatim-geocoding-package
>>>
>>> Diego, ya nos dirás como hiciste finalmente...
>>>
>>> Un saludo, Rubén.
>>>
>>> El 15/05/2019 a las 13:16, Diego Martín escribió:
>>> > Saludos estimados compañeros:
>>> > ¿Alguno de ustedes sabe de alguna librería con la que
>>> geolocalizar
>>> >   una calle de una ciudad española?, aunque no cuenten nada más que
>>> aquellas
>>> > a partir de un umbral de población.
>>> >  Muchas gracias.
>>> >
>>> >   [[alternative HTML version deleted]]
>>> >
>>> > ___
>>> > R-help-es mailing list
>>> > R-help-es@r-project.org
>>> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> >
>>>
>>>
>>> --
>>> Ruben Fernandez Casal
>>> https://rubenfcasal.github.io
>>> Department of Mathematics
>>> Faculty of Computer Science
>>> Universidade da Coruña
>>> Corporate email: ruben.fcasal  udc  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] how to identify record with broken format

2019-06-05 Thread Boris Steipe
I've seen that behaviour with a C" atom in a chemical structure.

Here is code to identify lines with an uneven number of quotation marks. Read 
your file with readLines() to use it.

myTxt<- '"This" "is" "fine"'
myTxt[2] <- '"This" "is "not"'
myTxt[3] <- 'This is ok'
 
x <- lengths(regmatches(myTxt, gregexpr('\\"', myTxt)))  # (1)
which(x %% 2 == 1)
[1] 2


Cheers,
Boris


(1) credit to 
https://stackoverflow.com/questions/12427385/how-to-calculate-the-number-of-occurrence-of-a-given-character-in-each-row-of-a




> On 2019-06-05, at 06:12, Luigi Marongiu  wrote:
> 
> Dear all,
> I have a large dataframe where one of the records in a column must
> have been wrongly formatted, in particular i think is missing a
> closing ".
> When I try to show only that column's value I get a [1] with plenty of
> empty space, the final record [45] and the system freezes. also, when
> i try to plot i get a table's printout instead of a real plot.
> 
> Is there a way to identify the record with the format? On a
> spreadsheet or text editor, all records seem OK; end there are too
> many records to visually inspect them all.
> 
> -- 
> Best regards,
> Luigi
> 
> __
> 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] Mac/PC differences in lmer results

2019-06-05 Thread Olivier Crouzet
Hi,

32bit vs. 64bit systems? 

Another thing I would look at would be how the windows machine will
read the data file. Though issues should probably only arise with
respect to text data, I've often experienced problems with reading
unicode csv files on windows computers compared with unix-based
computers. No guarantee though, just suggestions...

Olivier.

On Wed, 5 Jun 2019 12:15:53 +0200
Nicolas Schuck  wrote:

> bert: you are right, sorry for not cc-ing the list. thanks also for
> the hint. 
> 
> I wanted to bring this up here again, emphasising that we do find in
> at least one case *a very large difference* in the p value, using the
> same scripts and data on a windows versus mac machine (see
> reproducible example in the gitlab link posted below). I have now
> come across several instances in which results of (g)lmer models
> don’t agree on windows vs unix-based machines, which I find a bit
> disturbing. any ideas where non-negligible differences could come
> from? 
> 
> thanks, 
> nico 
> 
> 
> > On 30. May 2019, at 16:58, Bert Gunter 
> > wrote:
> > 
> > 
> > Unless there us good reason not to, always cc the list. I have done
> > so here.
> > 
> > The R Installation manual has some info on how to use different
> > BLASes I believe, but someone with expertise (I have none) needs to
> > respond to your queries.
> > 
> > On Thu, May 30, 2019 at 7:50 AM Nicolas Schuck
> > mailto:nico.sch...@gmail.com>> wrote: I
> > know that it is in use on the Mac, see sessionInfo below. I have to
> > check on the Win system. Why would that make such a difference and
> > how could I make the Win get the same results as the Unix Systems? 
> > 
> > R version 3.6.0 (2019-04-26) 
> > Platform: x86_64-apple-darwin15.6.0 (64-bit) 
> > Running under: macOS Mojave 10.14.5 
> > Matrix products: default 
> > BLAS:  
> > /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib 
> > LAPACK: 
> > /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib 
> > Random number generation: 
> > RNG:  Mersenne-Twister 
> > Normal:  Inversion Sample:  Rounding 
> > locale: [1]
> > en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> > attached base packages: [1] stats  graphics  grDevices utils
> > datasets  methods  base Thanks, Nico On 30. May 2019, at 16:34,
> > Bert Gunter  > > wrote:
> > 
> >> The BLAS in use on each?
> >> 
> >> Bert Gunter
> >> 
> >> "The trouble with having an open mind is that people keep coming
> >> along and sticking things into it."
> >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >> 
> >> 
> >> On Thu, May 30, 2019 at 5:27 AM Nicolas Schuck
> >> mailto:nico.sch...@gmail.com>> wrote: Dear
> >> fellow R coders, 
> >> 
> >> I am observing differences in results obtained using glmer when
> >> using a Mac or Linux computer versus a PC. Specifically, I am
> >> talking about a relatively complex glmer model with a nested
> >> random effects structure. The model is set up in the following
> >> way: gcctrl = glmerControl(optimizer=c('nloptwrap'), optCtrl = list
> >> (maxfun = 50), calc.derivs = FALSE)
> >> 
> >> glmer_pre_instr1 = glmer(
> >>   formula = cbind(FREQ, NSAMP-FREQ) ~ FDIST_minz + poly
> >> (RFREQ,2) + ROI + (1 + FDIST_minz + RFREQ + ROI|ID/COL), data =
> >> cdf_pre_instr, family = binomial, 
> >>   control = gcctrl)
> >> 
> >> Code and data of an example for which I find reproducible,
> >> non-negligible differences between Mac/Win can be found here:
> >> https://gitlab.com/nschuck/glmer_sandbox/tree/master
> >> 
> >>  >> > The
> >> differences between the fitted models seem to be most pronounced
> >> regarding the estimated correlation structure of the random
> >> effects terms. Mac and Linux yield very similar results, but
> >> Windows deviates quite a bit in some cases. This has a large
> >> impact on p values obtained when performing model comparisons. I
> >> have tried this on Mac OS 10.14, Windows 10 and Ubuntu and Debian.
> >> All systems I have tried are using lme 1.1.21 and R 3.5+. 
> >> 
> >> Does anyone have an idea what the underlying cause might be? 
> >> 
> >> Thanks, 
> >> Nico 
> >> 
> >> 
> >> 
> >> 
> >> [[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]]
> 
> __
> 

Re: [R] how to identify record with broken format

2019-06-05 Thread Duncan Murdoch

On 05/06/2019 6:12 a.m., Luigi Marongiu wrote:

Dear all,
I have a large dataframe where one of the records in a column must
have been wrongly formatted, in particular i think is missing a
closing ".
When I try to show only that column's value I get a [1] with plenty of
empty space, the final record [45] and the system freezes. also, when
i try to plot i get a table's printout instead of a real plot.

Is there a way to identify the record with the format? On a
spreadsheet or text editor, all records seem OK; end there are too
many records to visually inspect them all.



Without seeing the data it is hard to be specific, but the 
count.fields() function should normally return the same number of fields 
for every line.  You may need to specify some of its optional arguments, 
e.g. sep="," for a CSV file, etc.


For example, with this file:

1,2,3
1,2,"4"
1,2,"
1,2,5
1,2,"6"

I see

> count.fields("~/temp/test.txt",sep=",")
[1]  3  3 NA NA NA  3

indicating that there are problems on lines 3-5 (a missing closing quote 
on line 3).


Duncan Murdoch

__
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] Mac/PC differences in lmer results

2019-06-05 Thread Nicolas Schuck
bert: you are right, sorry for not cc-ing the list. thanks also for the hint. 

I wanted to bring this up here again, emphasising that we do find in at least 
one case *a very large difference* in the p value, using the same scripts and 
data on a windows versus mac machine (see reproducible example in the gitlab 
link posted below). I have now come across several instances in which results 
of (g)lmer models don’t agree on windows vs unix-based machines, which I find a 
bit disturbing. any ideas where non-negligible differences could come from? 

thanks, 
nico 


> On 30. May 2019, at 16:58, Bert Gunter  wrote:
> 
> 
> Unless there us good reason not to, always cc the list. I have done so here.
> 
> The R Installation manual has some info on how to use different BLASes I 
> believe, but someone with expertise (I have none) needs to respond to your 
> queries.
> 
> On Thu, May 30, 2019 at 7:50 AM Nicolas Schuck  > wrote:
> I know that it is in use on the Mac, see sessionInfo below. I have to check 
> on the Win system. Why would that make such a difference and how could I make 
> the Win get the same results as the Unix Systems? 
> 
> R version 3.6.0 (2019-04-26) 
> Platform: x86_64-apple-darwin15.6.0 (64-bit) 
> Running under: macOS Mojave 10.14.5 
> Matrix products: default 
> BLAS:  
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib 
> LAPACK: 
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib 
> Random number generation: 
> RNG:  Mersenne-Twister 
> Normal:  Inversion Sample:  Rounding 
> locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 
> attached base packages: [1] stats  graphics  grDevices utils  datasets  
> methods  base 
> Thanks, Nico 
> On 30. May 2019, at 16:34, Bert Gunter  > wrote:
> 
>> The BLAS in use on each?
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming along and 
>> sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> 
>> On Thu, May 30, 2019 at 5:27 AM Nicolas Schuck > > wrote:
>> Dear fellow R coders, 
>> 
>> I am observing differences in results obtained using glmer when using a Mac 
>> or Linux computer versus a PC. Specifically, I am talking about a relatively 
>> complex glmer model with a nested random effects structure. The model is set 
>> up in the following way: 
>> gcctrl = glmerControl(optimizer=c('nloptwrap'), optCtrl = list(maxfun = 
>> 50), calc.derivs = FALSE)
>> 
>> glmer_pre_instr1 = glmer(
>>   formula = cbind(FREQ, NSAMP-FREQ) ~ FDIST_minz + poly(RFREQ,2) + ROI + 
>> (1 + FDIST_minz + RFREQ + ROI|ID/COL), 
>>   data = cdf_pre_instr, 
>>   family = binomial, 
>>   control = gcctrl)
>> 
>> Code and data of an example for which I find reproducible, non-negligible 
>> differences between Mac/Win can be found here: 
>> https://gitlab.com/nschuck/glmer_sandbox/tree/master 
>>  
>> > >
>> The differences between the fitted models seem to be most pronounced 
>> regarding the estimated correlation structure of the random effects terms. 
>> Mac and Linux yield very similar results, but Windows deviates quite a bit 
>> in some cases. This has a large impact on p values obtained when performing 
>> model comparisons. I have tried this on Mac OS 10.14, Windows 10 and Ubuntu 
>> and Debian. All systems I have tried are using lme 1.1.21 and R 3.5+. 
>> 
>> Does anyone have an idea what the underlying cause might be? 
>> 
>> Thanks, 
>> Nico 
>> 
>> 
>> 
>> 
>> [[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.


Re: [R] How to generate mutiple set of samples in R?

2019-06-05 Thread PIKAL Petr
Hi Mayooran

It is better to keep your mails on rhelp. Others could answer too.

see in line

> -Original Message-
> From: m.thevar...@massey.ac.nz 
> Sent: Wednesday, June 5, 2019 11:55 AM
> To: PIKAL Petr 
> Subject: Re: How to generate mutiple set of samples in R?
>
> Hello Petr
>   Here given below that manual code (generate first three set of samples
> each contains 200 observations), but I need to write common function for
> generate set of samples,
>
> N <- 1e7
> n <- 200 #sample size
> m <- 3  # number of samples
> indx <- 1:N
> start1 <- sort(sample(indx,1))
this will select **one** random number from indx so easier version is

start1 <- sample(indx,1))

> start2 <- sort(sample(start1+1,1))
> start3 <- sort(sample(start2+1,1))

these will select one random number from 1:start1 or 1:start2, again easier 
version is

start2 <- sample(start1+1,1)
>
> grab.samp1 <- start1:(start1+n-1)
> grab.samp2 <- start2:(start2+n-1)
> grab.samp3 <- start3:(start3+n-1)

and this will just make vector of of 200 consecutive numbers. So

startn <- sample(indx,200)

gives you 200 random numbers from 1:N vector.

And this will give you list of m vectors with 200 consecutive numbers starting 
randomly.

lll <- vector("list", m)
for (i in 1:m) {
lll[[i]] <- startn[i]:(startn[i]+n-1)
}

Is this what you wanted?

Cheers
Petr

>
> grab.samp1
> grab.samp2
> grab.samp3
>
>
> If you have any ideas please let me know.
>
>
> cheers
>
>
> Mayooran
>
>
> _
> Sent from http://r.789695.n4.nabble.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] how to identify record with broken format

2019-06-05 Thread Luigi Marongiu
Dear all,
I have a large dataframe where one of the records in a column must
have been wrongly formatted, in particular i think is missing a
closing ".
When I try to show only that column's value I get a [1] with plenty of
empty space, the final record [45] and the system freezes. also, when
i try to plot i get a table's printout instead of a real plot.

Is there a way to identify the record with the format? On a
spreadsheet or text editor, all records seem OK; end there are too
many records to visually inspect them all.

-- 
Best regards,
Luigi

__
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] How to generate mutiple set of samples in R?

2019-06-05 Thread PIKAL Petr
Hi

Maybe ?sample within cycle? And collecting results in list.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Thevaraja,
> Mayooran
> Sent: Wednesday, June 5, 2019 4:38 AM
> To: r-help@r-project.org
> Subject: [R] How to generate mutiple set of samples in R?
>
> Hello
>
> I am trying to generate samples from a bulk set of number for my research.
> So I need to get an output which contains various collection of samples, for
> example, sample1, sample2, sample3,  Does anyone suggest any ideas?
>
>
>
>
>
>
> [[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.
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] How to generate mutiple set of samples in R?

2019-06-05 Thread Enrico Schumann via R-help
> "MT" == Thevaraja, Mayooran  writes:

MT> Hello

MT> I am trying to generate samples from a bulk set of number for my
MT> research. So I need to get an output which contains various
MT> collection of samples, for example, sample1, sample2, sample3,
MT>  Does anyone suggest any ideas?

If you want people to help you, you need to provide
more information about what you want to do.

MT> [[alternative HTML version deleted]]

Please do not post in HTML, but in plain text.

MT> __
MT> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
MT> https://stat.ethz.ch/mailman/listinfo/r-help
MT> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

If you want people to help you, PLEASE DO read this
guide and follow its advice.

MT> and provide commented, minimal, self-contained, reproducible code.


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] Including a large number of variables in a formula.

2019-06-05 Thread peter dalgaard
Two ideas:

nn <- names(wageszm14)
lvadd <- nn[grep("^lvacb", nn)]

or

lvadd <- paste0("lvacb", 23:81)
lvadd <- lvadd[lvadd %in% names(wageszm14)]

> On 5 Jun 2019, at 06:46 , Rolando I. Valdez via R-help  
> wrote:
> 
> Hello,
> 
> I have almost 40 variables that I am trying to include in a formula.
> 
> I tried to include them using as.formula(), however the variables do not
> follow a patter in the name. e.g. These variables are named like: lvacb23
> lvacb30 lvacb300  lvacb40 .  lvacb81.
> 
>> lvadd <- paste0("lvacb", 23:81)
>> (fmla <- as.formula(paste("lwage ~ ", paste(lvadd, collapse = "+"
>> fit <- lm(fmla, data = wageszm14)
> Error in eval(predvars, data, env) : object 'lvacb24' not found
> 
> The variable lvacb24 doesn't exist, because from lvacb23 it jumps to
> lvacb30.
> 
> Thanks in advance for any help.
> -- 
> Rolando Valdez
> Facultad de Economía y Relaciones Internacionales
> Universidad Autónoma de Baja California
> 
>   [[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.

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


[R] Including a large number of variables in a formula.

2019-06-05 Thread Rolando I. Valdez via R-help
Hello,

I have almost 40 variables that I am trying to include in a formula.

I tried to include them using as.formula(), however the variables do not
follow a patter in the name. e.g. These variables are named like: lvacb23
lvacb30 lvacb300  lvacb40 .  lvacb81.

> lvadd <- paste0("lvacb", 23:81)
> (fmla <- as.formula(paste("lwage ~ ", paste(lvadd, collapse = "+"
> fit <- lm(fmla, data = wageszm14)
Error in eval(predvars, data, env) : object 'lvacb24' not found

The variable lvacb24 doesn't exist, because from lvacb23 it jumps to
lvacb30.

Thanks in advance for any help.
-- 
Rolando Valdez
Facultad de Economía y Relaciones Internacionales
Universidad Autónoma de Baja California

[[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] How to generate mutiple set of samples in R?

2019-06-05 Thread Thevaraja, Mayooran
Hello

I am trying to generate samples from a bulk set of number for my research. 
So I need to get an output which contains various collection of samples, for 
example, sample1, sample2, sample3,  Does anyone suggest any ideas?






[[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] [R-pkgs] table.express: use dplyr verbs to build data.table expressions

2019-06-05 Thread Alexis Sarda
Hello everyone,

I like the expressiveness of dplyr's data manipulation verbs, but I also
appreciate the optimizations offered by data.table, so I figured: why not
both?

The table.express package leverages the rlang package to bridge dplyr and
data.table by essentially parsing and chaining the operations specified by
the verbs,
building expressions that are ultimately evaluated by data.table, letting
it handle optimizations as usual. Some custom verbs are also added to
facilitate building expressions that work on a subset of the data.

The package with single-table verbs is now on CRAN, and the documentation
can also be browsed online at
https://asardaes.github.io/table.express/index.html

Regards,
Alexis.

[[alternative HTML version deleted]]

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

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