Re: [R-es] tips para curso introductorio de R

2016-09-06 Thread Ruben Tobalina Ramirez
Buenos días,

Nunca di clases de R pero creo que la mejor forma de aprender es siempre,
hacer las cosas tu mismo. Así que, como tu dices, lo mejor es hacer que los
alumnos  hagan pequeñas practicas sobre pequeños tips de teoria. No sé muy
bien que teoria daras, pero por ejemplo enseñando a hacer un gráfico, yo
enseñaria las funciones basicas (plot, ggplot, lattice,...) y luego haria
ejercicios en donde los alumnos tengan que hacer más "bonito el grafico" o
cambiar alguna variable...cosas así. Que poco a poco, cojan confianza!

un saludo y suerte con las clases.

ruben.

El 7 de septiembre de 2016, 4:12, Angela Andrea Camargo Sanabria <
angela.andrea.cama...@gmail.com> escribió:

> Buen día a todos:
>
> les agradezco de antemano su ayuda sobre este tema relacionado a R pero no
> del lenguaje de R.
>
> Voy a dar un pequeño curso-taller de introducción al lenguaje de R a
> estudiantes de maestría y doctorado (primer semestre) en Ecología y
> quisiera conocer algunos tips o recomendaciones basados en su experiencia.
> ¿Cuál sería la mejor estrategia para enseñarles como trabaja R?
>
> Cuando he sido estudiante siento que las clases en las que el profe nos
> daba el script sólo para correr fueron poco significativas. Me parece mejor
> opción que los estudiantes vayan escribiendo para que se enfrenten a los
> errores comunes que uno tiene cuando empieza, por ejemplo, de simple
> sintaxis.
>
> Algo que me ayudó mucho cuando empecé, fue el hecho de escribir en texto lo
> que habíamos trabajado en el código. Es decir, en mis propias palabras
> describir qué instrucción estábamos dando. Pienso que eso puede funcionar
> también.
>
> Estoy abierta a sus comentarios o tal vez estoy en el foro equivocado?
>
> Saludos a todos!
>
>
>
>
> --
> *Angela Andrea Camargo Sanabria*
> Becaria Postdoctoral
> Laboratorio de Análisis para la Conservación de la Biodiversidad
> Instituto de Investigaciones sobre los Recursos Naturales (INIRENA)
> Universidad Michoacana de San Nicolás de Hidalgo (UMSNH)
> skype: angela.camargo26
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Rubén.

