[R-es] modelos COVID19

2020-04-08 Thread Javier Marcuzzi
Estimados

Por si les interesa, hoy leo un artículo, el cuál me parece
bastante interesante, sobre todo por lo que yo aprecio, yo que soy
veterinario y por ahí veo escrito que por inteligencia artificial, uff, y
eso que me apasiona analizar datos en forma científica, pero la ciencia
médica es un poco especial, por ejemplo, hay un anestésico que si el
paciente está tranquilo, produce la anestesia y se puede realizar la
cirugía, pero si hay un golpe, el efecto es el opuesto y se convierte en
excitador.

El artículo con citas se encuentra en
https://elpais.com/ciencia/2020-04-08/por-que-no-podemos-predecir-como-se-comportara-el-coronavirus.html


Posiblemente puedan acceder a modelos o ideas, si les sirve y pueden tomar
algo de esas referencias...

Saludos y fuerza en estos momentos dolorosos.

Javier 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


[ESS] TWITTER API environment variables

2020-04-08 Thread Patrick Connolly via ESS-help


I'm using the rtweet package which makes use of the Twitter API which
requires a token alluded to by an environment variable.

That environment variable is automatically set up from the Twitter web
site and takes the name TWITTER_ (where  is the
name of the user in block letters).  That worked fine on my work
computer where my username is 'work'.  When I copied that working
directory to my home computer, the environment variable became
TWITTER_HOME but the rtweet package was looking for
TWITTER_WORK. There was no error message: just a null result from the
search_users() function.

I tried editing the ~/.Renviron entry to
TWITTER_WORK=/home/home/.rtweet_token.rds

That worked for a short time but soon ceased working.  Then I noticed
a new entry had been automatically added to ~/.Renviron

TWITTER_HOME=/home/home/.rtweet_token1.rds

So now I had two environment variables which also worked for a short
time.

No such problem arises if R is run from the bash prompt or Rstudio,
but editing functions is so clunky that way.  I've used ESS for more
than 20 years and find it preferable.

R-3.6.3, ESS 17.11

Any ideas what could be causing the token connexion being lost
appreciated.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] TWITTER API environment variables

2020-04-08 Thread Patrick Connolly



Apart from allowing the twitter app access, I didn't do anything to
adjust the settings other than editing the ~/.Renviron file which set up
the environment variable/s.

It appears to me that they are appropriate since they work if I use R
from the bash prompt or Rstudio.  The problem is apparantly with ESS.
I really don't want to use Rstudio.  It's so clunky to edit and debug
functions, and of course, the bash CLI is even more clunky.

I'll ask on the ESS list.



On Wed, 08-Apr-2020 at 12:32PM +0300, K. Elo wrote:

|> Hi again,
|> 
|> ok, I see. How about repeating the steps described in the tutorial on
|> your second computer instead of cloning the settings from the computer
|> #1? There might be some other settings not correctly copied.
|> 
|> HTH,
|> Kimmo
|> 
|> ke, 2020-04-08 kello 19:02 +1200, Patrick Connolly kirjoitti:
|> > Hello Kimmo,
|> > 
|> > Yes.  I did that and it worked fine -- as far as it goes.  But it
|> > didn't cover what to do when using the same twitter account on a
|> > computer with a different user name -- which is what my question was
|> > about.
|> > 
|> > 
|> > On Wed, 08-Apr-2020 at 08:55AM +0300, K. Elo wrote:
|> > 
|> > > > Hi!
|> > > > 
|> > > > Have you already read this:
|> > > > 
|> > > > 
|> https://cran.r-project.org/web/packages/rtweet/vignettes/auth.html
|> > > > 
|> > > > I think they explain rather well how to use Twitter tokens with
|> > > > rtweet...
|> > > > 
|> > > > HTH,
|> > > > Kimmo
|> > > > 
|> > > > ke, 2020-04-08 kello 17:19 +1200, Patrick Connolly kirjoitti:
|> > > > > I'm using the rtweet package which makes use of the Twitter API
|> > > > > which
|> > > > > requires a token alluded to by an environment variable.
|> > > > > 
|> > > > > That environment variable is automatically set up from the
|> > > > > Twitter
|> > > > > web
|> > > > > site and takes the name TWITTER_ (where  is
|> > > > > the
|> > > > > name of the user in block letters).  That worked fine on my
|> > > > > work
|> > > > > computer where my username is 'work'.  When I copied that
|> > > > > working
|> > > > > directory to my home computer, the environment variable became
|> > > > > TWITTER_HOME but the rtweet package was looking for
|> > > > > TWITTER_WORK. There was no error message: just a null result
|> > > > > from the
|> > > > > search_users() function.
|> > > > > 
|> > > > > I tried editing the ~/.Renviron entry to
|> > > > > TWITTER_WORK=/home/home/.rtweet_token.rds
|> > > > > 
|> > > > > That worked for a short time but soon ceased working.  Then I
|> > > > > noticed
|> > > > > a new entry had been automatically added to ~/.Renviron
|> > > > > 
|> > > > > TWITTER_HOME=/home/home/.rtweet_token1.rds
|> > > > > 
|> > > > > So now I had two environment variables which also worked for a
|> > > > > short
|> > > > > time.
|> > > > > 
|> > > > > Recommendations please.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] how to create a new column with conditions

