[R] Fixed effects in negative binomial mixed model mgcv::gam

2018-10-19 Thread Smith, Desmond
I am using gam from the mgcv package to analyze a dataset with 24 entries :

ran  f1 f2   y
1   30005   545
1   300010  1045
1   1   5   536
1   1   10  770
2   30005   842
2   300010  2042
2   1   5   615
2   1   10  1361
3   30005   328
3   300010  1028
3   1   5   262
3   1   10  722
4   30005   349
4   300010  665
4   1   5   255
4   1   10  470
5   30005   680
5   300010  1510
5   1   5   499
5   1   10  1422
6   30005   628
6   300010  2062
6   1   5   499
6   1   10  2158

The data has two fixed effects (f1 and f2) and one random effect (ran). The 
dependent data is y. Because the dependent data y represents counts and is 
overdispersed, I am using a negative binomial model.

The gam model and its summary output is as follows:

library(mgcv)
summary(gam(y ~ f1 * f2 + s(ran, bs = "re"), data = df2, family = nb, method = 
"REML"))

Family: Negative Binomial(27.376)
Link function: log

Formula:
y ~ f1 * f2 + s(ran, bs = "re")

Parametric coefficients:
  Estimate Std. Error z value Pr(>|z|)
(Intercept)  5.500e+00  3.137e-01  17.533  < 2e-16 ***
f1  -3.421e-05  3.619e-05  -0.9450.345
f2   1.760e-01  3.355e-02   5.247 1.55e-07 ***
f1:f22.665e-07  4.554e-06   0.0590.953
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
 edf Ref.df Chi.sq p-value
s(ran) 4.726  5  85.66  <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.866   Deviance explained = 93.6%
-REML = 185.96  Scale est. = 1 n = 24

The Wald test from summary gives very high significance for f2 (P = 1.55e-07). 
However, when I test the significance of f2 by comparing two different models 
using anova, I get dramatically different results:

anova(gam(y ~ f1 * f2 + s(ran, bs = "re"), data = df2, family = nb, method = 
"ML"),
gam(y ~ f1 + s(ran, bs = "re"), data = df2, family = nb, method = "ML"),
test="Chisq")

Analysis of Deviance Table

Model 1: y ~ f1 * f2 + s(ran, bs = "re")
Model 2: y ~ f1 + s(ran, bs = "re")
  Resid. Df Resid. Dev  Df Deviance Pr(>Chi)
114.843 18.340
216.652 21.529 -1.8091   -3.188   0.1752

f2 is no longer significant. The models were changed from REML to ML, as 
recommended for evaluation of fixed effects.

If the interaction is preserved, f2 still remains insignificant using anova:

anova(gam(y ~ f1 + f2 + f1:f2 + s(ran, bs = "re"), data = df2, family = nb, 
method = "ML"),
gam(y ~ f1 + f1:f2 + s(ran, bs = "re"), data = df2, family = nb, method = "ML"),
test="Chisq")
Analysis of Deviance Table

Model 1: y ~ f1 + f2 + f1:f2 + s(ran, bs = "re")
Model 2: y ~ f1 + f1:f2 + s(ran, bs = "re")
  Resid. Df Resid. Dev   Df Deviance Pr(>Chi)
114.843 18.340
215.645 19.194 -0.80159 -0.85391   0.2855

I would be very grateful for advice on which of these approaches is most 
appropriate. Many thanks!



UCLA HEALTH SCIENCES IMPORTANT WARNING: This email (and any attachments) is 
only intended for the use of the person or entity to which it is addressed, and 
may contain information that is privileged and confidential. You, the 
recipient, are obligated to maintain it in a safe, secure and confidential 
manner. Unauthorized redisclosure or failure to maintain confidentiality may 
subject you to federal and state penalties. If you are not the intended 
recipient, please immediately notify us by return email, and delete this 
message from your computer.

