Re: [R] install.packages() R vs RStudio

2020-08-17 Thread Abby Spurdle
Duncan Murdoch  wrote:
> R is designed to be flexible, and to let people change its behaviour.
> Using that flexibility is what all users should do.  Improving the user
> experience is what front-end writers should do.  I don't find it
> inadvisable at all.

Well, that's a big whopping U-turn.

Abby Spurdle wrote:
> There's a work around.
> You can redefine the print function, using something like:
> print = function (...) base::print (...)

Duncan Murdoch replied:
> That's a really, really bad idea.  If there are two generics named the
> same, how are your users going to know which one they are getting when
> they just say print(myobj)?

https://stat.ethz.ch/pipermail/r-devel/2018-August/076581.html

I can't see how redefining a generic function is any different from
redefining a package installation function.
And can't help but suspect, you're making an exception for RStudio...

__
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] Plot math symbol with string and number

2020-08-17 Thread Paul Murrell



I think that comment is fair *on graphics devices that can handle unicode*.

So that is true for Cairo-based graphics devices, but not for the pdf() 
or postscript() devices, for example.


Paul

On 18/08/20 9:54 am, Bert Gunter wrote:

"Plotmath seems to be the right way to do it."

Not sure I agree with that. Paul Murrell put together plotmath around 2000
prior to the widescale development and adoption of the unicode standard
(corrections/modifications welcome!).  So at the time, there really was no
other way to handle this for most OS'es. With UTF8 now being generally
supported for Unicode, plotmath constructions may not be needed for simple
symbol labeling, as here. Of course for more complex symbolism (fractions,
integrals, ...) it will be. ?plotmath talks about this and has links to
further issues and options, btw.

In other words, unicode may indeed be better than my suggestion of plotmath
here.

I would welcome comments from others who are more knowledgeable about this
than I am.

Bert

On Mon, Aug 17, 2020 at 2:14 PM  wrote:


On 2020-08-17 03:13, Rasmus Liland wrote:

On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
| On Sun, Aug 16, 2020, 14:53 John wrote:
| |
| | I would like to make plots with
| | titles for different data sets and
| | different parameters. The first
| | title doesn't show sigma as a math
| | symbol, while the second one
| | doesn't contain the s value as a
| | numeric value
| |
| | s <- 1
| | y <- rnorm(100)
| | plot(y, main=paste("data", "sigma=", s))
| | plot(y, main=expression(paste("data", sigma,"=", s)))
|
| ?plotmath

Dear John, read ?plotmath, it is good, I
was not aware of its existence; then
backquote s like so:




Plotmath seems to be the right way to do it.  But without reading
plotmath I'd have gone with this:

plot(y, main=paste("data", "\u03C3=", s))






[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=02%7C01%7C%7C3624d54caaf64787734308d842f83677%7Cd1b36e950d5042e9958fb63fa906beaa%7C0%7C0%7C637332981200092221sdata=U7ywrEh7Z3XV84pkxXfzUJTYU8BEZ995Np5xo3%2Fbn9g%3Dreserved=0
PLEASE do read the posting guide 
https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=02%7C01%7C%7C3624d54caaf64787734308d842f83677%7Cd1b36e950d5042e9958fb63fa906beaa%7C0%7C0%7C637332981200092221sdata=7VBd7dQFox%2BCEUEKgJZk6TU6cwmDS7tnAcGok9UH1WQ%3Dreserved=0
and provide commented, minimal, self-contained, reproducible code.



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
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] Plot math symbol with string and number

2020-08-17 Thread Bert Gunter
"Plotmath seems to be the right way to do it. "

Not sure I agree with that. Paul Murrell put together plotmath around 2000
prior to the widescale development and adoption of the unicode standard
(corrections/modifications welcome!).  So at the time, there really was no
other way to handle this for most OS'es. With UTF8 now being generally
supported for Unicode, plotmath constructions may not be needed for simple
symbol labeling, as here. Of course for more complex symbolism (fractions,
integrals, ...) it will be. ?plotmath talks about this and has links to
further issues and options, btw.

In other words, unicode may indeed be better than my suggestion of plotmath
here.

I would welcome comments from others who are more knowledgeable about this
than I am.

Bert

On Mon, Aug 17, 2020 at 2:14 PM  wrote:

> On 2020-08-17 03:13, Rasmus Liland wrote:
> > On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
> > | On Sun, Aug 16, 2020, 14:53 John wrote:
> > | |
> > | | I would like to make plots with
> > | | titles for different data sets and
> > | | different parameters. The first
> > | | title doesn't show sigma as a math
> > | | symbol, while the second one
> > | | doesn't contain the s value as a
> > | | numeric value
> > | |
> > | | s <- 1
> > | | y <- rnorm(100)
> > | | plot(y, main=paste("data", "sigma=", s))
> > | | plot(y, main=expression(paste("data", sigma,"=", s)))
> > |
> > | ?plotmath
> >
> > Dear John, read ?plotmath, it is good, I
> > was not aware of its existence; then
> > backquote s like so:
> >
> >
>
> Plotmath seems to be the right way to do it.  But without reading
> plotmath I'd have gone with this:
>
> plot(y, main=paste("data", "\u03C3=", s))
>
>
>
>

[[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] Plot math symbol with string and number

2020-08-17 Thread Rasmus Liland
On 2020-08-17 22:14 +0100, cpolw...@chemo.org.uk wrote:
| On 2020-08-17 03:13, Rasmus Liland wrote:
| | On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
| | |
| | | ?plotmath
| | 
| | Dear John, read ?plotmath, it is 
| | good, I was not aware of its 
| | existence; then backquote s like 
| | so:
| 
| Plotmath seems to be the right way to 
| do it.  But without reading plotmath 
| I'd have gone with this:
| 
| plot(y, main=paste("data", "\u03C3=", s))

Good; for me copying the sigma unicode 
character into that line works too:

plot(y, main=paste("dataσ=", s))

How curious 


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] Plot math symbol with string and number

2020-08-17 Thread cpolwart

On 2020-08-17 03:13, Rasmus Liland wrote:

On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
| On Sun, Aug 16, 2020, 14:53 John wrote:
| |
| | I would like to make plots with
| | titles for different data sets and
| | different parameters. The first
| | title doesn't show sigma as a math
| | symbol, while the second one
| | doesn't contain the s value as a
| | numeric value
| |
| | s <- 1
| | y <- rnorm(100)
| | plot(y, main=paste("data", "sigma=", s))
| | plot(y, main=expression(paste("data", sigma,"=", s)))
|
| ?plotmath

Dear John, read ?plotmath, it is good, I
was not aware of its existence; then
backquote s like so:




Plotmath seems to be the right way to do it.  But without reading 
plotmath I'd have gone with this:


plot(y, main=paste("data", "\u03C3=", s))

__
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] [EXT] Re: Plot math symbol with string and number

2020-08-17 Thread John Smith
Thanks David for a quite interesting suggestion: Indeed I didn't know
paste0! Best!

On Mon, Aug 17, 2020 at 12:26 PM David K Stevens 
wrote:

> John - one more approach
>
> plot(y,main=parse(text=paste0('data ~~ sigma == ',s)))
>
> Good luck
>
> David Stevens
>
> On 8/17/2020 8:23 AM, John Smith wrote:
> > Thanks to Dunkan, Rasmus and Bert. Will keep the very useful tips. Best!
> >
> > On Sun, Aug 16, 2020 at 9:13 PM Rasmus Liland  wrote:
> >
> >> On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
> >> | On Sun, Aug 16, 2020, 14:53 John wrote:
> >> | |
> >> | | I would like to make plots with
> >> | | titles for different data sets and
> >> | | different parameters. The first
> >> | | title doesn't show sigma as a math
> >> | | symbol, while the second one
> >> | | doesn't contain the s value as a
> >> | | numeric value
> >> | |
> >> | | s <- 1
> >> | | y <- rnorm(100)
> >> | | plot(y, main=paste("data", "sigma=", s))
> >> | | plot(y, main=expression(paste("data", sigma,"=", s)))
> >> |
> >> | ?plotmath
> >>
> >> Dear John, read ?plotmath, it is good, I
> >> was not aware of its existence; then
> >> backquote s like so:
> >>
> >>  plot(y, main=bquote(paste(
> >>"data" ~~ widehat(aleph)
> >>%notin% .(s)^.(s
> >>
> >> V
> >>
> >> r
> >>
> >  [[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.
> > CAUTION: This email originated from outside of USU. If this appears to
> be a USU employee, beware of impersonators. Do not click links, reply,
> download images, or open attachments unless you verify the sender’s
> identity and know the content is safe.
> >
> --
> David K Stevens, P.E., Ph.D.
> Professor, Environmental Engineering
> Civil and Environmental Engineering
> Utah Water Research Laboratory
> 8200 Old Main Hill
> Logan, UT  84322-8200
> 435 797 3229 - voice
> 435 797 1363 - fax
> david.stev...@usu.edu
>
> __
> 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] install.packages() R vs RStudio

2020-08-17 Thread John Fox

Hi Duncan,

What you say is entirely sensible.

Yes, it's primarily the silent part that seems problematic to me. 
Messages about masking are uninteresting until one encounters a problem, 
and then they may provide an important clue to the source of the problem.


As to this specific case: It's not clear to me why it's necessary or 
even desirable for RStudio to mask utils::install.packages(). After all 
RStudio provides an alternative route to package installation via the 
Packages tab, and it wouldn't have been hard to name the function 
something different from install.packages() to provide additional 
functionality via direct commands.


Best,
 John

On 2020-08-17 3:15 p.m., Duncan Murdoch wrote:

Hi John.

I suspect most good front ends do similar things.  For example, on 
MacOS, R.app messes up "history()".  I've never used ESS, but I imagine 
one could find examples where it acts differently than base R:  isn't 
that the point?


One hopes all differences are improvements, but sometimes they're not. 
If the modifications cause trouble (e.g. the ones you and I have never 
experienced with install.packages() in RStudio, or the one I experience 
every now and then with history() in R.app), then that may be a bug in 
the front-end.  It should be reported to the authors.


R is designed to be flexible, and to let people change its behaviour. 
Using that flexibility is what all users should do.  Improving the user 
experience is what front-end writers should do.  I don't find it 
inadvisable at all.  If it's the "silent" part that you object to, I 
think that's a matter of taste.  Personally, I've stopped reading the 
messages like


"Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

     as.Date, as.Date.numeric"

so they may as well be silent.

Duncan Murdoch


On 17/08/2020 10:02 a.m., John Fox wrote:

Dear Duncan,

On 2020-08-17 9:03 a.m., Duncan Murdoch wrote:

On 17/08/2020 7:54 a.m., Ivan Calandra wrote:

Dear useRs,

Following the recent activity on the list, I have been made aware of
this discussion:
https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html

I used to install all packages in R, but for simplicity (I use RStudio
for all purposes), I now do it in RStudio. Now I am left wondering
whether I should continue installing packages directly from RStudio or
whether I should revert to using R.

My goal is not to flare a debate over whether RStudio is better or 
worse

than R, but rather simply to understand whether there are differences
and potential issues (that could lead to problems in code) about
installing packages through RStudio.

In general, it would be nice to have a list of the differences in
behavior between R and RStudio, but I believe this should come from the
RStudio side of things.

Thank you all for the insights.
Ivan



To see the install.packages function that RStudio installs, just type
its name:

  > install.packages
function (...)
.rs.callAs(name, hook, original, ...)


You can debug it to see the other variables:

  > debug(install.packages)
  > install.packages("abind")
debugging in: install.packages("abind")
debug: .rs.callAs(name, hook, original, ...)
Browse[2]> name
[1] "install.packages"
Browse[2]> hook
function (original, pkgs, lib, repos = getOption("repos"), ...)
{
      if (missing(pkgs))
      return(utils::install.packages())
      if (!.Call("rs_canInstallPackages", PACKAGE = "(embedding)")) {
      stop("Package installation is disabled in this version of
RStudio",
      call. = FALSE)
      }
      packratMode <- !is.na(Sys.getenv("R_PACKRAT_MODE", unset = NA))
      if (!is.null(repos) && !packratMode &&
.rs.loadedPackageUpdates(pkgs)) {
      installCmd <- NULL
      for (i in seq_along(sys.calls())) {
      if (identical(deparse(sys.call(i)[[1]]),
"install.packages")) {
      installCmd <- gsub("\\s+", " ",
paste(deparse(sys.call(i)),
    collapse = " "))
      break
      }
      }
      .rs.enqueLoadedPackageUpdates(installCmd)
      stop("Updating loaded packages")
      }
      .rs.addRToolsToPath()
      on.exit({
      .rs.updatePackageEvents()
      .Call("rs_packageLibraryMutated", PACKAGE = "(embedding)")
      .rs.restorePreviousPath()
      })
      original(pkgs, lib, repos, ...)
}


The .rs.callAs function just substitutes the call to "hook" for the call
to the original install.packages.  So you can see that they do the
following:
   - they allow a way to disable installing packages,
   - they support "packrat" (a system for installing particular versions
of packages, see https://github.com/rstudio/packrat),
   - they add RTools to the path (presumably only on Windows)
   - they call the original function, and at the end update internal
variables so they can show the library in the Packages pane.

So there is no reason not to do it in R.

By the way, saying that this is a "modified version of R" is like 

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Hadley Wickham
> | but they won't receive any new
> | features, and we believe that there
> | are now better approaches to solving
> | the same problem.
>
> Is tidyr::pivot_longer this better
> solution?  It is an easier to understand
> version of the now retired and confusing
> (for me) tidyr::gather which at least
> reigned back in 2018 (was that any good
> compared to reshape?).

Yes, and hopefully :)

library(tidyr)

tab <- structure(list(
date = c("2019M08", "2019M09", "2019M10"),
down = c(0.01709827, 0.02094724, 0.01750911),
uc = c(0.2653882, 0.2265797, 0.245003),
up = c(0.7175136, 0.7524731, 0.7374879)),
class = "data.frame", row.names = c(NA, -3L))

tab %>% pivot_longer(
  down:up,
  names_to = "direction",
  values_to = "percentage"
)
#> # A tibble: 9 x 3
#>   datedirection percentage
#>
#> 1 2019M08 down  0.0171
#> 2 2019M08 uc0.265
#> 3 2019M08 up0.718
#> 4 2019M09 down  0.0209
#> 5 2019M09 uc0.227
#> 6 2019M09 up0.752
#> 7 2019M10 down  0.0175
#> 8 2019M10 uc0.245
#> 9 2019M10 up0.737

Created on 2020-08-17 by the [reprex
package](https://reprex.tidyverse.org) (v0.3.0)



-- 
http://hadley.nz

__
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] install.packages() R vs RStudio

2020-08-17 Thread Duncan Murdoch

Hi John.

I suspect most good front ends do similar things.  For example, on 
MacOS, R.app messes up "history()".  I've never used ESS, but I imagine 
one could find examples where it acts differently than base R:  isn't 
that the point?


One hopes all differences are improvements, but sometimes they're not. 
If the modifications cause trouble (e.g. the ones you and I have never 
experienced with install.packages() in RStudio, or the one I experience 
every now and then with history() in R.app), then that may be a bug in 
the front-end.  It should be reported to the authors.


R is designed to be flexible, and to let people change its behaviour. 
Using that flexibility is what all users should do.  Improving the user 
experience is what front-end writers should do.  I don't find it 
inadvisable at all.  If it's the "silent" part that you object to, I 
think that's a matter of taste.  Personally, I've stopped reading the 
messages like


"Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

as.Date, as.Date.numeric"

so they may as well be silent.

Duncan Murdoch


On 17/08/2020 10:02 a.m., John Fox wrote:

Dear Duncan,

On 2020-08-17 9:03 a.m., Duncan Murdoch wrote:

On 17/08/2020 7:54 a.m., Ivan Calandra wrote:

Dear useRs,

Following the recent activity on the list, I have been made aware of
this discussion:
https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html

I used to install all packages in R, but for simplicity (I use RStudio
for all purposes), I now do it in RStudio. Now I am left wondering
whether I should continue installing packages directly from RStudio or
whether I should revert to using R.

My goal is not to flare a debate over whether RStudio is better or worse
than R, but rather simply to understand whether there are differences
and potential issues (that could lead to problems in code) about
installing packages through RStudio.

In general, it would be nice to have a list of the differences in
behavior between R and RStudio, but I believe this should come from the
RStudio side of things.

Thank you all for the insights.
Ivan



To see the install.packages function that RStudio installs, just type
its name:

  > install.packages
function (...)
.rs.callAs(name, hook, original, ...)


You can debug it to see the other variables:

  > debug(install.packages)
  > install.packages("abind")
debugging in: install.packages("abind")
debug: .rs.callAs(name, hook, original, ...)
Browse[2]> name
[1] "install.packages"
Browse[2]> hook
function (original, pkgs, lib, repos = getOption("repos"), ...)
{
      if (missing(pkgs))
      return(utils::install.packages())
      if (!.Call("rs_canInstallPackages", PACKAGE = "(embedding)")) {
      stop("Package installation is disabled in this version of
RStudio",
      call. = FALSE)
      }
      packratMode <- !is.na(Sys.getenv("R_PACKRAT_MODE", unset = NA))
      if (!is.null(repos) && !packratMode &&
.rs.loadedPackageUpdates(pkgs)) {
      installCmd <- NULL
      for (i in seq_along(sys.calls())) {
      if (identical(deparse(sys.call(i)[[1]]),
"install.packages")) {
      installCmd <- gsub("\\s+", " ",
paste(deparse(sys.call(i)),
    collapse = " "))
      break
      }
      }
      .rs.enqueLoadedPackageUpdates(installCmd)
      stop("Updating loaded packages")
      }
      .rs.addRToolsToPath()
      on.exit({
      .rs.updatePackageEvents()
      .Call("rs_packageLibraryMutated", PACKAGE = "(embedding)")
      .rs.restorePreviousPath()
      })
      original(pkgs, lib, repos, ...)
}


The .rs.callAs function just substitutes the call to "hook" for the call
to the original install.packages.  So you can see that they do the
following:
   - they allow a way to disable installing packages,
   - they support "packrat" (a system for installing particular versions
of packages, see https://github.com/rstudio/packrat),
   - they add RTools to the path (presumably only on Windows)
   - they call the original function, and at the end update internal
variables so they can show the library in the Packages pane.

So there is no reason not to do it in R.

By the way, saying that this is a "modified version of R" is like saying
every single user who defines a variable creates a modified version of
R.  If you type "x" in the plain R console, you see "Error: object 'x'
not found".  If you "modify" R by assigning a value to x, you'll see
something different.  Very scary!


I can't recall ever disagreeing with something you said on the R-help,
but this seems to me to be off-base. While what you say is technically
correct, silently masking a standard R function, in this case, I
believe, by messing with the namespace of the utils package, seems
inadvisable to me.

As has been noted, cryptic problems have arisen with install.packages()
in RStudio -- BTW, I use it regularly and haven't personally experienced
any issues. One could 

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Rasmus Liland
On 2020-08-17 10:09 -0700, Bert Gunter wrote:
| On Mon, Aug 17, 2020 at 9:53 AM Rasmus Liland wrote:
| |
| | Also, stack is also possible to use:
| |
| | tab <- structure(list(
| | date = c("2019M08", "2019M09", "2019M10"),
| | down = c(0.01709827, 0.02094724, 0.01750911),
| | uc = c(0.2653882, 0.2265797, 0.245003),
| | up = c(0.7175136, 0.7524731, 0.7374879)),
| | class = "data.frame", row.names = c(NA, -3L))
| |
| | out <- utils::stack(x=tab, select=-date)
| | colnames(out) <- c("percentage", "direction")
| | out$date <- tab$date
| | out <- out[,sort(colnames(out))]
| 
| Well, not that there is anything 
| "wrong" with previous suggestions, but 
| it is pretty straightforward just with 
| base R functionality:
| 
| > nm <- names(tab)[2:4]
| > with(tab, data.frame(date = rep(date, length(nm)),
| +  direction = rep(nm, e = 3),
| +  percentage = do.call(c, tab[, nm]))
| +  )

This is good :)  You can also use unlist 
directly instead of do.call(c, ...)

nm <- names(tab)[2:4]
data.frame(
  date=tab$date,
  direction=rep(nm, each=length(nm)),
  percentage=unlist(tab[,nm]))

V

r


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] Best settings for RStudio video recording?

2020-08-17 Thread Duncan Murdoch

On 17/08/2020 9:20 a.m., Ivan Calandra wrote:

I don't want to relight the fire, but I was wondering about that
statement from John C Frain:
"If you use RStudio and do not install any of the RStudio packages".

I guess you mean that some packages are bundled with RStudio. I had
never noticed any optional packages during the installation of
RStudio... Is there a way to identify (and delete, if wished) these
packages?
Or have I misunderstood?


When you are running RStudio, your search list will include 
"tools:rstudio".  It's not exactly a package, it's an environment 
containing functions used by the RStudio front end.  You can delete it 
and R will still work fine, but I'd expect some parts of the GUI to stop 
working.


Some RStudio actions (e.g. clicking the "knit" button) will prompt you 
to install packages if they are not found.  I don't think any of them 
are "bundled" with RStudio, but I might be wrong about that.


RStudio definitely installs Pandoc and maybe some other packages. 
(These aren't R packages, they are packages in a more general sense.) 
Certainly you should be able to delete Pandoc if you have permissions to 
install it; that may break RMarkdown if you don't have another copy 
somewhere.)


To identify what R packages got installed, just run 
"installed.packages()" before and after installing RStudio, and look for 
differences.


Duncan Murdoch




Thank you!
Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 16/08/2020 20:20, John C Frain wrote:

On Sun 16 Aug 2020 at 06:32, Jeff Newmiller 
wrote:


a) Read about it yourself. It is a legal definition.

b) Don't "correct" me with misinformation you are clearly inventing.
RStudio the software does not "introduce people to a modified version of
R." Each user has to opt in to that "modified" experience by explicitly
installing each of the the many CRAN packages that various employees of
RStudio have created and all of which can (to my knowledge) be used without
installing the RStudio IDE at all. Yes, a bunch of them can be grabbed at
once by installing the tidyverse package, but that is also a choice made by
users and by instructors struggling to deal with students who have a hard
time with Excel much less functional programming. But RStudio is an R IDE.

There are a lot of packages sponsored by RStudio that I find redundant and
slow, but portraying the RStudio company or the IDE as inherently "not R"
just because newbies like the IDE and the packages they sponsor, and who
end up confusing R with RStudio even though they have to install both, is
small-minded and biased


To clarify:  If you use RStudio and do not install any of the RStudio
packages, R in RStudio is the same R as if you were running it from the
command line.  I would think that many users find command completion,
access to help files, project management Etc. useful. Nobody is asking
anyone to install the RStudio packages.  I do sometimes but not always and
have found them useful. Jeff is 100% correct.



  On August 15, 2020 9:10:34 PM PDT, Abby Spurdle 
wrote:

On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller
 wrote:

  It is a public benefit corporation

Seriously?

On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller
 wrote:

  used to introduce people to R

Correction, it introduces people to a modified version of R.

--
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-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] confidence intervals for the difference between group means

2020-08-17 Thread varin sacha via R-help
Dear Matthias,

Many thanks for your response.

Best,
SV


Le mardi 4 août 2020 à 16:22:41 UTC+2, Prof. Dr. Matthias Kohl 
 a écrit : 





you could try:

library(MKinfer)
meanDiffCI(a, b, boot = TRUE)

Best
Matthias

Am 04.08.20 um 16:08 schrieb varin sacha via R-help:
> Dear R-experts,
> 
> Using the bootES package I can easily calculate the bootstrap confidence 
> intervals of the means like in the toy example here below. Now, I am looking 
> for the confidence intervals for the difference between group means. In my 
> case, the point estimate of the mean difference is 64.4. I am looking at the 
> 95% confidence intervals around this point estimate (64.4).
> 
> Many thanks for your response.
> 
> 
> library(bootES)
> a<-c(523,435,478,567,654)
> b<-c(423,523,421,467,501)
> bootES(a)
> bootES(b)

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

-- 
Prof. Dr. Matthias Kohl
www.stamats.de

__
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] [EXT] Re: Plot math symbol with string and number