[[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] Run an external software in R

2016-09-06 Thread William Dunlap via R-help
You can use system() or shell(), which adds "cmd.exe /c " to the front of
your command
so you can use DOS syntax.  Remember to add double quotes when file names
have
spaces in them.  E.g., I can call an old version of R with the following
and later read its
text output into my current session.

> infile <- tempfile()
> cat("getRversion()\n", file=infile)
> outfile <- tempfile()
> shell(paste("\"C:\\Program Files\\R\\R-2.15.1\\bin\\R\" --quiet --vanilla
<", infile, ">", outfile))
> readLines(outfile)
[1] "> getRversion()" "[1] '2.15.1'""> "



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Sep 6, 2016 at 6:13 PM, Marino David 
wrote:

> Hi all R users:
>
> Does anybody have the experience of running an external software in R? I
> try to use R to run ANSYS software, which is a engineering simulation
> package. I ever have done this task in Matlab platform by executing
> the following code line:
>
> system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p
> ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out');
>
>
> Any idea regarding implementing this work is very welcome.
>
> David
>
> [[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] Run an external software in R

2016-09-06 Thread Bert Gunter
?system

But this begs the question: WHY would you want to do this? More
specifically, what should R communicate to your other software, and
what should the other software communicate to R?


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 Tue, Sep 6, 2016 at 6:13 PM, Marino David  wrote:
> Hi all R users:
>
> Does anybody have the experience of running an external software in R? I
> try to use R to run ANSYS software, which is a engineering simulation
> package. I ever have done this task in Matlab platform by executing
> the following code line:
>
> system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p
> ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out');
>
>
> Any idea regarding implementing this work is very welcome.
>
> David
>
> [[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] element wise pattern recognition and string substitution

2016-09-06 Thread Bert Gunter
Jun:

"My problem is the pattern has to be dynamically constructed on the
input data of the function "

What does that mean? How can a pattern be "dynamically constructed"
when you have not made clear (at least to me, perhaps also to yourself
and/or others) *how* it is to be constructed?

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 Tue, Sep 6, 2016 at 8:56 PM, Bert Gunter  wrote:
> Jeff:
>
> Not sure what you meant by this:
>
> "There is no other reason to put parentheses in the pattern... they
> are not grouping symbols."
>
> ... but in fact, from ?regexp
>
> "Repetition takes precedence over concatenation, which in turn takes
> precedence over alternation. A whole subexpression may be enclosed in
> parentheses to override these precedence rules. "
>
> So parentheses *are* in fact "grouping symbols."
>
> 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 Tue, Sep 6, 2016 at 5:18 PM, Jeff Newmiller  
> wrote:
>> I am not near my computer today, but each parenthesis gets its own result 
>> number, so you should put the parenthesis around the whole pattern of 
>> alternatives instead of having many parentheses.
>>
>> I recommend thinking in terms of what common information you expect to find 
>> in these various strings, and place your parentheses to capture that 
>> information. There is no other reason to put parentheses in the pattern... 
>> they are not grouping symbols.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On September 6, 2016 5:01:04 PM PDT, Bert Gunter  
>> wrote:
>>>Jun:
>>>
>>>1. Tell us your desired result from your test vector and maybe someone
>>>will help.
>>>
>>>2. As we played this game once already (you couldn't do it; I showed
>>>you how), this seems to be a function of your limitations with regular
>>>expressions. I'm probably not much better, but in any case, I don't
>>>intend to be your consultant. See if you can find someone locally to
>>>help you if you do not receive a satisfactory reply from the list.
>>>There are many people here who are pretty good at this sort of thing,
>>>but I don't know if they'll reply. Regex's are certainly complex. PERL
>>>people tend to be pretty good at them, I believe. There are numerous
>>>web sites and books on them if you need to acquire expertise for your
>>>work.
>>>
>>>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 Tue, Sep 6, 2016 at 3:59 PM, Jun Shen  wrote:
 Hi Bert,

 I still couldn't make the multiple patterns to work. Here is an
>>>example. I
 make the pattern as follows

 final.pattern <-

>>>"(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\.g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\\.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>110\\.kg)\\.(.*)"

 test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
 '240.m.g.>50-70.kg.geo.mean')

 sub(final.pattern, '\\1', test.string)
 sub(final.pattern, '\\2', test.string)
 sub(final.pattern, '\\3', test.string)

 Only the third string has been correctly parsed, which matches the
>>>first
 pattern. It seems the rest of the patterns are not called.

 Jun


 On Mon, Sep 5, 2016 at 10:21 PM, Bert Gunter 
>>>wrote:
>
> Just noticed: My clumsy do.call() line in my previously posted code
> below should be replaced with:
> pat <- paste(pat,collapse = "|")
>
>
> > pat <- c(pat1,pat2)
> > paste(pat,collapse="|")
> [1] "a+\\.*a+|b+\\.*b+"
>
>  replace this **
> > pat <- do.call(paste,c(as.list(pat), sep="|"))
> 
> > sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
> [1] "a.a"   "bb""b.bbb"
>
>
> -- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter
>>>
> wrote:
> > Jun:
> >
> > You need to provide a clear specification via regular expressions

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Ista,

Thanks for the suggestion. I didn't know mapply can be used this way! Let
me take one more step. Instead of defining a pattern for each string, I
would like to define a set of patterns from all the possible combination of
the unique values of those variables. Then I need each string to find a
pattern for itself. I know this is getting a little stretching. Thanks for
all the suggestion/comments from everyone.

Jun

On Tue, Sep 6, 2016 at 9:44 PM, Ista Zahn  wrote:

> If you want to mach each element of 'strings' to a different regex, do
> it. Here are three ways, using your original example.
>
> pattern1 <- "([^.]*)\\.([^.]*\\.[^.]*)\\.(.*)"
> pattern2 <- "([^.]*)\\.([^.]*)\\.(.*)"
>
> patterns <- c(pattern1,pattern2)
> strings <- c('TX.WT.CUT.mean','mg.tx.cv')
>
> for(i in seq(strings)) print(sub(patterns[i], "\\2", strings[i]))
>
> mapply(sub, pattern = patterns, x = strings, MoreArgs=list(replacement =
> "\\2"))
>
> library(stringi)
> stri_replace_all_regex(strings, patterns, "$2")
>
> Best,
> Ista
> On Tue, Sep 6, 2016 at 9:20 PM, Jun Shen  wrote:
> > Hi Jeff,
> >
> > Thanks for the reply. I tried your suggestion and it doesn't seem to work
> > and I tried a simple pattern as follows and it works as expected
> >
> > sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\1', "3.mg.kg
> .>50-70.kg.P05")
> > [1] "3.mg.kg"
> >
> > sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\2', "3.mg.kg
> .>50-70.kg.P05")
> > [1] ">50-70.kg"
> >
> > sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\3', "3.mg.kg
> .>50-70.kg.P05")
> > [1] "P05"
> >
> > My problem is the pattern has to be dynamically constructed on the input
> > data of the function I am writing. It's actually not too difficult to
> > assemble the final.pattern with some code like the following
> >
> > sort.var <- c('TX','WTCUT')
> > combn.sort.var <- do.call(expand.grid, lapply(sort.var,
> > function(x)paste('(',gsub('\\.','.',unlist(unique(all.
> exposure[x]))),
> > ')', sep='')))
> > all.patterns <- do.call(paste, c(combn.sort.var, '(.*)', sep='\\.'))
> > final.pattern <- paste0(all.patterns, collapse='|')
> >
> > You cannot run the code directly since the data object "all.exposure" is
> > not provided here.
> >
> > Jun
> >
> >
> >
> > On Tue, Sep 6, 2016 at 8:18 PM, Jeff Newmiller  >
> > wrote:
> >
> >> I am not near my computer today, but each parenthesis gets its own
> result
> >> number, so you should put the parenthesis around the whole pattern of
> >> alternatives instead of having many parentheses.
> >>
> >> I recommend thinking in terms of what common information you expect to
> >> find in these various strings, and place your parentheses to capture
> that
> >> information. There is no other reason to put parentheses in the
> pattern...
> >> they are not grouping symbols.
> >> --
> >> Sent from my phone. Please excuse my brevity.
> >>
> >> On September 6, 2016 5:01:04 PM PDT, Bert Gunter <
> bgunter.4...@gmail.com>
> >> wrote:
> >> >Jun:
> >> >
> >> >1. Tell us your desired result from your test vector and maybe someone
> >> >will help.
> >> >
> >> >2. As we played this game once already (you couldn't do it; I showed
> >> >you how), this seems to be a function of your limitations with regular
> >> >expressions. I'm probably not much better, but in any case, I don't
> >> >intend to be your consultant. See if you can find someone locally to
> >> >help you if you do not receive a satisfactory reply from the list.
> >> >There are many people here who are pretty good at this sort of thing,
> >> >but I don't know if they'll reply. Regex's are certainly complex. PERL
> >> >people tend to be pretty good at them, I believe. There are numerous
> >> >web sites and books on them if you need to acquire expertise for your
> >> >work.
> >> >
> >> >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 Tue, Sep 6, 2016 at 3:59 PM, Jun Shen 
> wrote:
> >> >> Hi Bert,
> >> >>
> >> >> I still couldn't make the multiple patterns to work. Here is an
> >> >example. I
> >> >> make the pattern as follows
> >> >>
> >> >> final.pattern <-
> >> >>
> >> >"(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>
> >> 50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\
> >> .mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.
> >> kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\
> >> .g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\
> >> \.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.
> >> mg\\.kg)\\.(>110\\.kg)\\.(.*)"
> >> >>
> >> >> test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
> >> >> '240.m.g.>50-70.kg.geo.mean')
> >> >>
> >> >> sub(final.pattern, '\\1', test.string)
> >> >> sub(final.pattern, '\\2', 

[R-es] tips para curso introductorio de R

2016-09-06 Thread Angela Andrea Camargo Sanabria
Buen día a todos:

les agradezco de antemano su ayuda sobre este tema relacionado a R pero no
del lenguaje de R.

Voy a dar un pequeño curso-taller de introducción al lenguaje de R a
estudiantes de maestría y doctorado (primer semestre) en Ecología y
quisiera conocer algunos tips o recomendaciones basados en su experiencia.
¿Cuál sería la mejor estrategia para enseñarles como trabaja R?

Cuando he sido estudiante siento que las clases en las que el profe nos
daba el script sólo para correr fueron poco significativas. Me parece mejor
opción que los estudiantes vayan escribiendo para que se enfrenten a los
errores comunes que uno tiene cuando empieza, por ejemplo, de simple
sintaxis.

Algo que me ayudó mucho cuando empecé, fue el hecho de escribir en texto lo
que habíamos trabajado en el código. Es decir, en mis propias palabras
describir qué instrucción estábamos dando. Pienso que eso puede funcionar
también.

Estoy abierta a sus comentarios o tal vez estoy en el foro equivocado?

Saludos a todos!




--
*Angela Andrea Camargo Sanabria*
Becaria Postdoctoral
Laboratorio de Análisis para la Conservación de la Biodiversidad
Instituto de Investigaciones sobre los Recursos Naturales (INIRENA)
Universidad Michoacana de San Nicolás de Hidalgo (UMSNH)
skype: angela.camargo26

[[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] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Jeff,

Thanks for the reply. I tried your suggestion and it doesn't seem to work
and I tried a simple pattern as follows and it works as expected

sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\1', "3.mg.kg.>50-70.kg.P05")
[1] "3.mg.kg"

sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\2', "3.mg.kg.>50-70.kg.P05")
[1] ">50-70.kg"

sub("(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)", '\\3', "3.mg.kg.>50-70.kg.P05")
[1] "P05"

My problem is the pattern has to be dynamically constructed on the input
data of the function I am writing. It's actually not too difficult to
assemble the final.pattern with some code like the following

sort.var <- c('TX','WTCUT')
combn.sort.var <- do.call(expand.grid, lapply(sort.var,
function(x)paste('(',gsub('\\.','.',unlist(unique(all.exposure[x]))),
')', sep='')))
all.patterns <- do.call(paste, c(combn.sort.var, '(.*)', sep='\\.'))
final.pattern <- paste0(all.patterns, collapse='|')

You cannot run the code directly since the data object "all.exposure" is
not provided here.

Jun



On Tue, Sep 6, 2016 at 8:18 PM, Jeff Newmiller 
wrote:

> I am not near my computer today, but each parenthesis gets its own result
> number, so you should put the parenthesis around the whole pattern of
> alternatives instead of having many parentheses.
>
> I recommend thinking in terms of what common information you expect to
> find in these various strings, and place your parentheses to capture that
> information. There is no other reason to put parentheses in the pattern...
> they are not grouping symbols.
> --
> Sent from my phone. Please excuse my brevity.
>
> On September 6, 2016 5:01:04 PM PDT, Bert Gunter 
> wrote:
> >Jun:
> >
> >1. Tell us your desired result from your test vector and maybe someone
> >will help.
> >
> >2. As we played this game once already (you couldn't do it; I showed
> >you how), this seems to be a function of your limitations with regular
> >expressions. I'm probably not much better, but in any case, I don't
> >intend to be your consultant. See if you can find someone locally to
> >help you if you do not receive a satisfactory reply from the list.
> >There are many people here who are pretty good at this sort of thing,
> >but I don't know if they'll reply. Regex's are certainly complex. PERL
> >people tend to be pretty good at them, I believe. There are numerous
> >web sites and books on them if you need to acquire expertise for your
> >work.
> >
> >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 Tue, Sep 6, 2016 at 3:59 PM, Jun Shen  wrote:
> >> Hi Bert,
> >>
> >> I still couldn't make the multiple patterns to work. Here is an
> >example. I
> >> make the pattern as follows
> >>
> >> final.pattern <-
> >>
> >"(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>
> 50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\
> .mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.
> kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\
> .g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\
> \.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.
> mg\\.kg)\\.(>110\\.kg)\\.(.*)"
> >>
> >> test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
> >> '240.m.g.>50-70.kg.geo.mean')
> >>
> >> sub(final.pattern, '\\1', test.string)
> >> sub(final.pattern, '\\2', test.string)
> >> sub(final.pattern, '\\3', test.string)
> >>
> >> Only the third string has been correctly parsed, which matches the
> >first
> >> pattern. It seems the rest of the patterns are not called.
> >>
> >> Jun
> >>
> >>
> >> On Mon, Sep 5, 2016 at 10:21 PM, Bert Gunter 
> >wrote:
> >>>
> >>> Just noticed: My clumsy do.call() line in my previously posted code
> >>> below should be replaced with:
> >>> pat <- paste(pat,collapse = "|")
> >>>
> >>>
> >>> > pat <- c(pat1,pat2)
> >>> > paste(pat,collapse="|")
> >>> [1] "a+\\.*a+|b+\\.*b+"
> >>>
> >>>  replace this **
> >>> > pat <- do.call(paste,c(as.list(pat), sep="|"))
> >>> 
> >>> > sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
> >>> [1] "a.a"   "bb""b.bbb"
> >>>
> >>>
> >>> -- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter
> >
> >>> wrote:
> >>> > Jun:
> >>> >
> >>> > You need to provide a clear specification via regular expressions
> >of
> >>> > the patterns you wish to match -- at least for me to decipher it.
> >>> > Others may be smarter than I, though...
> >>> >
> >>> > Jeff: Thanks. I have now convinced myself that it 

[R] Run an external software in R

2016-09-06 Thread Marino David
Hi all R users:

Does anybody have the experience of running an external software in R? I
try to use R to run ANSYS software, which is a engineering simulation
package. I ever have done this task in Matlab platform by executing
the following code line:

system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p
ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out');


Any idea regarding implementing this work is very welcome.

David

[[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] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Bert,

In the final.pattern, there are ten patterns.

>sub(final.pattern, '\\1', test.string)
Expected results: "240.m.g" "3.mg.kg" "240.m.g"
Current results: "" "" "240.m.g"

>sub(final.pattern, '\\2', test.string)
Expected results: ">110.kg" ">110.kg" ">50-70.kg"
Current results: "" "" ">50-70.kg"

>sub(final.pattern, '\\3', test.string)
Expected results: "geo.mean" "P05" "geo.mean"
Current results: "" "" "geo.mean"

Right now, I only get the results from the third string.


On Tue, Sep 6, 2016 at 8:01 PM, Bert Gunter  wrote:

> Jun:
>
> 1. Tell us your desired result from your test vector and maybe someone
> will help.
>
> 2. As we played this game once already (you couldn't do it; I showed
> you how), this seems to be a function of your limitations with regular
> expressions. I'm probably not much better, but in any case, I don't
> intend to be your consultant. See if you can find someone locally to
> help you if you do not receive a satisfactory reply from the list.
> There are many people here who are pretty good at this sort of thing,
> but I don't know if they'll reply. Regex's are certainly complex. PERL
> people tend to be pretty good at them, I believe. There are numerous
> web sites and books on them if you need to acquire expertise for your
> work.
>
> 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 Tue, Sep 6, 2016 at 3:59 PM, Jun Shen  wrote:
> > Hi Bert,
> >
> > I still couldn't make the multiple patterns to work. Here is an example.
> I
> > make the pattern as follows
> >
> > final.pattern <-
> > "(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>50-
> 70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\.
> mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.
> kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\
> .g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\
> \.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.
> mg\\.kg)\\.(>110\\.kg)\\.(.*)"
> >
> > test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
> > '240.m.g.>50-70.kg.geo.mean')
> >
> > sub(final.pattern, '\\1', test.string)
> > sub(final.pattern, '\\2', test.string)
> > sub(final.pattern, '\\3', test.string)
> >
> > Only the third string has been correctly parsed, which matches the first
> > pattern. It seems the rest of the patterns are not called.
> >
> > Jun
> >
> >
> > On Mon, Sep 5, 2016 at 10:21 PM, Bert Gunter 
> wrote:
> >>
> >> Just noticed: My clumsy do.call() line in my previously posted code
> >> below should be replaced with:
> >> pat <- paste(pat,collapse = "|")
> >>
> >>
> >> > pat <- c(pat1,pat2)
> >> > paste(pat,collapse="|")
> >> [1] "a+\\.*a+|b+\\.*b+"
> >>
> >>  replace this **
> >> > pat <- do.call(paste,c(as.list(pat), sep="|"))
> >> 
> >> > sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
> >> [1] "a.a"   "bb""b.bbb"
> >>
> >>
> >> -- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter 
> >> wrote:
> >> > Jun:
> >> >
> >> > You need to provide a clear specification via regular expressions of
> >> > the patterns you wish to match -- at least for me to decipher it.
> >> > Others may be smarter than I, though...
> >> >
> >> > Jeff: Thanks. I have now convinced myself that it can be done (a
> >> > "proof" of sorts): If pat1, pat2,..., patn are m different patterns
> >> > (in a vector of patterns)  to be matched in a vector of n strings,
> >> > where only one of the patterns will match in any string,  then use
> >> > paste() (probably via do.call()) or otherwise to paste them together
> >> > separated by "|" to form the concatenated pattern, pat. Then
> >> >
> >> > sub(paste0("^.*(",pat, ").*$"),"\\1",thevector)
> >> >
> >> > should extract the matching pattern in each (perhaps with a little
> >> > fiddling due to precedence rules); e.g.
> >> >
> >> >> z <-c(".fg.h.g.a.a", "bb..dd.ef.tgf.", "foo...b.bbb.tgy")
> >> >
> >> >> pat1 <- "a+\\.*a+"
> >> >> pat2 <-"b+\\.*b+"
> >> >> pat <- c(pat1,pat2)
> >> >
> >> >> pat <- do.call(paste,c(as.list(pat), sep="|"))
> >> >> pat
> >> > [1] "a+\\.*a+|b+\\.*b+"
> >> >
> >> >> sub(paste0("^[^b]*(",pat,").*$"), "\\1", z)
> >> > [1] "a.a"   "bb""b.bbb"
> >> >
> >> > 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 Mon, Sep 5, 2016 at 9:56 AM, 

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jeff Newmiller
I am not near my computer today, but each parenthesis gets its own result 
number, so you should put the parenthesis around the whole pattern of 
alternatives instead of having many parentheses.

I recommend thinking in terms of what common information you expect to find in 
these various strings, and place your parentheses to capture that information. 
There is no other reason to put parentheses in the pattern... they are not 
grouping symbols. 
-- 
Sent from my phone. Please excuse my brevity.

On September 6, 2016 5:01:04 PM PDT, Bert Gunter  wrote:
>Jun:
>
>1. Tell us your desired result from your test vector and maybe someone
>will help.
>
>2. As we played this game once already (you couldn't do it; I showed
>you how), this seems to be a function of your limitations with regular
>expressions. I'm probably not much better, but in any case, I don't
>intend to be your consultant. See if you can find someone locally to
>help you if you do not receive a satisfactory reply from the list.
>There are many people here who are pretty good at this sort of thing,
>but I don't know if they'll reply. Regex's are certainly complex. PERL
>people tend to be pretty good at them, I believe. There are numerous
>web sites and books on them if you need to acquire expertise for your
>work.
>
>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 Tue, Sep 6, 2016 at 3:59 PM, Jun Shen  wrote:
>> Hi Bert,
>>
>> I still couldn't make the multiple patterns to work. Here is an
>example. I
>> make the pattern as follows
>>
>> final.pattern <-
>>
>"(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\.g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\\.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>110\\.kg)\\.(.*)"
>>
>> test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
>> '240.m.g.>50-70.kg.geo.mean')
>>
>> sub(final.pattern, '\\1', test.string)
>> sub(final.pattern, '\\2', test.string)
>> sub(final.pattern, '\\3', test.string)
>>
>> Only the third string has been correctly parsed, which matches the
>first
>> pattern. It seems the rest of the patterns are not called.
>>
>> Jun
>>
>>
>> On Mon, Sep 5, 2016 at 10:21 PM, Bert Gunter 
>wrote:
>>>
>>> Just noticed: My clumsy do.call() line in my previously posted code
>>> below should be replaced with:
>>> pat <- paste(pat,collapse = "|")
>>>
>>>
>>> > pat <- c(pat1,pat2)
>>> > paste(pat,collapse="|")
>>> [1] "a+\\.*a+|b+\\.*b+"
>>>
>>>  replace this **
>>> > pat <- do.call(paste,c(as.list(pat), sep="|"))
>>> 
>>> > sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
>>> [1] "a.a"   "bb""b.bbb"
>>>
>>>
>>> -- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter
>
>>> wrote:
>>> > Jun:
>>> >
>>> > You need to provide a clear specification via regular expressions
>of
>>> > the patterns you wish to match -- at least for me to decipher it.
>>> > Others may be smarter than I, though...
>>> >
>>> > Jeff: Thanks. I have now convinced myself that it can be done (a
>>> > "proof" of sorts): If pat1, pat2,..., patn are m different
>patterns
>>> > (in a vector of patterns)  to be matched in a vector of n strings,
>>> > where only one of the patterns will match in any string,  then use
>>> > paste() (probably via do.call()) or otherwise to paste them
>together
>>> > separated by "|" to form the concatenated pattern, pat. Then
>>> >
>>> > sub(paste0("^.*(",pat, ").*$"),"\\1",thevector)
>>> >
>>> > should extract the matching pattern in each (perhaps with a little
>>> > fiddling due to precedence rules); e.g.
>>> >
>>> >> z <-c(".fg.h.g.a.a", "bb..dd.ef.tgf.", "foo...b.bbb.tgy")
>>> >
>>> >> pat1 <- "a+\\.*a+"
>>> >> pat2 <-"b+\\.*b+"
>>> >> pat <- c(pat1,pat2)
>>> >
>>> >> pat <- do.call(paste,c(as.list(pat), sep="|"))
>>> >> pat
>>> > [1] "a+\\.*a+|b+\\.*b+"
>>> >
>>> >> sub(paste0("^[^b]*(",pat,").*$"), "\\1", z)
>>> > [1] "a.a"   "bb""b.bbb"
>>> >
>>> > 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 Mon, Sep 5, 2016 at 9:56 AM, Jun Shen 
>wrote:
>>> >> Thanks for the reply, Bert.
>>> >>
>>> >> Your 

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
Hi Bert,