2020-04-08 Thread Rasmus Liland
On April 8, 2020 1:17:38 PM PDT, Ana Marija wrote:
| Hi,
| 
| I have a data frame like this:

Or ... *drum-roll* ... you could use plain 
old indexing.  Have a look:

a <-
"FIDLASER2  CURRELIGPLASER  RTNPTHY
fam1000_G1000   1   1   1   1
fam1001_G1001   1   1   1   1
fam1003_G1003   2   1   2   2
fam1005_G1005   1   1   1   2
fam1009_G1009   1   1   1   2
fam1052_G1052   1   1   1   2"
a <- read.delim(text=a)

a$PHENO <- -9
a[a$CURRELIG==1 & a$RTNPTHY==1,"PHENO"] <- 1
a[a$PLASER==2,"PHENO"] <- 2

Best,
Rasmus

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


Re: [R] how to create a new column with conditions

2020-04-08 Thread William Dunlap via R-help
>I would like to create a new column called PHENO which would satisfy
>these
>conditions:
>
>if CURRELIG=1 and RTNPTHY=1 than PHENO=1
>if PLASER=2 than PHENO=2
>otherwise is -9

I assume that if CURRELIG==1 and RNPTHY==1 and PLASER==2 then PHENO should
be 1.  Or should that case flag a data error?.

In the former case try
a$PHENO <- with(a, {
tmp <- rep(-9, length(CURRELIG)),
tmp[CURRELIG==1 & RTNPTHY==1] <- 1
tmp[PLASER==2] <- 2
tmp})

In the latter case add some calls to stop() or warning() if any of the
"impossible" cases are seen.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Apr 8, 2020 at 1:32 PM Jeff Newmiller 
wrote:

> Now that you have been shown how to do this, post your (non-working) code
> next time. And configure your email program to send plain text so we will
> see what you saw.
>
> a$PHENO <- ifelse( a$CURRELIG==1
>  & a$RTNPTHY==1
>  , 1
>  ,  ifelse( a$PLASER==2
>   , 2
>   , -9 ) )
>
> or
>
> a$PHENO <- with( a
>, ifelse( CURRELIG==1
>& RTNPTHY==1
>, 1
>, ifelse( PLASER==2
>, 2
>, -9 ) ) )
>
>
> On April 8, 2020 1:17:38 PM PDT, Ana Marija 
> wrote:
> >Hi,
> >
> >I have a data frame like this:
> >
> >> head(a)
> >FID LASER2 CURRELIG PLASER RTNPTHY
> >1 fam1000_G1000  11  1   1
> >2 fam1001_G1001  11  1   1
> >3 fam1003_G1003  21  2   2
> >4 fam1005_G1005  11  1   2
> >5 fam1009_G1009  11  1   2
> >6 fam1052_G1052  11  1   2
> >...
> >
> >I would like to create a new column called PHENO which would satisfy
> >these
> >conditions:
> >
> >if CURRELIG=1 and RTNPTHY=1 than PHENO=1
> >if PLASER=2 than PHENO=2
> >otherwise is -9
> >
> >Thanks
> >Ana
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] how to create a new column with conditions