2020-08-17 Thread David K Stevens

John - one more approach

plot(y,main=parse(text=paste0('data ~~ sigma == ',s)))

Good luck

David Stevens

On 8/17/2020 8:23 AM, John Smith wrote:

Thanks to Dunkan, Rasmus and Bert. Will keep the very useful tips. Best!

On Sun, Aug 16, 2020 at 9:13 PM Rasmus Liland  wrote:


On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
| On Sun, Aug 16, 2020, 14:53 John wrote:
| |
| | I would like to make plots with
| | titles for different data sets and
| | different parameters. The first
| | title doesn't show sigma as a math
| | symbol, while the second one
| | doesn't contain the s value as a
| | numeric value
| |
| | s <- 1
| | y <- rnorm(100)
| | plot(y, main=paste("data", "sigma=", s))
| | plot(y, main=expression(paste("data", sigma,"=", s)))
|
| ?plotmath

Dear John, read ?plotmath, it is good, I
was not aware of its existence; then
backquote s like so:

 plot(y, main=bquote(paste(
   "data" ~~ widehat(aleph)
   %notin% .(s)^.(s

V

r


 [[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.
CAUTION: This email originated from outside of USU. If this appears to be a USU 
employee, beware of impersonators. Do not click links, reply, download images, 
or open attachments unless you verify the sender’s identity and know the 
content is safe.


--
David K Stevens, P.E., Ph.D.
Professor, Environmental Engineering
Civil and Environmental Engineering
Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stev...@usu.edu

__
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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Bert Gunter
Well, not that there is anything "wrong" with previous suggestions, but it
is pretty straightforward just with base R functionality:

> nm <- names(tab)[2:4]
> with(tab, data.frame(date = rep(date, length(nm)),
+ direction = rep(nm, e = 3),
+ percentage = do.call(c, tab[, nm]))
+ )
 date direction percentage
down1 2019M08  down 0.01709827
down2 2019M09  down 0.02094724
down3 2019M10  down 0.01750911
uc1   2019M08uc 0.26538820
uc2   2019M09uc 0.22657970
uc3   2019M10uc 0.24500300
up1   2019M08up 0.71751360
up2   2019M09up 0.75247310
up3   2019M10up 0.73748790


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, Aug 17, 2020 at 9:53 AM Rasmus Liland  wrote:

> Dear John,
>
> Op ma 17 aug. 2020 om 09:52 schreef Eric Berger:
> | On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx wrote:
> | |
> | | You are looking for tidyr::pivot_longer()
> |
> | Alternatively, melt() from the reshape2 package.
> |
> | library(reshape2)
> | melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
> | ="direction",value.name="percentage")
>
> Also, stack is also possible to use:
>
> tab <- structure(list(
> date = c("2019M08", "2019M09", "2019M10"),
> down = c(0.01709827, 0.02094724, 0.01750911),
> uc = c(0.2653882, 0.2265797, 0.245003),
> up = c(0.7175136, 0.7524731, 0.7374879)),
> class = "data.frame", row.names = c(NA, -3L))
>
> out <- utils::stack(x=tab, select=-date)
> colnames(out) <- c("percentage", "direction")
> out$date <- tab$date
> out <- out[,sort(colnames(out))]
>
> out
>
> yields
>
>  date direction percentage
> 1 2019M08  down 0.01709827
> 2 2019M09  down 0.02094724
> 3 2019M10  down 0.01750911
> 4 2019M08uc 0.26538820
> 5 2019M09uc 0.22657970
> 6 2019M10uc 0.24500300
> 7 2019M08up 0.71751360
> 8 2019M09up 0.75247310
> 9 2019M10up 0.73748790
>
> On 2020-08-17 07:46 -0500, Hadley Wickham wrote:
> | On Mon, Aug 17, 2020 at 11:23 AM Thierry Onkelinx wrote:
> | |
> | | reshape2 is a retired package. The
> | | author recommends to use his new
> | | package tidyr.
> |
> | We previously used the term retired to
> | suggest that the package is taking it
> | easy and relaxing, but isn't dead.
>
> Haha :)
>
> | This causes a lot of confusion so we
> | now call this state "superseded" —
> | we'll continue to keep reshape2 (and
> | reshape!) on CRAN
>
> Good!
>
> | but they won't receive any new
> | features, and we believe that there
> | are now better approaches to solving
> | the same problem.
>
> Is tidyr::pivot_longer this better
> solution?  It is an easier to understand
> version of the now retired and confusing
> (for me) tidyr::gather which at least
> reigned back in 2018 (was that any good
> compared to reshape?).
>
> 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.
>

[[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Rasmus Liland
Dear John,

Op ma 17 aug. 2020 om 09:52 schreef Eric Berger:
| On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx wrote:
| |
| | You are looking for tidyr::pivot_longer()
|
| Alternatively, melt() from the reshape2 package.
|
| library(reshape2)
| melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
| ="direction",value.name="percentage")

Also, stack is also possible to use:

tab <- structure(list(
date = c("2019M08", "2019M09", "2019M10"),
down = c(0.01709827, 0.02094724, 0.01750911),
uc = c(0.2653882, 0.2265797, 0.245003),
up = c(0.7175136, 0.7524731, 0.7374879)),
class = "data.frame", row.names = c(NA, -3L))

out <- utils::stack(x=tab, select=-date)
colnames(out) <- c("percentage", "direction")
out$date <- tab$date
out <- out[,sort(colnames(out))]

out

yields

 date direction percentage
1 2019M08  down 0.01709827
2 2019M09  down 0.02094724
3 2019M10  down 0.01750911
4 2019M08uc 0.26538820
5 2019M09uc 0.22657970
6 2019M10uc 0.24500300
7 2019M08up 0.71751360
8 2019M09up 0.75247310
9 2019M10up 0.73748790

On 2020-08-17 07:46 -0500, Hadley Wickham wrote:
| On Mon, Aug 17, 2020 at 11:23 AM Thierry Onkelinx wrote:
| |
| | reshape2 is a retired package. The 
| | author recommends to use his new 
| | package tidyr.
| 
| We previously used the term retired to 
| suggest that the package is taking it 
| easy and relaxing, but isn't dead. 

Haha :)

| This causes a lot of confusion so we 
| now call this state "superseded" — 
| we'll continue to keep reshape2 (and 
| reshape!) on CRAN

Good!

| but they won't receive any new 
| features, and we believe that there 
| are now better approaches to solving 
| the same problem.

Is tidyr::pivot_longer this better 
solution?  It is an easier to understand 
version of the now retired and confusing 
(for me) tidyr::gather which at least 
reigned back in 2018 (was that any good 
compared to reshape?).

Best,
Rasmus


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] Data With Ordinal Responses: Calculate ICC & Assessing Model Fit

2020-08-17 Thread Bert Gunter
I believe you should post on r-sig-mixed-models, not here. You are more
likely to find the interest and expertise you seek there.

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, Aug 17, 2020 at 3:28 AM Sidoti, Salvatore A. <
sidoti...@buckeyemail.osu.edu> wrote:

> To begin with, I'm not a fan of cross-posting. However, I posted my
> question on Stack Exchange more than two weeks ago, but I have yet to
> receive a sufficient answer:
>
>
> https://stats.stackexchange.com/questions/479600/data-with-ordinal-responses-calculate-icc-assessing-model-fit
>
> Here's what I've learned since then (hopefully):
>
> 1) ICC of a CLMM:
> Computed like this:
> (variance of the random effect) / (variance of the random effect + 1)
> If this is correct, I would love to see a reference/citation for it.
>
> 2) 95% Confidence Interval for the ICC from a CLMM Model
> To my current understanding, a confidence interval for an ICC is only
> obtainable via simulation. I've conducted simulations with GLMM model
> objects ('lme4' package) and the bootMer() function. Unfortunately,
> bootMer() will not accept a CLMM model ('ordinal' package).
>
> 3) Model Fit of a CLMM
> Assuming that the model converges without incident, the model summary
> includes a condition number of the Hessian ('cond.H'). This value should be
> below 10^4 for a "good fit". This is straightforward enough. However, I am
> not as sure about the value for 'max.grad', which needs to be "well below
> 1". The question is, to what magnitude should max.grad < 1 for a decent
> model fit? My reference is linked below (Christensen, 2019), but it does
> not elaborate further on this point:
>
>
> https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:b6a61fe2-b851-49ce-b8b1-cd760d290636
>
> 3) Effect Size of a CLMM
> The random variable's effect is determined by a comparison between the
> full model to a model with only the fixed effects via the anova() function.
> I found this information on the 'rcompanion' package website:
>
> https://rcompanion.org/handbook/G_12.html
>
> The output of this particular anova() will include a value named
> 'LR.stat', the likelihood ratio statistic. The LR.stat is twice the
> difference of each log-likelihood (absolute value) of the respective
> models. Is LR.stat the mixed-model version of an "effect size"? If so, how
> does one determine if the effect is small, large, in-between, etc?
>
> Cheers,
> Sal
>
> Salvatore A. Sidoti
> PhD Candidate
> Behavioral Ecology
> The Ohio State University
>
> __
> 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] Plot math symbol with string and number