I still couldn't make the multiple patterns to work. Here is an example. I
make the pattern as follows

final.pattern <-
"(240\\.m\\.g)\\.(>50-70\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>50-70\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>70-90\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>70-90\\.kg)\\.(.*)|(240\\.m\\.g)\\.(>90-110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>90-110\\.kg)\\.(.*)|(240\\.m\\.g)\\.(50\\.kg\\.or\\.less)\\.(.*)|(3\\.mg\\.kg)\\.(50\\.kg\\.or\\.less)\\.(.*)|(240\\.m\\.g)\\.(>110\\.kg)\\.(.*)|(3\\.mg\\.kg)\\.(>110\\.kg)\\.(.*)"

test.string <- c('240.m.g.>110.kg.geo.mean', '3.mg.kg.>110.kg.P05',
'240.m.g.>50-70.kg.geo.mean')

sub(final.pattern, '\\1', test.string)
sub(final.pattern, '\\2', test.string)
sub(final.pattern, '\\3', test.string)

Only the third string has been correctly parsed, which matches the
first pattern. It seems the rest of the patterns are not called.

Jun


On Mon, Sep 5, 2016 at 10:21 PM, Bert Gunter  wrote:

> Just noticed: My clumsy do.call() line in my previously posted code
> below should be replaced with:
> pat <- paste(pat,collapse = "|")
>
>
> > pat <- c(pat1,pat2)
> > paste(pat,collapse="|")
> [1] "a+\\.*a+|b+\\.*b+"
>
>  replace this **
> > pat <- do.call(paste,c(as.list(pat), sep="|"))
> 
> > sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
> [1] "a.a"   "bb""b.bbb"
>
>
> -- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter 
> wrote:
> > Jun:
> >
> > You need to provide a clear specification via regular expressions of
> > the patterns you wish to match -- at least for me to decipher it.
> > Others may be smarter than I, though...
> >
> > Jeff: Thanks. I have now convinced myself that it can be done (a
> > "proof" of sorts): If pat1, pat2,..., patn are m different patterns
> > (in a vector of patterns)  to be matched in a vector of n strings,
> > where only one of the patterns will match in any string,  then use
> > paste() (probably via do.call()) or otherwise to paste them together
> > separated by "|" to form the concatenated pattern, pat. Then
> >
> > sub(paste0("^.*(",pat, ").*$"),"\\1",thevector)
> >
> > should extract the matching pattern in each (perhaps with a little
> > fiddling due to precedence rules); e.g.
> >
> >> z <-c(".fg.h.g.a.a", "bb..dd.ef.tgf.", "foo...b.bbb.tgy")
> >
> >> pat1 <- "a+\\.*a+"
> >> pat2 <-"b+\\.*b+"
> >> pat <- c(pat1,pat2)
> >
> >> pat <- do.call(paste,c(as.list(pat), sep="|"))
> >> pat
> > [1] "a+\\.*a+|b+\\.*b+"
> >
> >> sub(paste0("^[^b]*(",pat,").*$"), "\\1", z)
> > [1] "a.a"   "bb""b.bbb"
> >
> > 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 Mon, Sep 5, 2016 at 9:56 AM, Jun Shen  wrote:
> >> Thanks for the reply, Bert.
> >>
> >> Your solution solves the example. I actually have a more general
> situation
> >> where I have this dot concatenated string from multiple variables. The
> >> problem is those variables may have values with dots in there. The
> number of
> >> dots are not consistent for all values of a variable. So I am thinking
> to
> >> define a vector of patterns for the vector of the string and hopefully
> to
> >> find a way to use a pattern from the pattern vector for each value of
> the
> >> string vector. The only way I can think of is "for" loop, which can be
> slow.
> >> Also these are happening in a function I am writing. Just wonder if
> there is
> >> another more efficient way. Thanks a lot.
> >>
> >> Jun
> >>
> >> On Mon, Sep 5, 2016 at 1:41 AM, Bert Gunter 
> wrote:
> >>>
> >>> Well, he did provide an example, and...
> >>>
> >>>
> >>> > z <- c('TX.WT.CUT.mean','mg.tx.cv')
> >>>
> >>> > sub("^.+?\\.(.+)\\.[^.]+$","\\1",z)
> >>> [1] "WT.CUT" "tx"
> >>>
> >>>
> >>> ## seems to do what was requested.
> >>>
> >>> Jeff would have to amplify on his initial statement however: do you
> >>> mean that separate patterns can always be combined via "|" ?  Or
> >>> something deeper?
> >>>
> >>> 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 Sun, Sep 4, 2016 at 9:30 PM, Jeff Newmiller <
> jdnew...@dcn.davis.ca.us>
> >>> wrote:
> >>> > Your opening assertion is false.
> >>> >
> >>> > Provide a reproducible example and someone will demonstrate.
> >>> > --
> >>> > Sent from my phone. Please excuse my brevity.
> >>> >
> >>> > On September 4, 2016 9:06:59 PM PDT, Jun Shen  

[R-es] igraph edges busqueda

2016-09-06 Thread javier.ruben.marcuzzi
Estimados

Tengo una duda

E(datos.network)[[inc('LoQueBusco')]]
+ 20/6795 edges (vertex names):

E(datos.network)[E(datos.network)$Cosa=="'LoQueBusco'"] 
+ 78/6795 edges (vertex names):

La primer forma es 20/… la segunda 78/… ¿Los resultados no tendrían que ser 
idénticos? Estos datos son pocos pero me desarman la cabeza.

Desde ya muchas gracias.

Javier Rubén Marcuzzi

