Re: [R] RStudio Exploratory Factor Analysis: write a function that extracts an increasing number of factors

2018-07-23 Thread Rui Barradas

Hello,

The output of kable() is a character vector, so you can solve your 
problem with a regex.



res <- do.call("rbind", efas) %>%
  kable()

res2 <- sub("^\\|[^|]+(\\|.*)", "\\1", res)
head(res2)


Alternatively, a more tidyverse like way would be to pipe the output of 
kable() through sub().



do.call("rbind", efas) %>%
  kable() %>%
  sub("^\\|[^|]+(\\|.*)", "\\1", .)


Hope this helps,

Rui Barradas

Às 04:21 de 24-07-2018, michael matta escreveu:

I have been trying to write a function in Rstudio that extracts an
increasing number of latent factors for the EFA and reports fit measures
for each solution in a final table. Below, I pasted what I was able to come
up with.

Unfortunately, it has some critical limitations:

The for loop requires to set the interval of factors that will be
extracted. That is fine but it would be nicer if the function stopped when
it reaches an error message (such as "maximum iteration exceeded",
"convergence not obtained in GPFoblq").

The final table includes an ugly first column with the label "RMSEA" which
is completely useless but I cannot get rid of it.

In general, the for loop might not be the most elegant way to reach the
goal.

  library(psych)
  library(GPArotation)
  library(dplyr)
  library(plyr)
  library(qgraph)

  efas <- list()

  for (i in 1:10) {
  fitn <- fa(big5, nfactors = i, fm = "pa", rotate = "oblimin",
  scores = "regression")
  efas[[i]] <- data.frame(fitn$TLI, fitn$RMSEA[1], fitn$rms, fitn$BIC)
%>%
  mutate(Factors = i) %>%
  dplyr::rename(TLI = fitn.TLI,
 RMSEA = fitn.RMSEA.1.,
 SRMR = fitn.rms,
 BIC = fitn.BIC) %>%
  dplyr::select(Factors, TLI, RMSEA, SRMR, BIC)

  }

   do.call("rbind", efas) %>%
 kable()


Thanks for any help!



__
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] RStudio Exploratory Factor Analysis: write a function that extracts an increasing number of factors

2018-07-23 Thread michael matta
I have been trying to write a function in Rstudio that extracts an
increasing number of latent factors for the EFA and reports fit measures
for each solution in a final table. Below, I pasted what I was able to come
up with.

Unfortunately, it has some critical limitations:

The for loop requires to set the interval of factors that will be
extracted. That is fine but it would be nicer if the function stopped when
it reaches an error message (such as "maximum iteration exceeded",
"convergence not obtained in GPFoblq").

The final table includes an ugly first column with the label "RMSEA" which
is completely useless but I cannot get rid of it.

In general, the for loop might not be the most elegant way to reach the
goal.

 library(psych)
 library(GPArotation)
 library(dplyr)
 library(plyr)
 library(qgraph)

 efas <- list()

 for (i in 1:10) {
 fitn <- fa(big5, nfactors = i, fm = "pa", rotate = "oblimin",
 scores = "regression")
 efas[[i]] <- data.frame(fitn$TLI, fitn$RMSEA[1], fitn$rms, fitn$BIC)
%>%
 mutate(Factors = i) %>%
 dplyr::rename(TLI = fitn.TLI,
RMSEA = fitn.RMSEA.1.,
SRMR = fitn.rms,
BIC = fitn.BIC) %>%
 dplyr::select(Factors, TLI, RMSEA, SRMR, BIC)

 }

  do.call("rbind", efas) %>%
kable()


Thanks for any help!

-- 
*Michael Matta, **Ph.D.*
Postdoctoral Research Associate, Department of Applied Psychology
408 International Village
360 Huntington Ave
Northeastern University
Boston, MA 02115