2020-08-17 Thread John Smith
Thanks to Dunkan, Rasmus and Bert. Will keep the very useful tips. Best!

On Sun, Aug 16, 2020 at 9:13 PM Rasmus Liland  wrote:

> On Sun, Aug 16, 2020 at 3:18 PM Bert wrote:
> | On Sun, Aug 16, 2020, 14:53 John wrote:
> | |
> | | I would like to make plots with
> | | titles for different data sets and
> | | different parameters. The first
> | | title doesn't show sigma as a math
> | | symbol, while the second one
> | | doesn't contain the s value as a
> | | numeric value
> | |
> | | s <- 1
> | | y <- rnorm(100)
> | | plot(y, main=paste("data", "sigma=", s))
> | | plot(y, main=expression(paste("data", sigma,"=", s)))
> |
> | ?plotmath
>
> Dear John, read ?plotmath, it is good, I
> was not aware of its existence; then
> backquote s like so:
>
> plot(y, main=bquote(paste(
>   "data" ~~ widehat(aleph)
>   %notin% .(s)^.(s
>
> V
>
> r
>

[[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] install.packages() R vs RStudio

2020-08-17 Thread John Fox

Dear Duncan,

On 2020-08-17 9:03 a.m., Duncan Murdoch wrote:

On 17/08/2020 7:54 a.m., Ivan Calandra wrote:

Dear useRs,

Following the recent activity on the list, I have been made aware of
this discussion:
https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html

I used to install all packages in R, but for simplicity (I use RStudio
for all purposes), I now do it in RStudio. Now I am left wondering
whether I should continue installing packages directly from RStudio or
whether I should revert to using R.

My goal is not to flare a debate over whether RStudio is better or worse
than R, but rather simply to understand whether there are differences
and potential issues (that could lead to problems in code) about
installing packages through RStudio.

In general, it would be nice to have a list of the differences in
behavior between R and RStudio, but I believe this should come from the
RStudio side of things.

Thank you all for the insights.
Ivan



To see the install.packages function that RStudio installs, just type 
its name:


 > install.packages
function (...)
.rs.callAs(name, hook, original, ...)


You can debug it to see the other variables:

 > debug(install.packages)
 > install.packages("abind")
debugging in: install.packages("abind")
debug: .rs.callAs(name, hook, original, ...)
Browse[2]> name
[1] "install.packages"
Browse[2]> hook
function (original, pkgs, lib, repos = getOption("repos"), ...)
{
     if (missing(pkgs))
     return(utils::install.packages())
     if (!.Call("rs_canInstallPackages", PACKAGE = "(embedding)")) {
     stop("Package installation is disabled in this version of 
RStudio",

     call. = FALSE)
     }
     packratMode <- !is.na(Sys.getenv("R_PACKRAT_MODE", unset = NA))
     if (!is.null(repos) && !packratMode && 
.rs.loadedPackageUpdates(pkgs)) {

     installCmd <- NULL
     for (i in seq_along(sys.calls())) {
     if (identical(deparse(sys.call(i)[[1]]), 
"install.packages")) {
     installCmd <- gsub("\\s+", " ", 
paste(deparse(sys.call(i)),

   collapse = " "))
     break
     }
     }
     .rs.enqueLoadedPackageUpdates(installCmd)
     stop("Updating loaded packages")
     }
     .rs.addRToolsToPath()
     on.exit({
     .rs.updatePackageEvents()
     .Call("rs_packageLibraryMutated", PACKAGE = "(embedding)")
     .rs.restorePreviousPath()
     })
     original(pkgs, lib, repos, ...)
}


The .rs.callAs function just substitutes the call to "hook" for the call 
to the original install.packages.  So you can see that they do the 
following:

  - they allow a way to disable installing packages,
  - they support "packrat" (a system for installing particular versions 
of packages, see https://github.com/rstudio/packrat),

  - they add RTools to the path (presumably only on Windows)
  - they call the original function, and at the end update internal 
variables so they can show the library in the Packages pane.


So there is no reason not to do it in R.

By the way, saying that this is a "modified version of R" is like saying 
every single user who defines a variable creates a modified version of 
R.  If you type "x" in the plain R console, you see "Error: object 'x' 
not found".  If you "modify" R by assigning a value to x, you'll see 
something different.  Very scary!


I can't recall ever disagreeing with something you said on the R-help, 
but this seems to me to be off-base. While what you say is technically 
correct, silently masking a standard R function, in this case, I 
believe, by messing with the namespace of the utils package, seems 
inadvisable to me.


As has been noted, cryptic problems have arisen with install.packages() 
in RStudio -- BTW, I use it regularly and haven't personally experienced 
any issues. One could concoct truly scary examples, such as redefining 
isTRUE().


Best,
 John



Duncan Murdoch

__
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] Best settings for RStudio video recording?

2020-08-17 Thread Ivan Calandra
I don't want to relight the fire, but I was wondering about that
statement from John C Frain:
"If you use RStudio and do not install any of the RStudio packages".

I guess you mean that some packages are bundled with RStudio. I had
never noticed any optional packages during the installation of
RStudio... Is there a way to identify (and delete, if wished) these
packages?
Or have I misunderstood?

Thank you!
Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 16/08/2020 20:20, John C Frain wrote:
> On Sun 16 Aug 2020 at 06:32, Jeff Newmiller 
> wrote:
>
>> a) Read about it yourself. It is a legal definition.
>>
>> b) Don't "correct" me with misinformation you are clearly inventing.
>> RStudio the software does not "introduce people to a modified version of
>> R." Each user has to opt in to that "modified" experience by explicitly
>> installing each of the the many CRAN packages that various employees of
>> RStudio have created and all of which can (to my knowledge) be used without
>> installing the RStudio IDE at all. Yes, a bunch of them can be grabbed at
>> once by installing the tidyverse package, but that is also a choice made by
>> users and by instructors struggling to deal with students who have a hard
>> time with Excel much less functional programming. But RStudio is an R IDE.
>>
>> There are a lot of packages sponsored by RStudio that I find redundant and
>> slow, but portraying the RStudio company or the IDE as inherently "not R"
>> just because newbies like the IDE and the packages they sponsor, and who
>> end up confusing R with RStudio even though they have to install both, is
>> small-minded and biased
>
> To clarify:  If you use RStudio and do not install any of the RStudio
> packages, R in RStudio is the same R as if you were running it from the
> command line.  I would think that many users find command completion,
> access to help files, project management Etc. useful. Nobody is asking
> anyone to install the RStudio packages.  I do sometimes but not always and
> have found them useful. Jeff is 100% correct.
>
>
>>  On August 15, 2020 9:10:34 PM PDT, Abby Spurdle 
>> wrote:
>>> On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller
>>>  wrote:
  It is a public benefit corporation
>>> Seriously?
>>>
>>> On Fri, Aug 14, 2020 at 12:11 PM Jeff Newmiller
>>>  wrote:
  used to introduce people to R
>>> Correction, it introduces people to a modified version of R.
>> --
>> 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-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] install.packages() R vs RStudio

2020-08-17 Thread Ivan Calandra
Thank you Duncan for the very detailed and clear answer!

Best,
Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 17/08/2020 15:03, Duncan Murdoch wrote:
> On 17/08/2020 7:54 a.m., Ivan Calandra wrote:
>> Dear useRs,
>>
>> Following the recent activity on the list, I have been made aware of
>> this discussion:
>> https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html
>>
>> I used to install all packages in R, but for simplicity (I use RStudio
>> for all purposes), I now do it in RStudio. Now I am left wondering
>> whether I should continue installing packages directly from RStudio or
>> whether I should revert to using R.
>>
>> My goal is not to flare a debate over whether RStudio is better or worse
>> than R, but rather simply to understand whether there are differences
>> and potential issues (that could lead to problems in code) about
>> installing packages through RStudio.
>>
>> In general, it would be nice to have a list of the differences in
>> behavior between R and RStudio, but I believe this should come from the
>> RStudio side of things.
>>
>> Thank you all for the insights.
>> Ivan
>>
>
> To see the install.packages function that RStudio installs, just type
> its name:
>
> > install.packages
> function (...)
> .rs.callAs(name, hook, original, ...)
> 
>
> You can debug it to see the other variables:
>
> > debug(install.packages)
> > install.packages("abind")
> debugging in: install.packages("abind")
> debug: .rs.callAs(name, hook, original, ...)
> Browse[2]> name
> [1] "install.packages"
> Browse[2]> hook
> function (original, pkgs, lib, repos = getOption("repos"), ...)
> {
>     if (missing(pkgs))
>     return(utils::install.packages())
>     if (!.Call("rs_canInstallPackages", PACKAGE = "(embedding)")) {
>     stop("Package installation is disabled in this version of
> RStudio",
>     call. = FALSE)
>     }
>     packratMode <- !is.na(Sys.getenv("R_PACKRAT_MODE", unset = NA))
>     if (!is.null(repos) && !packratMode &&
> .rs.loadedPackageUpdates(pkgs)) {
>     installCmd <- NULL
>     for (i in seq_along(sys.calls())) {
>     if (identical(deparse(sys.call(i)[[1]]),
> "install.packages")) {
>     installCmd <- gsub("\\s+", " ",
> paste(deparse(sys.call(i)),
>   collapse = " "))
>     break
>     }
>     }
>     .rs.enqueLoadedPackageUpdates(installCmd)
>     stop("Updating loaded packages")
>     }
>     .rs.addRToolsToPath()
>     on.exit({
>     .rs.updatePackageEvents()
>     .Call("rs_packageLibraryMutated", PACKAGE = "(embedding)")
>     .rs.restorePreviousPath()
>     })
>     original(pkgs, lib, repos, ...)
> }
> 
>
> The .rs.callAs function just substitutes the call to "hook" for the
> call to the original install.packages.  So you can see that they do
> the following:
>  - they allow a way to disable installing packages,
>  - they support "packrat" (a system for installing particular versions
> of packages, see https://github.com/rstudio/packrat),
>  - they add RTools to the path (presumably only on Windows)
>  - they call the original function, and at the end update internal
> variables so they can show the library in the Packages pane.
>
> So there is no reason not to do it in R.
>
> By the way, saying that this is a "modified version of R" is like
> saying every single user who defines a variable creates a modified
> version of R.  If you type "x" in the plain R console, you see "Error:
> object 'x' not found".  If you "modify" R by assigning a value to x,
> you'll see something different.  Very scary!
>
> Duncan Murdoch
>
>

__
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] install.packages() R vs RStudio

2020-08-17 Thread Duncan Murdoch

On 17/08/2020 7:54 a.m., Ivan Calandra wrote:

Dear useRs,

Following the recent activity on the list, I have been made aware of
this discussion:
https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html

I used to install all packages in R, but for simplicity (I use RStudio
for all purposes), I now do it in RStudio. Now I am left wondering
whether I should continue installing packages directly from RStudio or
whether I should revert to using R.

My goal is not to flare a debate over whether RStudio is better or worse
than R, but rather simply to understand whether there are differences
and potential issues (that could lead to problems in code) about
installing packages through RStudio.

In general, it would be nice to have a list of the differences in
behavior between R and RStudio, but I believe this should come from the
RStudio side of things.

Thank you all for the insights.
Ivan



To see the install.packages function that RStudio installs, just type 
its name:


> install.packages
function (...)
.rs.callAs(name, hook, original, ...)


You can debug it to see the other variables:

> debug(install.packages)
> install.packages("abind")
debugging in: install.packages("abind")
debug: .rs.callAs(name, hook, original, ...)
Browse[2]> name
[1] "install.packages"
Browse[2]> hook
function (original, pkgs, lib, repos = getOption("repos"), ...)
{
if (missing(pkgs))
return(utils::install.packages())
if (!.Call("rs_canInstallPackages", PACKAGE = "(embedding)")) {
stop("Package installation is disabled in this version of 
RStudio",

call. = FALSE)
}
packratMode <- !is.na(Sys.getenv("R_PACKRAT_MODE", unset = NA))
if (!is.null(repos) && !packratMode && 
.rs.loadedPackageUpdates(pkgs)) {

installCmd <- NULL
for (i in seq_along(sys.calls())) {
if (identical(deparse(sys.call(i)[[1]]), "install.packages")) {
installCmd <- gsub("\\s+", " ", 
paste(deparse(sys.call(i)),

  collapse = " "))
break
}
}
.rs.enqueLoadedPackageUpdates(installCmd)
stop("Updating loaded packages")
}
.rs.addRToolsToPath()
on.exit({
.rs.updatePackageEvents()
.Call("rs_packageLibraryMutated", PACKAGE = "(embedding)")
.rs.restorePreviousPath()
})
original(pkgs, lib, repos, ...)
}


The .rs.callAs function just substitutes the call to "hook" for the call 
to the original install.packages.  So you can see that they do the 
following:

 - they allow a way to disable installing packages,
 - they support "packrat" (a system for installing particular versions 
of packages, see https://github.com/rstudio/packrat),

 - they add RTools to the path (presumably only on Windows)
 - they call the original function, and at the end update internal 
variables so they can show the library in the Packages pane.


So there is no reason not to do it in R.

By the way, saying that this is a "modified version of R" is like saying 
every single user who defines a variable creates a modified version of 
R.  If you type "x" in the plain R console, you see "Error: object 'x' 
not found".  If you "modify" R by assigning a value to x, you'll see 
something different.  Very scary!


Duncan Murdoch

__
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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Hadley Wickham
We previously used the term retired to suggest that the package is
taking it easy and relaxing, but isn't dead. This causes a lot of
confusion so we now call this state "superseded" — we'll continue to
keep reshape2 (and reshape!) on CRAN, but they won't receive any new
features, and we believe that there are now better approaches to
solving the same problem.

Hadley

On Mon, Aug 17, 2020 at 3:58 AM Eric Berger  wrote:
>
> Thanks for this information Thierry. I was not aware.
> The author of the packages is Hadley Wickham. He writes on Github that he
> does plan to make changes necessary to keep the package available on CRAN.
>
>
>
> On Mon, Aug 17, 2020 at 11:23 AM Thierry Onkelinx 
> wrote:
>
> > Yes. However reshape2 is a retired package. The author recommends to use
> > his new package tidyr.
> >
> > ir. Thierry Onkelinx
> > Statisticus / Statistician
> >
> > Vlaamse Overheid / Government of Flanders
> > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> > FOREST
> > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> > thierry.onkel...@inbo.be
> > Havenlaan 88 bus 73, 1000 Brussel
> > www.inbo.be
> >
> >
> > ///
> > To call in the statistician after the experiment is done may be no more
> > than asking him to perform a post-mortem examination: he may be able to say
> > what the experiment died of. ~ Sir Ronald Aylmer Fisher
> > The plural of anecdote is not data. ~ Roger Brinner
> > The combination of some data and an aching desire for an answer does not
> > ensure that a reasonable answer can be extracted from a given body of data.
> > ~ John Tukey
> >
> > ///
> >
> > 
> >
> >
> > Op ma 17 aug. 2020 om 09:52 schreef Eric Berger :
> >
> >> Alternatively, melt() from the reshape2 package.
> >>
> >> library(reshape2)
> >> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
> >> ="direction",value.name="percentage")
> >>
> >> HTH,
> >> Eric
> >>
> >>
> >> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
> >> r-help@r-project.org> wrote:
> >>
> >>> You are looking for tidyr::pivot_longer()
> >>>
> >>> Best regards,
> >>>
> >>> ir. Thierry Onkelinx
> >>> Statisticus / Statistician
> >>>
> >>> Vlaamse Overheid / Government of Flanders
> >>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
> >>> AND
> >>> FOREST
> >>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> >>> thierry.onkel...@inbo.be
> >>> Havenlaan 88 bus 73, 1000 Brussel
> >>> www.inbo.be
> >>>
> >>>
> >>> ///
> >>> To call in the statistician after the experiment is done may be no more
> >>> than asking him to perform a post-mortem examination: he may be able to
> >>> say
> >>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> >>> The plural of anecdote is not data. ~ Roger Brinner
> >>> The combination of some data and an aching desire for an answer does not
> >>> ensure that a reasonable answer can be extracted from a given body of
> >>> data.
> >>> ~ John Tukey
> >>>
> >>> ///
> >>>
> >>> 
> >>>
> >>>
> >>> Op ma 17 aug. 2020 om 09:35 schreef John :
> >>>
> >>> > Is there any quick way (dplyr?) to arrange the data
> >>> >  date  down   uc   up
> >>> > 2019M08   0.01709827 0.2653882 0.7175136
> >>> > 2019M09   0.02094724 0.2265797 0.7524731
> >>> > 2019M10   0.01750911 0.2450030 0.7374879
> >>> >
> >>> > to
> >>> >  date  direction  percentage
> >>> > 2019M08   down 0.01709827
> >>> > 2019M09   down 0.02094724
> >>> > 2019M10   down 0.01750911
> >>> > 2019M08   uc 0.2653882
> >>> > 2019M09   uc 0.2265797
> >>> > 2019M10   uc 0.2450030
> >>> > 2019M08   up  0.7175136
> >>> > 2019M09   up 0.7524731
> >>> > 2019M10   up 0.7374879
> >>> >
> >>> > [[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.
> >>>
> >>
>
> [[alternative HTML version deleted]]
>
> 

[R] install.packages() R vs RStudio

2020-08-17 Thread Ivan Calandra
Dear useRs,

Following the recent activity on the list, I have been made aware of
this discussion:
https://stat.ethz.ch/pipermail/r-help/2020-May/466788.html

I used to install all packages in R, but for simplicity (I use RStudio
for all purposes), I now do it in RStudio. Now I am left wondering
whether I should continue installing packages directly from RStudio or
whether I should revert to using R.

My goal is not to flare a debate over whether RStudio is better or worse
than R, but rather simply to understand whether there are differences
and potential issues (that could lead to problems in code) about
installing packages through RStudio.

In general, it would be nice to have a list of the differences in
behavior between R and RStudio, but I believe this should come from the
RStudio side of things.

Thank you all for the insights.
Ivan

-- 
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

__
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] Ggplot2 Line Problem

2020-08-17 Thread Stephen P. Molnar

Many thanks. That solved the problem.

On 08/17/2020 01:49 AM, Rui Barradas wrote:

Hello,

This type of problem is almost always a data reshaping problem.
ggplot graphics work better if the data is in the long format and you 
have 3 columns for counts, one column for each category. If you 
reformat from the current wide format to the long format you will have 
a date vector, a categorical variable and a counts variable.


In the code below just change geom_point to geom_line and the problem 
is solved.



library(tidyverse)
library(lubridate)

datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;)
datO[ ,1] <- ymd(datO[ ,1])

dfO <- tibble::as_tibble(data.frame(date = datO[ ,"date"],
positive = datO[ ,"positive"],
negative = datO[ ,"negative"],
total = datO[ ,"total"]))

dfO %>%
  pivot_longer(
cols = -date,
names_to = "cases",
values_to = "count"
  ) %>%
  mutate(cases = factor(cases, levels = c("positive", "negative", 
"total"))) %>%

  ggplot(aes(date, count, color = cases)) +
  geom_point() +
  scale_color_manual(name = "Test",
 labels = c("Positive", "Negative", "Total"),
 values = c("red", "blue", "green")) +
  ylim(0, 175) +
  labs(x = "Date", y = "Number of Tests")+
  ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+
  theme_bw() +
  theme(axis.text.x = element_text(angle = 30, hjust = 1),
plot.title = element_text(hjust = 0.5))



Hope this helps,

Rui Barradas


??s 02:00 de 17/08/20, Stephen P. Molnar escreveu:

I have cobbled together a short script to plot Covid-19 data.

setwd("~/Apps/Models/1-CoronaVirus")

library(tidyverse)
library(lubridate)

datO <- read.csv("https://api.covidtracking.com/v1/states/oh/daily.csv;)
datO[ ,1] <- ymd(datO[ ,1])

dfO <- tibble::as_tibble(data.frame(datO[ ,"date"],datO[ 
,"positive"],datO[ ,"negative"],datO[ ,"total"]))


dfO %>%
   ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+
   geom_point(color = 'red', size = 0.025)+
   geom_point(y = datO[ ,"negative"], color = 'blue', size = 0.025)+
   geom_point(y = datO[ ,"total"], color = "green", size = 0.025)+
   theme(axis.text.x = element_text(angle=30, hjust=1))+
   theme_bw()+
   scale_y_continuous(limits = c(0,175))+
   labs(x = "Date", y = "Number of Tests")+
   ggtitle("COVID-19 Tests in Ohio \n (8/15/20)")+
   theme(plot.title = element_text(hjust = 0.5))+
   scale_fill_discrete(name = "Test", labels = c("Positive", 
"Negative", "Total"))


Here is the plot:




but, if I want lines rather that the code (the aspplicable plines) uis:

ggplot(aes(x = datO[ ,"date"],y = datO[ ,"positive"]))+
   geom_line(linetype = "solid",color = 'red')+
   geom_line(linetype = "dotdash",y = datO[ ,"negative"], color = 
'blue')+

   geom_line(linetype = "twodash",y = datO[ ,"total"], color = "green")+




Now two of the plots are reversed. Google has not been a friend in 
finding a solution.


Help will be much appreciated.

Thanks in advance





--
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1

__
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] Data With Ordinal Responses: Calculate ICC & Assessing Model Fit

2020-08-17 Thread Sidoti, Salvatore A.
To begin with, I'm not a fan of cross-posting. However, I posted my question on 
Stack Exchange more than two weeks ago, but I have yet to receive a sufficient 
answer:

https://stats.stackexchange.com/questions/479600/data-with-ordinal-responses-calculate-icc-assessing-model-fit
 
Here's what I've learned since then (hopefully):
 
1) ICC of a CLMM:
Computed like this:
(variance of the random effect) / (variance of the random effect + 1)
If this is correct, I would love to see a reference/citation for it.
 
2) 95% Confidence Interval for the ICC from a CLMM Model
To my current understanding, a confidence interval for an ICC is only 
obtainable via simulation. I've conducted simulations with GLMM model objects 
('lme4' package) and the bootMer() function. Unfortunately, bootMer() will not 
accept a CLMM model ('ordinal' package).
 
