Re: [R-es] Subset dentro de un for

2018-12-12 Thread Manuel Mendoza
Si, es lo primero que pensé, pero lo he comprobado y las 20 utilizadas  
para hacer el gradiente son numéricas. De hecho, si las pongo con su  
nombre, en vez de  get(GT[i]), me hace bien el mapa.



Quoting Marcelino De La Cruz Rot :


Ese error suena a que alguna de las variables fuese no numérica (factor
o character).


El 12/12/2018 a las 19:32, Manuel Mendoza escribió:


Gracias Marcelino. Si, (i in 1:length(GT)), lo he utilizado mil veces,
pero se me sigue olvidando de una vez a otra. Lo iba a mirar, pero me
centré primero en que me hiciera bien el mapa.

He probado el for y me da este error:

Error in aes(x = lon, y = lat, color = get(GT[i]), size = 2) +
scale_colour_gradient(low = ("white"),  :
  non-numeric argument to binary operator




Quoting Marcelino De La Cruz Rot :


Ten cuidado, porque empiezas el for como:

for(i in GT)

y luego el color del aes lo defines como:

color= GT[i]

Lo que, por ejemplo para el primer caso, se traduciría  en GT["var1"],
que, a no ser que GT tenga names , debería dar un error.

Yo creo que quieres decir

for(i in 1:length(GT))

...
color=get(GT[i])


El 12/12/2018 a las 18:21, Manuel Mendoza escribió:


Gracias a los tres, Raúl, Marcelino y Carlos.

Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente
preguntaba, y funciona, pero ahora tengo problemas con el for, por lo
que probablemente recurra al eval parse de Raúl o Carlos, que ya
tienen el for. Aún así, lo intento 1º con el get.

Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago
un ggplot cuyo color es = a la variable que condiciona el subset, y no
funciona poniendo GT[i] (como se ve abajo). Pretendo que me haga 20
mapas, cada uno de acuerdo a una de las 20 variables de GT.

GT<- c("var1","var2", … "var20")

for(i in GT) {

df2<-subset(df1, subset=get(GT[i])>0)

windows();print(ggplot(legend=FALSE)+geom_path( data=world,
aes(x=long, y=lat,group=group))+
theme(panel.background=element_blank())+theme(panel.grid.major =
element_blank())+
    theme(panel.grid.minor =
element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+

    theme(axis.ticks = element_blank())+xlab("") + ylab("")+
    geom_point(data=df2,aes(x=lon,y=lat,

    color= GT[i],size=2) +

scale_colour_gradient(low=("white"),high=("red"),guide="colourbar",limits=c(0,max))+

    geom_path(data=map_data('world'), aes(x=long,
y=lat,group=group))+
    labs(title =  paste("5026 Minimum number of IFd species to go
extinct"

}








Quoting Carlos Ortega :


Esta es una forma...


for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
+   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
+   print(res_ult)
+ }
[1] "Ozone"
[1] 77.34862
[1] "Solar.R"
[1] 71.85294

Y otra forma à la dplyr...:


library(rlang)
for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   res_ult <- airquality %>%
+ filter(!!sym(i) < 100) %>%
+ summarize(Media = mean(Temp, na.rm = TRUE))
+   print(res_ult)
+ }
[1] "Ozone"
 Media
1 77.34862
[1] "Solar.R"
 Media
1 71.85294

Saludos,
Carlos Ortega
www.qualityexcellence.es



El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza
()
escribió:


Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
un subset con el que se queda con las muestras para la que cierta
variable es positiva.

Si hago esto, sale bien:

df2<-subset(df, subset = var1>0)


Pero he probado así (y de no sé cuantas formas más), antes de
hacer el
for, y no sale:

GT<- c("var1","var2", … )

df2<-subset(df, subset=(GT[1]>0))

Gracias,
Manuel


























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
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





--
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España





--
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España



--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R-es] Donde obtener tablas de datos ejemplo

2018-12-12 Thread Jorge I Velez
?cor

El El mié, 12 de dic. de 2018 a las 3:51 p. m., jorge della gaspera <
jara...@gmail.com> escribió:

> Buenas tardes, donde puedo encontrar tablas de datos para trabajar con R
> las funciones de correlación de variables.
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
-- 
Sent from my phone. Please excuse my brevity and misspelling.

[[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] Donde obtener tablas de datos ejemplo

2018-12-12 Thread jorge della gaspera
Buenas tardes, donde puedo encontrar tablas de datos para trabajar con R
las funciones de correlación de variables.

[[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] Subset dentro de un for

2018-12-12 Thread Marcelino De La Cruz Rot
Ese error suena a que alguna de las variables fuese no numérica (factor 
o character).


El 12/12/2018 a las 19:32, Manuel Mendoza escribió:
>
> Gracias Marcelino. Si, (i in 1:length(GT)), lo he utilizado mil veces, 
> pero se me sigue olvidando de una vez a otra. Lo iba a mirar, pero me 
> centré primero en que me hiciera bien el mapa.
>
> He probado el for y me da este error:
>
> Error in aes(x = lon, y = lat, color = get(GT[i]), size = 2) + 
> scale_colour_gradient(low = ("white"),  :
>   non-numeric argument to binary operator
>
>
>
>
> Quoting Marcelino De La Cruz Rot :
>
>> Ten cuidado, porque empiezas el for como:
>>
>> for(i in GT)
>>
>> y luego el color del aes lo defines como:
>>
>> color= GT[i]
>>
>> Lo que, por ejemplo para el primer caso, se traduciría  en GT["var1"],
>> que, a no ser que GT tenga names , debería dar un error.
>>
>> Yo creo que quieres decir
>>
>> for(i in 1:length(GT))
>>
>> ...
>> color=get(GT[i])
>>
>>
>> El 12/12/2018 a las 18:21, Manuel Mendoza escribió:
>>>
>>> Gracias a los tres, Raúl, Marcelino y Carlos.
>>>
>>> Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente
>>> preguntaba, y funciona, pero ahora tengo problemas con el for, por lo
>>> que probablemente recurra al eval parse de Raúl o Carlos, que ya
>>> tienen el for. Aún así, lo intento 1º con el get.
>>>
>>> Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago
>>> un ggplot cuyo color es = a la variable que condiciona el subset, y no
>>> funciona poniendo GT[i] (como se ve abajo). Pretendo que me haga 20
>>> mapas, cada uno de acuerdo a una de las 20 variables de GT.
>>>
>>> GT<- c("var1","var2", … "var20")
>>>
>>> for(i in GT) {
>>>
>>> df2<-subset(df1, subset=get(GT[i])>0)
>>>
>>> windows();print(ggplot(legend=FALSE)+geom_path( data=world,
>>> aes(x=long, y=lat,group=group))+
>>> theme(panel.background=element_blank())+theme(panel.grid.major =
>>> element_blank())+
>>>     theme(panel.grid.minor =
>>> element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
>>>  
>>>
>>>     theme(axis.ticks = element_blank())+xlab("") + ylab("")+
>>>     geom_point(data=df2,aes(x=lon,y=lat,
>>>
>>>     color= GT[i],size=2) +
>>>
>>> scale_colour_gradient(low=("white"),high=("red"),guide="colourbar",limits=c(0,max))+
>>>  
>>>
>>>     geom_path(data=map_data('world'), aes(x=long,
>>> y=lat,group=group))+
>>>     labs(title =  paste("5026 Minimum number of IFd species to go
>>> extinct"
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Quoting Carlos Ortega :
>>>
 Esta es una forma...

> for(i in c('Ozone', 'Solar.R')) {
 +   print(i)
 +   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
 +   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
 +   print(res_ult)
 + }
 [1] "Ozone"
 [1] 77.34862
 [1] "Solar.R"
 [1] 71.85294

 Y otra forma à la dplyr...:

> library(rlang)
> for(i in c('Ozone', 'Solar.R')) {
 +   print(i)
 +   res_ult <- airquality %>%
 + filter(!!sym(i) < 100) %>%
 + summarize(Media = mean(Temp, na.rm = TRUE))
 +   print(res_ult)
 + }
 [1] "Ozone"
  Media
 1 77.34862
 [1] "Solar.R"
  Media
 1 71.85294

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es



 El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza
 ()
 escribió:

> Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
> un subset con el que se queda con las muestras para la que cierta
> variable es positiva.
>
> Si hago esto, sale bien:
>
> df2<-subset(df, subset = var1>0)
>
>
> Pero he probado así (y de no sé cuantas formas más), antes de 
> hacer el
> for, y no sale:
>
> GT<- c("var1","var2", … )
>
> df2<-subset(df, subset=(GT[1]>0))
>
> Gracias,
> Manuel
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> .
>
> -- 
> Dr Manuel Mendoza
> Department of Biogeography and Global Change
> National Museum of Natural Science (MNCN)
> Spanish Scientific Council (CSIC)
> C/ Serrano 115bis, 28006 MADRID
> Spain
>
> ___
> 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
>>>
>>>
>>
>> -- 
>> Marcelino de la Cruz Rot
>> Depto. de Biología y Geología
>> Física y Química Inorgánica
>> Universidad Rey Juan Carlos
>> Móstoles España
>
>

-- 
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-help-es mailing list
R-help-es@r-project.org

Re: [R] R and factorytalk historian

2018-12-12 Thread Hasan Diwan
Could you not script Excel to export automatically to CSV --
https://stackoverflow.com/a/10803229/783412, for example -- and import the
result into R? -- H

On Wed, 12 Dec 2018 at 07:17, PIKAL Petr  wrote:

> Hi
>
> Well, the final answer is that data from FTH could be transfered to other
> software **only** through Excel.
>
> Regarding RetroEncabulator, readings could be enahanced by extensive and
> elaborate use of nanoputian molecules chained together.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: Viechtbauer, Wolfgang (SP)
> > 
> > Sent: Wednesday, December 12, 2018 11:21 AM
> > To: PIKAL Petr ; r-help 
> > Subject: RE: R and factorytalk historian
> >
> > Dear Petr,
> >
> > Sorry, no experience with the FTH, but related to this, has anybody
> gotten R to
> > interface nicely with the Retro Encabulator, providing live read outs of
> the
> > synchronizing cardinal grammeters?
> >
> > (my apologies, I just couldn't resist)
> >
> > Best,
> > Wolfgang
> >
> > >-Original Message-
> > >From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL
> > >Petr
> > >Sent: Tuesday, 11 December, 2018 16:09
> > >To: r-help
> > >Subject: [R] R and factorytalk historian
> > >
> > >Hallo all
> > >
> > >Does anybody know if R could be used directly with FactoryTalk
> > >Historian programme from Rockwell automation.
> > >
> > >It is probably possible to use Excel as interface but I would prefer
> > >not to.
> > >
> > >Best regards.
> > >
> > >Petr Pikal
> 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.
>


-- 
OpenPGP:
https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
If you wish to request my time, please do so using
*bit.ly/hd1AppointmentRequest
*.
Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
*.

Sent
from my mobile device
Envoye de mon portable

[[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] Width of a text

2018-12-12 Thread Duncan Murdoch

On 12/12/2018 6:55 AM, Christofer Bogaso wrote:

Hi,

In HTML there is a way to measure the width of a Text before printing it on
screen as in https://www.w3schools.com/tags/canvas_measuretext.asp

In R we have nchar() function which just measures the number of letters in
a Text, but I wonder if we can measure the width of text as well.

I have a shiny app where I need to print a text in an Area onto the screen
which has a specific width, so some the texts are not showing within that
area (overflowing), where some are though all of them have the equal number
of letters.


Since Shiny displays in a web browser, it will be up to the web browser 
to measure the text.  (How would R know the font, magnification, etc?) 
You'll have to do this in Javascript.


If your R code needs to know the answer, Shiny provides a way to send 
the result back to R.  It's not trivial, but you can read how to do it 
here:  .


Duncan Murdoch



Thanks for any input.

[[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-es] Subset dentro de un for

2018-12-12 Thread Manuel Mendoza



Gracias Marcelino. Si, (i in 1:length(GT)), lo he utilizado mil veces,  
pero se me sigue olvidando de una vez a otra. Lo iba a mirar, pero me  
centré primero en que me hiciera bien el mapa.


He probado el for y me da este error:

Error in aes(x = lon, y = lat, color = get(GT[i]), size = 2) +  
scale_colour_gradient(low = ("white"),  :

  non-numeric argument to binary operator




Quoting Marcelino De La Cruz Rot :


Ten cuidado, porque empiezas el for como:

for(i in GT)

y luego el color del aes lo defines como:

color= GT[i]

Lo que, por ejemplo para el primer caso, se traduciría  en GT["var1"],
que, a no ser que GT tenga names , debería dar un error.

Yo creo que quieres decir

for(i in 1:length(GT))

...
color=get(GT[i])


El 12/12/2018 a las 18:21, Manuel Mendoza escribió:


Gracias a los tres, Raúl, Marcelino y Carlos.

Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente
preguntaba, y funciona, pero ahora tengo problemas con el for, por lo
que probablemente recurra al eval parse de Raúl o Carlos, que ya
tienen el for. Aún así, lo intento 1º con el get.

Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago
un ggplot cuyo color es = a la variable que condiciona el subset, y no
funciona poniendo GT[i] (como se ve abajo). Pretendo que me haga 20
mapas, cada uno de acuerdo a una de las 20 variables de GT.

GT<- c("var1","var2", … "var20")

for(i in GT) {

df2<-subset(df1, subset=get(GT[i])>0)

windows();print(ggplot(legend=FALSE)+geom_path( data=world,
aes(x=long, y=lat,group=group))+
theme(panel.background=element_blank())+theme(panel.grid.major =
element_blank())+
    theme(panel.grid.minor =
element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
    theme(axis.ticks = element_blank())+xlab("") + ylab("")+
    geom_point(data=df2,aes(x=lon,y=lat,

    color= GT[i],size=2) +

scale_colour_gradient(low=("white"),high=("red"),guide="colourbar",limits=c(0,max))+
    geom_path(data=map_data('world'), aes(x=long,
y=lat,group=group))+
    labs(title =  paste("5026 Minimum number of IFd species to go
extinct"

}








Quoting Carlos Ortega :


Esta es una forma...


for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
+   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
+   print(res_ult)
+ }
[1] "Ozone"
[1] 77.34862
[1] "Solar.R"
[1] 71.85294

Y otra forma à la dplyr...:


library(rlang)
for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   res_ult <- airquality %>%
+ filter(!!sym(i) < 100) %>%
+ summarize(Media = mean(Temp, na.rm = TRUE))
+   print(res_ult)
+ }
[1] "Ozone"
 Media
1 77.34862
[1] "Solar.R"
 Media
1 71.85294

Saludos,
Carlos Ortega
www.qualityexcellence.es



El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza
()
escribió:


Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
un subset con el que se queda con las muestras para la que cierta
variable es positiva.

Si hago esto, sale bien:

df2<-subset(df, subset = var1>0)


Pero he probado así (y de no sé cuantas formas más), antes de hacer el
for, y no sale:

GT<- c("var1","var2", … )

df2<-subset(df, subset=(GT[1]>0))

Gracias,
Manuel


























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
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





--
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España



--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R-es] Subset dentro de un for

2018-12-12 Thread Marcelino De La Cruz Rot


Ten cuidado, porque empiezas el for como:

for(i in GT)

y luego el color del aes lo defines como:

color= GT[i]

Lo que, por ejemplo para el primer caso, se traduciría  en GT["var1"], 
que, a no ser que GT tenga names , debería dar un error.

Yo creo que quieres decir

for(i in 1:length(GT))

...
color=get(GT[i])


El 12/12/2018 a las 18:21, Manuel Mendoza escribió:
>
> Gracias a los tres, Raúl, Marcelino y Carlos.
>
> Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente 
> preguntaba, y funciona, pero ahora tengo problemas con el for, por lo 
> que probablemente recurra al eval parse de Raúl o Carlos, que ya 
> tienen el for. Aún así, lo intento 1º con el get.
>
> Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago 
> un ggplot cuyo color es = a la variable que condiciona el subset, y no 
> funciona poniendo GT[i] (como se ve abajo). Pretendo que me haga 20 
> mapas, cada uno de acuerdo a una de las 20 variables de GT.
>
> GT<- c("var1","var2", … "var20")
>
> for(i in GT) {
>
> df2<-subset(df1, subset=get(GT[i])>0)
>
> windows();print(ggplot(legend=FALSE)+geom_path( data=world, 
> aes(x=long, y=lat,group=group))+
> theme(panel.background=element_blank())+theme(panel.grid.major = 
> element_blank())+
>     theme(panel.grid.minor = 
> element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+
>     theme(axis.ticks = element_blank())+xlab("") + ylab("")+
>     geom_point(data=df2,aes(x=lon,y=lat,
>
>     color= GT[i],size=2) +
>
> scale_colour_gradient(low=("white"),high=("red"),guide="colourbar",limits=c(0,max))+
>     geom_path(data=map_data('world'), aes(x=long, 
> y=lat,group=group))+
>     labs(title =  paste("5026 Minimum number of IFd species to go 
> extinct"
>
> }
>
>
>
>
>
>
>
>
> Quoting Carlos Ortega :
>
>> Esta es una forma...
>>
>>> for(i in c('Ozone', 'Solar.R')) {
>> +   print(i)
>> +   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
>> +   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
>> +   print(res_ult)
>> + }
>> [1] "Ozone"
>> [1] 77.34862
>> [1] "Solar.R"
>> [1] 71.85294
>>
>> Y otra forma à la dplyr...:
>>
>>> library(rlang)
>>> for(i in c('Ozone', 'Solar.R')) {
>> +   print(i)
>> +   res_ult <- airquality %>%
>> + filter(!!sym(i) < 100) %>%
>> + summarize(Media = mean(Temp, na.rm = TRUE))
>> +   print(res_ult)
>> + }
>> [1] "Ozone"
>>  Media
>> 1 77.34862
>> [1] "Solar.R"
>>  Media
>> 1 71.85294
>>
>> Saludos,
>> Carlos Ortega
>> www.qualityexcellence.es
>>
>>
>>
>> El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza 
>> ()
>> escribió:
>>
>>> Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
>>> un subset con el que se queda con las muestras para la que cierta
>>> variable es positiva.
>>>
>>> Si hago esto, sale bien:
>>>
>>> df2<-subset(df, subset = var1>0)
>>>
>>>
>>> Pero he probado así (y de no sé cuantas formas más), antes de hacer el
>>> for, y no sale:
>>>
>>> GT<- c("var1","var2", … )
>>>
>>> df2<-subset(df, subset=(GT[1]>0))
>>>
>>> Gracias,
>>> Manuel
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> .
>>>
>>> -- 
>>> Dr Manuel Mendoza
>>> Department of Biogeography and Global Change
>>> National Museum of Natural Science (MNCN)
>>> Spanish Scientific Council (CSIC)
>>> C/ Serrano 115bis, 28006 MADRID
>>> Spain
>>>
>>> ___
>>> 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
>
>

-- 
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

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


Re: [R-es] Subset dentro de un for

2018-12-12 Thread Manuel Mendoza



Gracias a los tres, Raúl, Marcelino y Carlos.

Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente  
preguntaba, y funciona, pero ahora tengo problemas con el for, por lo  
que probablemente recurra al eval parse de Raúl o Carlos, que ya  
tienen el for. Aún así, lo intento 1º con el get.


Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago  
un ggplot cuyo color es = a la variable que condiciona el subset, y no  
funciona poniendo GT[i] (como se ve abajo). Pretendo que me haga 20  
mapas, cada uno de acuerdo a una de las 20 variables de GT.


GT<- c("var1","var2", … "var20")

for(i in GT) {

df2<-subset(df1, subset=get(GT[i])>0)

windows();print(ggplot(legend=FALSE)+geom_path( data=world,  
aes(x=long, y=lat,group=group))+
 
theme(panel.background=element_blank())+theme(panel.grid.major =  
element_blank())+
theme(panel.grid.minor =  
element_blank())+theme(axis.text.x=element_blank(),axis.text.y=element_blank())+

theme(axis.ticks = element_blank())+xlab("") + ylab("")+
geom_point(data=df2,aes(x=lon,y=lat,

color= GT[i],size=2) +

 
scale_colour_gradient(low=("white"),high=("red"),guide="colourbar",limits=c(0,max))+

geom_path(data=map_data('world'), aes(x=long, y=lat,group=group))+
labs(title =  paste("5026 Minimum number of IFd species to go  
extinct"


}








Quoting Carlos Ortega :


Esta es una forma...


for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
+   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
+   print(res_ult)
+ }
[1] "Ozone"
[1] 77.34862
[1] "Solar.R"
[1] 71.85294

Y otra forma à la dplyr...:


library(rlang)
for(i in c('Ozone', 'Solar.R')) {

+   print(i)
+   res_ult <- airquality %>%
+ filter(!!sym(i) < 100) %>%
+ summarize(Media = mean(Temp, na.rm = TRUE))
+   print(res_ult)
+ }
[1] "Ozone"
 Media
1 77.34862
[1] "Solar.R"
 Media
1 71.85294

Saludos,
Carlos Ortega
www.qualityexcellence.es



El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza ()
escribió:


Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
un subset con el que se queda con las muestras para la que cierta
variable es positiva.

Si hago esto, sale bien:

df2<-subset(df, subset = var1>0)


Pero he probado así (y de no sé cuantas formas más), antes de hacer el
for, y no sale:

GT<- c("var1","var2", … )

df2<-subset(df, subset=(GT[1]>0))

Gracias,
Manuel


























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

___
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



--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R] R plot split screen in uneven panels

2018-12-12 Thread Bert Gunter
Incidentally, here is another way to do what (I think) you asked using
layout():

m <- matrix(c(1,2,2), nrow =1)
layout(m)
plot(1:10, type = "p",main = "The First Plot")
plot(10:1, type = "l", main ="The Second Plot")

On my device, the plots use different size fonts, point sizes, etc. and so
aesthetically differ. I do not know why and am too lazy to delve into the
code.

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 Wed, Dec 12, 2018 at 8:39 AM Bert Gunter  wrote:

> ?layout
> Please read the Help file **carefully** and work through the **examples**.
> I cannot explain better than they.
> Here is code using layout() that I think does what you want:
>
> m <- matrix(1:2, nrow =1)
> layout(m, widths = c(1,2))
> plot(1:10, type = "p",main = "The First Plot")
> plot(10:1, type = "l", main ="The Second Plot")
>
> Note that both the lattice package and ggplot2 can also do this sort of
> thing much more flexibly(and therefore requiring more effort to learn).
>
> Cheers,
> Bert
>
>
> 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 Wed, Dec 12, 2018 at 7:19 AM Luigi Marongiu 
> wrote:
>
>> Dear all,
>> I would like to draw two plots in the same device so that there is a
>> single row and two columns, with the first column being 1/3 of the
>> device's width.
>> I am creating a PNG object with width = 30 and height = 20 cm.
>> I know that I should use split.screen or layout but I am lost with the
>> matrix to pass to the functions.
>> For istance, I tried:
>> # distance in arbitrary units (so let's say cm) from of corners
>> # left, right, bottom, and top counting from bottom left corner
>> # that is first panel has the bottom right corner 20 cm from the bottom
>> left?
>> > m = matrix(c(0,20,40,0, 20,60,40,0), byrow=T, ncol=4)
>> > m
>>  [,1] [,2] [,3] [,4]
>> [1,]0   20   400
>> [2,]   20   60   400
>> > split.screen(m)
>> Error in par(split.screens[[cur.screen]]) :
>>   invalid value specified for graphical parameter "fig"
>> > m[1,]
>> [1]  0 20 40  0
>> > split.screen(m[1,])
>> Error in split.screen(m[1, ]) : 'figs' must specify at least one screen
>>
>> What should be the syntax for this task?
>>
>> --
>> 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.
>>
>

[[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] R plot split screen in uneven panels

2018-12-12 Thread Franklin Bretschneider
Dear Luigi Marongiu,


Re: 

> Dear all,
> I would like to draw two plots in the same device so that there is a
> single row and two columns, with the first column being 1/3 of the
> device's width.
> I am creating a PNG object with width = 30 and height = 20 cm.
> I know that I should use split.screen or layout but I am lost with the
> matrix to pass to the functions.
> For istance, I tried:
> # distance in arbitrary units (so let's say cm) from of corners
> # left, right, bottom, and top counting from bottom left corner
> # that is first panel has the bottom right corner 20 cm from the bottom left?
>> m = matrix(c(0,20,40,0, 20,60,40,0), byrow=T, ncol=4)
>> m
> [,1] [,2] [,3] [,4]
> [1,]0   20   400
> [2,]   20   60   400
>> split.screen(m)
> Error in par(split.screens[[cur.screen]]) :
>  invalid value specified for graphical parameter "fig"
>> m[1,]
> [1]  0 20 40  0
>> split.screen(m[1,])
> Error in split.screen(m[1, ]) : 'figs' must specify at least one screen
> 
> What should be the syntax for this task?
> 
> -- 
> 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.

Screen parrts shoeld be fractions (0 ...1), not percentages.
And bottom first, so ...

m = matrix(c(0,20,0,40, 20,60,0,40)/100, byrow=T, ncol=4)

 ... will work.

Success and
Best regards,

Franklin
---

Franklin Bretschneider
Dept of Biology
Utrecht University
brets...@xs4all.nl

__
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] R plot split screen in uneven panels

2018-12-12 Thread Bert Gunter
?layout
Please read the Help file **carefully** and work through the **examples**.
I cannot explain better than they.
Here is code using layout() that I think does what you want:

m <- matrix(1:2, nrow =1)
layout(m, widths = c(1,2))
plot(1:10, type = "p",main = "The First Plot")
plot(10:1, type = "l", main ="The Second Plot")

Note that both the lattice package and ggplot2 can also do this sort of
thing much more flexibly(and therefore requiring more effort to learn).

Cheers,
Bert


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 Wed, Dec 12, 2018 at 7:19 AM Luigi Marongiu 
wrote:

> Dear all,
> I would like to draw two plots in the same device so that there is a
> single row and two columns, with the first column being 1/3 of the
> device's width.
> I am creating a PNG object with width = 30 and height = 20 cm.
> I know that I should use split.screen or layout but I am lost with the
> matrix to pass to the functions.
> For istance, I tried:
> # distance in arbitrary units (so let's say cm) from of corners
> # left, right, bottom, and top counting from bottom left corner
> # that is first panel has the bottom right corner 20 cm from the bottom
> left?
> > m = matrix(c(0,20,40,0, 20,60,40,0), byrow=T, ncol=4)
> > m
>  [,1] [,2] [,3] [,4]
> [1,]0   20   400
> [2,]   20   60   400
> > split.screen(m)
> Error in par(split.screens[[cur.screen]]) :
>   invalid value specified for graphical parameter "fig"
> > m[1,]
> [1]  0 20 40  0
> > split.screen(m[1,])
> Error in split.screen(m[1, ]) : 'figs' must specify at least one screen
>
> What should be the syntax for this task?
>
> --
> 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.
>

[[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] Different performance with different R versions

2018-12-12 Thread MacQueen, Don via R-help
Probably more appropriate for R-SIG-Mac

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 12/11/18, 12:22 AM, "R-help on behalf of cowan robin" 
 
wrote:

I am running a small simulation, and getting very different run times when 
I use different versions of R. 
Two set-ups using the same machine (MacBook Pro 2013 vintage)

1. R version 3.1.3  running on system OS X 10.9.5

> system.time(source("simulationR-R.R"))

  user  system elapsed 
  3.890   0.061   3.965 



Compared to


2. R version 3.5.1  running on system OS X 10.12.6

> system.time(source("simulationR-R.R"))

  user  system elapsed 
277.924   2.087 280.841 


The source code is identical. This is a pretty big difference running the 
same code on the same hardware.
Before submitting the code, is this a known issue?

__
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] R plot split screen in uneven panels

2018-12-12 Thread Luigi Marongiu
Dear all,
I would like to draw two plots in the same device so that there is a
single row and two columns, with the first column being 1/3 of the
device's width.
I am creating a PNG object with width = 30 and height = 20 cm.
I know that I should use split.screen or layout but I am lost with the
matrix to pass to the functions.
For istance, I tried:
# distance in arbitrary units (so let's say cm) from of corners
# left, right, bottom, and top counting from bottom left corner
# that is first panel has the bottom right corner 20 cm from the bottom left?
> m = matrix(c(0,20,40,0, 20,60,40,0), byrow=T, ncol=4)
> m
 [,1] [,2] [,3] [,4]
[1,]0   20   400
[2,]   20   60   400
> split.screen(m)
Error in par(split.screens[[cur.screen]]) :
  invalid value specified for graphical parameter "fig"
> m[1,]
[1]  0 20 40  0
> split.screen(m[1,])
Error in split.screen(m[1, ]) : 'figs' must specify at least one screen

What should be the syntax for this task?

-- 
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] R and factorytalk historian

2018-12-12 Thread PIKAL Petr
Hi

Well, the final answer is that data from FTH could be transfered to other 
software **only** through Excel.

Regarding RetroEncabulator, readings could be enahanced by extensive and 
elaborate use of nanoputian molecules chained together.

Cheers
Petr

> -Original Message-
> From: Viechtbauer, Wolfgang (SP)
> 
> Sent: Wednesday, December 12, 2018 11:21 AM
> To: PIKAL Petr ; r-help 
> Subject: RE: R and factorytalk historian
>
> Dear Petr,
>
> Sorry, no experience with the FTH, but related to this, has anybody gotten R 
> to
> interface nicely with the Retro Encabulator, providing live read outs of the
> synchronizing cardinal grammeters?
>
> (my apologies, I just couldn't resist)
>
> Best,
> Wolfgang
>
> >-Original Message-
> >From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL
> >Petr
> >Sent: Tuesday, 11 December, 2018 16:09
> >To: r-help
> >Subject: [R] R and factorytalk historian
> >
> >Hallo all
> >
> >Does anybody know if R could be used directly with FactoryTalk
> >Historian programme from Rockwell automation.
> >
> >It is probably possible to use Excel as interface but I would prefer
> >not to.
> >
> >Best regards.
> >
> >Petr Pikal
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-es] Subset dentro de un for

2018-12-12 Thread Marcelino De La Cruz Rot
Hola, Manuel:

Tienes que usar get:

subset(df, subset=get(GT[1])>0)





El 12/12/2018 a las 14:08, Manuel Mendoza escribió:
> Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace 
> un subset con el que se queda con las muestras para la que cierta 
> variable es positiva.
>
> Si hago esto, sale bien:
>
> df2<-subset(df, subset = var1>0)
>
>
> Pero he probado así (y de no sé cuantas formas más), antes de hacer el 
> for, y no sale:
>
> GT<- c("var1","var2", … )
>
> df2<-subset(df, subset=(GT[1]>0))
>
> Gracias,
> Manuel
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> .
>

-- 
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

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


Re: [R-es] Subset dentro de un for

2018-12-12 Thread Carlos Ortega
Esta es una forma...

> for(i in c('Ozone', 'Solar.R')) {
+   print(i)
+   sub_data <- subset(airquality, eval(parse(text=i)) < 100)
+   res_ult <- mean(sub_data$Temp, na.rm = TRUE)
+   print(res_ult)
+ }
[1] "Ozone"
[1] 77.34862
[1] "Solar.R"
[1] 71.85294

Y otra forma à la dplyr...:

> library(rlang)
> for(i in c('Ozone', 'Solar.R')) {
+   print(i)
+   res_ult <- airquality %>%
+ filter(!!sym(i) < 100) %>%
+ summarize(Media = mean(Temp, na.rm = TRUE))
+   print(res_ult)
+ }
[1] "Ozone"
 Media
1 77.34862
[1] "Solar.R"
 Media
1 71.85294

Saludos,
Carlos Ortega
www.qualityexcellence.es



El mié., 12 dic. 2018 a las 14:09, Manuel Mendoza ()
escribió:

> Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
> un subset con el que se queda con las muestras para la que cierta
> variable es positiva.
>
> Si hago esto, sale bien:
>
> df2<-subset(df, subset = var1>0)
>
>
> Pero he probado así (y de no sé cuantas formas más), antes de hacer el
> for, y no sale:
>
> GT<- c("var1","var2", … )
>
> df2<-subset(df, subset=(GT[1]>0))
>
> Gracias,
> Manuel
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> .
>
> --
> Dr Manuel Mendoza
> Department of Biogeography and Global Change
> National Museum of Natural Science (MNCN)
> Spanish Scientific Council (CSIC)
> C/ Serrano 115bis, 28006 MADRID
> Spain
>
> ___
> 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] Subset dentro de un for

2018-12-12 Thread Raúl Vaquerizo

Hola,

Puedes hacer el mítico eval parse paste:

for (i in seq(1,maximo)){
  eval(parse(text=paste('df',i,'<-subset(df, subset = 
var',i,'>0)',sep='')))

}

Saludos.

El 12/12/2018 14:08, Manuel Mendoza escribió:

Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace
un subset con el que se queda con las muestras para la que cierta
variable es positiva.

Si hago esto, sale bien:

df2<-subset(df, subset = var1>0)


Pero he probado así (y de no sé cuantas formas más), antes de hacer el
 for, y no sale:

GT<- c("var1","var2", … )

df2<-subset(df, subset=(GT[1]>0))

Gracias,
Manuel



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


Re: [R] Width of a text

2018-12-12 Thread Ben Tupper
Hi,

Does strwidth() do the trick?

https://www.rdocumentation.org/packages/graphics/versions/3.5.1/topics/strwidth 


Ben

> On Dec 12, 2018, at 6:55 AM, Christofer Bogaso  
> wrote:
> 
> Hi,
> 
> In HTML there is a way to measure the width of a Text before printing it on
> screen as in https://www.w3schools.com/tags/canvas_measuretext.asp
> 
> In R we have nchar() function which just measures the number of letters in
> a Text, but I wonder if we can measure the width of text as well.
> 
> I have a shiny app where I need to print a text in an Area onto the screen
> which has a specific width, so some the texts are not showing within that
> area (overflowing), where some are though all of them have the equal number
> of letters.
> 
> Thanks for any input.
> 
>   [[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.

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

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






[[alternative HTML version deleted]]

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


[R-es] Subset dentro de un for

2018-12-12 Thread Manuel Mendoza
Muy buenas.  Quiero hacer un loop en el que en cada iteración se hace  
un subset con el que se queda con las muestras para la que cierta  
variable es positiva.


Si hago esto, sale bien:

df2<-subset(df, subset = var1>0)


Pero he probado así (y de no sé cuantas formas más), antes de hacer el  
for, y no sale:


GT<- c("var1","var2", … )

df2<-subset(df, subset=(GT[1]>0))

Gracias,
Manuel


























.

--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural Science (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


[R] Width of a text

2018-12-12 Thread Christofer Bogaso
Hi,

In HTML there is a way to measure the width of a Text before printing it on
screen as in https://www.w3schools.com/tags/canvas_measuretext.asp

In R we have nchar() function which just measures the number of letters in
a Text, but I wonder if we can measure the width of text as well.

I have a shiny app where I need to print a text in an Area onto the screen
which has a specific width, so some the texts are not showing within that
area (overflowing), where some are though all of them have the equal number
of letters.

Thanks for any input.

[[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] CRAN package NlcOptim query

2018-12-12 Thread Hans W Borchers
This is still not complete: `x_than0` is missing.
`Constr_new` is written with a capital 'C'.
And aeq2 is a list of column vectors, not a matrix.
Setting the tolerance to 0 does not seem to be a good idea.

Making aeq2 a matrix and adding `x_than0 <- matrix(c(1, 1))`, then

aeq2 <- as.matrix(aeq2)
x_than0 <- matrix(c(1, 1))

NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=-Constr_new, B=-x_than0,
Aeq=as.matrix(aeq2), Beq=beq2,
lb=c(rep(0,numel)),ub=c(rep(1,numel)), tolX = 0)

will indeed return in the same error, while it runs without error if you
either leave out the inequality constraints or the bounds constraints. So
I guess there may be a bug when the function internally combines these
constraints and the bounds.

You could / should write to the maintainer. I know he is very responsive.

For the moment, you can combine the bounds constraints and the lower and
upper bounds yourself:

myA <- rbind(-Constr_new, diag(-1,numel), diag(1,numel))
myB <- c(-x_than0, rep(0,numel), rep(1,numel))

NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=myA, B=myB,
Aeq=as.matrix(aeq2), Beq=beq2)

returns "constraints are inconsistent, no solution!", but that may be the
case because I don't know your `x_than` value.

__
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] R and factorytalk historian

2018-12-12 Thread Viechtbauer, Wolfgang (SP)
Dear Petr,

Sorry, no experience with the FTH, but related to this, has anybody gotten R to 
interface nicely with the Retro Encabulator, providing live read outs of the 
synchronizing cardinal grammeters?

(my apologies, I just couldn't resist)

Best,
Wolfgang

>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL
>Petr
>Sent: Tuesday, 11 December, 2018 16:09
>To: r-help
>Subject: [R] R and factorytalk historian
>
>Hallo all
>
>Does anybody know if R could be used directly with FactoryTalk Historian
>programme from Rockwell automation.
>
>It is probably possible to use Excel as interface but I would prefer not
>to.
>
>Best regards.
>
>Petr Pikal

__
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] R and factorytalk historian

2018-12-12 Thread PIKAL Petr
Hi Jeff,

FactoryTalk Historian should be system for operation data management. I am 
aware of some R capabilities in transfering data and during our training I will 
ask about the way FTH can export data. From my current knowledge export to 
Excel via integrated module is possible.

My question was mainly driven by broad expertise among R users and hope that 
maybe some R user already performed such task and I could learn from his/her 
experience.

S pozdravem | Best Regards
RNDr. Petr PIKAL
Vedoucí Výzkumu a vývoje | Research Manager
PRECHEZA a.s.
nábř. Dr. Edvarda Beneše 1170/24 | 750 02 Přerov | Czech Republic
Tel: +420 581 252 256 | GSM: +420 724 008 364
petr.pi...@precheza.cz | www.precheza.cz

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/

> -Original Message-
> From: Jeff Newmiller 
> Sent: Tuesday, December 11, 2018 5:18 PM
> To: r-help@r-project.org; PIKAL Petr ; r-help  h...@r-project.org>
> Subject: Re: [R] R and factorytalk historian
> 
> R supports a wide range of data transfer methods, Petr... you know for example
> that if you export data from Excel in CSV format then you can import it to R,
> yet this solution does not satisfy all users in all cases. What expectations 
> do you
> have?
> 
> Why don't you do some legwork and identify what data formats/mechanisms
> this "FactoryTalk Historian" understands? E.g. does it understand csv? ODBC?
> COM? HTTP API?
> 
> On December 11, 2018 7:09:23 AM PST, PIKAL Petr 
> wrote:
> >Hallo all
> >
> >Does anybody know if R could be used directly with FactoryTalk
> >Historian programme from Rockwell automation.
> >
> >It is probably possible to use Excel as interface but I would prefer
> >not to.
> >
> >Best regards.
> >
> >Petr Pikal
> >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/
> >
> >
> > [[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.
> 
> --
> Sent from my phone. Please excuse my brevity.
__
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] CRAN package NlcOptim query

2018-12-12 Thread aveek via R-help


Hello Eric,

Thanks for your response and suggestions. 

I have used dput() on the R objects - sharing below so that it is possible for 
anyone to recreate the situation.

I have still kept it as a 9*9 matrix but for simplicity we now only have 2 
equality and 2 non equality constraints.

Thanks again for your help.

InputTM


structure(c(0.813231189406663, 0.0199464964676128, 0.00100552815128915,

0.000465771436428336, 0.000736922016196076, 0.00203037431732662,

0.000596998285890709, 0.0011699714577823, 0, 0.103116692172408,

0.751775368068589, 0.0160957427707042, 0.00285542569941823, 0.0020295541916448,

0.00954562743564027, 0.00173399818906894, 0.00292299139663608,

0, 0.0481959576543631, 0.177032393868544, 0.811609524051149,

0.146703962329218, 0.0698423269415636, 0.168241524872922, 0.0505757280338206,

0.0324917017565673, 0, 0.026504623193874, 0.038430496838613,

0.134709744786799, 0.758322716164413, 0.176013939161559, 0.234265359508999,

0.108188555487004, 0.0476663548325017, 0, 0.00520614395937929,

0.00868690292550468, 0.0223895752360805, 0.0581458712447338,

0.681496895121054, 0.0733970775224908, 0.0508491985259732, 0.0268876385360338,

0, 0.000749001395622802, 0.00181690494827145, 0.00317194515883476,

0.00705434604769267, 0.0211989316284324, 0.464732208379131, 0.0165146818291576,

0.00721872506710652, 0, 0.000960493069403903, 0.00138444384054219,

0.00703528202498607, 0.0163983255053438, 0.0301780379843763,

0.0280699612529658, 0.491157627745315, 0.0235353949469527, 0,

0.00112628575287418, 0.000477300396419488, 0.00223238360574478,

0.00521558462566306, 0.00925149338117537, 0.00878272484051914,

0.163654071683595, 0.611806567272906, 0, 0.000909613395411595,

0.000449692645903539, 0.00175027421441265, 0.00483799694708872,

0.00925189957399783, 0.0109351418700064, 0.116729140220175, 0.246300654733514,

1), .Dim = c(9L, 9L))

 

 

Constr_new

structure(c(1, 0, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(2L,

81L), .Dimnames = list(NULL, c("X11", "X12", "X13", "X14", "X15",

"X16", "X17", "X18", "X19", "X21", "X22", "X23", "X24", "X25",

"X26", "X27", "X28", "X29", "X31", "X32", "X33", "X34", "X35",

"X36", "X37", "X38", "X39", "X41", "X42", "X43", "X44", "X45",

"X46", "X47", "X48", "X49", "X51", "X52", "X53", "X54", "X55",

"X56", "X57", "X58", "X59", "X61", "X62", "X63", "X64", "X65",

"X66", "X67", "X68", "X69", "X71", "X72", "X73", "X74", "X75",

"X76", "X77", "X78", "X79", "X81", "X82", "X83", "X84", "X85",

"X86", "X87", "X88", "X89", "X91", "X92", "X93", "X94", "X95",

"X96", "X97", "X98", "X99")))

 

 

x_than0

c(1e-04, 1e-04)

 

aeq2

structure(list(X1 = c(1, 0), X2 = c(1, 0), X3 = c(1, 0), X4 = c(1,

0), X5 = c(1, 0), X6 = c(1, 0), X7 = c(1, 0), X8 = c(1, 0), X9 = c(1,

0), X10 = c(0, 1), X11 = c(0, 1), X12 = c(0, 1), X13 = c(0, 1

), X14 = c(0, 1), X15 = c(0, 1), X16 = c(0, 1), X17 = c(0, 1),

X18 = c(0, 1), X19 = c(0, 0), X20 = c(0, 0), X21 = c(0, 0

    ), X22 = c(0, 0), X23 = c(0, 0), X24 = c(0, 0), X25 = c(0,

0), X26 = c(0, 0), X27 = c(0, 0), X28 = c(0, 0), X29 = c(0,

0), X30 = c(0, 0), X31 = c(0, 0), X32 = c(0, 0), X33 = c(0,

0), X34 = c(0, 0), X35 = c(0, 0), X36 = c(0, 0), X37 = c(0,

0), X38 = c(0, 0), X39 = c(0, 0), X40 = c(0, 0), X41 = c(0,

0), X42 = c(0, 0), X43 = c(0, 0), X44 = c(0, 0), X45 = c(0,

0), X46 = c(0, 0), X47 = c(0, 0), X48 = c(0, 0), X49 = c(0,

0), X50 = c(0, 0), X51 = c(0, 0), X52 = c(0, 0), X53 = c(0,

0), X54 = c(0, 0), X55 = c(0, 0), X56 = c(0, 0), X57 = c(0,

0), X58 = c(0, 0), X59 = c(0, 0), X60 = c(0, 0), X61 = c(0,

0), X62 = c(0, 0), X63 = c(0, 0), X64 = c(0, 0), X65 = c(0,

0), X66 = c(0, 0), X67 = c(0, 0), X68 = c(0, 0), X69 = c(0,

0), X70 = c(0, 0), X71 = c(0, 0), X72 = c(0, 0), X73 = c(0,

0), X74 = c(0, 0), X75 = c(0, 0), X76 = c(0, 0), X77 = c(0,

0), X78 = c(0, 0), X79 = c(0, 0), X80 = c(0, 0), X81 = c(0,

0)), .Names = c("X1", "X2", "X3", "X4", "X5", "X6", "X7",

"X8", "X9", "X10", "X11", "X12", "X13", "X14", "X15", "X16",

"X17", "X18", "X19", "X20", "X21", "X22", "X23", "X24", "X25",

"X26", "X27", "X28", "X29", "X30", "X31", "X32", "X33", "X34",

"X35", "X36", "X37", "X38", "X39", "X40", "X41", "X42", "X43",

"X44", "X45", "X46", "X47", "X48", "X49", "X50", "X51", "X52",

"X53", "X54", "X55", "X56", "X57", "X58", "X59", "X60", "X61",

"X62", "X63", "X64", "X65", "X66", "X67", "X68", "X69", "X70",

"X71", "X72", "X73", "X74", "X75", "X76", "X77", "X78", "X79",

"X80", "X81"), row.names = 1:2, class = "data.frame")

 

beq2