Re: [R] Names of variables needed in newdata for predict.glm

2018-03-08 Thread Marc Schwartz
Hi Bendix,

If the 'model' argument to glm() is TRUE (the default), you can get the 
structure of the model frame that was used to fit the model, by using:

> str(mx$data)
'data.frame':   200 obs. of  4 variables:
 $ D: int  0 1 0 1 1 0 1 1 1 1 ...
 $ x: num  0.705 2.15 0.572 1.249 0.807 ...
 $ f: Factor w/ 4 levels "a","b","c","d": 1 4 1 4 4 1 4 2 4 4 ...
 $ Y: num  0.787 8.267 3.085 5.738 9.593 ...


> str(mi$data)
'data.frame':   200 obs. of  4 variables:
 $ D: int  0 1 0 1 1 0 1 1 1 1 ...
 $ x: num  0.705 2.15 0.572 1.249 0.807 ...
 $ f: Factor w/ 4 levels "a","b","c","d": 1 4 1 4 4 1 4 2 4 4 ...
 $ Y: num  0.787 8.267 3.085 5.738 9.593 ...


The first column in the data frame will be the response variable.

In both cases, the offset variable 'Y' is included, whether the offset was part 
of the formula or specified as a separate argument.

You can then process the results as you need from there, such as:

> sapply(mx$data, class)
D x f Y 
"integer" "numeric"  "factor" "numeric" 


Regards,

Marc Schwartz




> On Mar 8, 2018, at 12:26 AM, Marc Girondot via R-help  
> wrote:
> 
> Hi,
> 
> Some try:
> > names(mi$xlevels)
> [1] "f"
> > all.vars(mi$formula)
> [1] "D" "x" "f" "Y"
> > names(mx$xlevels)
> [1] "f"
> > all.vars(mx$formula)
> [1] "D" "x" "f"
> 
> When offset is indicated out of the formula, it does not work...
> 
> Marc
> 
> Le 07/03/2018 à 06:20, Bendix Carstensen a écrit :
>> I would like to extract the names, modes [numeric/factor] and levels
>> of variables needed in a data frame supplied as newdata= argument to
>> predict.glm()
>> 
>> Here is a small example illustrating my troubles; what I want from
>> (both of) the glm objects is the vector c("x","f","Y") and an
>> indication that f is a factor:
>> 
>> library( splines )
>> dd <- data.frame( D = sample(0:1,200,rep=T),
>>   x = abs(rnorm(200)),
>>   f = factor(sample(letters[1:4],200,rep=T)),
>>   Y = runif(200,0.5,10) )
>> mx <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) , offset=log(Y) , 
>> family=poisson, data=dd)
>> mi <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) + offset(log(Y)), 
>> family=poisson, data=dd)
>> 
>> attr(mx$terms,"dataClasses")
>> attr(mi$terms,"dataClasses")
>> mi$xlevels
>> mx$xlevels
>> 
>> ...so far not quite there.
>> 
>> Regards,
>> 
>> Bendix Carstensen
>> 
>> Senior Statistician
>> Steno Diabetes Center
>> Clinical Epidemiology
>> Niels Steensens Vej 2-4
>> DK-2820 Gentofte, Denmark
>> b...@bxc.dk
>> bendix.carsten...@regionh.dk
>> http://BendixCarstensen.com