[[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] Fwd: SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread palazon
Hola:

Efectivamente, el fichero .R debe incluirse en un chunk,
de forma literal o como bien dices tu con la función source().

Si quieres probar, pulsa, estando en el editor con la pestaña
del fichero .R: ctrl+alt+k y así tejeras, así,
si funciona compruebas que puede incluirlo tal como se ha dicho
en un .Rmd

Cuidado: con los nombres de los ficheros, y usa un proyecto
para organizar todos los ficheros.

Seguimos

El 23/07/18 a las 21:55, Víctor Granda García escribió:
> Hola Carlos y demás erreros.
>
> Si entiendo bien tu problema, estas intentando crear un rmarkdown pero 
> usando objetos que tienes en un archivo r aparte (un script). Para 
> poder usar estos objetos debes poner en el primer chunk de código del 
> rmarkdown algo como esto:
>
> source("ruta/al/script.R")
>
> Donde "ruta/al/script.R" es la ruta a tu archivo R.
> Esto lo que hace es correr el script para que los objetos estén 
> disponibles en el environment del rmarkdown.
>
> Espero que te sirva, un saludo.
>
> El lun., 23 jul. 2018 21:44, palazon  > escribió:
>
> ¿Puedes enviar un ejemplo?
>
> El 23/07/18 a las 21:32, Carlos Córcoles escribió:
> > -- Mensaje reenviado --
> > De: Carlos Córcoles  >
> > Fecha: 23 de julio de 2018, 21:09
> > Asunto: SOLICITUD DE AYUDA CON R MARKDOWN
> > Para: R-help-es@r-project.org 
> >
> >
> > A quien corresponda:
> >
> > Escribo este e-mail porque necesito ayuda con R Markdown. Estoy
> intentado
> > crear textos con objetos creados en un archivo R y siempre me
> pasa igual,
> > me dice que el objeto no se reconoce...
> >
> > ¿Alguien me puede ayudar? 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
>
> -- 
> ___
> José Antonio Palazón Ferrando
> Profesor Titular. Departamento de Ecología e Hidrología.
> Facultad de Biología. Universidad de Murcia.
> Campus Universitario de Espinardo
> 30100 MURCIA-SPAIN
> Telf: +34 868 88 49 80
> Fax : +34 868 88 39 63
> Email: pala...@um.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
>
> -- 
> *Víctor Granda García*
> Data Technician
>
>
> v.gra...@creaf.uab.cat 
> Tel. +34 93 581 33 53
>
>
> Campus UAB. Edifici C. 08193 Bellaterra (Barcelona)|*www.creaf.cat* 
> 
>
> Abans d'imprimir aquest missatge electrònic penseu en el medi ambient.
>
>

-- 


José Antonio Palazón Ferrando
Profesor Titular. Departamento de Ecología e Hidrología.
Facultad de Biología. Universidad de Murcia.
Campus Universitario de Espinardo
30100 MURCIA-SPAIN
Telf: +34 868 88 49 80
Fax : +34 868 88 39 63
Email: pala...@um.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] Fwd: SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread Víctor Granda García
Hola Carlos y demás erreros.

Si entiendo bien tu problema, estas intentando crear un rmarkdown pero
usando objetos que tienes en un archivo r aparte (un script). Para poder
usar estos objetos debes poner en el primer chunk de código del rmarkdown
algo como esto:

source("ruta/al/script.R")

Donde "ruta/al/script.R" es la ruta a tu archivo R.
Esto lo que hace es correr el script para que los objetos estén disponibles
en el environment del rmarkdown.

Espero que te sirva, un saludo.

El lun., 23 jul. 2018 21:44, palazon  escribió:

> ¿Puedes enviar un ejemplo?
>
> El 23/07/18 a las 21:32, Carlos Córcoles escribió:
> > -- Mensaje reenviado --
> > De: Carlos Córcoles 
> > Fecha: 23 de julio de 2018, 21:09
> > Asunto: SOLICITUD DE AYUDA CON R MARKDOWN
> > Para: R-help-es@r-project.org
> >
> >
> > A quien corresponda:
> >
> > Escribo este e-mail porque necesito ayuda con R Markdown. Estoy intentado
> > crear textos con objetos creados en un archivo R y siempre me pasa igual,
> > me dice que el objeto no se reconoce...
> >
> > ¿Alguien me puede ayudar? 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
>
> --
> ___
> José Antonio Palazón Ferrando
> Profesor Titular. Departamento de Ecología e Hidrología.
> Facultad de Biología. Universidad de Murcia.
> Campus Universitario de Espinardo
> 30100 MURCIA-SPAIN
> Telf: +34 868 88 49 80
> Fax : +34 868 88 39 63
> Email: pala...@um.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
>
-- 
*Víctor Granda García*
Data Technician


v.gra...@creaf.uab.cat
Tel. +34 93 581 33 53


Campus UAB. Edifici C. 08193 Bellaterra (Barcelona) | *www.creaf.cat*


Abans d'imprimir aquest missatge electrònic penseu en el medi ambient.

[[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] Fwd: SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread palazon
¿Puedes enviar un ejemplo?

El 23/07/18 a las 21:32, Carlos Córcoles escribió:
> -- Mensaje reenviado --
> De: Carlos Córcoles 
> Fecha: 23 de julio de 2018, 21:09
> Asunto: SOLICITUD DE AYUDA CON R MARKDOWN
> Para: R-help-es@r-project.org
>
>
> A quien corresponda:
>
> Escribo este e-mail porque necesito ayuda con R Markdown. Estoy intentado
> crear textos con objetos creados en un archivo R y siempre me pasa igual,
> me dice que el objeto no se reconoce...
>
> ¿Alguien me puede ayudar? 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

-- 
___
José Antonio Palazón Ferrando
Profesor Titular. Departamento de Ecología e Hidrología.
Facultad de Biología. Universidad de Murcia.
Campus Universitario de Espinardo
30100 MURCIA-SPAIN
Telf: +34 868 88 49 80
Fax : +34 868 88 39 63
Email: pala...@um.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] Automate running files in R

2018-07-23 Thread Michael Friendly

Hi Serena

I'll add one more "in addition" to this list of suggestions. It may not 
be what you were thinking of, but may be far simpler in the long run.


The complexity of your approach comes from having separate data files 
for each subject and trial, for which you have to have a convention for

naming files and organizing them into coherently named directories.

The ideal solution would be to write your data into a single file, in 
which subjects and trials would just be separate columns.  More 
generally, anything you can do to change separate files into 
lines/records in a data frame will ease your task.


-Michael

On 7/22/18 6:40 PM, Rich Shepard wrote:

On Sun, 22 Jul 2018, Serena De Stefani wrote:


I need to automate a process in R. Basically I have a an R script (I will
call it R1) that needs three separate files to run. These three files are
the results output of one trial in my study.


The trials are specified by the labels: AA AB AM BA BB BM MA MB MM. So 
for

subject 1, trial 1, I will have three files with the ending
…mov1_AA

For subject one, trial 2, R should choose the three files with the 
ending …

mov1_AB and so on.


Serena,

   In addition to Jim's advice about your directory structure you should
seriously consider your file naming convention. Just like variable names in
a program, you're almost guaranteed to not remember what each two-character
name means within six months of creating them. Spend a little more time
typing and use descriptive names ... and think of using a .dat extension 
and

using read.table(*.dat).

   You can name your files, for example, input_1.R, input_2.R, and 
input_3.R

for your run sources. And, for (e.g.,) subject 1, trial 1, name the file
sub1_trial1. This might produce output called sub1_trial1_input1,
sub1_trial1_input2, and sub1_trial1_input3.

   Now when you look at data.frames or output you and everyone else will 
know

just what each contains.

Have fun,

Rich



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