2020-04-08 Thread Jeff Newmiller
Now that you have been shown how to do this, post your (non-working) code next 
time. And configure your email program to send plain text so we will see what 
you saw.

a$PHENO <- ifelse( a$CURRELIG==1
 & a$RTNPTHY==1
 , 1
 ,  ifelse( a$PLASER==2
  , 2
  , -9 ) )

or

a$PHENO <- with( a
   , ifelse( CURRELIG==1
   & RTNPTHY==1
   , 1
   , ifelse( PLASER==2
   , 2
   , -9 ) ) )


On April 8, 2020 1:17:38 PM PDT, Ana Marija  wrote:
>Hi,
>
>I have a data frame like this:
>
>> head(a)
>FID LASER2 CURRELIG PLASER RTNPTHY
>1 fam1000_G1000  11  1   1
>2 fam1001_G1001  11  1   1
>3 fam1003_G1003  21  2   2
>4 fam1005_G1005  11  1   2
>5 fam1009_G1009  11  1   2
>6 fam1052_G1052  11  1   2
>...
>
>I would like to create a new column called PHENO which would satisfy
>these
>conditions:
>
>if CURRELIG=1 and RTNPTHY=1 than PHENO=1
>if PLASER=2 than PHENO=2
>otherwise is -9
>
>Thanks
>Ana
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

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


[R] how to create a new column with conditions

2020-04-08 Thread Ana Marija
Hi,

I have a data frame like this:

> head(a)
FID LASER2 CURRELIG PLASER RTNPTHY
1 fam1000_G1000  11  1   1
2 fam1001_G1001  11  1   1
3 fam1003_G1003  21  2   2
4 fam1005_G1005  11  1   2
5 fam1009_G1009  11  1   2
6 fam1052_G1052  11  1   2
...

I would like to create a new column called PHENO which would satisfy these
conditions:

if CURRELIG=1 and RTNPTHY=1 than PHENO=1
if PLASER=2 than PHENO=2
otherwise is -9

Thanks
Ana