[[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] add single points to a level plot

2018-03-08 Thread lily li
Hi all,

I ran the code:
> s <- stack(replicate(2, raster(matrix(runif(100), 10
> xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
+  z1=runif(10), z2=runif(10))
> levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
+   layer(sp.points(xy, pch=ifelse(pts$z1 < 0.5, 2, 3), cex=2, col=1),
columns=1) +
+   layer(sp.points(xy, pch=ifelse(pts$z2 < 0.5, 2, 3), cex=2, col=1),
columns=2)

And got the error:
Error in UseMethod("levelplot") :
  no applicable method for 'levelplot' applied to an object of class
"c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"

what is the problem? Thanks.

On Thu, Mar 8, 2018 at 12:07 AM, lily li  wrote:

> Hi all,
>
> I'm trying to add single points with known coordinates to a level plot,
> but could not find the proper answer. I got to know that layer() function
> is good for this, but I don't know which package is related to this
> function. The source is here:
> https://stackoverflow.com/questions/28597149/add-xy-points-to-raster-map-
> generated-by-levelplot
>
> but my question is a little different as I know the coordinates of the
> single point, rather than a range. Thanks for any help you could provide.
>

[[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] add single points to a level plot

2018-03-08 Thread lily li
Thanks.
Now it can run and generate plots, but there are the two lines on each of
the plots. I don't know the problem for this?

Error using packet 1
any(sp) is not TRUE



On Thu, Mar 8, 2018 at 8:48 AM, Eric Berger  wrote:

> You need to load the package 'rasterVis'
>
> > library(rasterVis)
>
> HTH,
> Eric
>
>
> On Thu, Mar 8, 2018 at 5:11 PM, lily li  wrote:
>
>> Hi all,
>>
>> I ran the code:
>> > s <- stack(replicate(2, raster(matrix(runif(100), 10
>> > xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
>> +  z1=runif(10), z2=runif(10))
>> > levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
>> +   layer(sp.points(xy, pch=ifelse(pts$z1 < 0.5, 2, 3), cex=2, col=1),
>> columns=1) +
>> +   layer(sp.points(xy, pch=ifelse(pts$z2 < 0.5, 2, 3), cex=2, col=1),
>> columns=2)
>>
>> And got the error:
>> Error in UseMethod("levelplot") :
>>   no applicable method for 'levelplot' applied to an object of class
>> "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"
>>
>> what is the problem? Thanks.
>>
>> On Thu, Mar 8, 2018 at 12:07 AM, lily li  wrote:
>>
>> > Hi all,
>> >
>> > I'm trying to add single points with known coordinates to a level plot,
>> > but could not find the proper answer. I got to know that layer()
>> function
>> > is good for this, but I don't know which package is related to this
>> > function. The source is here:
>> > https://stackoverflow.com/questions/28597149/add-xy-points-
>> to-raster-map-
>> > generated-by-levelplot
>> >
>> > but my question is a little different as I know the coordinates of the
>> > single point, rather than a range. Thanks for any help you could
>> provide.
>> >
>>
>> [[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/posti
>> ng-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] add single points to a level plot

2018-03-08 Thread Jeff Newmiller
library(sos)
findFn( "layer" )
findFn( "levelplot" )

Also, experts in spatial analysis tend to answer questions on the special 
mailing list where the Posting Guide says they should. Read it to find out 
where that is. 
-- 
Sent from my phone. Please excuse my brevity.

On March 8, 2018 7:11:34 AM PST, lily li  wrote:
>Hi all,
>
>I ran the code:
>> s <- stack(replicate(2, raster(matrix(runif(100), 10
>> xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
>+  z1=runif(10), z2=runif(10))
>> levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
>+   layer(sp.points(xy, pch=ifelse(pts$z1 < 0.5, 2, 3), cex=2, col=1),
>columns=1) +
>+   layer(sp.points(xy, pch=ifelse(pts$z2 < 0.5, 2, 3), cex=2, col=1),
>columns=2)
>
>And got the error:
>Error in UseMethod("levelplot") :
>  no applicable method for 'levelplot' applied to an object of class
>"c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"
>
>what is the problem? Thanks.
>
>On Thu, Mar 8, 2018 at 12:07 AM, lily li  wrote:
>
>> Hi all,
>>
>> I'm trying to add single points with known coordinates to a level
>plot,
>> but could not find the proper answer. I got to know that layer()
>function
>> is good for this, but I don't know which package is related to this
>> function. The source is here:
>>
>https://stackoverflow.com/questions/28597149/add-xy-points-to-raster-map-
>> generated-by-levelplot
>>
>> but my question is a little different as I know the coordinates of
>the
>> single point, rather than a range. Thanks for any help you could
>provide.
>>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] add single points to a level plot

2018-03-08 Thread Eric Berger
You need to load the package 'rasterVis'

> library(rasterVis)

HTH,
Eric


On Thu, Mar 8, 2018 at 5:11 PM, lily li  wrote:

> Hi all,
>
> I ran the code:
> > s <- stack(replicate(2, raster(matrix(runif(100), 10
> > xy <- data.frame(coordinates(sampleRandom(s, 10, sp=TRUE)),
> +  z1=runif(10), z2=runif(10))
> > levelplot(s, margin=FALSE, at=seq(0, 1, 0.05)) +
> +   layer(sp.points(xy, pch=ifelse(pts$z1 < 0.5, 2, 3), cex=2, col=1),
> columns=1) +
> +   layer(sp.points(xy, pch=ifelse(pts$z2 < 0.5, 2, 3), cex=2, col=1),
> columns=2)
>
> And got the error:
> Error in UseMethod("levelplot") :
>   no applicable method for 'levelplot' applied to an object of class
> "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"
>
> what is the problem? Thanks.
>
> On Thu, Mar 8, 2018 at 12:07 AM, lily li  wrote:
>
> > Hi all,
> >
> > I'm trying to add single points with known coordinates to a level plot,
> > but could not find the proper answer. I got to know that layer() function
> > is good for this, but I don't know which package is related to this
> > function. The source is here:
> > https://stackoverflow.com/questions/28597149/add-xy-
> points-to-raster-map-
> > generated-by-levelplot
> >
> > but my question is a little different as I know the coordinates of the
> > single point, rather than a range. Thanks for any help you could provide.
> >
>
> [[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-es] exportar resultados a CSV

2018-03-08 Thread Xavier-Andoni Tibau Alberdi
Si usas R studio puedes pulsar sobre la variable, en el explorador de
variables en la parte derecha superior. Des de allí podras mirarlo bien,
sin necessidad de exportarlo a csv solo para explorarlo. Analogamente a
pulsar encima, puedes usar la función View(), que te dará el mismo
resultado.

Un saludo,

Xavier

——
*Deutsches Zentrum für Luft- und Raumfahrt* e.V. (DLR)
German Aerospace Center

Xavier-Andoni Tibau Alberdi | Scientific Staff
Institute of Data Science | Data Management and Analysis | Mälzerstraße 3 |
07745 Jena



2018-03-08 8:32 GMT+01:00 Yesica Pallavicini Fernandez 
:

> Hola,
> tengo dos dudas
> 1) he corrido una matriz de correlación con demasiadas variables y R no me
> muestra todos los resultados porque ha llegado a su máxima capacidad. ¿cómo
> puedo ver tdos los resultados?
>
> 2) Quisiera exportar los resultados a un CVS para poder verlos mejor ¿Se
> puede hacer?
>
> Gracias
> Yésica
>
> [[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] Correlacionar una variable con muchas a la vez

2018-03-08 Thread Yesica Pallavicini Fernandez
 Hola,
Estoy intentando correlacionar una sola variable con 52 mas
 ¿Sabéis cómo se puede automatizar la función?
Gracias
Yésica

Ya lo he sacado
cor(data)[,1]
Con esta función se correlaciona la primer variable con todas las demás del
arreglo de datos.

¿Cómo me puedo contestar a mi misma para que todos los veáis?
Gracias



El 8 de marzo de 2018, 8:51, Yesica Pallavicini Fernandez <
yesipa...@gmail.com> escribió:

> Hola,
> Estoy intentando correlacionar una sola variable con 52 mas
>  ¿Sabéis cómo se puede automatizar la función?
> Gracias
> Yésica
>
>

[[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] ver los resutados cuando son muy extensos y normalmente se cortan

2018-03-08 Thread Yesica Pallavicini Fernandez
Gracias Carlos y Xavy

Efectivamente, cuando la salida del resultado es muy grande y por defecto
se cortan y no los puedes ver, se puede usar el comando
options(max.print=9)


Saludos

[[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] exportar resultados a CSV

2018-03-08 Thread Carlos Ortega
Hola,


   - Puedes exportar cualquier variable a csv con la función "write()" que
   tiene múltiples parámetros para determinar el formato de salida, separador,
   etc.
   - Y sobre la primera pregunta, si R no te muestra todos los resultados
   es porque hay un límite de resultados que se pueden mostrar por pantalla.
   Esto lo puedes cambiar con "options()". Creo que por defecto son 1500
   líneas, pero es con esta función como puedes cambiar a lo que necesites.
  - Entiendo que no es que te esté generando un error o que R se quede
  colgado. Puede ocurrir si la matriz de la que quieres obtener las
  correlaciones es demasiado grande. Por tu siguiente pregunta en el foro
  parece que este no es el caso.

Gracias,
Carlos Ortega
www.qualityexcellence.es

El 8 de marzo de 2018, 8:32, Yesica Pallavicini Fernandez <
yesipa...@gmail.com> escribió:

> Hola,
> tengo dos dudas
> 1) he corrido una matriz de correlación con demasiadas variables y R no me
> muestra todos los resultados porque ha llegado a su máxima capacidad. ¿cómo
> puedo ver tdos los resultados?
>
> 2) Quisiera exportar los resultados a un CVS para poder verlos mejor ¿Se
> puede hacer?
>
> Gracias
> Yésica
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


Re: [R-es] Más filtrado de variables

2018-03-08 Thread jose luis via R-help-es
Bueno, finalmente lo resolví así. Creé una nueva variable ORDEN2 con un ifelse 
que me señalase los duplicados de clase y luego selecciono los de menor ORDEN. 
Pierdo algunos registros de  GRUPO porque solo tienen duplicados, pero esto 
estaba dentro de lo previsto.Gracias por la ayuda!


Datos%>% mutate(ORDEN2= ifelse(duplicated(CLASE),ORDEN==FALSE,ORDEN)) 
Datos2<-subset(Datos,!ORDEN2==FALSE)%>%
group_by(GRUPO) %>%
 slice(which.min(ORDEN2))
Datos2

Datos2
  grupo ordenclase orden2
1 A 1 CLASE-01  1
2 B 7 CLASE-04  7
3 E 1 CLASE-06  1
4 F 7 CLASE-05  7
5 G 1 CLASE-07  1
 

El Miércoles 7 de marzo de 2018 13:51, Isidro Hidalgo Arellano 
 escribió:
 

 #yiv2107649944 #yiv2107649944 -- _filtered #yiv2107649944 
{font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv2107649944 
{panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv2107649944 
{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv2107649944 
{panose-1:2 11 6 9 4 5 4 2 2 4;}#yiv2107649944 #yiv2107649944 
p.yiv2107649944MsoNormal, #yiv2107649944 li.yiv2107649944MsoNormal, 
#yiv2107649944 div.yiv2107649944MsoNormal 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv2107649944 a:link, 
#yiv2107649944 span.yiv2107649944MsoHyperlink 
{color:blue;text-decoration:underline;}#yiv2107649944 a:visited, #yiv2107649944 
span.yiv2107649944MsoHyperlinkFollowed 
{color:purple;text-decoration:underline;}#yiv2107649944 pre 
{margin:0cm;margin-bottom:.0001pt;font-size:10.0pt;}#yiv2107649944 
span.yiv2107649944HTMLconformatoprevioCar {}#yiv2107649944 
span.yiv2107649944EstiloCorreo19 {color:#1F497D;}#yiv2107649944 
span.yiv2107649944gghfmyibcpb {}#yiv2107649944 span.yiv2107649944gghfmyibcob 
{}#yiv2107649944 span.yiv2107649944EstiloCorreo22 
{color:#1F497D;}#yiv2107649944 .yiv2107649944MsoChpDefault {font-size:10.0pt;} 
_filtered #yiv2107649944 {margin:70.85pt 3.0cm 70.85pt 3.0cm;}#yiv2107649944 
div.yiv2107649944WordSection1 {}#yiv2107649944 Perdona. A ver ahora:  > datos   
GRUPO ORDEN    CLASE1  A 1 CLASE-012  A 2 CLASE-023  A 
5 CLASE-034  B 1 CLASE-015  B 2 CLASE-026  B 5 
CLASE-037  B 7 CLASE-048  C 2 CLASE-029  C 5 CLASE-0310 
    C 7 CLASE-0411 D 5 CLASE-0312 D 7 CLASE-0413 E 
1 CLASE-0614 F 2 CLASE-0215 F 5 CLASE-0316 F 7 
CLASE-0517 G 1 CLASE-07> clases = attr(table(datos$CLASE), "names")> 
grupos = attr(table(datos$GRUPO), "names")> datosFinal = datos[1,]> clases = 
clases[-1]> grupos = grupos[-1]> for (g in grupos){+  selec = 
datos[datos$GRUPO ==g & datos$CLASE %in% clases,]+  selec = selec[1,]+  
clases = clases[clases != selec$CLASE]+  datosFinal = rbind(datosFinal, 
selec)+ }> datosFinal   GRUPO ORDEN    CLASE1  A 1 CLASE-015  B 
2 CLASE-029  C 5 CLASE-0312 D 7 CLASE-0413 E 1 
CLASE-0616     F 7 CLASE-0517 G 1 CLASE-07    Un saludo  Isidro 
Hidalgo ArellanoObservatorio del Mercado de TrabajoConsejería de Economía, 
Empresas y Empleohttp://www.castillalamancha.es/    De: Isidro Hidalgo Arellano 
[mailto:ihida...@jccm.es] 
Enviado el: miércoles, 07 de marzo de 2018 13:00
Para: 'jose luis' ; 'r-help-es@r-project.org' 

Asunto: RE: [R-es] Más filtrado de variables  Una forma sería ésta:  > datos   
GRUPO ORDEN    CLASE1  A 1 CLASE-012  A 2 CLASE-023  A 
5 CLASE-034  B 1 CLASE-015  B 2 CLASE-026  B 5 
CLASE-037  B 7 CLASE-048  C 2 CLASE-029  C 5 CLASE-0310 
    C 7 CLASE-0411 D 5 CLASE-0312 D 7 CLASE-0413 E 
1 CLASE-0614 F 2 CLASE-0215 F 5 CLASE-0316 F 7 
CLASE-0517 G 1 CLASE-07> clases = attr(table(datos$CLASE), "names")> 
grupos = attr(table(datos$GRUPO), "names")> datosFinal = datos[1,]> clases = 
clases[-1]> grupos = grupos[-1]> for (g in grupos){+  selec = 
datos[datos$GRUPO ==g & datos$CLASE %in% clases,]+  selec = selec[1,]+  
clases = clases[clases != selec$CLASE]+  datosFinal = rbind(datosFinal, 
selec)+ }> datosFinal   GRUPO ORDEN    CLASE1  A 1 CLASE-015  B 
2 CLASE-029  C 5 CLASE-0312 D 7 CLASE-0413 E 1 
CLASE-0616 F 7 CLASE-0517 G 1 CLASE-07  Básicamente es montar 
un cola con las clases para ir quitándole el valor que va saliendo en cada 
grupo.  Un saludo  Isidro Hidalgo ArellanoObservatorio del Mercado de 
TrabajoConsejería de Economía, Empresas y Empleohttp://www.castillalamancha.es/ 
     De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de jose 
luis via R-help-es
Enviado el: miércoles, 07 de marzo de 2018 12:01
Para: jose luis ; Lista R. 

Re: [R-es] Imputar NA a SQL Server

2018-03-08 Thread Javier Marcuzzi
Estimado Jesús Para Fernández

Pruebe lo siguiente:

str_replace_all(values, "'NA'", "NULL")



El 8 de marzo de 2018, 17:38, Jesús Para Fernández <
j.para.fernan...@hotmail.com> escribió:

> Buenas,
>
> Quiero meter NULL en algunos valores al hacer un insert en una base ded
> datos SQL Server, pero no me reconoce NA, por lo que no se como meterlos...
>
> ¿Alguno sabe como podria hacerse? La opción de no meter el valor no es
> válida porque tengo que meter varias columans y los NA se pueden dar en
> cualqueira de ellas...
>
> Gracias
> Jesús
>
> [[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] ver los resutados cuando son muy extensos y normalmente se cortan

2018-03-08 Thread Carlos Ortega
Mejor que volcarlos a la consola... utiliza este paquete para visualizar
las relaciones..

https://cloud.r-project.org/web/packages/corrr/index.html

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 8 de marzo de 2018, 10:22, Yesica Pallavicini Fernandez <
yesipa...@gmail.com> escribió:

> Gracias Carlos y Xavy
>
> Efectivamente, cuando la salida del resultado es muy grande y por defecto
> se cortan y no los puedes ver, se puede usar el comando
> options(max.print=9)
>
>
> Saludos
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


Re: [R-es] ver los resutados cuando son muy extensos y normalmente se cortan

2018-03-08 Thread Javier Marcuzzi
Estimada Yesica Pallavicini Fernandez

Como ya le escribieron, es un problema relacionado a cuánto se imprime en
pantalla, en mi caso personal cuándo hay muchos datos me resulta simple
tenerlos en una base de datos, aunque hay otras alternativas más modernas,
la que yo aprendí hace mucho tiempo es sqldf, tiene la ventaja de lo simple
para filtrar datos usando SQL (sqlite) todo dentro de R.

Que hacer con miles de resultados? Solo hay una respuesta, utilizar una
herramienta para tratarlos, filtrarlos, etc.

Javier Rubén Marcuzzi

El 8 de marzo de 2018, 6:22, Yesica Pallavicini Fernandez <
yesipa...@gmail.com> escribió:

> Gracias Carlos y Xavy
>
> Efectivamente, cuando la salida del resultado es muy grande y por defecto
> se cortan y no los puedes ver, se puede usar el comando
> options(max.print=9)
>
>
> Saludos
>
> [[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: [ESS] Developing R packages under ESS

2018-03-08 Thread Ross Boylan
On Thu, Mar 08, 2018 at 03:29:14PM +, Sparapani, Rodney wrote:
> Hi Ross:
> I agree with Rich and Vitalie.  This just works out of the box: no .emacs 
> fiddling.
> Perhaps, you are tripping over the recent tightening of the interface.  The 
> last bullet point
> in the New features section of 17.11 states…
> 
>   *   ESS[R] Namespaced evaluation is now automatically enabled only in the 
> R/directory. This way ESS will not attempt to update function definitions 
> from a package if you are working from e.g. a test file.
> http://ess.r-project.org/Manual/ess.html#New-features

Hmm, before I got the latest ESS updates, when I did code evaluation
commands in the .Rnw (vignette) file ESS evaluated the code in R.  Now, when
I did C-c C-r, it tried to build some tex files.  I think I was using
C-c C-n before, so I'm not sure if this is a change.  But it sounds as if
it might be related to the change you highlighted.

BTW, my intention was that the vignette code is evaluated at global scope.

> 
> So, are you opening source code from the R subdirectory of your package and
> submitting them with C-c C-p, C-c C-r, C-c C-b, etc.?

As reported in an earlier message (but after you asked that question),
C-c C-p seems to work, but C-c C-l does not.

> That is what this feature
> provides with respect to R package development and it is awesome!
> --
> Rodney Sparapani, PhD
> Assistant Professor of Biostatistics
> Medical College of Wisconsin, Milwaukee

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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Ross Boylan
On Wed, Mar 07, 2018 at 09:55:51PM -0500, Richard M. Heiberger wrote:
> My guess is that starting from outside the package misled ESS.
> Try this sequence.
> 
> library(mypackage)
> ## then open the R source in directory mypackage/R/
> ## modify the R files and C-c C-c revised functions.  They will go
> inside the namespace.
> 
That works!  Yay!  In particular, no complaints about a locked namespace.

However, doing C-c C-l does not work; if I modify the code and read in
the whole file, the old code seems to still be in force.

The particular way I found this out was that I inadvertently installed
the package with code that had a breakpoint in it.  When I removed the
breakpoint in the package source directory and did C-c C-l it remained
in force.  When I did C-c C-c on the function that had the breakpoint,
the breakpoint stopped firing.

Ross

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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Ross Boylan
On Thu, Mar 08, 2018 at 04:22:04PM +0100, Vitalie Spinu wrote:
> 
> 
> >> On Wed, Mar 07 2018 18:29, Ross Boylan wrote:
> 
> > The file I opened initially, the one that sources all the others, is above 
> > the
> > package directory.  It sources files under the package directory.  When I
> > modified one of them I used C-c C-t C-s to disable the namespace before I 
> > did
> > C-c C-l.  This was on the theory that the source() commands earlier stuck
> > everything in the global namespace.
> 
> This sounds too complicated.

I was only doing it because of namespace locked errors, which now seem
to be gone.  I was trying to do everything in the global namespace.

> You don't need to source anything or use C-c C-t
> C-s as all ess eval commmands are executed automatically in the package
> directory. Even if the package is installed from CRAN you shouldn't see
> "namespaced locked" error. Just start R inside package directory and start
> eval-ing stuff as you normally do.

Do you mean that R must be launched from inside the package directory?
Or at least have the current working directory inside the package?  I
haven't been doing that.  ESS has seemed aware when a particular file
was in a package regardless of where R is running (I was using C-c C-t
C-s to put things in the global namespace; using the package namespace
was automatic).

> 
> As to the devtools integration, it's a breeze - C-c C-w i or C-c C-w l are
> pretty fast, surely not slow enough to interfere with the workflow.
> 
I haven't been using devtools, partly (as I recall) because they force
certain other tool choices.  But I might have another look.

Ross

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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Boylan, Ross
I just wanted to evaluate some of the R code in the .Rnw file in my main R 
process, at global scope.  But ESS seemed to think C-c C-r meant to do 
something else (in that file), like sweaving, instead.  It may have tried just 
to do that on the highlighted region; I didn't investigate except to note it 
failed.

Ross


From: Sparapani, Rodney 
Sent: Thursday, March 8, 2018 11:21:57 AM
To: Boylan, Ross
Cc: ess-help
Subject: Re: [ESS] Developing R packages under ESS

Hi Ross:

Oh, you mean Sweaving and knitting?  That does work but it is a little
flaky at the moment.  There is a recent thread on ess-help about some
bugs in that code, however, no resolution as of yet.  Stay tuned!

--
Rodney Sparapani, PhD
Assistant Professor of Biostatistics
Medical College of Wisconsin, Milwaukee
-Original Message-
From: Ross Boylan 
Date: Thursday, March 8, 2018 at 1:14 PM
To: Rodney Sparapani 
Cc: ess-help , "Boylan, Ross" 
Subject: Re: [ESS] Developing R packages under ESS

Hmm, before I got the latest ESS updates, when I did code evaluation
commands in the .Rnw (vignette) file ESS evaluated the code in R.  Now, when
I did C-c C-r, it tried to build some tex files.  I think I was using
C-c C-n before, so I'm not sure if this is a change.  But it sounds as if
it might be related to the change you highlighted.

BTW, my intention was that the vignette code is evaluated at global scope.



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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Vitalie Spinu

>> Just start R inside package directory and start eval-ing stuff as you
>> normally do.

> Do you mean that R must be launched from inside the package directory?

I was imprecise. No, R process could be run from anywhere. It's that
ess-r-package-mode is active only within the package directory.

> I haven't been using devtools,

It's an implementation detail. We are relying on devtools because it's
convenient. For most commands (install, check etc) we could have done
without.

 Vitalie

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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Vitalie Spinu


>> On Wed, Mar 07 2018 18:29, Ross Boylan wrote:

> The file I opened initially, the one that sources all the others, is above the
> package directory.  It sources files under the package directory.  When I
> modified one of them I used C-c C-t C-s to disable the namespace before I did
> C-c C-l.  This was on the theory that the source() commands earlier stuck
> everything in the global namespace.

This sounds too complicated. You don't need to source anything or use C-c C-t
C-s as all ess eval commmands are executed automatically in the package
directory. Even if the package is installed from CRAN you shouldn't see
"namespaced locked" error. Just start R inside package directory and start
eval-ing stuff as you normally do.

As to the devtools integration, it's a breeze - C-c C-w i or C-c C-w l are
pretty fast, surely not slow enough to interfere with the workflow.

  Vitalie

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


Re: [ESS] Developing R packages under ESS

2018-03-08 Thread Sparapani, Rodney
Hi Ross:
I agree with Rich and Vitalie.  This just works out of the box: no .emacs 
fiddling.
Perhaps, you are tripping over the recent tightening of the interface.  The 
last bullet point
in the New features section of 17.11 states…

  *   ESS[R] Namespaced evaluation is now automatically enabled only in the 
R/directory. This way ESS will not attempt to update function definitions from 
a package if you are working from e.g. a test file.
http://ess.r-project.org/Manual/ess.html#New-features

So, are you opening source code from the R subdirectory of your package and
submitting them with C-c C-p, C-c C-r, C-c C-b, etc.?  That is what this feature
provides with respect to R package development and it is awesome!
--
Rodney Sparapani, PhD
Assistant Professor of Biostatistics
Medical College of Wisconsin, Milwaukee
__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help