3) Model Fit of a CLMM
Assuming that the model converges without incident, the model summary includes 
a condition number of the Hessian ('cond.H'). This value should be below 10^4 
for a "good fit". This is straightforward enough. However, I am not as sure 
about the value for 'max.grad', which needs to be "well below 1". The question 
is, to what magnitude should max.grad < 1 for a decent model fit? My reference 
is linked below (Christensen, 2019), but it does not elaborate further on this 
point:
 
https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:b6a61fe2-b851-49ce-b8b1-cd760d290636
 
3) Effect Size of a CLMM
The random variable's effect is determined by a comparison between the full 
model to a model with only the fixed effects via the anova() function. I found 
this information on the 'rcompanion' package website:
 
https://rcompanion.org/handbook/G_12.html
 
The output of this particular anova() will include a value named 'LR.stat', the 
likelihood ratio statistic. The LR.stat is twice the difference of each 
log-likelihood (absolute value) of the respective models. Is LR.stat the 
mixed-model version of an "effect size"? If so, how does one determine if the 
effect is small, large, in-between, etc?

Cheers,
Sal

Salvatore A. Sidoti
PhD Candidate
Behavioral Ecology
The Ohio State University

__
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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Eric Berger
Thanks for this information Thierry. I was not aware.
The author of the packages is Hadley Wickham. He writes on Github that he
does plan to make changes necessary to keep the package available on CRAN.