[R-es] Fwd: SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread Carlos Córcoles
-- Mensaje reenviado --
De: Carlos Córcoles 
Fecha: 23 de julio de 2018, 21:09
Asunto: SOLICITUD DE AYUDA CON R MARKDOWN
Para: R-help-es@r-project.org


A quien corresponda:

Escribo este e-mail porque necesito ayuda con R Markdown. Estoy intentado
crear textos con objetos creados en un archivo R y siempre me pasa igual,
me dice que el objeto no se reconoce...

¿Alguien me puede ayudar? 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


Re: [R-es] Ayuda ggplot

2018-07-23 Thread Javier Marcuzzi
Estimada Dayana Muñoz

Si comprendo bien su correo, usted desea un gráfico como el ejemplo que
envía, donde se ven 6 columnas y una línea que recorre todas las columnas,
desde mi punto de vista eso es inconsistente, la línea iría para mostrar en
el incremento o decremento a lo largo del tiempo de una variable, pero
usted utiliza la misma línea para las tres.

Javier Rubén Marcuzzi

El lun., 23 jul. 2018 a las 10:55, Dayana Muñoz ()
escribió:

> Estimad@s,
>
> Junto con saludar, quería saber si alguien me podría ayudar con este
> gráfico, tengo un análisis de datos del año 2016 de 3 variables con dos
> dimensiones (muestra objetivo y muestra lograda), y quería agregar la
> comparación con el año 2015, me gustaría agregar un gráfico de linea y
> puntos para el año 2015, pero no he podido lograrlo , la idea es generar un
> gráfico de esta forma.  Adjunto mi scrip y mis bases.
>
> Agradeceré su colaboración.
>
>
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Ayuda ggplot

2018-07-23 Thread jose luis via R-help-es
 HolaExactamente.. ¿qué uniria la linea y los puntos?
En lunes, 23 de julio de 2018 15:55:53 CEST, Dayana Muñoz 
 escribió:  
 
  #yiv4057929109 P {margin-top:0;margin-bottom:0;}Estimad@s,
Junto con saludar, quería saber si alguien me podría ayudar con este gráfico, 
tengo un análisis de datos del año 2016 de 3 variables con dos dimensiones 
(muestra objetivo y muestra lograda), y quería agregar la comparación con el 
año 2015, me gustaría agregar un gráfico de linea y puntos para el año 2015, 
pero no he podido lograrlo , la idea es generar un gráfico de esta forma.  
Adjunto mi scrip y mis bases.
Agradeceré su colaboración.



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


Re: [R-es] SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread Javier Marcuzzi
Estimado Carlos Córcoles

¿Pero que objeto?

Le propongo correr cualquier ejemplo de internet, si este funciona quiere
decir que tiene todo instalado, entonces camparte algo de su código como
del error para tener un abanico de posibilidades más reducido.

Javier Rubén Marcuzzi

El lun., 23 jul. 2018 a las 16:10, Carlos Córcoles ()
escribió:

> A quien corresponda:
>
> Escribo este e-mail porque necesito ayuda con R Markdown. Estoy intentado
> crear textos con objetos creados en un archivo R y siempre me pasa igual,
> me dice que el objeto no se reconoce...
>
> ¿Alguien me puede ayudar? 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
>

[[alternative HTML version deleted]]

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


[R-es] SOLICITUD DE AYUDA CON R MARKDOWN

2018-07-23 Thread Carlos Córcoles
A quien corresponda:

Escribo este e-mail porque necesito ayuda con R Markdown. Estoy intentado
crear textos con objetos creados en un archivo R y siempre me pasa igual,
me dice que el objeto no se reconoce...

¿Alguien me puede ayudar? 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


Re: [R] [bug] spdep package?

2018-07-23 Thread Jeremie Juste


Many thanks for the info.

I see the point but I'll think calling the spData would be a cheaper
price to pay. If each package one load provide access to their variables
things are likely to get messy.