[[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] Importing SAS datasets into R efficiently

2018-10-19 Thread Kevin Thorpe
For some reason, the mailing list got dropped from my reply below.


  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: Kevin Thorpe
Sent: Friday, October 19, 2018 12:30 PM
To: Bert Gunter; Marc Schwartz
Subject: Re: [R] Importing SAS datasets into R efficiently
  

Related to Marc's suggestion, if you have SAS on the same computer as R, try 
the sas.get function in the Hmisc package.

I know it doesn't help you, but I have not had speed issues with haven.

Kevin
  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: R-help  on behalf of Marc Schwartz via 
R-help 
Sent: Friday, October 19, 2018 11:05 AM
To: Bert Gunter
Cc: R-help
Subject: Re: [R] Importing SAS datasets into R efficiently
  

Hi,

'foreign' will only read SAS XPT files, not the proprietary BDAT files, which I 
presume is the case here.

I don't use 'haven', but it looks like the key functions are written in C/C++, 
which should be relatively efficient.

If you are having specific issues with particular files,  because they are 
rather large, and/or have some kind of complex structure, you might want to 
communicate directly with the haven maintainers to see if there are some 
performance bottlenecks that perhaps   they can resolve.

The only other option, to my knowledge, to directly read BDAT files in R, is 
the sas7bdat package on CRAN:

  https://cran.r-project.org/web/packages/sas7bdat/ 



CRAN - Package sas7bdat
cran.r-project.org
sas7bdat: SAS Database Reader (experimental) Read SAS files in the sas7bdat 
data format.


CRAN - Package sas7bdat
cran.r-project.org
sas7bdat: SAS Database Reader (experimental) Read SAS files in the sas7bdat 
data format.

However, it looks like it has not been updated in several years, so not sure of 
status.

Another alternative, if you have access to SAS, is to export the BDAT 
datasets(s) to CSV files in SAS, and them import them into R, using read.csv().

Regards,

Marc Schwartz


> On Oct 19, 2018, at 10:41 AM, Bert Gunter  wrote:
> 
> Have you looked at the "foreign" package?
> 
> -- 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 Fri, Oct 19, 2018 at 6:48 AM Jomy Jose  wrote:
> 
>> Hi
>> 
>> Is there an efficient way to import SAS datasets into R,presently while
>> using haven package it takes long time...Is there a smart work around this
>> ?
>> 
>> Thanks in advance
>> Jose


    [[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] Importing SAS datasets into R efficiently

2018-10-19 Thread Marc Schwartz via R-help
Hi,

'foreign' will only read SAS XPT files, not the proprietary BDAT files, which I 
presume is the case here.

I don't use 'haven', but it looks like the key functions are written in C/C++, 
which should be relatively efficient.

If you are having specific issues with particular files,  because they are 
rather large, and/or have some kind of complex structure, you might want to 
communicate directly with the haven maintainers to see if there are some 
performance bottlenecks that perhaps they can resolve.

The only other option, to my knowledge, to directly read BDAT files in R, is 
the sas7bdat package on CRAN:

  https://cran.r-project.org/web/packages/sas7bdat/ 


However, it looks like it has not been updated in several years, so not sure of 
status.

Another alternative, if you have access to SAS, is to export the BDAT 
datasets(s) to CSV files in SAS, and them import them into R, using read.csv().

Regards,

Marc Schwartz


> On Oct 19, 2018, at 10:41 AM, Bert Gunter  wrote:
> 
> Have you looked at the "foreign" package?
> 
> -- 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 Fri, Oct 19, 2018 at 6:48 AM Jomy Jose  wrote:
> 
>> Hi
>> 
>> Is there an efficient way to import SAS datasets into R,presently while
>> using haven package it takes long time...Is there a smart work around this
>> ?
>> 
>> Thanks in advance
>> Jose


[[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] Importing SAS datasets into R efficiently

2018-10-19 Thread Bert Gunter
Have you looked at the "foreign" package?

-- 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 Fri, Oct 19, 2018 at 6:48 AM Jomy Jose  wrote:

> Hi
>
> Is there an efficient way to import SAS datasets into R,presently while
> using haven package it takes long time...Is there a smart work around this
> ?
>
> Thanks in advance
> Jose
>
> [[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] Importing SAS datasets into R efficiently

2018-10-19 Thread Jomy Jose
Hi

Is there an efficient way to import SAS datasets into R,presently while
using haven package it takes long time...Is there a smart work around this ?

Thanks in advance
Jose

[[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] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-19 Thread Ista Zahn
Here is another approach, just for fun:

library(tidyverse)
library(tokenizers)

anyall <- function(x, # a character vector
   terms # a list of character vectors
   ){
any(map_lgl(terms, function(term) {
all(term %in% x)
}))
}

mutate(th,
   flag = map_lgl(tokenize_tweets(text),
  anyall,
  terms = tokenize_words(st$terms)))

Best,
Ista
On Tue, Oct 16, 2018 at 5:39 PM Nathan Parsons
 wrote:
>
> Thanks all for your patience. Here’s a second go that is perhaps more
> explicative of what it is I am trying to accomplish (and hopefully in plain
> text form)...
>
>
> I’m using the following packages: tidyverse, purrr, tidytext
>
>
> I have a number of tweets in the following form:
>
>
> th <- structure(list(status_id = c("x1047841705729306624",
> "x1046966595610927105",
>
> "x1047094786610552832", "x1046988542818308097", "x1046934493553221632",
>
> "x1047227442899775488"), created_at = c("2018-10-04T13:31:45Z",
>
> "2018-10-02T03:34:22Z", "2018-10-02T12:03:45Z", "2018-10-02T05:01:35Z",
>
> "2018-10-02T01:26:49Z", "2018-10-02T20:50:53Z"), text = c("Technique is
> everything with olympic lifts ! @ Body By John https://t.co/UsfR6DafZt;,
>
> "@Subtronics just went back and rewatched ur FBlice with ur CDJs and let me
> tell you man. You are the fucking messiah",
>
> "@ic4rus1 Opportunistic means short-game. As in getting drunk now vs. not
> being hung over tomorrow vs. not fucking up your life ten years later.",
>
> "I tend to think about my dreams before I sleep.", "@MichaelAvenatti
> @SenatorCollins So, if your client was in her 20s, attending parties with
> teenagers, doesn't that make her at the least immature as hell, or at the
> worst, a pedophile and a person contributing to the delinquency of minors?",
>
> "i wish i could take credit for this"), lat = c(43.6835853, 40.284123,
>
> 37.7706565, 40.431389, 31.1688935, 33.9376735), lng = c(-70.3284118,
>
> -83.078589, -122.4359785, -79.9806895, -100.0768885, -118.130426
>
> ), county_name = c("Cumberland County", "Delaware County", "San Francisco
> County",
>
> "Allegheny County", "Concho County", "Los Angeles County"), fips = c(23005L,
>
> 39041L, 6075L, 42003L, 48095L, 6037L), state_name = c("Maine",
>
> "Ohio", "California", "Pennsylvania", "Texas", "California"),
>
> state_abb = c("ME", "OH", "CA", "PA", "TX", "CA"), urban_level = c("Medium
> Metro",
>
> "Large Fringe Metro", "Large Central Metro", "Large Central Metro",
>
> "NonCore (Nonmetro)", "Large Central Metro"), urban_code = c(3L,
>
> 2L, 1L, 1L, 6L, 1L), population = c(277308L, 184029L, 830781L,
>
> 1160433L, 4160L, 9509611L)), class = c("data.table", "data.frame"
>
> ), row.names = c(NA, -6L), .internal.selfref = )
>
>
> I also have a number of search terms in the following form:
>
>
> st <- structure(list(terms = c("me abused depressed", "me hurt depressed",
>
> "feel hopeless depressed", "feel alone depressed", "i feel helpless",
>
> "i feel worthless")), row.names = c(NA, -6L), class = c("tbl_df",
>
> "tbl", "data.frame”))
>
>
> I am trying to isolate the tweets that contain all of the words in each of
> the search terms, i.e “me” “abused” and “depressed” from the first example
> search term, but they do not have to be in order or even next to one
> another.
>
>
> I am familiar with the dplyr suite of tools and have been attempting to
> generate some sort of ‘filter()’ to do this. I am not very familiar with
> purrr, but there may be a solution using the map function? I have also
> explored the tidytext ‘unnest_tokens’ function which transforms the ’th’
> data in the following way:
>
>
> > tidytext::unnest_tokens(th, word, text, token = "tweets") -> tt
>
> > head(tt)
>
> status_id created_at lat lng
>
> 1: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> 2: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> 3: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> 4: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> 5: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> 6: x1047841705729306624 2018-10-04T13:31:45Z 43.68359 -70.32841
>
> county_name fips state_name state_abb urban_level urban_code
>
> 1: Cumberland County 23005 Maine ME Medium Metro 3
>
> 2: Cumberland County 23005 Maine ME Medium Metro 3
>
> 3: Cumberland County 23005 Maine ME Medium Metro 3
>
> 4: Cumberland County 23005 Maine ME Medium Metro 3
>
> 5: Cumberland County 23005 Maine ME Medium Metro 3
>
> 6: Cumberland County 23005 Maine ME Medium Metro 3
>
> population word
>
> 1: 277308 technique
>
> 2: 277308 is
>
> 3: 277308 everything
>
> 4: 277308 with
>
> 5: 277308 olympic
>
> 6: 277308 lifts
>
>
> but once I have unnested the tokens, I am unable to recombine them back
> into tweets.
>
>
> Ideally the end result would append a new column to the ‘th’ data that
> would flag a tweet that contained all of the search words for any of the
> search terms; so the work flow 

Re: [R] Genuine relative paths with R

2018-10-19 Thread Olivier GIVAUDAN
Hello Katharina,
​
Indeed, I forgot this solution to have your own server, probably because in my 
organisation this is not an option, yet.​
​
I'm pushing for that in our organisation for months now but there is quite some 
resistance and heavy processes around that, and ultimately I'm not deciding on 
that unfortunately...​
​
That would be for me the ideal solution.​
​
Best regards,​
​
Olivier

De : Fritsch, Katharina (NNL) 
Envoyé : vendredi 19 octobre 2018 08:08
À : Olivier GIVAUDAN
Cc : r-help@r-project.org
Objet : RE: [R] Genuine relative paths with R

Hello Olivier,
You can definitely use Shiny Server to share data and apps on a server you (or 
the people who asked you to share the data) own and which is only accessible 
from specified networks. I’ve personally contributed R code to exactly such a 
project that involved confidential data.
Kind regards,
Katharina.

--

Dr Katharina Fritsch B.Sc. M.Sc. MRSC
Chemical Modeller, Chemical and Process Modelling


E.
katharina.frit...@nnl.co.uk
T.
+44 (0)1925 289387
@uknnl

National Nuclear Laboratory Limited, 5th Floor, Chadwick House,
Birchwood Park, Warrington, WA3 6AE, UK

www.nnl.co.uk

From: Olivier GIVAUDAN [mailto:olivier_givau...@hotmail.com]
Sent: 19 October 2018 06:26
To: Fritsch, Katharina (NNL); Peter Claussen
Cc: r-help@r-project.org
Subject: RE: [R] Genuine relative paths with R

Hi Katharina,

Apologies for the late reply.

Thank you for your proposal which was not made yet.

That's actually a Shiny app which I am working on. The problem is that the data 
are confidential: except when I share the R codes and data (via a marvelous 
secured SharePoint system...), the data should stay local.

When looking at [1], it seems inevitable that the data are published to a 
third-party server, which I want to avoid.

But I will look into it more closely, esp. whether it is possible to segregate 
the sharing of R codes / Shiny app (to the server, no problem) and data (only 
local).

Best regards,

Olivier

​[1] BLOCKEDshiny[.]rstudio[.]com/articles/deployment-local[.]htmlBLOCKED

De : Fritsch, Katharina (NNL) 
Envoyé : jeudi 11 octobre 2018 08:22
À : Olivier GIVAUDAN; Peter Claussen
Cc : r-help@r-project.org
Objet : RE: [R] Genuine relative paths with R

Hiya,
I have lost track of half the discussion so forgive me if that suggestion has 
been made before, but would it be suitable to wrap your code in a shiny app and 
disseminate it this way?
Kind regards,
Katharina.

--

Dr Katharina Fritsch B.Sc. M.Sc. MRSC
Chemical Modeller, Chemical and Process Modelling


E.
katharina.frit...@nnl.co.uk
T.
+44 (0)1925 289387
@uknnl

National Nuclear Laboratory Limited, 5th Floor, Chadwick House,
Birchwood Park, Warrington, WA3 6AE, UK

BLOCKEDnnl[.]co[.]ukBLOCKED

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Olivier GIVAUDAN
Sent: 11 October 2018 00:54
To: Peter Claussen
Cc: r-help@r-project.org
Subject: Re: [R] Genuine relative paths with R

Yes, I am aware that both '__FILE__' and 'SAS_EXECFILENAME' are macro 
variables. I don't know how the VBA 'Application.ThisWorkbook.Path' VBA or PHP 
'__DIR__' (or '__FILE__') work.

And yes, indeed, until now I didn't even realise that this simple 
find-and-replace solution of "mine" is actually the basic job of a preprocessor 
when it expands macro variables, thank you!

A macro language in R, yes, I think it would be useful, at least for this 
function. If nothing simpler is available, of course...

De : Peter Claussen  Envoy  : mercredi 10 octobre 2018 
23:29   : Olivier GIVAUDAN Cc : Duncan Murdoch; Jeff Newmiller; 
r-help@r-project.org Objet : Re: [R] Genuine relative paths with R

If I m following all this correctly, it seems your criticism is that R doesn t 
provide a run-time function that is equivalent to a compile-time macro. You do 
realize that __FILE__ is not part of the C programming language - it s a 
predefined variable recognized by the cpp - the C preprocessor program. 
Similarly, SAS_EXECFILENAME is a predefined variable that can be recognized by 
the SAS macro processor, but has no meaning in the SAS language itself.

So, to go back to your original post:
1.  Either create a variable "ScriptPath" in the first lines of each of my R 
scripts and run a batch (or shell, etc.) to replace every single occurrence of 
"ScriptPath <-" by "ScriptPath <- [Absolute path of the R script]" in all the R 
scripts located in the folder (and possibly subfolders) of the batch file.

This is what a macro processor does. Are you asking for a macro language in R?

Cheers

On Oct 10, 2018, at 6:11 PM, Olivier GIVAUDAN 
mailto:olivier_givau...@hotmail.com>> wrote:

It is not wrong to claim that R currently doesn't have a function returning the 
path of the R file where this same function was invoked.

'getwd()' is indeed not equivalent to VBA 

Re: [R] Project in emacs + ess

2018-10-19 Thread Eric Berger
Not exactly sure what you are looking for but here is my workflow which may
give you another perspective
1. my OS is linux
2. I edit my files in emacs (with ESS pulled in)
3. I use make (and Makefile) to compile .o's and .so's from .cpp where
necessary (i.e. I use Rcpp etc)
(and also to build server.R and ui.R from smaller .R's for my shiny app)
4. I kick off RStudio in what you would call the "project" directory and
use source() commands as appropriate
(For a given project I would generally have a small script that I
source as the first command in RStudio.)

This gives me the power of the various components
linux - make, git, shell scripts, etc
emacs - great editor
RStudio - for debugging, testing etc

I definitely do not claim my workflow is optimal and am certainly open -
and curious - to understand your proposed workflow.

Regards,
Eric


On Fri, Oct 19, 2018 at 9:57 AM Martin Maechler 
wrote:

> > Bert Gunter
> > on Thu, 18 Oct 2018 21:45:33 -0700 writes:
>
> > Wrong list. This list is about R programming. You should
> > address this to an emacs support list. Better yet, to an
> > ess list . Here's one place you might start:
>
> > https://www.r-bloggers.com/using-r-with-emacs-and-ess/
>
> > Other resources can be found by a web search on "R ess" .
>
> Indeed, for completeness :
>
> - The ESS website is at https://ess.r-project.org/
>
> - There's an ESS dedicated mailing list "just parallel to" R-help:
>   https://stat.ethz.ch/mailman/listinfo/ess-help
>
> - We are currently beta testing a new release of ESS, "18.10",
>   which *does* contain some project support.
>   Prerelease tar/zip balls available from
>   https://stat.ethz.ch/ESS/downloads/ess/Prerelease/
>
> - ESS is developed on github now, and issues are tracked here:
>   https://github.com/emacs-ess/ESS/issues/
>
> Last but not least :
>  Welcome to the world of Emacs and ESS !
>
> --
> Martin Maechler
> ETH Zurich  (and ESS core team)
>
>
> > 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 Thu, Oct 18, 2018 at 9:12 PM Naresh Gurbuxani <
> > naresh_gurbux...@hotmail.com> wrote:
>
> >> I have switched from RStudio to emacs.  In emacs, how can
> >> I create a project like in RStudio?
> >>
> >>
> >> Within the project directory, I would like to create
> >> different directories for code, data, results, figures,
> >> documents, etc.  In RStudio project, relative references
> >> work well.  For example, an Sweave document in document
> >> directory can use command source('code/mycode.R').  In
> >> emacs, this does not work "out of the box".  In document
> >> folder, the command needs to be
> >> source('../code/mycode.R').  This is minor effort, but a
> >> better method must exist.
> >>
> >>
> >> Thanks,
> >>
> >> Naresh
> >>
> >> [[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-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] Genuine relative paths with R

2018-10-19 Thread Fritsch, Katharina (NNL)
Hello Olivier,
You can definitely use Shiny Server to share data and apps on a server you (or 
the people who asked you to share the data) own and which is only accessible 
from specified networks. I’ve personally contributed R code to exactly such a 
project that involved confidential data.
Kind regards,
Katharina.

--

Dr Katharina Fritsch B.Sc. M.Sc. MRSC
Chemical Modeller, Chemical and Process Modelling


E.
katharina.frit...@nnl.co.uk
T.
+44 (0)1925 289387
@uknnl

National Nuclear Laboratory Limited, 5th Floor, Chadwick House,
Birchwood Park, Warrington, WA3 6AE, UK

www.nnl.co.uk

From: Olivier GIVAUDAN [mailto:olivier_givau...@hotmail.com]
Sent: 19 October 2018 06:26
To: Fritsch, Katharina (NNL); Peter Claussen
Cc: r-help@r-project.org
Subject: RE: [R] Genuine relative paths with R

Hi Katharina,

Apologies for the late reply.

Thank you for your proposal which was not made yet.

That's actually a Shiny app which I am working on. The problem is that the data 
are confidential: except when I share the R codes and data (via a marvelous 
secured SharePoint system...), the data should stay local.

When looking at [1], it seems inevitable that the data are published to a 
third-party server, which I want to avoid.

But I will look into it more closely, esp. whether it is possible to segregate 
the sharing of R codes / Shiny app (to the server, no problem) and data (only 
local).

Best regards,

Olivier

​[1] BLOCKEDshiny[.]rstudio[.]com/articles/deployment-local[.]htmlBLOCKED

De : Fritsch, Katharina (NNL) 
Envoyé : jeudi 11 octobre 2018 08:22
À : Olivier GIVAUDAN; Peter Claussen
Cc : r-help@r-project.org
Objet : RE: [R] Genuine relative paths with R

Hiya,
I have lost track of half the discussion so forgive me if that suggestion has 
been made before, but would it be suitable to wrap your code in a shiny app and 
disseminate it this way?
Kind regards,
Katharina.

--

Dr Katharina Fritsch B.Sc. M.Sc. MRSC
Chemical Modeller, Chemical and Process Modelling


E.
katharina.frit...@nnl.co.uk
T.
+44 (0)1925 289387
@uknnl

National Nuclear Laboratory Limited, 5th Floor, Chadwick House,
Birchwood Park, Warrington, WA3 6AE, UK

BLOCKEDnnl[.]co[.]ukBLOCKED

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Olivier GIVAUDAN
Sent: 11 October 2018 00:54
To: Peter Claussen
Cc: r-help@r-project.org
Subject: Re: [R] Genuine relative paths with R

Yes, I am aware that both '__FILE__' and 'SAS_EXECFILENAME' are macro 
variables. I don't know how the VBA 'Application.ThisWorkbook.Path' VBA or PHP 
'__DIR__' (or '__FILE__') work.

And yes, indeed, until now I didn't even realise that this simple 
find-and-replace solution of "mine" is actually the basic job of a preprocessor 
when it expands macro variables, thank you!

A macro language in R, yes, I think it would be useful, at least for this 
function. If nothing simpler is available, of course...

De : Peter Claussen  Envoy  : mercredi 10 octobre 2018 
23:29   : Olivier GIVAUDAN Cc : Duncan Murdoch; Jeff Newmiller; 
r-help@r-project.org Objet : Re: [R] Genuine relative paths with R

If I m following all this correctly, it seems your criticism is that R doesn t 
provide a run-time function that is equivalent to a compile-time macro. You do 
realize that __FILE__ is not part of the C programming language - it s a 
predefined variable recognized by the cpp - the C preprocessor program. 
Similarly, SAS_EXECFILENAME is a predefined variable that can be recognized by 
the SAS macro processor, but has no meaning in the SAS language itself.

So, to go back to your original post:
1.  Either create a variable "ScriptPath" in the first lines of each of my R 
scripts and run a batch (or shell, etc.) to replace every single occurrence of 
"ScriptPath <-" by "ScriptPath <- [Absolute path of the R script]" in all the R 
scripts located in the folder (and possibly subfolders) of the batch file.

This is what a macro processor does. Are you asking for a macro language in R?

Cheers

On Oct 10, 2018, at 6:11 PM, Olivier GIVAUDAN 
mailto:olivier_givau...@hotmail.com>> wrote:

It is not wrong to claim that R currently doesn't have a function returning the 
path of the R file where this same function was invoked.

'getwd()' is indeed not equivalent to VBA 'Application.ThisWorkbook.Path' or C 
macro '__FILE__' or SAS %sysget(SAS_EXECFILENAME), etc.


[[alternative HTML version deleted]]


This e-mail is from National Nuclear Laboratory Limited ("NNL"). This e-mail 
and any attachments are intended for the addressee and may also be legally 
privileged. If you are not the intended recipient please do not print, 
re-transmit, store or act in reliance on it or any attachments. Instead, please 
e-mail it back to the sender and then immediately permanently delete it.

National Nuclear Laboratory Limited (Company number 3857752) Registered in 
England and Wales. Registered office: 

Re: [R] Project in emacs + ess

2018-10-19 Thread Martin Maechler
> Bert Gunter 
> on Thu, 18 Oct 2018 21:45:33 -0700 writes:

> Wrong list. This list is about R programming. You should
> address this to an emacs support list. Better yet, to an
> ess list . Here's one place you might start:

> https://www.r-bloggers.com/using-r-with-emacs-and-ess/

> Other resources can be found by a web search on "R ess" .

Indeed, for completeness :

- The ESS website is at https://ess.r-project.org/

- There's an ESS dedicated mailing list "just parallel to" R-help:
  https://stat.ethz.ch/mailman/listinfo/ess-help

- We are currently beta testing a new release of ESS, "18.10",
  which *does* contain some project support.
  Prerelease tar/zip balls available from
  https://stat.ethz.ch/ESS/downloads/ess/Prerelease/
  
- ESS is developed on github now, and issues are tracked here:
  https://github.com/emacs-ess/ESS/issues/

Last but not least :
 Welcome to the world of Emacs and ESS !

--
Martin Maechler
ETH Zurich  (and ESS core team)


> 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 Thu, Oct 18, 2018 at 9:12 PM Naresh Gurbuxani <
> naresh_gurbux...@hotmail.com> wrote:

>> I have switched from RStudio to emacs.  In emacs, how can
>> I create a project like in RStudio?
>> 
>> 
>> Within the project directory, I would like to create
>> different directories for code, data, results, figures,
>> documents, etc.  In RStudio project, relative references
>> work well.  For example, an Sweave document in document
>> directory can use command source('code/mycode.R').  In
>> emacs, this does not work "out of the box".  In document
>> folder, the command needs to be
>> source('../code/mycode.R').  This is minor effort, but a
>> better method must exist.
>> 
>> 
>> Thanks,
>> 
>> Naresh
>> 
>> [[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-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.