On Mon, Aug 17, 2020 at 11:23 AM Thierry Onkelinx 
wrote:

> Yes. However reshape2 is a retired package. The author recommends to use
> his new package tidyr.
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkel...@inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
>
> ///
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ///
>
> 
>
>
> Op ma 17 aug. 2020 om 09:52 schreef Eric Berger :
>
>> Alternatively, melt() from the reshape2 package.
>>
>> library(reshape2)
>> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
>> ="direction",value.name="percentage")
>>
>> HTH,
>> Eric
>>
>>
>> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
>> r-help@r-project.org> wrote:
>>
>>> You are looking for tidyr::pivot_longer()
>>>
>>> Best regards,
>>>
>>> ir. Thierry Onkelinx
>>> Statisticus / Statistician
>>>
>>> Vlaamse Overheid / Government of Flanders
>>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
>>> AND
>>> FOREST
>>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>>> thierry.onkel...@inbo.be
>>> Havenlaan 88 bus 73, 1000 Brussel
>>> www.inbo.be
>>>
>>>
>>> ///
>>> To call in the statistician after the experiment is done may be no more
>>> than asking him to perform a post-mortem examination: he may be able to
>>> say
>>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of
>>> data.
>>> ~ John Tukey
>>>
>>> ///
>>>
>>> 
>>>
>>>
>>> Op ma 17 aug. 2020 om 09:35 schreef John :
>>>
>>> > Is there any quick way (dplyr?) to arrange the data
>>> >  date  down   uc   up
>>> > 2019M08   0.01709827 0.2653882 0.7175136
>>> > 2019M09   0.02094724 0.2265797 0.7524731
>>> > 2019M10   0.01750911 0.2450030 0.7374879
>>> >
>>> > to
>>> >  date  direction  percentage
>>> > 2019M08   down 0.01709827
>>> > 2019M09   down 0.02094724
>>> > 2019M10   down 0.01750911
>>> > 2019M08   uc 0.2653882
>>> > 2019M09   uc 0.2265797
>>> > 2019M10   uc 0.2450030
>>> > 2019M08   up  0.7175136
>>> > 2019M09   up 0.7524731
>>> > 2019M10   up 0.7374879
>>> >
>>> > [[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.
>>>
>>

[[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread John
Thanks!

Thierry Onkelinx  於 2020年8月17日 週一 下午4:23寫道:

> Yes. However reshape2 is a retired package. The author recommends to use
> his new package tidyr.
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkel...@inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
>
> ///
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ///
>
> 
>
>
> Op ma 17 aug. 2020 om 09:52 schreef Eric Berger :
>
>> Alternatively, melt() from the reshape2 package.
>>
>> library(reshape2)
>> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
>> ="direction",value.name="percentage")
>>
>> HTH,
>> Eric
>>
>>
>> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
>> r-help@r-project.org> wrote:
>>
>>> You are looking for tidyr::pivot_longer()
>>>
>>> Best regards,
>>>
>>> ir. Thierry Onkelinx
>>> Statisticus / Statistician
>>>
>>> Vlaamse Overheid / Government of Flanders
>>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
>>> AND
>>> FOREST
>>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>>> thierry.onkel...@inbo.be
>>> Havenlaan 88 bus 73, 1000 Brussel
>>> www.inbo.be
>>>
>>>
>>> ///
>>> To call in the statistician after the experiment is done may be no more
>>> than asking him to perform a post-mortem examination: he may be able to
>>> say
>>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of
>>> data.
>>> ~ John Tukey
>>>
>>> ///
>>>
>>> 
>>>
>>>
>>> Op ma 17 aug. 2020 om 09:35 schreef John :
>>>
>>> > Is there any quick way (dplyr?) to arrange the data
>>> >  date  down   uc   up
>>> > 2019M08   0.01709827 0.2653882 0.7175136
>>> > 2019M09   0.02094724 0.2265797 0.7524731
>>> > 2019M10   0.01750911 0.2450030 0.7374879
>>> >
>>> > to
>>> >  date  direction  percentage
>>> > 2019M08   down 0.01709827
>>> > 2019M09   down 0.02094724
>>> > 2019M10   down 0.01750911
>>> > 2019M08   uc 0.2653882
>>> > 2019M09   uc 0.2265797
>>> > 2019M10   uc 0.2450030
>>> > 2019M08   up  0.7175136
>>> > 2019M09   up 0.7524731
>>> > 2019M10   up 0.7374879
>>> >
>>> > [[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.
>>>
>>

[[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Thierry Onkelinx via R-help
Yes. However reshape2 is a retired package. The author recommends to use
his new package tidyr.

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///




Op ma 17 aug. 2020 om 09:52 schreef Eric Berger :

> Alternatively, melt() from the reshape2 package.
>
> library(reshape2)
> melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
> ="direction",value.name="percentage")
>
> HTH,
> Eric
>
>
> On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
> r-help@r-project.org> wrote:
>
>> You are looking for tidyr::pivot_longer()
>>
>> Best regards,
>>
>> ir. Thierry Onkelinx
>> Statisticus / Statistician
>>
>> Vlaamse Overheid / Government of Flanders
>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
>> FOREST
>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>> thierry.onkel...@inbo.be
>> Havenlaan 88 bus 73, 1000 Brussel
>> www.inbo.be
>>
>>
>> ///
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to
>> say
>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>> The plural of anecdote is not data. ~ Roger Brinner
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of
>> data.
>> ~ John Tukey
>>
>> ///
>>
>> 
>>
>>
>> Op ma 17 aug. 2020 om 09:35 schreef John :
>>
>> > Is there any quick way (dplyr?) to arrange the data
>> >  date  down   uc   up
>> > 2019M08   0.01709827 0.2653882 0.7175136
>> > 2019M09   0.02094724 0.2265797 0.7524731
>> > 2019M10   0.01750911 0.2450030 0.7374879
>> >
>> > to
>> >  date  direction  percentage
>> > 2019M08   down 0.01709827
>> > 2019M09   down 0.02094724
>> > 2019M10   down 0.01750911
>> > 2019M08   uc 0.2653882
>> > 2019M09   uc 0.2265797
>> > 2019M10   uc 0.2450030
>> > 2019M08   up  0.7175136
>> > 2019M09   up 0.7524731
>> > 2019M10   up 0.7374879
>> >
>> > [[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.
>>
>

[[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Eric Berger
Alternatively, melt() from the reshape2 package.

library(reshape2)
melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name
="direction",value.name="percentage")

HTH,
Eric


On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help <
r-help@r-project.org> wrote:

> You are looking for tidyr::pivot_longer()
>
> Best regards,
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkel...@inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
>
> ///
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ///
>
> 
>
>
> Op ma 17 aug. 2020 om 09:35 schreef John :
>
> > Is there any quick way (dplyr?) to arrange the data
> >  date  down   uc   up
> > 2019M08   0.01709827 0.2653882 0.7175136
> > 2019M09   0.02094724 0.2265797 0.7524731
> > 2019M10   0.01750911 0.2450030 0.7374879
> >
> > to
> >  date  direction  percentage
> > 2019M08   down 0.01709827
> > 2019M09   down 0.02094724
> > 2019M10   down 0.01750911
> > 2019M08   uc 0.2653882
> > 2019M09   uc 0.2265797
> > 2019M10   uc 0.2450030
> > 2019M08   up  0.7175136
> > 2019M09   up 0.7524731
> > 2019M10   up 0.7374879
> >
> > [[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.
>

[[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Thierry Onkelinx via R-help
You are looking for tidyr::pivot_longer()

Best regards,

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkel...@inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///




Op ma 17 aug. 2020 om 09:35 schreef John :

> Is there any quick way (dplyr?) to arrange the data
>  date  down   uc   up
> 2019M08   0.01709827 0.2653882 0.7175136
> 2019M09   0.02094724 0.2265797 0.7524731
> 2019M10   0.01750911 0.2450030 0.7374879
>
> to
>  date  direction  percentage
> 2019M08   down 0.01709827
> 2019M09   down 0.02094724
> 2019M10   down 0.01750911
> 2019M08   uc 0.2653882
> 2019M09   uc 0.2265797
> 2019M10   uc 0.2450030
> 2019M08   up  0.7175136
> 2019M09   up 0.7524731
> 2019M10   up 0.7374879
>
> [[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] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread John
Is there any quick way (dplyr?) to arrange the data
 date  down   uc   up
2019M08   0.01709827 0.2653882 0.7175136
2019M09   0.02094724 0.2265797 0.7524731
2019M10   0.01750911 0.2450030 0.7374879

to
 date  direction  percentage
2019M08   down 0.01709827
2019M09   down 0.02094724
2019M10   down 0.01750911
2019M08   uc 0.2653882
2019M09   uc 0.2265797
2019M10   uc 0.2450030
2019M08   up  0.7175136
2019M09   up 0.7524731
2019M10   up 0.7374879

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