[[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 con gráfico típico de histograma más linea

2016-09-06 Thread Carlos Ortega
Hola,

Dell es los pocos que yo sepa que ofrecen equipos con Linux instalado como
SO de base:

http://www.dell.com/es/empresas/p/xps-13-9350-laptop-ubuntu/pd?oc=bnx9333

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 6 de septiembre de 2016, 21:33, Ruben Tobalina Ramirez <
lagrimaescr...@gmail.com> escribió:

> Buenas,
>
> gracias a los que me ayudaron, he conseguido hacer el código más o menos
> como queria. Lo pego por aqui por si a alguien le interesa. Me hubiese
> gustado hacerlo en dos ejes pero tengo que entregar la practica de la
> especialidad en 3 dias y hay muchas cosas que revisar, pero ya que he visto
> como se hace lo investigaré.
>
> ft$hora <- strptime(ft$hora, format = "%H:%M", tz="GMT-2")
> ft$Miles <- as.numeric(gsub("\\.", "", as.character(ft$Miles)))
> ft$Share <- as.numeric(gsub("\\,", ".", as.character(ft$Share)))
>
> ggbar <- ggplot(ft, aes(x = hora, y = frec)) +
>   geom_area(fill= "gray") +
>   scale_x_datetime(date_breaks = "5 mins", date_labels = "%H:%M") +
>   theme(panel.background = element_rect(fill = "white")) +
>   scale_y_continuous(limits=c(0,1500)) +
>   labs(x = "Minutos", y = "Tweets") + # Etiquetas o títulos de los ejes
>   theme(axis.text.x=element_text(angle=90)) # Orientación texto eje x
>
> ggshr <- ggplot(ft, aes(x = hora, y = Share)) + geom_line(color="blue") +
>   scale_x_datetime(date_breaks = "5 mins", date_labels = "%H:%M") +
>   theme(panel.background = element_rect(fill = "white")) +
>   scale_y_continuous(limits=c(0,50)) +
>   labs(x = "Minutos", y = "Share (%)") + # Etiquetas o títulos de los ejes
>   theme(axis.text.x=element_text(angle=90)) # Orientación texto eje x
>
> library(gridExtra)
> grid.arrange(ggbar, ggshr, nrow=2, ncol=1)
>
> Buenas noches!
>
> PD: Se me jodido, o esta punto de hacerlo mi portátil. Alguna sugerencia de
> marca "normal" que funcione de base muy bien con Linux??
>
> Rubén.
>
> [[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] Gráfico de Barras

2016-09-06 Thread Carlos Ortega
Hola,

En los gráficos "base", las barras se construyen repartiéndolas sobre el
eje "X". Para saber sobre qué punto cae el punto intermedio, la forma de
hacerlo es recuperando los valores del objeto "barplot" como has hecho. Y
una vez recuperados, utilizas estos puntos para pintar líneas de forma que
coincidan las "Xs" de los centros de las barras y tus "Xs" que quieres
añadir de tus puntos o líneas que vas a superponer.

Esto, aparece reflejado en la ayuda de *barplot*, lo destaco en negrita.
El epígrafe de la ayuda "Value" siempre detalla los valores que devuelve el
objeto descrito.

#--

*Value*

A numeric vector (or matrix, when beside = TRUE), say mp, *giving the
coordinates of all the bar midpoints drawn, useful for adding to the graph.*

If beside is true, use colMeans(mp) for the midpoints of each *group* of
bars, see example.
#--

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 6 de septiembre de 2016, 22:23, Mauricio Monsalvo 
escribió:

> Hola.
> Siguiendo a Mittal (2001); R Graph Cookbook creo haber logrado construir
> el gráfico de barras que buscada. La matriz que utilizo para el "height" va
> adjunta.
> Y mi sintaxis:
> barplot(t(barras), col=col.segmentos, border=F
> , names.arg=Meses, las=2, cex=.75, cex.axis=0.8
> , ylab="% del Segmento sobre el Total")
>legend(.5, .2, ncol=5, cex=.75, bty="n" #bg="white" #, lwd=F ,
> horiz=T), pch = 15
>   , segmentos #Referencias
>   , fill = col.segmentos, border = "darkblue" ) #
>grid(nx=NA, ny=NULL, col = "gray", lwd = 1, lty = 3) #
>abline(v=c(12, 24, 36, 48, 60), lwd = 1, lty = 3, col = "red") #red
> para que se ven los cortes en los años
>text(c(6, 18, 30, 42, 54), rep(.3, 5), c(2011, 2012, 2013, 2014,
> 2015))
> ​Queda bastante lindo, pero el problema lo tengo con ​abline y text, que
> quedan "desajustados" de los meses Dic de cada año, porque está mal
> indicada la referencia en c(12, 24, 36, 48, 60), a pesar de que dim(barras)
> y las categorías claramente son 67, que son las barras que contruyo.
> Luego, cuando intento entender por qué, pruebo:
> mm <- barplot(t(barras), col=col.segmentos, border=F
> , names.arg=Meses, las=2, cex=.75, cex.axis=0.8
> , ylab="% del Segmento sobre el Total")
> y resulta:
> > mm
>  [1]  0.7  1.9  3.1  4.3  5.5  6.7  7.9  9.1 10.3 11.5 12.7 13.9 15.1 16.3
> 17.5 18.7 19.9 21.1 22.3 23.5 24.7 25.9 27.1 28.3 29.5
> [26] 30.7 31.9 33.1 34.3 35.5 36.7 37.9 39.1 40.3 41.5 42.7 43.9 45.1 46.3
> 47.5 48.7 49.9 51.1 52.3 53.5 54.7 55.9 57.1 58.3 59.5
> [51] 60.7 61.9 63.1 64.3 65.5 66.7 67.9 69.1 70.3 71.5 72.7 73.9 75.1 76.3
> 77.5 78.7 79.9
> Lo cual parece una buena pista, pero no consigo entender qué hace... por
> qué el resultado no es 1:67? ¿Tengo que hacer algo especial para eso?
> Obvio, que ahora si utilizo:
>abline(v=mm[c(12, 24, 36, 48, 60)], lwd = 1, lty = 3, col = "red")
> #Para los Años
>text(mm[c(12, 24, 36, 48, 60)]-6, rep(.3, 5), c(2011, 2012, 2013,
> 2014, 2015))
> funcionaría, pero me parece poco intuitivo y además no entiendo por qué lo
> hace y me "obliga" a crear el objeto mm, en lugar de hacerlo directamente.
> Muchas gracias.
> --
> Mauricio
>
> ___
> 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

[R-es] Gráfico de Barras

2016-09-06 Thread Mauricio Monsalvo
Hola.
Siguiendo a Mittal (2001); R Graph Cookbook creo haber logrado construir el
gráfico de barras que buscada. La matriz que utilizo para el "height" va
adjunta.
Y mi sintaxis:
barplot(t(barras), col=col.segmentos, border=F
, names.arg=Meses, las=2, cex=.75, cex.axis=0.8
, ylab="% del Segmento sobre el Total")
   legend(.5, .2, ncol=5, cex=.75, bty="n" #bg="white" #, lwd=F ,
horiz=T), pch = 15
  , segmentos #Referencias
  , fill = col.segmentos, border = "darkblue" ) #
   grid(nx=NA, ny=NULL, col = "gray", lwd = 1, lty = 3) #
   abline(v=c(12, 24, 36, 48, 60), lwd = 1, lty = 3, col = "red") #red
para que se ven los cortes en los años
   text(c(6, 18, 30, 42, 54), rep(.3, 5), c(2011, 2012, 2013, 2014,
2015))
​Queda bastante lindo, pero el problema lo tengo con ​abline y text, que
quedan "desajustados" de los meses Dic de cada año, porque está mal
indicada la referencia en c(12, 24, 36, 48, 60), a pesar de que dim(barras)
y las categorías claramente son 67, que son las barras que contruyo.
Luego, cuando intento entender por qué, pruebo:
mm <- barplot(t(barras), col=col.segmentos, border=F
, names.arg=Meses, las=2, cex=.75, cex.axis=0.8
, ylab="% del Segmento sobre el Total")
y resulta:
> mm
 [1]  0.7  1.9  3.1  4.3  5.5  6.7  7.9  9.1 10.3 11.5 12.7 13.9 15.1 16.3
17.5 18.7 19.9 21.1 22.3 23.5 24.7 25.9 27.1 28.3 29.5
[26] 30.7 31.9 33.1 34.3 35.5 36.7 37.9 39.1 40.3 41.5 42.7 43.9 45.1 46.3
47.5 48.7 49.9 51.1 52.3 53.5 54.7 55.9 57.1 58.3 59.5
[51] 60.7 61.9 63.1 64.3 65.5 66.7 67.9 69.1 70.3 71.5 72.7 73.9 75.1 76.3
77.5 78.7 79.9
Lo cual parece una buena pista, pero no consigo entender qué hace... por
qué el resultado no es 1:67? ¿Tengo que hacer algo especial para eso?
Obvio, que ahora si utilizo:
   abline(v=mm[c(12, 24, 36, 48, 60)], lwd = 1, lty = 3, col = "red")
#Para los Años
   text(mm[c(12, 24, 36, 48, 60)]-6, rep(.3, 5), c(2011, 2012, 2013,
2014, 2015))
funcionaría, pero me parece poco intuitivo y además no entiendo por qué lo
hace y me "obliga" a crear el objeto mm, en lugar de hacerlo directamente.
Muchas gracias.
-- 
Mauricio
"","OyTE","SFM","PAMI 100%","TRANSPLANTE","Hemofilia","TIRAS","INSULINA","Eritropoyetina","Coagulacion"
"Jan",0.402968827961749,0.257408832587665,0.0305388353662353,0.0445265407084394,0.0351238712987791,0.0907656132858987,0.133624159792322,0.00504331899891206,0
"Feb",0.388046519726048,0.27691100819193,0.0308084877199341,0.0442206588388275,0.0276407353796231,0.0941602850144472,0.132491761255669,0.00572054387352031,0
"Mar",0.396816232597955,0.285427858005844,0.0272743423663153,0.0372215758528325,0.0396944241509067,0.0883491416054905,0.119708284160237,0.00550814126041944,0
"Apr",0.377076200559931,0.291733655566432,0.0347555766579469,0.0419224041672145,0.0356733157801241,0.0903000477739997,0.123399308227161,0.00513949126719042,0
"May",0.397033899592251,0.279261158441758,0.0322250974637028,0.0399772856853863,0.0281518816503729,0.0926082130383577,0.125252628152313,0.00548983597585879,0
"Jun",0.394488322045226,0.270849846529311,0.0359704345594814,0.0389537287221118,0.0374198758495455,0.0914482100121024,0.1250261185139,0.00584346376832189,0
"Jul",0.394458170352748,0.268964821914657,0.0328955869284503,0.0371685718578826,0.0378466420404039,0.0943826647174312,0.128057637193603,0.00622590499482426,0
"Aug",0.39963691673089,0.257150562198302,0.0348346122706993,0.0402760578516048,0.0368711176751811,0.0948540968954327,0.130943881787159,0.00543275459073121,0
"Sep",0.407388235759253,0.249104085879809,0.031748094222342,0.0362032211697,0.0296552145289262,0.10246745629875,0.136843630308877,0.00659006183234324,0
"Oct",0.387609483724748,0.255859059824067,0.0375631476012162,0.0435943883205955,0.0362138326088776,0.100369652159307,0.13232941186,0.00545720282000312,0
"Nov",0.385688190697047,0.250515375999841,0.0359287946141362,0.0390475441885595,0.0352069018855444,0.107531611159626,0.140671578776663,0.005410002678583,0
"Dec",0.398067499861435,0.256929306094169,0.0373294465506162,0.0440215008887216,0.0232996101627119,0.0988165832097856,0.135683618071302,0.00585243516125887,0
"Jan",0.387573892385901,0.243467223568122,0.0374281829988855,0.0385231733925119,0.034490022780355,0.107112145287775,0.145517579591619,0.00588777999482931,0
"Feb",0.383875346683581,0.217634398469975,0.0344871839624882,0.0374884803420337,0.0482480235452724,0.117054669965787,0.155339034318647,0.00587286271221514,0
"Mar",0.434407650263776,0.233122693204075,0.0334978990595036,0.0426145310681265,0.0250870924745336,0.0969021359045427,0.127955439576328,0.00641255844911469,0
"Apr",0.417663717793382,0.221267629500663,0.0285621777360624,0.037637973478347,0.0385678315998472,0.107051044489174,0.142952932202841,0.00629669319968329,0
"May",0.421818084612946,0.242610876055651,0.0370871913383265,0.0398815056727648,0.0242635669160382,0.0992793065569617,0.12906385055901,0.00599561828830147,0

Re: [R-es] Ayuda con gráfico típico de histograma más linea

2016-09-06 Thread Ruben Tobalina Ramirez
Buenas,

gracias a los que me ayudaron, he conseguido hacer el código más o menos
como queria. Lo pego por aqui por si a alguien le interesa. Me hubiese
gustado hacerlo en dos ejes pero tengo que entregar la practica de la
especialidad en 3 dias y hay muchas cosas que revisar, pero ya que he visto
como se hace lo investigaré.

ft$hora <- strptime(ft$hora, format = "%H:%M", tz="GMT-2")
ft$Miles <- as.numeric(gsub("\\.", "", as.character(ft$Miles)))
ft$Share <- as.numeric(gsub("\\,", ".", as.character(ft$Share)))

ggbar <- ggplot(ft, aes(x = hora, y = frec)) +
  geom_area(fill= "gray") +
  scale_x_datetime(date_breaks = "5 mins", date_labels = "%H:%M") +
  theme(panel.background = element_rect(fill = "white")) +
  scale_y_continuous(limits=c(0,1500)) +
  labs(x = "Minutos", y = "Tweets") + # Etiquetas o títulos de los ejes
  theme(axis.text.x=element_text(angle=90)) # Orientación texto eje x

ggshr <- ggplot(ft, aes(x = hora, y = Share)) + geom_line(color="blue") +
  scale_x_datetime(date_breaks = "5 mins", date_labels = "%H:%M") +
  theme(panel.background = element_rect(fill = "white")) +
  scale_y_continuous(limits=c(0,50)) +
  labs(x = "Minutos", y = "Share (%)") + # Etiquetas o títulos de los ejes
  theme(axis.text.x=element_text(angle=90)) # Orientación texto eje x

library(gridExtra)
grid.arrange(ggbar, ggshr, nrow=2, ncol=1)

Buenas noches!

PD: Se me jodido, o esta punto de hacerlo mi portátil. Alguna sugerencia de
marca "normal" que funcione de base muy bien con Linux??

Rubén.

[[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] usar un for para cambiar indice

2016-09-06 Thread Jorge I Velez
Es más fácil si usas matplot.  Mira ?matplot para más información.  Saludos
cordiales.   --JIV


2016-09-06 13:48 GMT-05:00 Sebastian Kruk :

> Estimados usuarios-de-R:
>
> Tengo un problema.
>
> Si por ejemplo tengo una lista conformada por la serie historia del PBI de
> 10 paìses.
>
> >Tiempo <- seq(1:100)
> >plot(Tiempo, PP$"Serie 1", type="l",col="1")
> >lines(Tiempo, PPcapita$"Serie 2")
> >lines(Tiempo, PPcapita$"Serie 3")
> >lines(Tiempo, PPcapita$"Serie 4")
> >lines(Tiempo, PPcapita$"Serie 5")
> >lines(Tiempo, PPcapita$"Serie 6")
> >lines(Tiempo, PPcapita$"Serie 7")
> >lines(Tiempo, PPcapita$"Serie 8")
> >lines(Tiempo, PPcapita$"Serie 9")
> >lines(Tiempo, PPcapita$"Serie 10")
>
> ¡Y quiero usar un for para lo anterior o vectorizar como lo hago?
>
> Me da error hacer lo siguiente:
>
> Tiempo <- seq(1:100)
> plot(Tiempo, PP$"Serie 1", type="l",col="red")
> for (i in 2:10) {lines(Tiempo, PPcapita$"Serie i",col=i)
>
> ¿Hay alguna forma de resolverlo?
>
> Saludos,
>
> Sebas.
>
> [[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] usar un for para cambiar indice

2016-09-06 Thread Sebastian Kruk
Estimados usuarios-de-R:

Tengo un problema.

Si por ejemplo tengo una lista conformada por la serie historia del PBI de
10 paìses.

>Tiempo <- seq(1:100)
>plot(Tiempo, PP$"Serie 1", type="l",col="1")
>lines(Tiempo, PPcapita$"Serie 2")
>lines(Tiempo, PPcapita$"Serie 3")
>lines(Tiempo, PPcapita$"Serie 4")
>lines(Tiempo, PPcapita$"Serie 5")
>lines(Tiempo, PPcapita$"Serie 6")
>lines(Tiempo, PPcapita$"Serie 7")
>lines(Tiempo, PPcapita$"Serie 8")
>lines(Tiempo, PPcapita$"Serie 9")
>lines(Tiempo, PPcapita$"Serie 10")

¡Y quiero usar un for para lo anterior o vectorizar como lo hago?

Me da error hacer lo siguiente:

Tiempo <- seq(1:100)
plot(Tiempo, PP$"Serie 1", type="l",col="red")
for (i in 2:10) {lines(Tiempo, PPcapita$"Serie i",col=i)

¿Hay alguna forma de resolverlo?

Saludos,

Sebas.

[[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] save R object into a remote directory

2016-09-06 Thread Henrik Bengtsson
On Tue, Sep 6, 2016 at 2:00 AM, Rainer M Krug  wrote:
> Please reply to the mailing list to keep the conversation available for
> everybody. I Send this mail to the mailing list as well.
>
> Simone Tenan  writes:
>
>> Thanks Rainer,
>> it's very kind of you.
>> Unfortunately, I cannot save the (large) R object where the current R 
>> session is running. There is not enough memory and when I tried I got the 
>> error "error
>> writing to connection".
>
> OK - essential piece of information.

Assuming the remote machine you're logging into is running Linux:

Before anything else, did you try to save elsewhere than to your
/home/ folder/account? Try /tmp/.  That probably / hopefully doesn't
count to your account quota (and it gets wiped at every reboot).
There's also /var/tmp/ (a bit more persistent storage - survives
reboots).

/Henrik

PS. In R, the tempdir() function often points to a directory under
/tmp/, e.g.  tempdir() => "/tmp/RtmpWZPsip".  However, that will be
wiped by R itself when you quit the R session, so if you use tempdir()
you need to scp that file before you quit R.  It's probably better to
avoid tempdir() in your case.

>
> In this case, your best bet is trying to mount an a flder from your
> client on the server and than save there.
>
> Contact you administrator to find out if this is possible or (s)he has
> other suggestions.
>
>> For that reason I was trying to save the object of of the remote server.
>>
>> Best,
>
> Cheers,
>
> Rainer
>
>> Simone
>>
>> On 6 September 2016 at 10:30, Rainer M Krug  wrote:
>>
>>  Simone Tenan  writes:
>>
>>  > Hi all,
>>  > I'm using R remotely via ssh connection in linux. I need to save a large R
>>  > object from the remote server to my laptop. How can I specify the path in
>>  > the save() function?
>>
>>  You are working on the remote machine and there is no way that you can
>>  specify "out of the box" a save to client machine (I stand to be corrected).
>>
>>  You could mount a directory on the client on the server, but I would
>>  suggest to
>>
>>  1) save the object on the server (the where R is running on)
>>  2) use scp from the client to copy the file from the server to the
>>  client (the one you are typing on).
>>
>>  scp user@host1:file1 ./TheNameOfTheLocalFile
>>
>>  Cheers,
>>
>>  Rainer
>>
>>  >
>>  > Thanks much for your help,
>>  > Simone
>>  >
>>  > [[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.
>>
>>  --
>>  Rainer M. Krug
>>  email: Rainerkrugsde
>>  PGP: 0x0F52F982
>>
>>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
> UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :   +33 - (0)9 53 10 27 44
> Cell:   +33 - (0)6 85 62 59 98
> Fax :   +33 - (0)9 58 10 27 44
>
> Fax (D):+49 - (0)3 21 21 25 22 44
>
> email:  rai...@krugs.de
>
> Skype:  RMkrug
>
> PGP: 0x0F52F982
>
> __
> 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] graph together 4 series after HP filter

2016-09-06 Thread Giorgio Garziano
Hi Sebastian,

here are examples with ggplot2 and basic graphic.

http://stackoverflow.com/questions/3777174/plotting-two-variables-as-lines-using-ggplot2-on-the-same-graph

http://stackoverflow.com/questions/17150183/r-plot-multiple-lines-in-one-graph


You may also impress your audience by using iterative graphs as provided by 
dygraphs package.

https://blog.rstudio.org/2015/04/14/interactive-time-series-with-dygraphs/

You have to convert your xts objects starting from your ts ones.

An example:

getSymbols("AAPL", src = "yahoo", from = as.Date("2013-07-01"), to = 
as.Date("2016-06-30"))
getSymbols("YHOO", src = "yahoo", from = as.Date("2013-07-01"), to = 
as.Date("2016-06-30"))
getSymbols("CPHD", src = "yahoo", from = as.Date("2013-07-01"), to = 
as.Date("2016-06-30"))
getSymbols("EMC", src = "yahoo", from = as.Date("2013-07-01"), to = 
as.Date("2016-06-30"))
AAPL.xts <- Ad(AAPL)
YHOO.xts <- Ad(YHOO)
CPHD.xts <- Ad(CPHD)
EMC.xts <- Ad(EMC)

df <- data.frame(AAPL.xts, YHOO.xts, CPHD.xts, EMC.xts)
head(df)

library(dygraphs)
dygraph(df)

--

Best,

GG





[[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-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Cade, Brian
For a linear model without an intercept term as in this example, neither
the usual permutation scheme for testing Ho: B1 = 0 nor usual definition of
R-squared apply.  So you need to check what the developer of this code
chose to do.  If I'm recalling correctly, in a linear model with an
intercept term the permutation test for Ho: B1 = B2 = ... Bp = 0 (i.e., all
coefficients other than the intercept = 0) is equivalent to a permutation
test for Ho: R-squared = 0.

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  ca...@usgs.gov 
tel:  970 226-9326


On Tue, Sep 6, 2016 at 8:35 AM, Jeff Newmiller 
wrote:

> That is contributed code. It could do anything the author felt like. I
> recommend reading the source code.
> --
> Sent from my phone. Please excuse my brevity.
>
> On September 5, 2016 11:52:15 PM PDT, Agustin Lobo 
> wrote:
> >Any reason why the R-square prob is not calculated by randomization in
> >lmPerm::lmp? The help pages states "Either permutation test p-values
> >or the usual F-test p-values will be output", but I always get the F
> >test for R-square as with lm():
> >
> >require(lmPerm)
> >x <- 1:1000
> >set.seed(1000)
> >y1 <- x*2+runif(1000,-100,100)
> >dat <- data.frame(x =x,y=y1)
> >summary(lmp(y~x, data=dat,center=FALSE,perm="Prob"))
> >
> >[1] "Settings:  unique SS "
> >
> >Call:
> >lmp(formula = y ~ x, data = dat, center = FALSE)
> >
> >Residuals:
> > Min   1Q   Median   3Q  Max
> >-100.431  -48.6452.843   48.640  101.800
> >
> >Coefficients:
> >  Estimate Iter Pr(Prob)
> >x1.993 5000   <2e-16 ***
> >---
> >Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> >
> >Residual standard error: 57.3 on 998 degrees of freedom
> >Multiple R-Squared: 0.9902, Adjusted R-squared: 0.9902
> >F-statistic: 1.009e+05 on 1 and 998 DF,  p-value: < 2.2e-16
>
> __
> 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] graph together 4 series after HP filter

2016-09-06 Thread Bert Gunter
?lines
?points

to add to an existing base graphics graph. There are other ways to do
this in the other graph systems (ggplot, lattice,...) used in R.

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 Tue, Sep 6, 2016 at 6:40 AM, Sebastian Kruk  wrote:
> Dear R-users:
>
> Let's see if you can help.
>
> I have an matrix of class "ts" of 100 rows by 4 columns which called PP.
>
> In each column I have the time series of quarterly GDP from 4 countries.
>
> They applied the Hodrick -Prescott filter and now I want to plot
> simultaneously cyclical component of the 4 countries and another window
> graphed together the trend conponentes .
>
> #If PP include the series of one country would do:
> lambda <- 1600
> DFIL <- hpfilter (PP, freq = lambda, type = "lambda" )
> #First graph
> plot(DFIL$x, plot.type = "single" col = 1:Countries , main = "Economy and
> Trend" )
> #Second graphic
> plot(DFIL$cycle, plot.type = "single" col = 1:Countries, main = "Cycle" )
> #A Deactivate the two graphics
> pair(mfrow = c (1,1))
>
> But I want to put on each graph window all the components'series.
>
> Then I made first:
> DFIL <- apply ( PP , 2, hpfilter , freq = lambda, type = "lambda" )
> How can I graph all cyclical components together?
>
> Regards,
>
> Sebastian.
>
> [[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] R-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Jeff Newmiller
That is contributed code. It could do anything the author felt like. I 
recommend reading the source code. 
-- 
Sent from my phone. Please excuse my brevity.

On September 5, 2016 11:52:15 PM PDT, Agustin Lobo  wrote:
>Any reason why the R-square prob is not calculated by randomization in
>lmPerm::lmp? The help pages states "Either permutation test p-values
>or the usual F-test p-values will be output", but I always get the F
>test for R-square as with lm():
>
>require(lmPerm)
>x <- 1:1000
>set.seed(1000)
>y1 <- x*2+runif(1000,-100,100)
>dat <- data.frame(x =x,y=y1)
>summary(lmp(y~x, data=dat,center=FALSE,perm="Prob"))
>
>[1] "Settings:  unique SS "
>
>Call:
>lmp(formula = y ~ x, data = dat, center = FALSE)
>
>Residuals:
> Min   1Q   Median   3Q  Max
>-100.431  -48.6452.843   48.640  101.800
>
>Coefficients:
>  Estimate Iter Pr(Prob)
>x1.993 5000   <2e-16 ***
>---
>Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
>Residual standard error: 57.3 on 998 degrees of freedom
>Multiple R-Squared: 0.9902, Adjusted R-squared: 0.9902
>F-statistic: 1.009e+05 on 1 and 998 DF,  p-value: < 2.2e-16

__
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] Factor analysis and time as an offset variable

2016-09-06 Thread Tahereh Dehdarirad
Thank you for your reply. I am grouping citation and some social media
indictors ( number of tweets, mendeley readers, etc). The number of
citaions a paper recievs or the number of social media indicators that a
papers receives depends on time. For example a paper published in 2009 has
more time to get citation than a paper pubished lets say in year 2016.

That is the reason I like to consider  time ( in my case the number of
years) a paper has been to the exposure of receiving citations in the
factor analysis.

Best,

Tahereh




Tahereh Dehdarirad
PhD Student of Library and Information Science
University of Barcelona, Spain

On Tue, Sep 6, 2016 at 4:31 PM, Jeff Newmiller 
wrote:

> That step is easy, but context is hard. You really need to provide a
> reproducible example. There are many models, many analysis tools,  and many
> timescales to choose from. In fact, this could easily be mistaken for a
> question about statistics (not really on-topic here) since you have failed
> to indicate what any of your constraints or decisions in those areas are.
>
> It may be as simple as you not knowing about date or POSIXt arithmetic
> (see ?DateTimeClasses).
> --
> Sent from my phone. Please excuse my brevity.
>
> On September 6, 2016 6:08:41 AM PDT, Tahereh Dehdarirad <
> tdehd...@gmail.com> wrote:
> >Hi,
> >
> >Is it possible to use time as an offset (exposure variable) in factor
> >analysis? If yes, would you please advise how?
> >
> >
> >Thanks,
> >
> >Tahereh
> >
> >
> >
> >
> >Tahereh Dehdarirad
> >PhD Student of Library and Information Science
> >University of Barcelona, Spain
> >
> >   [[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] Factor analysis and time as an offset variable

2016-09-06 Thread Jeff Newmiller
That step is easy, but context is hard. You really need to provide a 
reproducible example. There are many models, many analysis tools,  and many 
timescales to choose from. In fact, this could easily be mistaken for a 
question about statistics (not really on-topic here) since you have failed to 
indicate what any of your constraints or decisions in those areas are. 

It may be as simple as you not knowing about date or POSIXt arithmetic  (see 
?DateTimeClasses).
-- 
Sent from my phone. Please excuse my brevity.

On September 6, 2016 6:08:41 AM PDT, Tahereh Dehdarirad  
wrote:
>Hi,
>
>Is it possible to use time as an offset (exposure variable) in factor
>analysis? If yes, would you please advise how?
>
>
>Thanks,
>
>Tahereh
>
>
>
>
>Tahereh Dehdarirad
>PhD Student of Library and Information Science
>University of Barcelona, Spain
>
>   [[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] (no subject)

2016-09-06 Thread Jeff Newmiller
It is not the implementation of regex that requires double backslashes, but the 
R string parser. You can use cat to see what the pattern looks like to the 
parser. Try

cat( "\\(.*?\\)" )
-- 
Sent from my phone. Please excuse my brevity.

On September 6, 2016 6:33:15 AM PDT, Sarah Goslee  
wrote:
>R's implementation of regex requires double backslashes. Reading
>?regex will tell you more.
>
>
>cleanBetweenBrackets <- function(String)
>{
>  return(gsub("\\(.*?\\)", "", String))
>}
>
>Str <- "The cat is crazy (but not too crazy)"
>
>cleanBetweenBrackets(Str)
>
>> cleanBetweenBrackets(Str)
>[1] "The cat is crazy "
>
>
>The trailing space is left as an exercise for the reader.
>
>Sarah
>
>On Tue, Sep 6, 2016 at 2:56 AM, Audrey Riddell 
>wrote:
>> Hello,
>>
>>
>> I am trying to remove brackets and the text contained in brackets. I
>tried
>> to do a user defined formula... my attempt at this is pasted below.
>>
>> cleanBetweenBrackets <- function(String)
>>   { return(gsub("\(.*?\)", "", String))}
>>
>>  I keep getting errors (namely that there is an unrecognised escape
>> character in the string). I have looked at regex forums a bit, but
>cant
>> figure this out.
>>
>> I want the above formula to be able to produce the following result
>>
>>>Str<-"The cat is crazy (but not too crazy)"
>>>StrNoBrackets<-cleanBetweenBrackets(Str)
>>>StrNoBrackets
>> [1]  "The cat is crazy "
>>
>> Assistance would be appreciated,
>>
>> Audrey
>>

__
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] igraph V a partir de E y subgrafos

2016-09-06 Thread javier.ruben.marcuzzi
Estimado Luisfo

Gracias por la acotación, tendía que ver ese cambio, hora ¿el resultado sería 
el mismo al crear el subgrafo o hay una diferencia entre el subgrafo entre: 
subgraph.edges y induced.subgraph? Yo pienso que colocando correctamente los 
parámetros el resultado no debería ser distinto.

Otra pregunta, hay una forma de colocar más de un filtro en lo siguiente:
plot(subgraph.edges(datos.network, E(datos.network)[[inc(‘Casa’)]]))
a por ejemplo
plot(subgraph.edges(datos.network, E(datos.network)[[inc('Casa')    otro 
filtro +++]]))

Porque me parece que tendré que filtrar y luego crear los grafos, no estoy 
dando justo con lo que necesito, me resulta muy fácil crear un montón de 
igraph(….), pero me parece que sería ineficiente.

Javier Rubén Marcuzzi

De: Luisfo
[[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] Conditional gap time frailty cox model for recurrent events

2016-09-06 Thread Therneau, Terry M., Ph.D.
You can ignore the message below.  The maximizing routine buried within the frailty() 
command buried with coxph() has a maximizer that is not the brightest.  It sometimes gets 
lost but then finds its way again.  The message is from one of those.  It likely took a 
not-so-good update step, and took a couple of iterations to recover.


In coxpenal.fit(X, Y, strats, offset, init = init, control, weights = weights,  
:
   Inner loop failed to coverge for iterations 3 4

To be fair the maximizing problem for a mixed effects Cox model is not easy.  In the coxme 
code I have spent much more time on the details of this.


Terry Therneau

--

On 09/06/2016 05:00 AM, r-help-requ...@r-project.org wrote:

Dear Elisabetta,

I have no direct answer to your question, but a suggestion: Use the
'coxme' function (in the package with the same name). In the help page
for 'frailty' (survival) you will find: "The coxme package has
superseded this method. It is faster, more stable, and more flexible."

Hth, G?ran

On 2016-09-05 11:42, Elisabetta Petracci wrote:

>Dear users,
>
>I am fitting a conditional gap time frailty cox model weighting
>observations by means of inverse probability time dependent weigths.
>Attached find the self-explaining dataset.
>
>I have used the following sintax:
>
>coxph(Surv(gaptstart,gaptstop,status)~treat+strata(nrecord01)+frailty(id,distribution="gamma",method="em"),
>data=dataNOTDrr,weights=dataNOTDrr$weight)
>
>
>And I get the following warning:
>
>Warning message:
>In coxpenal.fit(X, Y, strats, offset, init = init, control, weights =
>weights,  :
>   Inner loop failed to coverge for iterations 3 4
>
>
>I have tried to:
>- leave out the weights but I get the error anyway
>- to randomly select a subset of patients and I don't get the error. This
>seems to suggest that the problem is with some observations.
>
>Any suggestion?
>
>Many thanks,
>
>Elisabetta
>


__
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] save R object into a remote directory

2016-09-06 Thread peter dalgaard

On 06 Sep 2016, at 11:00 , Rainer M Krug  wrote:

> Please reply to the mailing list to keep the conversation available for
> everybody. I Send this mail to the mailing list as well.
> 
> Simone Tenan  writes:
> 
>> Thanks Rainer,
>> it's very kind of you. 
>> Unfortunately, I cannot save the (large) R object where the current R 
>> session is running. There is not enough memory and when I tried I got the 
>> error "error
>> writing to connection".
> 
> OK - essential piece of information.
> 
> In this case, your best bet is trying to mount an a flder from your
> client on the server and than save there.


I think you can in principle do something with a socketConnection and SSH port 
forwarding, but it is not trivial.

> Contact you administrator to find out if this is possible or (s)he has
> other suggestions.
> 

yep.

>> For that reason I was trying to save the object of of the remote server.
>> 
>> Best,
> 
> Cheers,
> 
> Rainer
> 
>> Simone
>> 
>> On 6 September 2016 at 10:30, Rainer M Krug  wrote:
>> 
>> Simone Tenan  writes:
>> 
>>> Hi all,
>>> I'm using R remotely via ssh connection in linux. I need to save a large R
>>> object from the remote server to my laptop. How can I specify the path in
>>> the save() function?
>> 
>> You are working on the remote machine and there is no way that you can
>> specify "out of the box" a save to client machine (I stand to be corrected).
>> 
>> You could mount a directory on the client on the server, but I would
>> suggest to
>> 
>> 1) save the object on the server (the where R is running on)
>> 2) use scp from the client to copy the file from the server to the
>> client (the one you are typing on).
>> 
>> scp user@host1:file1 ./TheNameOfTheLocalFile
>> 
>> Cheers,
>> 
>> Rainer
>> 
>>> 
>>> Thanks much for your help,
>>> Simone
>>> 
>>> [[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.
>> 
>> --
>> Rainer M. Krug
>> email: Rainerkrugsde
>> PGP: 0x0F52F982
>> 
>> 
> 
> -- 
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
> UCT), Dipl. Phys. (Germany)
> 
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
> 
> Tel :   +33 - (0)9 53 10 27 44
> Cell:   +33 - (0)6 85 62 59 98
> Fax :   +33 - (0)9 58 10 27 44
> 
> Fax (D):+49 - (0)3 21 21 25 22 44
> 
> email:  rai...@krugs.de
> 
> Skype:  RMkrug
> 
> PGP: 0x0F52F982
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] graph together 4 series after HP filter

2016-09-06 Thread Sebastian Kruk
Dear R-users:

Let's see if you can help.

I have an matrix of class "ts" of 100 rows by 4 columns which called PP.

In each column I have the time series of quarterly GDP from 4 countries.

They applied the Hodrick -Prescott filter and now I want to plot
simultaneously cyclical component of the 4 countries and another window
graphed together the trend conponentes .

#If PP include the series of one country would do:
lambda <- 1600
DFIL <- hpfilter (PP, freq = lambda, type = "lambda" )
#First graph
plot(DFIL$x, plot.type = "single" col = 1:Countries , main = "Economy and
Trend" )
#Second graphic
plot(DFIL$cycle, plot.type = "single" col = 1:Countries, main = "Cycle" )
#A Deactivate the two graphics
pair(mfrow = c (1,1))

But I want to put on each graph window all the components'series.

Then I made first:
DFIL <- apply ( PP , 2, hpfilter , freq = lambda, type = "lambda" )
How can I graph all cyclical components together?

Regards,

Sebastian.

[[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] (no subject)

2016-09-06 Thread Sarah Goslee
R's implementation of regex requires double backslashes. Reading
?regex will tell you more.


cleanBetweenBrackets <- function(String)
{
  return(gsub("\\(.*?\\)", "", String))
}

Str <- "The cat is crazy (but not too crazy)"

cleanBetweenBrackets(Str)

> cleanBetweenBrackets(Str)
[1] "The cat is crazy "


The trailing space is left as an exercise for the reader.

Sarah

On Tue, Sep 6, 2016 at 2:56 AM, Audrey Riddell  wrote:
> Hello,
>
>
> I am trying to remove brackets and the text contained in brackets. I tried
> to do a user defined formula... my attempt at this is pasted below.
>
> cleanBetweenBrackets <- function(String)
>   { return(gsub("\(.*?\)", "", String))}
>
>  I keep getting errors (namely that there is an unrecognised escape
> character in the string). I have looked at regex forums a bit, but cant
> figure this out.
>
> I want the above formula to be able to produce the following result
>
>>Str<-"The cat is crazy (but not too crazy)"
>>StrNoBrackets<-cleanBetweenBrackets(Str)
>>StrNoBrackets
> [1]  "The cat is crazy "
>
> Assistance would be appreciated,
>
> Audrey
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] Factor analysis and time as an offset variable

2016-09-06 Thread Tahereh Dehdarirad
Hi,

Is it possible to use time as an offset (exposure variable) in factor
analysis? If yes, would you please advise how?


Thanks,

Tahereh




Tahereh Dehdarirad
PhD Student of Library and Information Science
University of Barcelona, Spain

[[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] outliers in Box Plot

2016-09-06 Thread Giorgio Garziano
Hi Rosa,

you may take advantage of the extremevalues package.

https://cran.r-project.org/web/packages/extremevalues/extremevalues.pdf

An example:

set.seed(1023)
v3 <- c(rnorm(100, 0, 0.2), rnorm(5, 4, 0.1), rnorm(5, -4, 0.1))
v4 <- sample(v3, length(v3))
nam <- as.character(1:length(v4))
df <- data.frame(names = nam, values = v4)


library(extremevalues)

res <- getOutliersI(as.vector(df[,"values"]), FLim=c(0.001, 0.999), 
distribution="normal")

# indexes where outliers are located
res$iLeft
res$iRight

outliers_idx <- c(res$iLeft, res$iRight)

df_outliers <- data.frame(index= outliers_idx, values = 
df[outliers_idx,"values"])
df_outliers

outlierPlot(df[,"values"], L=res)


--

Best

GG



[[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] Fwd:

2016-09-06 Thread Audrey Riddell
Hello,

I have been able to figure this out using \\ (two back slashes for escape)
Working R code for what I wanted is...

cleanBetweenBrackets <- function(String)
  { return(gsub("\\(.*?\\)", "", String))}

I thought I had tried that (the \\) before I emailed the list. Please
ignore my previous email.

Sorry for any inconvenience caused.

Audrey



-- Forwarded message --
From: Audrey Riddell 
Date: Tue, Sep 6, 2016 at 4:56 PM
Subject:
To: r-help@r-project.org


Hello,


I am trying to remove brackets and the text contained in brackets. I tried
to do a user defined formula... my attempt at this is pasted below.

cleanBetweenBrackets <- function(String)
  { return(gsub("\(.*?\)", "", String))}

 I keep getting errors (namely that there is an unrecognised escape
character in the string). I have looked at regex forums a bit, but cant
figure this out.

I want the above formula to be able to produce the following result

>Str<-"The cat is crazy (but not too crazy)"
>StrNoBrackets<-cleanBetweenBrackets(Str)
>StrNoBrackets
[1]  "The cat is crazy "

Assistance would be appreciated,

Audrey

[[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] Help with a code in R

2016-09-06 Thread Bert Gunter
?traceback
?debug
?trace

R has built-in debugging tools. Learn to use them.

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 Mon, Sep 5, 2016 at 11:25 AM, Erika Rocío Espinosa Balbuena
 wrote:
> Hi,
>
> I am working with this code:
>
> forecast_nal<-data.frame()
> out<-vector()
> x<-foreach(i=1:nrow(comb)) %do%
> {
>
> s<-comb[i,'prod_id']
>
> #Familia+Sumbarca+prod_id
> #Serie
>
> bcomb1<-b
> bcomb1<-subset(bcomb1,bcomb1$prod_id == s & bcomb1$year <= 2015)
> bcomb1<-arrange(bcomb1,year,week)
> a<-bcomb1[1:1,'week']
> d<-bcomb1[1:1,'year']
> f<-nrow(bcomb1)
> h<-bcomb1[f:f,'year']
> j<-bcomb1[f:f,'week']
> bcomb1<-bcomb1[,c(6)]
>
> if (length(bcomb1)<=10 || h=="2014" || (h=="2015" && j<=48))
> {
> out[i]<-s
> }
> else
> {
>y <- ts(bcomb1, frequency=52, start=c(d, a))
> ##Casos
>
> if (length(y)<=60)
> {
>
> v<-auto.arima(y)
> v<-arimaorder(v)
> fit <- arima(y, order = v ,method="ML")
>   fca <- forecast(fit, h = 16)
> dates <- attr(forecast_nal$mean, "tsp")
> datecol <- seq(from=dates[1], to=dates[2], by=1/dates[3])
> fct<-cbind.data.frame(s,datecol,Point=fca$mean)
> forecast_nal<- rbind.data.frame(forecast_nal,fct)
> }
> else
> {
>
> fit <- tbats(y)
> fcb <- forecast(fit, h = 16)
> dates <- attr(forecast_nal$mean, "tsp")
> datecol <- seq(from=dates[1], to=dates[2], by=1/dates[3])
> fct<-cbind.data.frame(s,datecol,Point=fcb$mean)
> forecast_nal<- rbind.data.frame(forecast_nal,fct)
> }
> }
> }
>  But I am getting this error:
>
> Error in `[<-.ts`(`*tmp*`, ri, value = c(26656.136365833, 26750.9374514082,
>  :
>   only replacement of elements is allowed
>
> Can someone help me with this?
>
> Thanks
>
>
> --
> Erika Rocío Espinosa Balbuena
>
> [[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] element wise pattern recognition and string substitution

2016-09-06 Thread Bert Gunter
Just noticed: My clumsy do.call() line in my previously posted code
below should be replaced with:
pat <- paste(pat,collapse = "|")


> pat <- c(pat1,pat2)
> paste(pat,collapse="|")
[1] "a+\\.*a+|b+\\.*b+"

 replace this **
> pat <- do.call(paste,c(as.list(pat), sep="|"))

> sub(paste0("^[^b]*(",pat,").*$"),"\\1",z)
[1] "a.a"   "bb""b.bbb"


-- 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 Mon, Sep 5, 2016 at 12:11 PM, Bert Gunter  wrote:
> Jun:
>
> You need to provide a clear specification via regular expressions of
> the patterns you wish to match -- at least for me to decipher it.
> Others may be smarter than I, though...
>
> Jeff: Thanks. I have now convinced myself that it can be done (a
> "proof" of sorts): If pat1, pat2,..., patn are m different patterns
> (in a vector of patterns)  to be matched in a vector of n strings,
> where only one of the patterns will match in any string,  then use
> paste() (probably via do.call()) or otherwise to paste them together
> separated by "|" to form the concatenated pattern, pat. Then
>
> sub(paste0("^.*(",pat, ").*$"),"\\1",thevector)
>
> should extract the matching pattern in each (perhaps with a little
> fiddling due to precedence rules); e.g.
>
>> z <-c(".fg.h.g.a.a", "bb..dd.ef.tgf.", "foo...b.bbb.tgy")
>
>> pat1 <- "a+\\.*a+"
>> pat2 <-"b+\\.*b+"
>> pat <- c(pat1,pat2)
>
>> pat <- do.call(paste,c(as.list(pat), sep="|"))
>> pat
> [1] "a+\\.*a+|b+\\.*b+"
>
>> sub(paste0("^[^b]*(",pat,").*$"), "\\1", z)
> [1] "a.a"   "bb""b.bbb"
>
> 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 Mon, Sep 5, 2016 at 9:56 AM, Jun Shen  wrote:
>> Thanks for the reply, Bert.
>>
>> Your solution solves the example. I actually have a more general situation
>> where I have this dot concatenated string from multiple variables. The
>> problem is those variables may have values with dots in there. The number of
>> dots are not consistent for all values of a variable. So I am thinking to
>> define a vector of patterns for the vector of the string and hopefully to
>> find a way to use a pattern from the pattern vector for each value of the
>> string vector. The only way I can think of is "for" loop, which can be slow.
>> Also these are happening in a function I am writing. Just wonder if there is
>> another more efficient way. Thanks a lot.
>>
>> Jun
>>
>> On Mon, Sep 5, 2016 at 1:41 AM, Bert Gunter  wrote:
>>>
>>> Well, he did provide an example, and...
>>>
>>>
>>> > z <- c('TX.WT.CUT.mean','mg.tx.cv')
>>>
>>> > sub("^.+?\\.(.+)\\.[^.]+$","\\1",z)
>>> [1] "WT.CUT" "tx"
>>>
>>>
>>> ## seems to do what was requested.
>>>
>>> Jeff would have to amplify on his initial statement however: do you
>>> mean that separate patterns can always be combined via "|" ?  Or
>>> something deeper?
>>>
>>> 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 Sun, Sep 4, 2016 at 9:30 PM, Jeff Newmiller 
>>> wrote:
>>> > Your opening assertion is false.
>>> >
>>> > Provide a reproducible example and someone will demonstrate.
>>> > --
>>> > Sent from my phone. Please excuse my brevity.
>>> >
>>> > On September 4, 2016 9:06:59 PM PDT, Jun Shen 
>>> > wrote:
>>> >>Dear list,
>>> >>
>>> >>I have a vector of strings that cannot be described by one pattern. So
>>> >>let's say I construct a vector of patterns in the same length as the
>>> >>vector
>>> >>of strings, can I do the element wise pattern recognition and string
>>> >>substitution.
>>> >>
>>> >>For example,
>>> >>
>>> >>pattern1 <- "([^.]*)\\.([^.]*\\.[^.]*)\\.(.*)"
>>> >>pattern2 <- "([^.]*)\\.([^.]*)\\.(.*)"
>>> >>
>>> >>patterns <- c(pattern1,pattern2)
>>> >>strings <- c('TX.WT.CUT.mean','mg.tx.cv')
>>> >>
>>> >>Say I want to extract "WT.CUT" from the first string and "tx" from the
>>> >>second string. If I do
>>> >>
>>> >>sub(patterns, '\\2', strings), only the first pattern will be used.
>>> >>
>>> >>looping the patterns doesn't work the way I want. Appreciate any
>>> >>comments.
>>> >>Thanks.
>>> >>
>>> >>Jun
>>> >>
>>> >>   [[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, 

[R] (no subject)

2016-09-06 Thread Audrey Riddell
Hello,


I am trying to remove brackets and the text contained in brackets. I tried
to do a user defined formula... my attempt at this is pasted below.

cleanBetweenBrackets <- function(String)
  { return(gsub("\(.*?\)", "", String))}

 I keep getting errors (namely that there is an unrecognised escape
character in the string). I have looked at regex forums a bit, but cant
figure this out.

I want the above formula to be able to produce the following result

>Str<-"The cat is crazy (but not too crazy)"
>StrNoBrackets<-cleanBetweenBrackets(Str)
>StrNoBrackets
[1]  "The cat is crazy "

Assistance would be appreciated,

Audrey

[[alternative HTML version deleted]]

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


[R] R-square prob is not calculated by randomization in lmPerm::lmp

2016-09-06 Thread Agustin Lobo
Any reason why the R-square prob is not calculated by randomization in
lmPerm::lmp? The help pages states "Either permutation test p-values
or the usual F-test p-values will be output", but I always get the F
test for R-square as with lm():

require(lmPerm)
x <- 1:1000
set.seed(1000)
y1 <- x*2+runif(1000,-100,100)
dat <- data.frame(x =x,y=y1)
summary(lmp(y~x, data=dat,center=FALSE,perm="Prob"))

[1] "Settings:  unique SS "

Call:
lmp(formula = y ~ x, data = dat, center = FALSE)

Residuals:
 Min   1Q   Median   3Q  Max
-100.431  -48.6452.843   48.640  101.800

Coefficients:
  Estimate Iter Pr(Prob)
x1.993 5000   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 57.3 on 998 degrees of freedom
Multiple R-Squared: 0.9902, Adjusted R-squared: 0.9902
F-statistic: 1.009e+05 on 1 and 998 DF,  p-value: < 2.2e-16


-- 
Agustin Lobo
aloboa...@gmail.com

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


Re: [R] finegray function in survival package

2016-09-06 Thread Ahalya Sivathayalan
Dear R-Team,

I have been trying to use the finegray routine that creates a special data
so that Fine and Gray model can be fit. However, it does not seem to work.
Could you please help me with this issue?


Thanks,
Ahalya.

[[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] igraph V a partir de E y subgrafos

2016-09-06 Thread Luisfo via R-help-es
Estimado Javier,

Me alegra que hayas avanzado con tu error.

Te respondo a esto último.
La función induced.subgraph() espera como segundo parámetro una lista de 
los IDs de los vértices, mientras que tú le estás pasando una lista de 
'edges'.

Prueba lo siguiente:

c <- induced.subgraph(datos.network, which(V(datos.network)$name == 'Casa'))

Si entendí bien todo, debería funcionar.

Un saludo,

*Luisfo Chiroque*
/PhD Student | PhD Candidate
IMDEA Networks Institute/
http://fourier.networks.imdea.org/people/~luis_nunez/ 


On 09/05/2016 07:08 PM, javier.ruben.marcu...@gmail.com wrote:
> Estimados
>
> Encontré una solución, que no comprendo pero arregla uno de los problemas.
>
> En la preparación de datos tengo varias partes, al final realizo un cbind y 
> luego un merge, esto da error, pero si realizo merge y luego cbind, no hay 
> error (no se “pierde eso que comenté en el correo anterior”).
>
> Luego igraph crea el grafo y el sub grafo que al graficar es correcto.
>
> Ahora, porqué esa diferencia, no tengo la menor idea.
>
> Solo queda el problema de
>
>> c <- induced.subgraph(datos.network, E(datos.network)[[inc('Casa')]])
> Error in .Call("R_igraph_induced_subgraph", graph, vids - 1, impl, PACKAGE = 
> "igraph") :
>At iterators.c:759 : Cannot create iterator, invalid vertex id, Invalid 
> vertex id
>   
> Pero hay un avance, por lo menos regreso a la lógica de los libros, aunque me 
> desconcierta el porqué esa diferencia al preparar el data.frame que luego es 
> leído por igraph. En varios años con R y muchísimos errores, es lo primero 
> que me sorprende sin entender nada.
>
> Javier Rubén Marcuzzi
>
> De: javier.ruben.marcu...@gmail.com
>   [[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] Iteration over variables

2016-09-06 Thread Rolf Turner


You need to *print* results explicitly within a for-loop.

E.g.

  print(head(d_dataset[,
c(paste0("v_turnover_",year),
  paste0("v_customer_", year))]))

See FAQ 7.16 for a related discussion.

cheers,

Rolf Turner

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

On 06/09/16 11:54, g.maub...@weinwolf.de wrote:

Hi All,

I would like to write a program that iterates over a set of dynamically
generated variables and produces some stats or prints parts of the data.

# --- data
v_turnover_2011 <- c(10, 20, 30, 40 , 50)
v_customer_2011 <- c(0, 1, NA, 0, 1)
v_turnover_2012 <- c(10, 20, 30, 40 , 50)
v_customer_2012 <- c(0, 1, NA, 0, 1)
d_dataset <- data.frame(v_turnover_2011, v_turnover_2012,
v_customer_2011, v_customer_2012)

# -- Aim is to iterate over dynamically generated variables and compute
# -- statistics or print parts of the data

# -- Does not produce any output
for (year in 2011:2012) {
  head(d_dataset[, c(paste0("v_turnover_", year),
 paste0("v_customer_", year))])
}

# -- Does not produce any output
aux_func <- function(year) {
  head(d_dataset[, c(paste0("v_turnover_", year),
 paste0("v_customer_", year))])
}

for (year in 2011:2012) {
  aux_func(year = year)
}


d_results <- data.frame()
for (year in 2011:2012) {
  d_results <- rbind(d_results,
 paste0("mean", year) = mean(d_dataset[,
c(paste0("v_turnover_", year))]))
}

Is there a way to iterate over variables and compute statistics and print
parts of the dataset?


__
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] Iteration over variables

2016-09-06 Thread G . Maubach
Hi All,

I would like to write a program that iterates over a set of dynamically 
generated variables and produces some stats or prints parts of the data.

# --- data
v_turnover_2011 <- c(10, 20, 30, 40 , 50)
v_customer_2011 <- c(0, 1, NA, 0, 1)
v_turnover_2012 <- c(10, 20, 30, 40 , 50)
v_customer_2012 <- c(0, 1, NA, 0, 1)
d_dataset <- data.frame(v_turnover_2011, v_turnover_2012,
v_customer_2011, v_customer_2012)

# -- Aim is to iterate over dynamically generated variables and compute
# -- statistics or print parts of the data

# -- Does not produce any output
for (year in 2011:2012) {
  head(d_dataset[, c(paste0("v_turnover_", year),
 paste0("v_customer_", year))])
}

# -- Does not produce any output
aux_func <- function(year) {
  head(d_dataset[, c(paste0("v_turnover_", year),
 paste0("v_customer_", year))])
}

for (year in 2011:2012) {
  aux_func(year = year)
}


d_results <- data.frame()
for (year in 2011:2012) {
  d_results <- rbind(d_results,
 paste0("mean", year) = mean(d_dataset[, 
c(paste0("v_turnover_", year))]))
}

Is there a way to iterate over variables and compute statistics and print 
parts of the dataset?

Kind regards

Georg

__
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] R SE QUEDA PEGADO e imposibilitado de trabajar.

2016-09-06 Thread miguel.angel.rodriguez.muinos
Hola Javier.

Por lo que comentas (que como bien dice Carlos Ortega, es una
información incompleta) parece que el detonante del error es que la
máquina entre en suspensión/economode.

Varias preguntas

- Es un portátil? un sobremesa?

- Has probado si te pasa eso (en esas condiciones) con otro software que
tenga algún tipo de "trabajo" gráfico?

- Si es un equipo nuevo por qué tiene Windows 7 ¿?¿? Estamos
hablando de trabajo en un entorno corporativo? Tienes algún tipo de
restricción en tu usuario?

Así, sin tener más info, yo te recomendaría revisar qué es lo que hace
tu equipo cuando entra en modo de ahorro de energía (pone sólo la
pantalla en standby? apaga discos? gráfica? ...) .. de hecho, podrías
configurarlo para que estuviera siempre activo y probar un tiempo así
(para intentar determinar las condiciones en las que te pasa).


Un saludo,
Miguel.



El 05/09/2016 a las 22:51, Javier Valdes Cantallopts (DGA) escribió:
> Hola Carlos:
> -Mira, mi máquina es nueva, con 16 giga de memoria Ram, así que no creo que 
> sea problema de recursos
> -En general me pasa esto cuando despliego un Plot. (Después que me paro y 
> vuelvo a mi escritorio, pasado 15 min) el plot se deforma en la pantalla y 
> después al eliminarlo se queda pegado.
> -Me pasa sobre Rstudio.
> -Windows 7 PROF.
>
>
> El 5 de septiembre de 2016, 22:10, Javier Valdes Cantallopts (DGA) 
> > escribió:
> Estimados:
> Tengo problemas con mi programa R. Cada vez que dejo stand-by mi compu por 
> unos minutos, R se queda pegado, e imposibilitado de trabajar, lo que me 
> obliga a cerrarlo y volver a abrirlo cada vez que sucede.
>







Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso-confidencialidad

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


Re: [R] save R object into a remote directory

2016-09-06 Thread Rainer M Krug
Please reply to the mailing list to keep the conversation available for
everybody. I Send this mail to the mailing list as well.

Simone Tenan  writes:

> Thanks Rainer,
> it's very kind of you. 
> Unfortunately, I cannot save the (large) R object where the current R session 
> is running. There is not enough memory and when I tried I got the error "error
> writing to connection".

OK - essential piece of information.

In this case, your best bet is trying to mount an a flder from your
client on the server and than save there.

Contact you administrator to find out if this is possible or (s)he has
other suggestions.

> For that reason I was trying to save the object of of the remote server.
>
> Best,

Cheers,

Rainer

> Simone
>
> On 6 September 2016 at 10:30, Rainer M Krug  wrote:
>
>  Simone Tenan  writes:
>
>  > Hi all,
>  > I'm using R remotely via ssh connection in linux. I need to save a large R
>  > object from the remote server to my laptop. How can I specify the path in
>  > the save() function?
>
>  You are working on the remote machine and there is no way that you can
>  specify "out of the box" a save to client machine (I stand to be corrected).
>
>  You could mount a directory on the client on the server, but I would
>  suggest to
>
>  1) save the object on the server (the where R is running on)
>  2) use scp from the client to copy the file from the server to the
>  client (the one you are typing on).
>
>  scp user@host1:file1 ./TheNameOfTheLocalFile
>
>  Cheers,
>
>  Rainer
>
>  >
>  > Thanks much for your help,
>  > Simone
>  >
>  > [[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.
>
>  --
>  Rainer M. Krug
>  email: Rainerkrugsde
>  PGP: 0x0F52F982
>
>

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax :   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug

PGP: 0x0F52F982


signature.asc
Description: PGP signature
__
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] save R object into a remote directory

2016-09-06 Thread Rainer M Krug
Simone Tenan  writes:

> Hi all,
> I'm using R remotely via ssh connection in linux. I need to save a large R
> object from the remote server to my laptop. How can I specify the path in
> the save() function?

You are working on the remote machine and there is no way that you can
specify "out of the box" a save to client machine (I stand to be corrected). 

You could mount a directory on the client on the server, but I would
suggest to

1) save the object on the server (the where R is running on)
2) use scp from the client to copy the file from the server to the
client (the one you are typing on).

scp user@host1:file1 ./TheNameOfTheLocalFile

Cheers,

Rainer

>
> Thanks much for your help,
> Simone
>
>   [[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.

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature
__
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] save R object into a remote directory

2016-09-06 Thread Simone Tenan
Hi all,
I'm using R remotely via ssh connection in linux. I need to save a large R
object from the remote server to my laptop. How can I specify the path in
the save() function?

Thanks much for your help,
Simone

[[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] Help with a code in R

2016-09-06 Thread PIKAL Petr
Hi

Well, it seems to me that it is coded in different language like C++.
The code is not reproducible but the error seems to be from your call of ts

You can check it line by line with setting i to arbitrary value and inspect how 
your objects look like, however some of your constructions seems to me quite 
weird.

e.g.
forecast_nal<-data.frame()

leads to mempty data frame with no column named mean
> forecast_nal
data frame with 0 columns and 0 rows
> forecast_nal$mean
NULL

and I am rather surprised how this column come into existence.

BTW, are you sure that in each cycle your rbinded or cbinded objects have the 
same size?

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Erika Rocío
> Espinosa Balbuena
> Sent: Monday, September 5, 2016 8:26 PM
> To: r-help@r-project.org
> Subject: [R] Help with a code in R
>
> Hi,
>
> I am working with this code:
>
> forecast_nal<-data.frame()
> out<-vector()
> x<-foreach(i=1:nrow(comb)) %do%
> {
>
> s<-comb[i,'prod_id']
>
> #Familia+Sumbarca+prod_id
> #Serie
>
> bcomb1<-b
> bcomb1<-subset(bcomb1,bcomb1$prod_id == s & bcomb1$year <= 2015)
> bcomb1<-arrange(bcomb1,year,week)
> a<-bcomb1[1:1,'week']
> d<-bcomb1[1:1,'year']
> f<-nrow(bcomb1)
> h<-bcomb1[f:f,'year']
> j<-bcomb1[f:f,'week']
> bcomb1<-bcomb1[,c(6)]
>
> if (length(bcomb1)<=10 || h=="2014" || (h=="2015" && j<=48)) { out[i]<-s }
> else {
>y <- ts(bcomb1, frequency=52, start=c(d, a)) ##Casos
>
> if (length(y)<=60)
> {
>
> v<-auto.arima(y)
> v<-arimaorder(v)
> fit <- arima(y, order = v ,method="ML")
>   fca <- forecast(fit, h = 16)
> dates <- attr(forecast_nal$mean, "tsp")
> datecol <- seq(from=dates[1], to=dates[2], by=1/dates[3])
> fct<-cbind.data.frame(s,datecol,Point=fca$mean)
> forecast_nal<- rbind.data.frame(forecast_nal,fct)
> }
> else
> {
>
> fit <- tbats(y)
> fcb <- forecast(fit, h = 16)
> dates <- attr(forecast_nal$mean, "tsp")
> datecol <- seq(from=dates[1], to=dates[2], by=1/dates[3])
> fct<-cbind.data.frame(s,datecol,Point=fcb$mean)
> forecast_nal<- rbind.data.frame(forecast_nal,fct)
> }
> }
> }
>  But I am getting this error:
>
> Error in `[<-.ts`(`*tmp*`, ri, value = c(26656.136365833, 26750.9374514082,
>  :
>   only replacement of elements is allowed
>
> Can someone help me with this?
>
> Thanks
>
>
> --
> Erika Rocío Espinosa Balbuena
>
>   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such