I guess many R users would like to control the variables in their global
environment.

And since it is not trival to protect variables inside a function from
the parent environment this is potentially dangerous.

Best wishes,

Jeremie










Henrik Bengtsson  writes:

> This is intended/expected because the spdep package *depends* on the
> spData package (see https://cran.r-project.org/web/packages/spdep/),
> which means that the maintainer of spdep intends also spData to be
> *attached* whenever spdep is attached.If they would have only
> imported it, then spData would only be *loaded* (but not attached),
> and you would not get 'spData' on your search() path and therefore not
> see 'x' either.
>
> Example:
>
> ## Loading spData
>> loadNamespace("spData")
> 
>
>> loadedNamespaces()
> [1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
> [7] "methods"   "spData""base"
>
> ## The search path used to find objects
>> search()
> [1] ".GlobalEnv""package:stats" "package:graphics"
> [4] "package:grDevices" "package:utils" "package:datasets"
> [7] "package:methods"   "Autoloads" "package:base"
>
> ## So, spData::x is not found
>> x
> Error: object 'x' not found
>
> ## But is still there
>> spData::x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
> ## Attaching spData, which also happens when you do library(spdat)
>> library(spData)
> To access larger datasets in this package, install the spDataLarge
> package with: `install.packages('spDataLarge',
> repos='https://nowosad.github.io/drat/', type='source'))
>
>> loadedNamespaces()
> [1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
> [7] "methods"   "spData""base"
>
> ## Now, spData is on the search path
>> search()
>  [1] ".GlobalEnv""package:spData""package:stats"
>  [4] "package:graphics"  "package:grDevices" "package:utils"
>  [7] "package:datasets"  "package:methods"   "Autoloads"
> [10] "package:base
>
>> x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
>> find("x")
> [1] "package:spData"
>
> /Henrik
> On Mon, Jul 23, 2018 at 2:01 PM Jeremie Juste  wrote:
>>
>>
>> Helllo,
>>
>> Thanks for the info. I still think these variables should not be loaded
>> when library(spdep) is called.
>>
>> But I'll handle it following your suggestion.
>>
>> Thanks,
>>
>> Jeremie
>>
>>
>>
>>
>>
>>
>> > It turns out that that 'x' comes from the spData package and lives
>> > inside that package (part of its namespace).
>> >
>> >> spData::x
>> >  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >
>> > This is conceptually no different from other objects in package
>> > namespace, although we are more used to seeing functions and not data
>> > object.  Another well-known example of this is:
>> >
>> >> base::pi
>> > [1] 3.141593
>> >
>> > So, this 'x' is *not* in your global workspace and you cannot remove
>> > it without unloading the package.
>> >
>> > /Henrik
>>
>>
>> >>
>> >>
>> >> I found a dangerous issue in the library spdep. I get variables x and y
>> >> that cannot be removed by rm() and I don't don't how they show up. Can
>> >> anyone reproduce this?
>> >>
>> >> ~$ R --vanilla
>> >> > rm(list=ls())
>> >> > library(spdep)
>> >> > x
>> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >> > rm(list=ls())
>> >> > x
>> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >>
>> >>
>> >>
>> >> > Sys.info()
>> >>
>> >> sysname"Linux"
>> >> release"4.9.0-6-amd64"
>> >> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
>> >> nodename   "freegnu"
>> >> machine"x86_64"
>> >>
>> >>
>> >> > Session
>> >>
>> >>
>> >> > sessionInfo()
>> >>
>> >> R version 3.4.1 (2017-06-30)
>> >> Platform: x86_64-pc-linux-gnu (64-bit)
>> >> Running under: Debian GNU/Linux 9 (stretch)
>> >>
>> >> Matrix products: default
>> >> BLAS: /usr/local/lib/R/lib/libRblas.so
>> >> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>> >>
>> >> locale:
>> >>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>> >>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>> >>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>> >>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>> >>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>> >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>> >>
>> >> attached base packages:
>> >> [1] stats graphics  grDevices utils datasets  methods   base
>> >>
>> >> loaded via a namespace (and not attached):
>> >> [1] compiler_3.4.1
>> >>
>> >> __
>> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the 

Re: [R] [FORGED] [bug] spdep package?

2018-07-23 Thread Jeremie Juste


Hello,


>This is *very* unlikely to be a bug.  People should always exercise a
>great deal of caution about conjecturing bugs when they encounter a
>phenomenon that they don't understand.

Ok,  I over reacted and I should let the package maintainers
qualify what is a bug or not. My point is that it is surprising to have
access these variables in the global environment when loading the spdep
library.

I normally I would expect the following

 rm(list=ls())
 myfun <- function(x){
y+ 33}

> myfun(x)
> Error in myfun(4) : object 'y' not found

But this is not cool 
> myfun()
 [1]  33  63  93 123 153 183 213 243 273 303 333 363 393 423 453 483


> It puzzles me that your sessionInfo() doesn't show something like:
You are right. My apologies. I confused sessions when I pasted the
sessionInfo.  Allow me to correct.



 R --vanilla -q 
> ls()
character(0)
> library(spdep)
Loading required package: sp
Loading required package: Matrix
Loading required package: spData
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge')`
> ls()
character(0)
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

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

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

other attached packages:
[1] spdep_0.7-7spData_0.2.6.7 Matrix_1.2-10  sp_1.2-5  

loaded via a namespace (and not attached):
 [1] lattice_0.20-35 deldir_0.1-14   gtools_3.5.0   
 [4] MASS_7.3-47 grid_3.4.1  nlme_3.1-131   
 [7] coda_0.19-1 data.table_1.10.4-3 gdata_2.18.0   
[10] LearnBayes_2.15 gmodels_2.16.2  boot_1.3-19
[13] splines_3.4.1   compiler_3.4.1  filehash_2.4-1 
[16] expm_0.999-2   
> x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450


I think Henrik Bengtsson has identified the issue see the next thread. 

Best regards,

Jeremie

__
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] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
This is intended/expected because the spdep package *depends* on the
spData package (see https://cran.r-project.org/web/packages/spdep/),
which means that the maintainer of spdep intends also spData to be
*attached* whenever spdep is attached.If they would have only
imported it, then spData would only be *loaded* (but not attached),
and you would not get 'spData' on your search() path and therefore not
see 'x' either.

Example:

## Loading spData
> loadNamespace("spData")


> loadedNamespaces()
[1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
[7] "methods"   "spData""base"

## The search path used to find objects
> search()
[1] ".GlobalEnv""package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:methods"   "Autoloads" "package:base"

## So, spData::x is not found
> x
Error: object 'x' not found

## But is still there
> spData::x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450


## Attaching spData, which also happens when you do library(spdat)
> library(spData)
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source'))

> loadedNamespaces()
[1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
[7] "methods"   "spData""base"

## Now, spData is on the search path
> search()
 [1] ".GlobalEnv""package:spData""package:stats"
 [4] "package:graphics"  "package:grDevices" "package:utils"
 [7] "package:datasets"  "package:methods"   "Autoloads"
[10] "package:base

> x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

> find("x")
[1] "package:spData"

/Henrik
On Mon, Jul 23, 2018 at 2:01 PM Jeremie Juste  wrote:
>
>
> Helllo,
>
> Thanks for the info. I still think these variables should not be loaded
> when library(spdep) is called.
>
> But I'll handle it following your suggestion.
>
> Thanks,
>
> Jeremie
>
>
>
>
>
>
> > It turns out that that 'x' comes from the spData package and lives
> > inside that package (part of its namespace).
> >
> >> spData::x
> >  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >
> > This is conceptually no different from other objects in package
> > namespace, although we are more used to seeing functions and not data
> > object.  Another well-known example of this is:
> >
> >> base::pi
> > [1] 3.141593
> >
> > So, this 'x' is *not* in your global workspace and you cannot remove
> > it without unloading the package.
> >
> > /Henrik
>
>
> >>
> >>
> >> I found a dangerous issue in the library spdep. I get variables x and y
> >> that cannot be removed by rm() and I don't don't how they show up. Can
> >> anyone reproduce this?
> >>
> >> ~$ R --vanilla
> >> > rm(list=ls())
> >> > library(spdep)
> >> > x
> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >> > rm(list=ls())
> >> > x
> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >>
> >>
> >>
> >> > Sys.info()
> >>
> >> sysname"Linux"
> >> release"4.9.0-6-amd64"
> >> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
> >> nodename   "freegnu"
> >> machine"x86_64"
> >>
> >>
> >> > Session
> >>
> >>
> >> > sessionInfo()
> >>
> >> R version 3.4.1 (2017-06-30)
> >> Platform: x86_64-pc-linux-gnu (64-bit)
> >> Running under: Debian GNU/Linux 9 (stretch)
> >>
> >> Matrix products: default
> >> BLAS: /usr/local/lib/R/lib/libRblas.so
> >> LAPACK: /usr/local/lib/R/lib/libRlapack.so
> >>
> >> locale:
> >>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> >>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
> >>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
> >>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
> >>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> >>
> >> attached base packages:
> >> [1] stats graphics  grDevices utils datasets  methods   base
> >>
> >> loaded via a namespace (and not attached):
> >> [1] compiler_3.4.1
> >>
> >> __
> >> 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] [bug] spdep package?

2018-07-23 Thread Jeremie Juste


Helllo,

Thanks for the info. I still think these variables should not be loaded
when library(spdep) is called.

But I'll handle it following your suggestion.

Thanks,

Jeremie






> It turns out that that 'x' comes from the spData package and lives
> inside that package (part of its namespace).
>
>> spData::x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
> This is conceptually no different from other objects in package
> namespace, although we are more used to seeing functions and not data
> object.  Another well-known example of this is:
>
>> base::pi
> [1] 3.141593
>
> So, this 'x' is *not* in your global workspace and you cannot remove
> it without unloading the package.
>
> /Henrik


>>
>>
>> I found a dangerous issue in the library spdep. I get variables x and y
>> that cannot be removed by rm() and I don't don't how they show up. Can
>> anyone reproduce this?
>>
>> ~$ R --vanilla
>> > rm(list=ls())
>> > library(spdep)
>> > x
>> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> > rm(list=ls())
>> > x
>> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>>
>>
>>
>> > Sys.info()
>>
>> sysname"Linux"
>> release"4.9.0-6-amd64"
>> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
>> nodename   "freegnu"
>> machine"x86_64"
>>
>>
>> > Session
>>
>>
>> > sessionInfo()
>>
>> R version 3.4.1 (2017-06-30)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>> Running under: Debian GNU/Linux 9 (stretch)
>>
>> Matrix products: default
>> BLAS: /usr/local/lib/R/lib/libRblas.so
>> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>>
>> locale:
>>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] compiler_3.4.1
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

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


[R] pROC

2018-07-23 Thread Maria Enzian



Hello,
I'm using the package pROC in RStudio to create my ROC-curves and I have 
patients in my data - healthy or sick - in the column "Status" and the value 
"SUVmax" to examine it.
I used the following code:
plot.roc(daten$Status,daten$SUVmax,percent=TRUE,ci=TRUE,print.auc=TRUE,main="ROC-Kurve
 für den SUVmax")
The ROC-curve I got is ok, but on the x-axis I got a specificity from 150% to 
-50%, but I want the scale from 100% to 0% (as usual).
xlim=c(100,0) doesn't work.
Can someone help me?
 
Best regards
M.Enzian

__
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: [ESS] Hang when opening remote session

2018-07-23 Thread Vitalie Spinu via ESS-help


Do you have a proper ssh remote to test this on? Could this be docker specific?

>> On ma, jul 23 2018 05:58, Gammel Holte via ESS-help wrote:

>>
>> Just a shot in the dark, but does /ssh:root@localhost#6000:/root/.Rhistory
>> exist and you have read/write permission?
>>

> Apologies for the late reply. Yes, it does exist and I have rw permissions.

> Anything else I can do to debug this issue?

> Thanks.

>   [[alternative HTML version deleted]]

> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] [FORGED] [bug] spdep package?

2018-07-23 Thread Rolf Turner

On 23/07/18 22:30, Jeremie Juste wrote:



Hello,


I found a dangerous issue in the library spdep. I get variables x and y
that cannot be removed by rm() and I don't don't how they show up. Can
anyone reproduce this?


I cannot.

This is *very* unlikely to be a bug.  People should always exercise a 
great deal of caution about conjecturing bugs when they encounter a

phenomenon that they don't understand.

What do you see if you simply do "ls()"?  (After loading spdep.)
I.e. do you see an "x" listed as an object in your workspace/global 
environment?


What does find("x") return?

It puzzles me that your sessionInfo() doesn't show something like:


other attached packages:
[1] spdep_0.6-13  Matrix_1.2-10 sp_1.2-5


There are probably other issues that you have not told us about.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



~$ R --vanilla

rm(list=ls())
library(spdep)
x

[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

rm(list=ls())
x

[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450




Sys.info()


sysname"Linux"
release"4.9.0-6-amd64"
version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
nodename   "freegnu"
machine"x86_64"



Session




sessionInfo()


R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1


__
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] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
It turns out that that 'x' comes from the spData package and lives
inside that package (part of its namespace).

> spData::x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

This is conceptually no different from other objects in package
namespace, although we are more used to seeing functions and not data
object.  Another well-known example of this is:

> base::pi
[1] 3.141593

So, this 'x' is *not* in your global workspace and you cannot remove
it without unloading the package.

/Henrik

On Mon, Jul 23, 2018 at 12:30 PM Jeremie Juste  wrote:
>
>
>
> Hello,
>
>
> I found a dangerous issue in the library spdep. I get variables x and y
> that cannot be removed by rm() and I don't don't how they show up. Can
> anyone reproduce this?
>
> ~$ R --vanilla
> > rm(list=ls())
> > library(spdep)
> > x
> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> > rm(list=ls())
> > x
> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
>
>
> > Sys.info()
>
> sysname"Linux"
> release"4.9.0-6-amd64"
> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
> nodename   "freegnu"
> machine"x86_64"
>
>
> > Session
>
>
> > sessionInfo()
>
> R version 3.4.1 (2017-06-30)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Debian GNU/Linux 9 (stretch)
>
> Matrix products: default
> BLAS: /usr/local/lib/R/lib/libRblas.so
> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.1
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] [bug] spdep package?

2018-07-23 Thread Jeremie Juste



Hello,


I found a dangerous issue in the library spdep. I get variables x and y
that cannot be removed by rm() and I don't don't how they show up. Can
anyone reproduce this?

~$ R --vanilla
> rm(list=ls())
> library(spdep)
> x
[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> rm(list=ls())
> x
[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450



> Sys.info()

sysname"Linux" 
release"4.9.0-6-amd64" 
version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
nodename   "freegnu"   
machine"x86_64"


> Session


> sessionInfo()

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1

__
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: [ESS] Hang when opening remote session

2018-07-23 Thread Gammel Holte via ESS-help
>
> Just a shot in the dark, but does /ssh:root@localhost#6000:/root/.Rhistory
> exist and you have read/write permission?
>

Apologies for the late reply. Yes, it does exist and I have rw permissions.

Anything else I can do to debug this issue?

Thanks.

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help