[[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 Markdown & chunk extraction in R

2020-04-08 Thread Yihui Xie
Hi Ashim,

read_chunk() can only read R scripts.

Regards,
Yihui
--
https://yihui.org

On Wed, Apr 8, 2020 at 10:24 AM Ashim Kapoor  wrote:
>
> Dear Yihui,
>
> Can we not 1st use read_chunk to import an Rmd and then do knit_code()$get ? 
> I could be mistaken. Please correct me if I am wrong.
>
> Best,
> Ashim
>
> On Wed, Apr 8, 2020 at 8:47 PM Yihui Xie  wrote:
>>
>> And please note that knitr::knit_code$get() only works (i.e. returns a
>> named list of code chunks) inside a knitr document when the document
>> _is being knitted_. It doesn't work outside the document. Ideally, you
>> should use the document parser of knitr, but it is not exported.
>>
>> Regards,
>> Yihui
>> --
>> https://yihui.org
>>
>> On Wed, Apr 8, 2020 at 2:54 AM Ashim Kapoor  wrote:
>> >
>> > Dear Sigbert,
>> >
>> > Also see this :-
>> >
>> > https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code
>> >
>> > Best,
>> > Ashim
>> >
>> > On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor  wrote:
>> >
>> > > Dear Sigbert,
>> > >
>> > > Please see this.
>> > >
>> > > https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
>> > >
>> > > Best,
>> > > Ashim
>> > >
>> > > On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
>> > > wrote:
>> > >
>> > >> Hi,
>> > >>
>> > >> exists a possibility to extract chunks from a R Markdown file and to
>> > >> return them as (named) list in R?
>> > >>
>> > >> Thanks Sigbert
>> > >>
>> > >> --
>> > >> https://hu.berlin/sk
>> > >> https://hu.berlin/mmstat3
>> > >>
>> > >> __
>> > >> 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.

__
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 create .docx file ?

2020-04-08 Thread Jeff Newmiller
The OP clearly hasn't followed the excellent documentation... this is not a 
maintainer problem. It is the act of printing the completed object that puts a 
file on disk.

However, the package author recommends in the README that help be requested 
from stackoverflow, as the mailing list Posting Guidelines do warn that 
contributed packages are not technically on topic in R-help. (Simply from a 
practicality standpoint... there are thousands of them, each with potentially 
voluminous details to distract from the R language itself.)

On April 8, 2020 10:08:09 AM PDT, Bert Gunter  wrote:
>But the OP explicitly notes that the read_docx package does *not* write
>files and asks whether there are *other* packages or functions that
>provide
>that functionality. It still seems to me that the ReporteR maintainer
>might
>be the best place to go for that info, although there is certainly no
>assurance that he can provide it.
>
>Bert
>
>On Wed, Apr 8, 2020 at 9:56 AM Jeff Newmiller
>
>wrote:
>
>> But before hassling the maintainer the OP should read the package
>> vignettes and run some examples... read_docx does not write to any
>files,
>> so complaining that it doesn't will be fruitless.
>>
>> On April 8, 2020 9:31:41 AM PDT, Bert Gunter 
>> wrote:
>> >This sounds like the sort of specialized question that should be
>> >directed
>> >to the maintainer (?maintainer) rather than to a general Help list
>such
>> >as
>> >this.
>> >
>> >Bert Gunter
>> >
>> >"The trouble with having an open mind is that people keep coming
>along
>> >and
>> >sticking things into it."
>> >-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >
>> >
>> >On Wed, Apr 8, 2020 at 9:23 AM A Biologist
>
>> >wrote:
>> >
>> >> Dear All,
>> >>
>> >> Mac Catalina - R 3.6.3 - all up-to-date packages.
>> >> I would like to re-create the functionality which was found in the
>> >package
>> >> {ReporteRs} by creating a .docx file in a folder on my computer
>from
>> >within
>> >> R - which can subsequently be used by the {officer} function
>> >read_docx.
>> >> The function read_docx on my system does NOT create a new
>document,
>> >and
>> >> neither does the following code:
>> >> new.word.doc=function(){ report = read_docx(path ..name..
>".docx"))
>> >> return(report) }
>> >> doc=new.word.doc()
>> >>
>> >> I can use {base} file.create to create a file with an extension
>.docx
>> >- but
>> >> apparently this is not a .docx file - and read_docx can't read it.
>> >> Is there another R package or function which I can use in order to
>> >create
>> >> (and then close the link to R so that it can be used by another
>> >package) a
>> >> .docx file ?
>> >>
>> >> Many thanks in advance.
>> >>
>> >> [[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.
>>
>> --
>> Sent from my phone. Please excuse my brevity.
>>

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R] R create .docx file ?

2020-04-08 Thread Bert Gunter
But the OP explicitly notes that the read_docx package does *not* write
files and asks whether there are *other* packages or functions that provide
that functionality. It still seems to me that the ReporteR maintainer might
be the best place to go for that info, although there is certainly no
assurance that he can provide it.

Bert

On Wed, Apr 8, 2020 at 9:56 AM Jeff Newmiller 
wrote:

> But before hassling the maintainer the OP should read the package
> vignettes and run some examples... read_docx does not write to any files,
> so complaining that it doesn't will be fruitless.
>
> On April 8, 2020 9:31:41 AM PDT, Bert Gunter 
> wrote:
> >This sounds like the sort of specialized question that should be
> >directed
> >to the maintainer (?maintainer) rather than to a general Help list such
> >as
> >this.
> >
> >Bert Gunter
> >
> >"The trouble with having an open mind is that people keep coming along
> >and
> >sticking things into it."
> >-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> >On Wed, Apr 8, 2020 at 9:23 AM A Biologist 
> >wrote:
> >
> >> Dear All,
> >>
> >> Mac Catalina - R 3.6.3 - all up-to-date packages.
> >> I would like to re-create the functionality which was found in the
> >package
> >> {ReporteRs} by creating a .docx file in a folder on my computer from
> >within
> >> R - which can subsequently be used by the {officer} function
> >read_docx.
> >> The function read_docx on my system does NOT create a new document,
> >and
> >> neither does the following code:
> >> new.word.doc=function(){ report = read_docx(path ..name.. ".docx"))
> >> return(report) }
> >> doc=new.word.doc()
> >>
> >> I can use {base} file.create to create a file with an extension .docx
> >- but
> >> apparently this is not a .docx file - and read_docx can't read it.
> >> Is there another R package or function which I can use in order to
> >create
> >> (and then close the link to R so that it can be used by another
> >package) a
> >> .docx file ?
> >>
> >> Many thanks in advance.
> >>
> >> [[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.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[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 create .docx file ?

2020-04-08 Thread Jeff Newmiller
But before hassling the maintainer the OP should read the package vignettes and 
run some examples... read_docx does not write to any files, so complaining that 
it doesn't will be fruitless. 

On April 8, 2020 9:31:41 AM PDT, Bert Gunter  wrote:
>This sounds like the sort of specialized question that should be
>directed
>to the maintainer (?maintainer) rather than to a general Help list such
>as
>this.
>
>Bert Gunter
>
>"The trouble with having an open mind is that people keep coming along
>and
>sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>On Wed, Apr 8, 2020 at 9:23 AM A Biologist 
>wrote:
>
>> Dear All,
>>
>> Mac Catalina - R 3.6.3 - all up-to-date packages.
>> I would like to re-create the functionality which was found in the
>package
>> {ReporteRs} by creating a .docx file in a folder on my computer from
>within
>> R - which can subsequently be used by the {officer} function
>read_docx.
>> The function read_docx on my system does NOT create a new document,
>and
>> neither does the following code:
>> new.word.doc=function(){ report = read_docx(path ..name.. ".docx"))
>> return(report) }
>> doc=new.word.doc()
>>
>> I can use {base} file.create to create a file with an extension .docx
>- but
>> apparently this is not a .docx file - and read_docx can't read it.
>> Is there another R package or function which I can use in order to
>create
>> (and then close the link to R so that it can be used by another
>package) a
>> .docx file ?
>>
>> Many thanks in advance.
>>
>> [[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.

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R] R create .docx file ?

2020-04-08 Thread Bert Gunter
This sounds like the sort of specialized question that should be directed
to the maintainer (?maintainer) rather than to a general Help list such as
this.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Apr 8, 2020 at 9:23 AM A Biologist  wrote:

> Dear All,
>
> Mac Catalina - R 3.6.3 - all up-to-date packages.
> I would like to re-create the functionality which was found in the package
> {ReporteRs} by creating a .docx file in a folder on my computer from within
> R - which can subsequently be used by the {officer} function read_docx.
> The function read_docx on my system does NOT create a new document, and
> neither does the following code:
> new.word.doc=function(){ report = read_docx(path ..name.. ".docx"))
> return(report) }
> doc=new.word.doc()
>
> I can use {base} file.create to create a file with an extension .docx - but
> apparently this is not a .docx file - and read_docx can't read it.
> Is there another R package or function which I can use in order to create
> (and then close the link to R so that it can be used by another package) a
> .docx file ?
>
> Many thanks in advance.
>
> [[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.


[R] R create .docx file ?

2020-04-08 Thread A Biologist
Dear All,

Mac Catalina - R 3.6.3 - all up-to-date packages.
I would like to re-create the functionality which was found in the package
{ReporteRs} by creating a .docx file in a folder on my computer from within
R - which can subsequently be used by the {officer} function read_docx.
The function read_docx on my system does NOT create a new document, and
neither does the following code:
new.word.doc=function(){ report = read_docx(path ..name.. ".docx"))
return(report) }
doc=new.word.doc()

I can use {base} file.create to create a file with an extension .docx - but
apparently this is not a .docx file - and read_docx can't read it.
Is there another R package or function which I can use in order to create
(and then close the link to R so that it can be used by another package) a
.docx file ?

Many thanks in advance.

[[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 Markdown & chunk extraction in R

2020-04-08 Thread Ashim Kapoor
Dear Yihui,

Can we not 1st use read_chunk to import an Rmd and then do knit_code()$get
? I could be mistaken. Please correct me if I am wrong.

Best,
Ashim

On Wed, Apr 8, 2020 at 8:47 PM Yihui Xie  wrote:

> And please note that knitr::knit_code$get() only works (i.e. returns a
> named list of code chunks) inside a knitr document when the document
> _is being knitted_. It doesn't work outside the document. Ideally, you
> should use the document parser of knitr, but it is not exported.
>
> Regards,
> Yihui
> --
> https://yihui.org
>
> On Wed, Apr 8, 2020 at 2:54 AM Ashim Kapoor  wrote:
> >
> > Dear Sigbert,
> >
> > Also see this :-
> >
> >
> https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code
> >
> > Best,
> > Ashim
> >
> > On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor 
> wrote:
> >
> > > Dear Sigbert,
> > >
> > > Please see this.
> > >
> > > https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
> > >
> > > Best,
> > > Ashim
> > >
> > > On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke <
> sigb...@wiwi.hu-berlin.de>
> > > wrote:
> > >
> > >> Hi,
> > >>
> > >> exists a possibility to extract chunks from a R Markdown file and to
> > >> return them as (named) list in R?
> > >>
> > >> Thanks Sigbert
> > >>
> > >> --
> > >> https://hu.berlin/sk
> > >> https://hu.berlin/mmstat3
> > >>
> > >> __
> > >> 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.
>

[[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 Markdown & chunk extraction in R

2020-04-08 Thread Yihui Xie
And please note that knitr::knit_code$get() only works (i.e. returns a
named list of code chunks) inside a knitr document when the document
_is being knitted_. It doesn't work outside the document. Ideally, you
should use the document parser of knitr, but it is not exported.

Regards,
Yihui
--
https://yihui.org

On Wed, Apr 8, 2020 at 2:54 AM Ashim Kapoor  wrote:
>
> Dear Sigbert,
>
> Also see this :-
>
> https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code
>
> Best,
> Ashim
>
> On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor  wrote:
>
> > Dear Sigbert,
> >
> > Please see this.
> >
> > https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
> >
> > Best,
> > Ashim
> >
> > On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
> > wrote:
> >
> >> Hi,
> >>
> >> exists a possibility to extract chunks from a R Markdown file and to
> >> return them as (named) list in R?
> >>
> >> Thanks Sigbert
> >>
> >> --
> >> https://hu.berlin/sk
> >> https://hu.berlin/mmstat3
> >>
> >> __
> >> 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.

__
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] TWITTER API environment variables

2020-04-08 Thread K. Elo
Hi again,

ok, I see. How about repeating the steps described in the tutorial on
your second computer instead of cloning the settings from the computer
#1? There might be some other settings not correctly copied.

HTH,
Kimmo

ke, 2020-04-08 kello 19:02 +1200, Patrick Connolly kirjoitti:
> Hello Kimmo,
> 
> Yes.  I did that and it worked fine -- as far as it goes.  But it
> didn't cover what to do when using the same twitter account on a
> computer with a different user name -- which is what my question was
> about.
> 
> 
> On Wed, 08-Apr-2020 at 08:55AM +0300, K. Elo wrote:
> 
> > > Hi!
> > > 
> > > Have you already read this:
> > > 
> > > 
https://cran.r-project.org/web/packages/rtweet/vignettes/auth.html
> > > 
> > > I think they explain rather well how to use Twitter tokens with
> > > rtweet...
> > > 
> > > HTH,
> > > Kimmo
> > > 
> > > ke, 2020-04-08 kello 17:19 +1200, Patrick Connolly kirjoitti:
> > > > I'm using the rtweet package which makes use of the Twitter API
> > > > which
> > > > requires a token alluded to by an environment variable.
> > > > 
> > > > That environment variable is automatically set up from the
> > > > Twitter
> > > > web
> > > > site and takes the name TWITTER_ (where  is
> > > > the
> > > > name of the user in block letters).  That worked fine on my
> > > > work
> > > > computer where my username is 'work'.  When I copied that
> > > > working
> > > > directory to my home computer, the environment variable became
> > > > TWITTER_HOME but the rtweet package was looking for
> > > > TWITTER_WORK. There was no error message: just a null result
> > > > from the
> > > > search_users() function.
> > > > 
> > > > I tried editing the ~/.Renviron entry to
> > > > TWITTER_WORK=/home/home/.rtweet_token.rds
> > > > 
> > > > That worked for a short time but soon ceased working.  Then I
> > > > noticed
> > > > a new entry had been automatically added to ~/.Renviron
> > > > 
> > > > TWITTER_HOME=/home/home/.rtweet_token1.rds
> > > > 
> > > > So now I had two environment variables which also worked for a
> > > > short
> > > > time.
> > > > 
> > > > Recommendations please.
> > > > 
> > > 
> > > __
> > > 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 Markdown & chunk extraction in R

2020-04-08 Thread Ashim Kapoor
Dear Sigbert,

Also see this :-

https://www.rdocumentation.org/packages/knitr/versions/1.28/topics/knit_code

Best,
Ashim

On Wed, Apr 8, 2020 at 1:13 PM Ashim Kapoor  wrote:

> Dear Sigbert,
>
> Please see this.
>
> https://bookdown.org/yihui/rmarkdown-cookbook/purl.html
>
> Best,
> Ashim
>
> On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
> wrote:
>
>> Hi,
>>
>> exists a possibility to extract chunks from a R Markdown file and to
>> return them as (named) list in R?
>>
>> Thanks Sigbert
>>
>> --
>> https://hu.berlin/sk
>> https://hu.berlin/mmstat3
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

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


Re: [R] R Markdown & chunk extraction in R

2020-04-08 Thread Ashim Kapoor
Dear Sigbert,

Please see this.

https://bookdown.org/yihui/rmarkdown-cookbook/purl.html

Best,
Ashim

On Wed, Apr 8, 2020 at 1:02 PM Sigbert Klinke 
wrote:

> Hi,
>
> exists a possibility to extract chunks from a R Markdown file and to
> return them as (named) list in R?
>
> Thanks Sigbert
>
> --
> https://hu.berlin/sk
> https://hu.berlin/mmstat3
>
> __
> 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.


[R] R Markdown & chunk extraction in R

2020-04-08 Thread Sigbert Klinke

Hi,

exists a possibility to extract chunks from a R Markdown file and to 
return them as (named) list in R?


Thanks Sigbert

--
https://hu.berlin/sk
https://hu.berlin/mmstat3

__
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] TWITTER API environment variables

2020-04-08 Thread Patrick Connolly
Hello Kimmo,

Yes.  I did that and it worked fine -- as far as it goes.  But it
didn't cover what to do when using the same twitter account on a
computer with a different user name -- which is what my question was
about.


On Wed, 08-Apr-2020 at 08:55AM +0300, K. Elo wrote:

|> Hi!
|> 
|> Have you already read this:
|> 
|> https://cran.r-project.org/web/packages/rtweet/vignettes/auth.html
|> 
|> I think they explain rather well how to use Twitter tokens with
|> rtweet...
|> 
|> HTH,
|> Kimmo
|> 
|> ke, 2020-04-08 kello 17:19 +1200, Patrick Connolly kirjoitti:
|> > I'm using the rtweet package which makes use of the Twitter API which
|> > requires a token alluded to by an environment variable.
|> > 
|> > That environment variable is automatically set up from the Twitter
|> > web
|> > site and takes the name TWITTER_ (where  is the
|> > name of the user in block letters).  That worked fine on my work
|> > computer where my username is 'work'.  When I copied that working
|> > directory to my home computer, the environment variable became
|> > TWITTER_HOME but the rtweet package was looking for
|> > TWITTER_WORK. There was no error message: just a null result from the
|> > search_users() function.
|> > 
|> > I tried editing the ~/.Renviron entry to
|> > TWITTER_WORK=/home/home/.rtweet_token.rds
|> > 
|> > That worked for a short time but soon ceased working.  Then I noticed
|> > a new entry had been automatically added to ~/.Renviron
|> > 
|> > TWITTER_HOME=/home/home/.rtweet_token1.rds
|> > 
|> > So now I had two environment variables which also worked for a short
|> > time.
|> > 
|> > Recommendations please.
|> >
|> 
|> __
|> 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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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