Re: [R] "--" < 0

2024-06-25 Thread peter dalgaard
Also notice that

> "+5" < 0
[1] TRUE

> as.numeric("+5") < 0
[1] FALSE

So the presumption is wrong. It is really about

> sort(c(0:3, "+", "-"))
[1] "-" "+" "0" "1" "2" "3"

-pd

> On 25 Jun 2024, at 10:02 , Martin Maechler  wrote:
> 
>>>>>> Adrian Dusa 
>>>>>>on Tue, 25 Jun 2024 10:56:07 +0300 writes:
> 
>> Dear R fellows,
> 
>>> From time to time, just when I thought I knew my R, I get
>>> bitten by some
>> small things that reminds one to constantly return to the
>> basics.
> 
>> I knew for instance that "-1" < 0 is TRUE, presumably
>> because R first coerces to numeric before comparing with
>> 0.
> 
>> But I did not expect that "--" < 0 is a TRUE statement.
>> (and the same holds for any string prepended by a minus
>> sign, e.g. "-a" < 0)
> 
>> I would be grateful for an explanation, I'm sure that
>> something very obvious escapes me but it sure does seem
>> counter intuitive to me.
> 
>> Best wishes, Adrian
> 
>>  [[alternative HTML version deleted]]
> 
> Nice, quiz, yes.
> 
> You must have forgotten that all Op's (+,-, <= , &, | ..)
> must coerce to common type.
> 
> ... and so does  c()  where coercion is defined a bit more.
> 
> -->  does  c("--", 0)   give you a clue, now ?
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Help trying to understand R documentation on libraries paths

2024-06-17 Thread peter dalgaard
I am not going to search the sources for it (your problem, your work ;-) ), but 
the wording would be consistent with a call like

.libPaths(c(Sys.getenv("R_LIBS"), Sys.getenv("R_LIBS_USER")))

-pd

> On 17 Jun 2024, at 13:40 , Iago Giné Vázquez  wrote:
> 
> Thanks,
> 
> Regarding .libPaths, I am asking for the call to `.libPaths()`, so I 
> understand there is no `new` in the call, as in the documentation I cited.
> 
> Iago
> 
> De: peter dalgaard 
> Enviat el: dilluns, 17 de juny de 2024 13:26
> Per a: Iago Giné Vázquez 
> A/c: r-help@r-project.org 
> Tema: Re: [R] Help trying to understand R documentation on libraries paths
>  
> (Inline)
> 
> > On 17 Jun 2024, at 09:51 , Iago Giné Vázquez  wrote:
> > 
> > Hi,
> > 
> > 1 - On help(".libPaths", help_type = "text") one can read:
> > 
> > First, '.Library.site' is initialized from 'R_LIBS_SITE'.
> > 
> > However, I have
> > 
> >> Sys.getenv("R_LIBS_SITE")
> > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library"
> >> .Library.site
> > character(0)
> > 
> > Is this consistent?
> 
> It is implied that R_LIBS_SITE should point to an existing directory. I see 
> the same thing on Mac:
> 
> > .Library.site
> character(0)
> > Sys.getenv("R_LIBS_SITE")
> [1] "/Library/Frameworks/R.framework/Resources/site-library"
> > list.files(Sys.getenv("R_LIBS_SITE"))
> character(0)
> 
> I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not 
> there, there is no poin in searching it. Unless you actually have a 
> site-library, I don't think there is a problem.
> 
> > 
> > 2 - Next, on the same help document, one can read:
> > 
> > Then, '.libPaths()' is called with the combination
> > of the directories given by 'R_LIBS' and 'R_LIBS_USER'.
> > 
> > 
> > This time, I get
> >> Sys.getenv("R_LIBS")
> > [1] ""
> >> Sys.getenv("R_LIBS_USER")
> > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library"
> >> .libPaths()
> > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" 
> > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library"
> > 
> > 
> > Later is written:
> > 
> > Function '.libPaths' always uses the values of '.Library' and
> > '.Library.site' in the base namespace.
> > 
> > and indeed
> > 
> >> .Library
> > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library"
> > 
> > 
> > Then, shouldn't be this specified above together with "directories given by 
> > 'R_LIBS' and 'R_LIBS_USER'"?
> > 
> 
> The logic of .libPath() is 
> 
> > .libPaths
> function (new, include.site = TRUE) 
> {
> if (!missing(new)) {
> new <- Sys.glob(path.expand(new))
> paths <- c(new, if (include.site) .Library.site, .Library)
> paths <- paths[dir.exists(paths)]
> .lib.loc <<- unique(normalizePath(paths, "/"))
> }
> else .lib.loc
> }
> 
> so if you "call it with" new=something, then (.Library.site, .Library) is 
> automagically appended, unless you expressly tell it not to. 
> 
> -pd
> 
> > 
> > Am I understanding it wrongly? Otherwise, what do you think on the current 
> > way this help page is explained?
> > 
> > Thank you for your help and time.
> > 
> > Best regards,
> > 
> > Iago
> > 
> >[[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.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com

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

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


Re: [R] Help trying to understand R documentation on libraries paths

2024-06-17 Thread peter dalgaard
(Inline)

> On 17 Jun 2024, at 09:51 , Iago Giné Vázquez  wrote:
> 
> Hi,
> 
> 1 - On help(".libPaths", help_type = "text") one can read:
> 
> First, '.Library.site' is initialized from 'R_LIBS_SITE'.
> 
> However, I have
> 
>> Sys.getenv("R_LIBS_SITE")
> [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library"
>> .Library.site
> character(0)
> 
> Is this consistent?

It is implied that R_LIBS_SITE should point to an existing directory. I see the 
same thing on Mac:

> .Library.site
character(0)
> Sys.getenv("R_LIBS_SITE")
[1] "/Library/Frameworks/R.framework/Resources/site-library"
> list.files(Sys.getenv("R_LIBS_SITE"))
character(0)

I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not 
there, there is no poin in searching it. Unless you actually have a 
site-library, I don't think there is a problem.

> 
> 2 - Next, on the same help document, one can read:
> 
> Then, '.libPaths()' is called with the combination
> of the directories given by 'R_LIBS' and 'R_LIBS_USER'.
> 
> 
> This time, I get
>> Sys.getenv("R_LIBS")
> [1] ""
>> Sys.getenv("R_LIBS_USER")
> [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library"
>> .libPaths()
> [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" 
> "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library"
> 
> 
> Later is written:
> 
> Function '.libPaths' always uses the values of '.Library' and
> '.Library.site' in the base namespace.
> 
> and indeed
> 
>> .Library
> [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library"
> 
> 
> Then, shouldn't be this specified above together with "directories given by 
> 'R_LIBS' and 'R_LIBS_USER'"?
> 

The logic of .libPath() is 

> .libPaths
function (new, include.site = TRUE) 
{
if (!missing(new)) {
new <- Sys.glob(path.expand(new))
paths <- c(new, if (include.site) .Library.site, .Library)
paths <- paths[dir.exists(paths)]
.lib.loc <<- unique(normalizePath(paths, "/"))
}
else .lib.loc
}

so if you "call it with" new=something, then (.Library.site, .Library) is 
automagically appended, unless you expressly tell it not to. 

-pd

> 
> Am I understanding it wrongly? Otherwise, what do you think on the current 
> way this help page is explained?
> 
> Thank you for your help and time.
> 
> Best regards,
> 
> Iago
> 
>   [[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.

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

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


Re: [R] Column names of model.matrix's output with contrast.arg

2024-06-14 Thread peter dalgaard
You're at the mercy of the various contr.XXX functions. They may or may not set 
the colnames on the matrices that they generate. 

The rationales for (not) setting them is not perfectly transparent, but you 
obviously cannot use level names on contr.poly, so it uses .L, .Q, etc. 

In MASS, contr.sdif is careful about labeling the columns with the levels that 
are being diff'ed. 

For contr.treatment, there is a straightforward connection to 0/1 dummy 
variables, so level names there are natural.

One could use levels in contr.sum and contr.helmert, but it might confuse users 
that comparisons are with the average of all levels or preceding levels. (It 
can be quite confusing when coding is +1 for male and -1 for female, so that 
the gender difference is twice the coefficient.)

-pd

> On 14 Jun 2024, at 08:12 , Christophe Dutang  wrote:
> 
> Dear list,
> 
> Changing the default contrasts used in glm() makes me aware how 
> model.matrix() set column names.
> 
> With default contrasts, model.matrix() use the level values to name the 
> columns. However with other contrasts, model.matrix() use the level indexes. 
> In the documentation, I don’t see anything in the documentation related to 
> this ? It does not seem natural to have such a behavior?
> 
> Any comment is welcome.
> 
> An example is below.
> 
> Kind regards, Christophe  
> 
> 
> #example from ?glm
> counts <- c(18,17,15,20,10,20,25,13,12)
> outcome <- paste0("O", gl(3,1,9))
> treatment <- paste0("T", gl(3,3))
> 
> X3 <- model.matrix(counts ~ outcome + treatment)
> X4 <- model.matrix(counts ~ outcome + treatment, contrasts = 
> list("outcome"="contr.sum"))
> X5 <- model.matrix(counts ~ outcome + treatment, contrasts = 
> list("outcome"="contr.helmert"))
> 
> #check with original factor
> cbind.data.frame(X3, outcome)
> cbind.data.frame(X4, outcome)
> cbind.data.frame(X5, outcome)
> 
> #same issue with glm
> glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
> glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = 
> list("outcome"="contr.sum"))
> glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = 
> list("outcome"="contr.helmert"))
> 
> coef(glm.D93)
> coef(glm.D94)
> coef(glm.D95)
> 
> #check linear predictor
> cbind(X3 %*% coef(glm.D93), predict(glm.D93))
> cbind(X4 %*% coef(glm.D94), predict(glm.D94))
> 
> -
> Christophe DUTANG
> LJK, Ensimag, Grenoble INP, UGA, France
> ILB research fellow
> Web: http://dutangc.free.fr
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] [Rd] R 4.4.1 is released

2024-06-14 Thread peter dalgaard
The build system rolled up R-4.4.1.tar.gz (codename "Race for Your Life") this 
morning.

===
This release is dedicated to the memory of Friedrich (Fritz) Leisch, 1968-2024.
===

This is a minor update, with a few bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.4.1.tar.gz
https://cran.r-project.org/src/base/R-4/R-4.4.1.tar.xz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course. 
(The Mac binaries will be delayed for a couple of days because the maintainer 
is traveling.)



For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 0ba932825aefae5566dc44822916b266
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = b3c330c22effc753f0b6fdf3a9612ff5
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 3b5b817ed476957d84b35984fd1aaa40
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = f8466e418dec6b958b4ce484a13f9a9d
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = 307e75ba323c08b8694f916e45886aa4
MD5 (R-latest.tar.gz) = cfe520ea9fbca4f3c3d8462aaee7af46
MD5 (R-latest.tar.xz) = 7e8bce91f0ed90931cf9b73d6ac64aeb
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = d52fde03caf726a4339a6079911a80e7
MD5 (R-4/R-4.4.1.tar.gz) = cfe520ea9fbca4f3c3d8462aaee7af46
MD5 (R-4/R-4.4.1.tar.xz) = 7e8bce91f0ed90931cf9b73d6ac64aeb

4cc9dcdfa46a2e2cff45c27df8f3a9f851ec97b44b8647ab8a9fbf844f37937f  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
f7703fe28f81edc79b4201665d69b5b41fda4241e832a03acaf7c2cafdf5f939  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
59232c66854ee8e09f215a71f5a532ab23422a653a90196b5c1af744ce0c6053  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
602f3a40ef759c7b2a6c485a33dc674af34249644ac5fb53b21283d4e12e808d  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
05f3f9fc664b845bb3dcc6492503860df72c63b3f179ab241c095e25bb7628f9  NEWS.3
b4cb675deaaeb7299d3b265d218cde43f192951ce5b89b7bb1a5148a36b2d94d  
R-latest.tar.gz
fbd755314a5cc08c57aabff839ff791fb43a9052a2c6524ec3be96075fd34dde  
R-latest.tar.xz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
74f11ad0053b5a7b2a3a8eccebcd58dfce69d61980b937966687710ab0d77dae  
VERSION-INFO.dcf
b4cb675deaaeb7299d3b265d218cde43f192951ce5b89b7bb1a5148a36b2d94d  
R-4/R-4.4.1.tar.gz
fbd755314a5cc08c57aabff839ff791fb43a9052a2c6524ec3be96075fd34dde  
R-4/R-4.4.1.tar.xz


This is the relevant part of the NEWS file

CHANGES IN R 4.4.1:

  C-LEVEL FACILITIES:

* Functions R_atof and R_strtod declared in header R_ext/Utils.h
  are now documented in 'Writing R Extensions' and so formally part
  of the API.

* The non-API entry points Rf_setSVector, Rf_StringFalse,
  Rf_StringTrue and Rf_isBlankString have been added to those
  reported by R CMD check.

* The new function Rf_allocLang is now available. This provides an
  alternative to the idiom of calling Rf_allocList followed by
  SET_TYPEOF.

  UTILITIES:

* R CMD check now reports as warnings what gfortran calls 'Fortran
  2018 deleted features', all of which have long been marked as
  'obsolescent' and some of which were deleted in Fortran 2008 or
  earlier.  Fortran compilers are no longer required to support
  these.

  BUG FIXES:

* as.numeric(), scan(), type.convert() and other places which use
  the internal C function R_strtod now require a _non-empty_ digit
  sequence in a decimal or binary exponent.  This aligns with the
  C/POSIX standard for strtod and with ?NumericConstants.

* as.data.frame(m, make.names=NA) now works correctly for a matrix
  m with NA's in row names.

* The error message from [["hour"]] and similar now
  mentions *[[, "hour"]], as wished for in PR#17409 and proposed by
  Michael Chirico.

* qbinom() and potentially qpois(), qnbinom(), no longer sometimes
  fail accurate inversion (of pbinom(), etc), thanks to Christopher
  Chang's report and patch in PR#18711.

* The internal help server on Windows can again serve requests sent
  in quick succession, 

Re: [R] R code for overlapping variables -- count

2024-06-03 Thread peter dalgaard
If they are binary (0/1 dummies), can't you just "&" them as in 

table(Female & USA & MidIncome)

(or sum() if you don't care about the number of 0s)

-pd

> On 2 Jun 2024, at 00:31 , Shadee Ashtari  wrote:
> 
> Hi!
> 
> I am trying to find the code for how to get counts for intersectional
> variables. For example, I have three unique categorical variables --
> "Female," "USA," and "MidIncome" -- and I'm trying to see how many people I
> have at the intersection of the three.
> 
> Thank you so much,
> Shadee
> 
>   [[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.

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

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


[R] [Rd] R 4.4.1 scheduled for June 14

2024-05-31 Thread peter dalgaard
Full schedule is available on developer.r-project.org (pending update from SVN).

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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


Re: [R] R, RStudio, and a server for my iPad.

2024-05-21 Thread peter dalgaard
...or look inside the administration interface for your router. Typically 
starts with opening a browser on 192.168.0.1 or 192.168.1.1 (with a password 
that you presumably have from your provider) and going to "Access Control" or 
thereabouts.

-pd

> On 12 Apr 2014, at 20:08 , Viechtbauer Wolfgang (STAT) 
>  wrote:
> 
> You will have to enter the external IP address and then use port forwarding.
> 
> Just google for that term (port forwarding) ... For example:
> 
> http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/
> http://en.wikipedia.org/wiki/Port_forwarding
> 
> Best,
> Wolfgang
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of John Sorkin [jsor...@grecc.umaryland.edu]
> Sent: Saturday, April 12, 2014 7:37 PM
> To: fransiepansiekever...@gmail.com
> Cc: r-help@r-project.org
> Subject: Re: [R] R, RStudio, and a server for my iPad.
> 
> Grand,
> Thank you. I have been able to use my iPad to connect to a server running 
> RStudio server as described in an earlier email and can use the virtual 
> keyboard, which works but is not convenient as one needs to go from keyboard 
> screen to another.
> My current problem is that while I can get everything to work when my iPad is 
> on my local network, I don't know how to access my server from outside my 
> LAN. I know my server's private IP address I know my cable modem's external 
> IP address, but I have no idea what IP address to enter in my iPad, when my 
> iPad is outside my LAN trying to access my server.
> John
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] De-serialization vulnerability?

2024-05-02 Thread peter dalgaard
As a general matter, security holes are usually not advertised by detailing 
them in the NEWS file. 

The disclosure of such things goes on a different schedule, typically _after_ 
binaries are out, at which point editing the NEWS file is too late. 

There are other things that do not go into NEWS: Documentation fixups, etc. 
What does go in is end-user visible functional changes and items that have an 
explicit PR# against them. 

- Peter D. 



> On 1 May 2024, at 18:57 , Howard, Tim G (DEC) via R-help 
>  wrote:
> 
> All, 
> There seems to be a hullaboo about a vulnerability in R when deserializing 
> untrusted data:
> 
> https://hiddenlayer.com/research/r-bitrary-code-execution
> 
> https://nvd.nist.gov/vuln/detail/CVE-2024-27322
> 
> https://www.kb.cert.org/vuls/id/238194
> 
> 
> Apparently a fix was made for R 4.4.0, but I see no mention of it in the 
> changes report:
> 
> https://cloud.r-project.org/bin/windows/base/NEWS.R-4.4.0.html
> 
> Is this real?  Were there changes in R 4.4.0 that aren't reported?
> 
> Of course, we should *always* update to the most recent version, but I was 
> confused why it wasn't mentioned in the release info. 
> 
> Thanks,
> Tim
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] [Rd] R 4.4.0 is released

2024-04-24 Thread Peter Dalgaard via R-announce
The build system rolled up R-4.4.0.tar.gz and R-4.4.0.tar.xz (codename "Puppy 
Cup") this morning.

This is a major update, containing many new features and bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.4.0.tar.gz
https://cran.r-project.org/src/base/R-4/R-4.4.0.tar.xz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 7af154b485d63c810210f8093c300dc6
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 8c980fe8c8bd9fe872fd9cd9774e5c9e
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 1eeb7eec5f4d1c1121a433938b1515a5
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = f8466e418dec6b958b4ce484a13f9a9d
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = 307e75ba323c08b8694f916e45886aa4
MD5 (R-latest.tar.gz) = 400b43da0c2e67e62ec9f90d509a9e10
MD5 (R-latest.tar.xz) = 647ef3e012e9cf36a187db64a6082217
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = 0d8b5abfa71e0a6b6d934ce28dfc81b8
MD5 (R-4/R-4.4.0.tar.gz) = 400b43da0c2e67e62ec9f90d509a9e10
MD5 (R-4/R-4.4.0.tar.xz) = 647ef3e012e9cf36a187db64a6082217


f00177d1ba0a6fdf85a87ef2bb20a39edbc7108dec2852042c2b5a00783b2df5  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
64eecb635b7c2d511d58ace067825dfc5174bf2225b0935d880ca869b037c7e1  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
d17ac7c22d5411b47597fa84cd887e75c6976b38ad0cdfd2fd37e4333a7f19b4  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
602f3a40ef759c7b2a6c485a33dc674af34249644ac5fb53b21283d4e12e808d  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
05f3f9fc664b845bb3dcc6492503860df72c63b3f179ab241c095e25bb7628f9  NEWS.3
ace4125f9b976d2c53bcc5fca30c75e30d4edc401584859cbadb080e72b5f030  
R-latest.tar.gz
5c6c4c2df763fcdd985c5696e909e13c80d75d5f80d42c1adb72fabef4b23d57  
R-latest.tar.xz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
9ec1217b980300e2f422548703811f12cc0cdd40d152050cf78e4ffb63c85f76  
VERSION-INFO.dcf
ace4125f9b976d2c53bcc5fca30c75e30d4edc401584859cbadb080e72b5f030  
R-4/R-4.4.0.tar.gz
5c6c4c2df763fcdd985c5696e909e13c80d75d5f80d42c1adb72fabef4b23d57  
R-4/R-4.4.0.tar.xz

This is the relevant part of the NEWS file

CHANGES IN R 4.4.0:

  SIGNIFICANT USER-VISIBLE CHANGES:

* Startup banners, R --version, sessionInfo() and R CMD check no
  longer report (64-bit) as part of the platform as this is almost
  universal - the increasingly rare 32-bit platforms will still
  report (32-bit).

  On Windows, ditto for window titles.

* is.atomic(NULL) now returns FALSE, as NULL is not an atomic
  vector.  Strict back-compatibility would replace is.atomic(foo)
  by (is.null(foo) || is.atomic(foo)) but should happen only
  sparingly.

  NEW FEATURES:

* The confint() methods for "glm" and "nls" objects have been
  copied to the stats package.  Previously, they were stubs which
  called versions in package MASS. The MASS namespace is no longer
  loaded if you invoke (say) confint(glmfit).  Further, the "glm"
  method for profile() and the plot() and pairs() methods for class
  "profile" have been copied from MASS to stats.  (profile.nls()
  and plot.profile.nls() were already in stats.)

* The confint() and profile methods for "glm" objects have gained a
  possibility to do profiling based on the Rao Score statistic in
  addition to the default Likelihood Ratio. This is controlled by a
  new test = argument.

* The pairs() method for "profile" objects has been extended with a
  which = argument to allow plotting only a subset of the
  parameters.

* The "glm" method for anova() computes test statistics and
  p-values by default, using a chi-squared test or an F test
  depending on whether the dispersion is fixed or free.  Test
  statistics can be suppressed by giving argument test a false
  logical value.

* In setRepositories() the repositories can be set using their
  names via name = instead of index ind =.

* methods() and .S3methods() gain a all.names option for the (rare)
  

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Peter Dalgaard via R-help
Doesn't sound like you got the point. x[-1] normally removes the first element. 
With 0-based indices, this cannot work.

- pd 

> On 22 Apr 2024, at 17:31 , Ebert,Timothy Aaron  wrote:
> 
> You could have negative indices. There are two ways to do this.
> 1) provide a large offset.
> Offset <- 30
> for (i in -29 to 120) { print(df[i+Offset])}
> 
> 
> 2) use absolute values if all indices are negative.
> for (i in -200 to -1) {print(df[abs(i)])}
> 
> Tim
> 
> 
> 
> -Original Message-
> From: R-help  On Behalf Of Peter Dalgaard via 
> R-help
> Sent: Monday, April 22, 2024 10:36 AM
> To: Rolf Turner 
> Cc: R help project ; Hans W 
> Subject: Re: [R] x[0]: Can '0' be made an allowed index in R?
> 
> [External Email]
> 
> Heh. Did anyone bring up negative indices yet?
> 
> -pd
> 
>> On 22 Apr 2024, at 10:46 , Rolf Turner  wrote:
>> 
>> 
>> See fortunes::fortune(36).
>> 
>> cheers,
>> 
>> Rolf Turner
>> 
>> --
>> Honorary Research Fellow
>> Department of Statistics
>> University of Auckland
>> Stats. Dep't. (secretaries) phone:
>>+64-9-373-7599 ext. 89622
>> Home phone: +64-9-480-4619
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat/
>> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C02%7Ctebert%40ufl.edu
>> %7C79ca6aadcaee4aa3241308dc62d986f6%7C0d4da0f84a314d76ace60a62331e1b84
>> %7C0%7C0%7C638493933686698527%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
>> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
>> wmv9OYcMES0nElT9OAKTdjBk%2BB55bQ7BjxOuaVVkPg4%3D=0
>> PLEASE do read the posting guide
>> http://www.r/
>> -project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7C79
>> ca6aadcaee4aa3241308dc62d986f6%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
>> 7C0%7C638493933686711061%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
>> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=AP78X
>> nfKrX6B0YVM0N76ty9v%2Fw%2BchHIytw33X7M9umE%3D=0
>> and provide commented, minimal, self-contained, reproducible code.
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
> Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.r-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Peter Dalgaard via R-help
Heh. Did anyone bring up negative indices yet?

-pd

> On 22 Apr 2024, at 10:46 , Rolf Turner  wrote:
> 
> 
> See fortunes::fortune(36).
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Stats. Dep't. (secretaries) phone:
> +64-9-373-7599 ext. 89622
> Home phone: +64-9-480-4619
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] missing() fails to detect missing

2024-04-18 Thread Peter Dalgaard via R-help
I'm not really sure how verboten it is to have methods that omit "...". The 
code seems to be instrumented to handle that case. 

The catch is that it does so by inserting a call to .local where .local is the 
method function, e.g. if you insert a browser() call at the start of the 
method, you'll see

> foo("a")
Called from: .local(x, y, ...)
Browse[1]> sys.status()
$sys.calls
$sys.calls[[1]]
foo("a")

$sys.calls[[2]]
foo("a")

$sys.calls[[3]]
.local(x, y, ...)

$sys.calls[[4]]
browser()

and the 3rd call is absent for foo(0). But y is not missing in the .local call, 
because, hey, it has a default in the parent. 

This also happens in plain function calls, e.g.

> f <- function(a=0)(function(a)missing(a))(a)
> f()
[1] FALSE

Also notice that it is not really "..." that is the trigger of this effect, but 
the fact that the method has different arguments from the generic in any way: 
You get the same situation with

> setMethod("foo", signature="numeric", function(x, y=0, z=1, ...){
+ if (missing(y))
+return("must give y for numeric")
+  y
+ })
> foo(0)
[1] 0

 -pd 



> On 18 Apr 2024, at 06:32 , Jeff Newmiller via R-help  
> wrote:
> 
> Fascinating. Or, well, not.
> 
> Failing to use a method signature that is compatible with the generic is a 
> no-no. So your bug seems to me to be outside the bounds of how R is supposed 
> to be used. So don't do that.
> 
> On April 17, 2024 4:25:38 PM PDT, "Boylan, Ross via R-help" 
>  wrote:
>> When a generic (S4) has an argument with a default followed by ..., 
>> missing() doesn't seem to work if the method omits the ...
>> Sample---
>> foo <- function(x, y=0, ...){
>> "you are very generic"
>> }
>> 
>> # no ... in function arguments
>> setMethod("foo", signature="character", function(x, y=0){
>> if (missing(y))
>>   return("must give y for character")
>> y
>> })
>> 
>> setMethod("foo", signature="numeric", function(x, y=0, ...){
>> if (missing(y))
>>   return("must give y for numeric")
>> y
>> })
>> 
>> print(foo("a"))  #[1] 0
>> print(foo(0))#[1] "must give y for numeric"
>> --
>> It's the result for foo("a") I'm puzzled by, since missing(y) does not 
>> evaluate to TRUE.
>> 
>> Background
>> ==
>> The methods documentation has 2 points on which the above definitions may 
>> fail.
>> 
>> 1. The generic has regular arguments and ... arguments.  But dotsMethods 
>> docs say
>>> either the signature of the generic function is "..." only, or it
>>> does not contain "..."
>> Since the arguments in ... are not part of the signatures I think I'm OK, 
>> but another reading is that
>> one just shouldn't mix ... and other arguments.
>> 
>> 2. setMethod docs say
>>> The definition must be a function with the same formal arguments as the 
>>> generic; however, setMethod() will handle methods that add arguments, if 
>>> ... is a formal argument to the generic.
>> Since the initial definition has arguments x, y, ... and the first method 
>> definition has only x, y, the arguments don't match.  So maybe that's the 
>> problem.
>> 
>> I don't know if the fact that y has a default value matters.
>> 
>> The real code has a function f that ordinarily requires an additional piece 
>> of information, y, to compute a result.  But for one class, the result 
>> doesn't depend on y and so that argument may be omitted.
>> 
>> Context
>> ==
>> R 4.3.3 on MS-Windows under RStudio 2023.12.1 build 402.
>> 
>> Thanks for any insights.
>> Ross
>> 
>> ______
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Question regarding reservoir volume and water level

2024-04-09 Thread peter dalgaard
tion regarding reservoir volume and water level
>> 
>> Aside from the fact that the original question might well be a class
>> exercise (or homework), the question is unanswerable given the data given
>> by
>> the original poster. One needs to know the dimensions of the reservoir,
>> above and below the current waterline. Are the sides, above and below the
>> waterline smooth? Is the region currently above the waterline that can
>> store
>> water a mirror image of the region below the waterline? Is the region above
>> the reservoir include a flood plane? Will the additional water go into the
>> flood plane?
>> 
>> The lack of required detail in the question posed by the original poster
>> suggests that there are strong assumptions, assumptions that typically
>> would
>> be made in a class-room example or exercise.
>> 
>> John
>> 
>> John David Sorkin M.D., Ph.D.
>> Professor of Medicine, University of Maryland School of Medicine;
>> Associate Director for Biostatistics and Informatics, Baltimore VA Medical
>> Center Geriatrics Research, Education, and Clinical Center;
>> PI Biostatistics and Informatics Core, University of Maryland School of
>> Medicine Claude D. Pepper Older Americans Independence Center;
>> Senior Statistician University of Maryland Center for Vascular Research;
>> 
>> Division of Gerontology and Paliative Care,
>> 10 North Greene Street
>> GRECC (BT/18/GR)
>> Baltimore, MD 21201-1524
>> Cell phone 443-418-5382
>> 
>> 
>> 
>> 
>> 
>> From: R-help  on behalf of Rui Barradas
>> 
>> Sent: Sunday, April 7, 2024 10:53 AM
>> To: javad bayat; R-help
>> Subject: Re: [R] Question regarding reservoir volume and water level
>> 
>> Às 13:27 de 07/04/2024, javad bayat escreveu:
>>> Dear all;
>>> I have a question about the water level of a reservoir, when the volume
>>> changed or doubled.
>>> There is a DEM file with the highest elevation 1267 m. The lowest
>> elevation
>>> is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m.
>>> Now I want to know what would be the water level if the volume rises to
>>> 1250 m? or what would be the water level if the volume doubled
>> (14,000,000
>>> m3)?
>>> 
>>> Is there any way to write codes to do this in R?
>>> I would be more than happy if anyone could help me.
>>> Sincerely
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> Hello,
>> 
>> This is a simple rule of three.
>> If you know the level l the argument doesn't need to be named but if you
>> know the volume v then it must be named.
>> 
>> 
>> water_level <- function(l, v, level = 1240, volume = 7e6) {
>>   if(missing(v)) {
>> volume * l / level
>>   } else level * v / volume
>> }
>> 
>> lev <- 1250
>> vol <- 14e6
>> 
>> water_level(l = lev)
>> #> [1] 7056452
>> water_level(v = vol)
>> #> [1] 2480
>> 
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> 
>> --
>> Este e-mail foi analisado pelo software antivírus AVG para verificar a
>> presença de vírus.
>> http://www.avg.com/
>> 
>> ______
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.r-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> __
>> R-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.
>> 
>> 
> 
> -- 
> Best Regards
> Javad Bayat
> M.Sc. Environment Engineering
> Alternative Mail: bayat...@yahoo.com
> 
>   [[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.

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

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


Re: [R] CEoptim problems

2024-04-09 Thread peter dalgaard
Hi, Adelchi,

Depends on what you want help with... 

The proximate cause would seem to be that the code ought to have "is.null(A) || 
any(is.NA(A))", which I presume you could fairly easily fix for yourself in the 
package sources or even locally in an R session. Vector-valued logicals in flow 
control constructions have gone through an elborate deprecation process before 
getting turned into errors.

If the problem is how to activate a dormant maintainer and fix the issue for 
everyone, I don't really have a clue,  but you might consider cantacting the 
CRAN team.

Best,
Peter D.

> On 9 Apr 2024, at 12:04 , Adelchi Azzalini  wrote:
> 
> In the attempt to explore the usage of package CEoptim, I have run the code 
> listed at the end of this message. This code is nothing but the one 
> associated to example 5.7 in the main reference of the package, available at 
> https://www.jstatsoft.org/article/view/v076i08
> and is included in the associated file  v76i08.R
> 
> Unfortunately, the call to CEoptim stops with error message 
> 
> Error in is.null(A) || is.na(A) : 
>  'length = 18' in coercion to 'logical(1)’
> 
> On 2024–04-03, I have written about this problem to 
> Maintainer: Benoit Liquet 
> but so far no reply has reached me. 
> 
> Could anyone help?
> 
> Best regards,
> 
> Adelchi Azzalini
> http://azzalini.stat.unipd.it
> 
> 
> 
> library(CEoptim)
> ## 5.7 AR(1) Model with Regime Switching
> set.seed(123)
> 
> sumsqrs <- function(theta, rm1, x) {
>  N <- length(x)  #without x[0]
>  r <- 1 + sort(rm1)  # internal end points of regimes
>  if (r[1] == r[2]) {
># test for dupes -> invalid regime
>return(Inf)
>  }
> thetas <- rep(theta, times = c(r, N) - c(1, r + 1) + 1)
>  xhat <- c(0, head(x, -1)) * thetas
>  ## Compute sum of squared errors
>  sum((x - xhat)^2)
> }
> 
> ## Read the data from CEoptim package
> data("yt", package = "CEoptim")
> xt <- yt - c(0, yt[-300])
> A <- rbind(diag(3), -diag(3))
> b <- rep(1, 6)
> 
> res <- CEoptim(sumsqrs, f.arg = list(xt), continuous = list(mean = c(0, 0, 
> 0), sd = rep(1,3), conMat = A, conVec = b), discrete = list(categories = 
> c(298L, 298L), smoothProb = 0.5),N = 1, rho = 0.001)
> 
> Error in is.null(A) || is.na(A) : 
>  'length = 18' in coercion to 'logical(1)'
> 
> R> sessionInfo()
> R version 4.3.3 (2024-02-29)
> Platform: aarch64-apple-darwin20 (64-bit)
> Running under: macOS Ventura 13.0
> 
> Matrix products: default
> BLAS:   
> /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
>  
> LAPACK: 
> /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;
>   LAPACK version 3.11.0
> 
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> 
> time zone: Europe/Rome
> tzcode source: internal
> 
> attached base packages:
> [1] stats utils datasets  grDevices graphics  methods   base 
> 
> other attached packages:
> [1] CEoptim_1.3  sna_2.7-2network_1.18.2   
> statnet.common_4.9.0
> [5] msm_1.7.1MASS_7.3-60.0.1 
> 
> loaded via a namespace (and not attached):
> [1] vctrs_0.6.2cli_3.6.1  rlang_1.1.1generics_0.1.3   
>  
> [5] jsonlite_1.8.4 glue_1.6.2 colorspace_2.1-0   scales_1.2.1 
>  
> [9] fansi_1.0.4dlstats_0.1.7  grid_4.3.3 expm_0.999-9 
>  
> [13] munsell_0.5.0  tibble_3.2.1   mvtnorm_1.1-3  lifecycle_1.0.3 
>   
> [17] compiler_4.3.3 dplyr_1.1.2coda_0.19-4.1  
> RColorBrewer_1.1-3
> [21] pkgconfig_2.0.3lattice_0.22-5 R6_2.5.1   
> tidyselect_1.2.0  
> [25] utf8_1.2.3 splines_4.3.3  pillar_1.9.0   magrittr_2.0.3  
>   
> [29] Matrix_1.6-5   tools_4.3.3gtable_0.3.3   survival_3.5-8  
>   
> [33] ggplot2_3.4.2 
> R> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Building Packages.

2024-03-21 Thread peter dalgaard
Um, what's with the triple colon? At least on my install, double seems to 
suffice:

> identical(utils:::install.packages, utils::install.packages)
[1] TRUE
> install.packages
function (...) 
.rs.callAs(name, hook, original, ...)


-pd

> On 21 Mar 2024, at 09:58 , Duncan Murdoch  wrote:
> 
> The good news for Jorgen (who may not be reading this thread any more) is 
> that one can still be sure of getting the original install.packages() by using
> 
>utils:::install.packages( ... )
> 
> with *three* colons, to get the internal (namespace) version of the function.
> 
> Duncan Murdoch
> 
> 
> On 21/03/2024 4:31 a.m., Martin Maechler wrote:
>>>>>>> "Duncan Murdoch on Wed, 20 Mar 2024 13:20:12 -0400 writes:
>> > On 20/03/2024 1:07 p.m., Duncan Murdoch wrote:
>> >> On 20/03/2024 12:37 p.m., Ben Bolker wrote:
>> >>> Ivan, can you give more detail on this? I've heard this
>> >>> issue mentioned, but when I open RStudio and run
>> >>> find("install.packages") it returns
>> >>> "utils::install.packages", and running dump() from
>> >>> within RStudio console and from an external "R
>> >>> --vanilla" gives identical results.
>> >>>
>> >>> I thought at one point this might only refer to the GUI
>> >>> package-installation interface, but you seem to be
>> >>> saying it's the install.packages() function as well.
>> >>>
>> >>> Running an up-to-date RStudio on Linux, FWIW -- maybe
>> >>> weirdness only happens on other OSs?
>> >>
>> >> On MacOS, I see this:
>> >>
>> >> > install.packages function (...)  .rs.callAs(name, hook,
>> >> original, ...)  
>> >>
>> >> I get the same results as you from find().  I'm not sure
>> >> what RStudio is doing to give a different value for the
>> >> function than what find() sees.
>> > Turns out that RStudio replaces the install.packages
>> > object in the utils package.
>> > Duncan Murdoch
>> Yes, and this has been the case for several years now, and I
>> have mentioned this several times, too  (though some of it
>> possibly not in a public R-* mailing list).
>> And yes, that they modify the package environment
>>   as.environment("package:utils")
>> but leave the
>>   namespace  asNamespace("utils")
>> unchanged, makes it harder to see what's
>> going on (but also has less severe consequences; if they kept to
>> the otherwise universal *rule* that the namespace and package must have the 
>> same objects
>> apart from those only in the namespace,
>> people would not even have access to R's true install.packages()
>> but only see the RStudio fake^Hsubstitute..
>> We are still not happy with their decision. Also
>> help(install.packages) goes to R's documentation of R's
>> install.packages, so there's even more misleading of useRs.
>> Martin
>> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] [Rd] R 4.4.0 scheduled for April 24

2024-03-19 Thread Peter Dalgaard via R-announce
Full schedule is available on developer.r-project.org (pending update from SVN).

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Problem when trying to install packages

2024-03-18 Thread peter dalgaard
stalling *source* package 'cluster' ...
>>> ** package 'cluster' successfully unpacked and MD5 sums checked
>>> ** using staged installation
>>> ** libs
>>> Warning in system(cmd) : 'make' not found
>>> ERROR: compilation failed for package 'cluster'
>>> * removing 'C:/R_Libs/cluster'
>>> Warning in install.packages :
>>>   installation of package ‘cluster’ had non-zero exit status
>>> ERROR: dependency 'lattice' is not available for package 'hexbin'
>>> * removing 'C:/R_Libs/hexbin'
>>> Warning in install.packages :
>>>   installation of package ‘hexbin’ had non-zero exit status
>>> * installing *source* package 'lifecycle' ...
>>> ** package 'lifecycle' successfully unpacked and MD5 sums checked
>>> ** using staged installation
>>> ** R
>>> ** inst
>>> ** byte-compile and prepare package for lazy loading
>>> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck =
>> vI[[i]]) :
>>>   namespace 'rlang' 0.3.4 is being loaded, but >= 1.1.0 is required
>>> Calls:  ... withCallingHandlers -> loadNamespace ->
>>> namespaceImport -> loadNamespace
>>> Execution halted
>>> ERROR: lazy loading failed for package 'lifecycle'
>>> * removing 'C:/R_Libs/lifecycle'
>>> Warning in install.packages :
>>>   installation of package ‘lifecycle’ had non-zero exit status
>>> ERROR: dependencies 'deldir', 'RcppEigen' are not available for package
>> 'interp'
>>> * removing 'C:/R_Libs/interp'
>>> Warning in install.packages :
>>>   installation of package ‘interp’ had non-zero exit status
>>> ERROR: dependency 'timechange' is not available for package 'lubridate'
>>> * removing 'C:/R_Libs/lubridate'
>>> Warning in install.packages :
>>>   installation of package ‘lubridate’ had non-zero exit status
>>> ERROR: dependency 'maps' is not available for package 'mapproj'
>>> * removing 'C:/R_Libs/mapproj'
>>> Warning in install.packages :
>>>   installation of package ‘mapproj’ had non-zero exit status
>>> ERROR: dependencies 'nlme', 'Matrix' are not available for package 'mgcv'
>>> * removing 'C:/R_Libs/mgcv'
>>> Warning in install.packages :
>>>   installation of package ‘mgcv’ had non-zero exit status
>>> ERROR: dependency 'lifecycle' is not available for package 'vctrs'
>>> * removing 'C:/R_Libs/vctrs'
>>> Warning in install.packages :
>>>   installation of package ‘vctrs’ had non-zero exit status
>>> ERROR: dependencies 'lattice', 'png', 'jpeg', 'interp', 'MASS' are not
>>> available for package 'latticeExtra'
>>> * removing 'C:/R_Libs/latticeExtra'
>>> Warning in install.packages :
>>>   installation of package ‘latticeExtra’ had non-zero exit status
>>> ERROR: dependencies 'lifecycle', 'vctrs' are not available for package
>> 'pillar'
>>> * removing 'C:/R_Libs/pillar'
>>> Warning in install.packages :
>>>   installation of package ‘pillar’ had non-zero exit status
>>> ERROR: dependencies 'lifecycle', 'vctrs' are not available for package
>>> 'tidyselect'
>>> * removing 'C:/R_Libs/tidyselect'
>>> Warning in install.packages :
>>>   installation of package ‘tidyselect’ had non-zero exit status
>>> ERROR: dependencies 'lifecycle', 'vctrs' are not available for package
>> 'purrr'
>>> * removing 'C:/R_Libs/purrr'
>>> Warning in install.packages :
>>>   installation of package ‘purrr’ had non-zero exit status
>>> ERROR: dependencies 'lifecycle', 'pillar', 'vctrs' are not available
>>> for package 'tibble'
>>> * removing 'C:/R_Libs/tibble'
>>> Warning in install.packages :
>>>   installation of package ‘tibble’ had non-zero exit status
>>> ERROR: dependencies 'lifecycle', 'pillar', 'vctrs' are not available
>>> for package 'dplyr'
>>> * removing 'C:/R_Libs/dplyr'
>>> Warning in install.packages :
>>>   installation of package ‘dplyr’ had non-zero exit status
>>> ERROR: dependencies 'cluster', 'hexbin', 'lattice', 'latticeExtra',
>>> 'lubridate', 'mapproj', 'MASS', 'mgcv' are not available for package
>>> 'openair'
>>> * removing 'C:/R_Libs/openair'
>>> Warning in install.packages :
>>>   installation of package ‘openair’ had non-zero exit status
>>> 
>>> 
>>> 
>> Hello,
>> 
>> If you are on Windows, do you have rtools [1] installed?
>> Also, please address your question to R-Help [2], [3], not to me directly.
>> 
>> 
>> [1] https://cran.r-project.org/bin/windows/Rtools/
>> [2] r-help@r-project.org
>> [3] https://stat.ethz.ch/mailman/listinfo/r-help
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> 
>> --
>> Este e-mail foi analisado pelo software antivírus AVG para verificar a
>> presença de vírus.
>> www.avg.com
>> 
> 
> 
> -- 
> Best Regards
> Javad Bayat
> M.Sc. Environment Engineering
> Alternative Mail: bayat...@yahoo.com
> 
>   [[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.

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

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


[R] R 4.3.3 is released

2024-02-29 Thread Peter Dalgaard via R-announce
The build system rolled up R-4.3.3.tar.gz and .xz (codename "Angel Food Cake") 
this morning.

This is a minor update, intended as the wrap-up release for the 4.3.x series. 

This also marks the 6th anniversary of R-1.0.0. (2000-02-29)

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.3.3.tar.gz
https://cran.r-project.org/src/base/R-4/R-4.3.3.tar.xz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 97a3ddc25aab502a70bfb1a79ab6f862
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 0aa4babeb5349c3abc6fb02700e8cf53
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = 4108ab429e768e29b1c3b418c224246e
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = 4de100b35e3614c19df5e95e483cc3c3
MD5 (R-latest.tar.xz) = 5602f5996107c346dba12a16e866d2e2
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = becc8fce6e97db1703f9ca6d80e36c9d
MD5 (R-4/R-4.3.3.tar.gz) = 4de100b35e3614c19df5e95e483cc3c3
MD5 (R-4/R-4.3.3.tar.xz) = 5602f5996107c346dba12a16e866d2e2

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
3a47bca1e2a7db27c0ca12be388c238e2608ff2f768e627650a71a0ffc826038  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
f28b88bf20aa2a0078214b89353985680c53092d55f83e59b8295e61ad1150e0  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
5de7657c5e58e481403c0dd1a74a5c090b3ef481ce75a91dfe05d4b03f63163f  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
80851231393b85bf3877ee9e39b282e750ed864c5ec60cbd68e6e139f0520330  
R-latest.tar.gz
9b4c5f4cabab23f38e72fee36d98772c640a97305d06ce6e1a6a73e82b850954  
R-latest.tar.xz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
b8c2534c643ffcd942e8df370a4970c913be5dfc24e687bb12d609e974308aef  
VERSION-INFO.dcf
80851231393b85bf3877ee9e39b282e750ed864c5ec60cbd68e6e139f0520330  
R-4/R-4.3.3.tar.gz
9b4c5f4cabab23f38e72fee36d98772c640a97305d06ce6e1a6a73e82b850954  
R-4/R-4.3.3.tar.xz

This is the relevant part of the NEWS file

CHANGES IN R 4.3.3:

  NEW FEATURES:

* iconv() now fixes up variant encoding names such as "utf8"
  case-insensitively.

  DEPRECATED AND DEFUNCT:

* The legacy encoding = "MacRoman" is deprecated in pdf() and
  postscript(): support was incomplete in earlier versions of R.

  BUG FIXES:

* Arguments are now properly forwarded to methods on S4 generics
  with ... in the middle of their formal arguments. This was broken
  for the case when a method introduced an argument but did not
  include ... in its own formals. Thanks to Herv'e Pag`es for the
  report PR#18538.

* Some invalid file arguments to pictex(), postscript() and xfig()
  opened a file called NA rather than throw an error.  These
  included postscript(NULL) (which some people expected to work
  like pdf(NULL)).

* Passing filename = NA to svg(), cairo_pdf(), cairo_ps() or the
  Cairo-based bitmap devices opened a file called NA: it now throws
  an error.

* quartz(file = NA) opened a file called NA, including when used as
  a Quartz-based bitmap device.  It now gives an error.

* rank() now works, fixing PR#18617, thanks to Ilia
  Kats.

* seq.int() did not adequately check its length.out argument.

* match(, .) is correct again for differing time zones,
  ditto for "POSIXlt", fixing PR#18618 reported by Bastian Klein.

* drop.terms(*, dropx = <0-length>) now works, fixing PR#18563 as
  proposed by Mikael Jagan.

* drop.terms(*) keeps + offset(.) terms when it should, PR#18565,
  and drop.terms() no longer makes up a response, PR#18566, fixing
  both bugs thanks to Mikael Jagan.

* getS3method("t", "test") no longer finds the t.test() function,
  fixing PR#18627.

* pdf() and postscript() support for the documented Adobe encodings
   

Re: [R] converting MATLAB -> R | element-wise operation

2024-02-28 Thread peter dalgaard
Agree that sweep is the tool here.  (If you think it is clunky, check how more 
general array-sweep operations can be done in Matlab.)

However, it isn't really true that sweep isn't  moving things around. Notice 
the call to aperm() at the end of the code for sweep(): 

perm <- c(MARGIN, seq_along(dims)[-MARGIN])
FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...)

What this essentially does for "our" case is

> rbind(1:3,4:6)/t(matrix(c(2,3,4), 3,2))
 [,1]  [,2] [,3]
[1,]  0.5 0.667 0.75
[2,]  2.0 1.667 1.50

I.e. take the matrix, create the divisor by replicating STATS to form a matrix 
of same size. This is easier if the MARGIN indices come first, because the 
recycling works. So you get the 2x3 matrix by filling a 3x2 and then 
transposing it (aperm() does this more generally). Finally, just call FUN on 
the two arrays.

-pd



> On 27 Feb 2024, at 22:51 , Jeff Newmiller via R-help  
> wrote:
> 
> Why anything but sweep?
> 
> The fundamental data type in Matlab is a matrix... they don't have vectors, 
> they have Nx1 matrices and 1xM matrices.
> 
> Vectors don't have any concept of "row" vs. "column". Straight division is 
> always elementwise with recycling as needed, and matrices are really vectors 
> in row-major order:
> 
> 1 2 3
> 4 5 6
> 
> is really
> 
> 1 4 2 5 3 6
> 
> and when you do straight division NN / lambda then lambda is repeated:
> 
> 1 4 2 5 3 6
> 2 3 4 2 3 4
> 
> to get
> 
> 0.5 1.3 0.5 2.5 1.0 1.5
> 
> but if you transpose first
> 
> 1 4
> 2 5
> 3 6
> 
> then that corresponds to an underlying vector:
> 
> 1 2 3 4 5 6
> 
> which lines up with lambda in t(NN)/lambda as:
> 
> 1 2 3 4 5 6
> 2 3 4 2 3 4
> 
> to obtain:
> 
> 0.50 0.67 0.75 2.0 1.67 1.50
> 
> and inherits the dimensions of t(NN):
> 
> 0.50 2.00
> 0.67 1.67
> 0.75 1.50
> 
> which can be transposed back as in t( t( NN ) / lambda ):
> 
> 0.50 0.67 0.75
> 2.00 1.67 1.50
> 
> but that requires a lot of moving elements around while sweep does not.
> 
> Operators are not necessarily "better" than named functions... they just look 
> different.
> 
> 
> On February 27, 2024 11:54:26 AM PST, Evan Cooch  wrote:
>> So, trying to convert a very long, somewhat technical bit of lin alg 
>> MATLAB code to R. Most of it working, but raninto a stumbling block that 
>> is probaably simple enough for someone to explain.
>> 
>> Basically, trying to 'line up' MATLAB results from an element-wise 
>> division of a matrix by a vector with R output.
>> 
>> Here is a simplified version of the MATLAB code I'm translating:
>> 
>> NN = [1, 2, 3; 4, 5, 6];  % Example matrix
>> lambda = [2, 3, 4];  % Example vector
>> result_matlab = NN ./ lambda;
>> 
>> which yields
>> 
>>  0.5   0.7   0.75000
>>  2.0   1.7   1.5
>> 
>> 
>> So, the only way I have stumbled onto in R to generate the same results 
>> is to use 'sweep'. The following 'works', but I'm hoping someone can 
>> explain why I need something as convoluted as this seems (to me, at least).
>> 
>> NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)  # Example matrix
>> lambda <- c(2, 3, 4)  # Example vector
>> sweep(NN, 2, lambda, "/")
>> 
>> 
>>  [,1]  [,2] [,3]
>> [1,]  0.5 0.667 0.75
>> [2,]  2.0 1.667 1.50
>> 
>> First tried the more 'obvious' NN/lambda, but that yields 'the wrong 
>> answer' (based solely on what I'm trying to accomplish):
>> 
>> 
>>[,1] [,2] [,3]
>> [1,] 0.50  0.5  1.0
>> [2,] 1.33  2.5  1.5
>> 
>> So, why 'sweep'?
>> 
>>  [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> -- 
> Sent from my phone. Please excuse my brevity.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Packages sometimes don't update, but no error or warning is thrown

2024-02-19 Thread peter dalgaard
> prompt, if I want to compile from source.
>> 
>>> RStudio is doing its own thing for some task, including
>>> 'install.packages()' (and for some reasons, at least on
>>> the platforms on which I use RStudio, RStudio calls
>>> 'install.packages()' and not 'update.packages()' when an
>>> update is requested via the GUI). See:
>> 
>> RStudio> install.packages
>>> function (...) .rs.callAs(name, hook, original, ...)
>>> 
>> 
>>> compared to:
>> 
>> R> install.packages
>>> function (pkgs, lib, repos = getOption("repos"),
>>> contriburl = contrib.url(repos, type), method, available =
>>> NULL, destdir = NULL, dependencies = NA, type =
>>> getOption("pkgType"), configure.args =
>>> getOption("configure.args"), configure.vars =
>>> getOption("configure.vars"), clean = FALSE, Ncpus =
>>> getOption("Ncpus", 1L), verbose = getOption("verbose"),
>>> libs_only = FALSE, INSTALL_opts, quiet = FALSE,
>>> keep_outputs = FALSE, ...) { [...]
>> 
>> 
>>> So if you use Install/Update in the Packages tab of
>>> RStudio and do not experience the behaviour you are
>>> expecting, it is something that you need to discuss with
>>> Posit, not with R. :)
>> 
>>>> However, the only message I get is: ``` trying URL
>>>> ''
>> 
>>> The package name has the version number encoded in it, so
>>> theoretical you should be able to tell at this point
>>> whether the package that is downloaded is the version that
>>> is already installed, hence no update will happen.
>> 
>>> Best wishes,
>> 
>>> Berwin
>> 
>> 
>> Yes, thank's a lot, Berwin.
>> 
>> Indeed I've raised the fact that RStudio
>> hides R's own install.packages() from the user and uses its
>> own, undocumented one ... this has been the case for quite a few years.
>> I found out during teaching --- one of the few times, I use
>> RStudio to use R... in another case where RStudio's
>> install.packages() behaved differently than R's.
>> 
>> I'm pretty sure this is reason for quite a bit of confusion...
> 
> Did they ignore your bug report?
> 
> Duncan Murdoch
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help[https://stat.ethz.ch/mailman/listinfo/r-help][https://stat.ethz.ch/mailman/listinfo/r-help[https://stat.ethz.ch/mailman/listinfo/r-help]]
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html[http://www.R-project.org/posting-guide.html][http://www.R-project.org/posting-guide.html[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.

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

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


Re: [R] Looping

2024-02-18 Thread Peter Langfelder
Try

for (ind in 1:24)
{
   data = read.csv(paste0("data", ind, ".csv"))
   ...
}


Peter

On Mon, Feb 19, 2024 at 11:33 AM Steven Yen  wrote:
>
> I need to read csv files repeatedly, named data1.csv, data2.csv,… data24.csv, 
> 24 altogether. That is,
>
> data<-read.csv(“data1.csv”)
> …
> data<-read.csv(“data24.csv”)
> …
>
> Is there a way to do this in a loop? Thank you.
>
> Steven from iPhone
> [[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.


[R] [Rd] R 4.3.3 scheduled for February 29

2024-02-16 Thread Peter Dalgaard via R-help
Full schedule available on developer.r-project.org in a short while.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Packages sometimes don't update, but no error or warning is thrown

2024-02-14 Thread peter dalgaard
What Martin says...

Also, it might help to know that the original, base-R functions are still 
there, as

utils::install.packages()
utils::update.packages()

(+ most likely, a restart of RStudio to make it adapt to the packages that you 
installed behind its back.)

- Peter D.

> On 14 Feb 2024, at 11:50 , Martin Maechler  wrote:
> 
>>>>>> Berwin A Turlach 
>>>>>>on Wed, 14 Feb 2024 11:47:41 +0800 writes:
>>>>>> Berwin A Turlach 
>>>>>>on Wed, 14 Feb 2024 11:47:41 +0800 writes:
> 
>> G'day Philipp,
> 
>> On Tue, 13 Feb 2024 09:59:17 +0100 gernophil--- via R-help
>>  wrote:
> 
>>> this question is related to this
>>> (https://community.rstudio.com/t/packages-are-not-updating/166214/3),
>>> [...]
> 
>>> To sum it up: If I am updating packages (be it via
>>> Bioconductor or CRAN) some packages simply don’t update,
>>> [...]
> 
>>> I would expect any kind of message that the package will
>>> not be updated, since no newer binary is available or a
>>> prompt, if I want to compile from source.
> 
>> RStudio is doing its own thing for some task, including
>> 'install.packages()' (and for some reasons, at least on
>> the platforms on which I use RStudio, RStudio calls
>> 'install.packages()' and not 'update.packages()' when an
>> update is requested via the GUI). See:
> 
>RStudio> install.packages
>> function (...)  .rs.callAs(name, hook, original, ...)
>> 
> 
>> compared to:
> 
>R> install.packages
>> function (pkgs, lib, repos = getOption("repos"),
>> contriburl = contrib.url(repos, type), method, available =
>> NULL, destdir = NULL, dependencies = NA, type =
>> getOption("pkgType"), configure.args =
>> getOption("configure.args"), configure.vars =
>> getOption("configure.vars"), clean = FALSE, Ncpus =
>> getOption("Ncpus", 1L), verbose = getOption("verbose"),
>> libs_only = FALSE, INSTALL_opts, quiet = FALSE,
>> keep_outputs = FALSE, ...)  { [...]
> 
> 
>> So if you use Install/Update in the Packages tab of
>> RStudio and do not experience the behaviour you are
>> expecting, it is something that you need to discuss with
>> Posit, not with R. :)
> 
>>> However, the only message I get is: ``` trying URL
>>> ''
> 
>> The package name has the version number encoded in it, so
>> theoretical you should be able to tell at this point
>> whether the package that is downloaded is the version that
>> is already installed, hence no update will happen.
> 
>> Best wishes,
> 
>>  Berwin
> 
> 
> Yes, thank's a lot, Berwin.
> 
> Indeed I've raised the fact that RStudio
> hides R's own install.packages() from the user  and uses its
> own, undocumented one ... this has been the case for quite a few years.
> I found out during teaching --- one of the few times, I use
> RStudio to use R... in another case where RStudio's
> install.packages() behaved differently than R's.
> 
> I'm pretty sure this is reason for quite a bit of confusion...
> 
> Martin
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] back tick names with predict function

2023-12-01 Thread peter dalgaard
Also, and possibly more constructively, when you get an error like
 
> CI.c = predict(mod2, data.frame( `plant-density` = x), interval = 'c')  # fail
Error in eval(predvars, data, env) : object 'plant-density' not found

you should check your assumptions. Does "newdata" actually contain a columnn 
called "plant-density":

> head(data.frame( `plant-density` = x))
  plant.density
1  65.0
2  65.11912
3  65.23824
4  65.35736
5  65.47648
6  65.59560
> 

I.e., it doesn't. So check help for data.frame and looking for something with 
names.

> On 1 Dec 2023, at 01:47 , Bert Gunter  wrote:
> 
> "Thank you Rui.  I didn't know about the check.names = FALSE argument.
>> Another good reminder to always read help, but I'm not sure I understood
>> what help to read in this case"
> 
> ?data.frame , of course, which says:
> 
> "check.names
> 
> logical. If TRUE then the names of the variables in the data frame are
> checked to ensure that they are syntactically valid variable names and
> are not duplicated. If necessary they are adjusted (by make.names) so
> that they are. "
> 
> -- Bert
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] anyone having trouble accesing CRAN?

2023-11-20 Thread peter dalgaard
Notice that getCRANmirrors() without the local.only=TRUE gets its list from 
...tada cran.r-project.org. 

Arguably, that might be in for a change. Meanwhile, you might just use 
cloud.r-project.org right away.  

-pd

> On 15 Nov 2023, at 20:23 , Ivan Krylov  wrote:
> 
> On Wed, 15 Nov 2023 14:13:00 -0500
> "Christopher W. Ryan via R-help"  wrote:
> 
>> Anyone seeing similar?
> 
> Same for me.
> 
> While it worked, CRAN website had the following message:
> 
>>> The CRAN Admin Team will perform system upgrades during the period
>>> Wednesday November 15 until Thursday November 16, 2023. There will
>>> be intermittent outages in service during this time. 
> 
> Use chooseCRANmirror(local.only = TRUE) (or subset() the return value
> of getCRANmirrors(local.only = TRUE)) to access a mirror that works.
> 
> -- 
> Best regards,
> Ivan
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Bug in print for data frames?

2023-11-03 Thread peter dalgaard
It's still kind of weird; embedded 2-column data frames print differently than 
1-column ones:

> d <- data.frame(a=1, b=I(data.frame(d=1,e=2)))
> d
  a b.d b.e
1 1   1   2
> str(d)
'data.frame':   1 obs. of  2 variables:
 $ a: num 1
 $ b:Classes 'AsIs' and 'data.frame':   1 obs. of  2 variables:
  ..$ d: num 1
  ..$ e: num 2
> names(d)
[1] "a" "b"
> d <- data.frame(a=1, b=I(data.frame(d=1)))
> d
  a d
1 1 1
> str(d)
'data.frame':   1 obs. of  2 variables:
 $ a: num 1
 $ b:Classes 'AsIs' and 'data.frame':   1 obs. of  1 variable:
  ..$ d: num 1
> names(d)
[1] "a" "b"

It is happening inside format.data.frame() or as.data.frame.list() but I can't 
figure out the logic at this point.

-pd


> On 26 Oct 2023, at 10:55 , Duncan Murdoch  wrote:
> 
> On 25/10/2023 2:18 a.m., Christian Asseburg wrote:
>> Hi! I came across this unexpected behaviour in R. First I thought it was a 
>> bug in the assignment operator <- but now I think it's maybe a bug in the 
>> way data frames are being printed. What do you think?
>> Using R 4.3.1:
>>> x <- data.frame(A = 1, B = 2, C = 3)
>>> y <- data.frame(A = 1)
>>> x
>>   A B C
>> 1 1 2 3
>>> x$B <- y$A # works as expected
>>> x
>>   A B C
>> 1 1 1 3
>>> x$C <- y[1] # makes C disappear
>>> x
>>   A B A
>> 1 1 1 1
>>> str(x)
>> 'data.frame':   1 obs. of  3 variables:
>>  $ A: num 1
>>  $ B: num 1
>>  $ C:'data.frame':  1 obs. of  1 variable:
>>   ..$ A: num 1
>> Why does the print(x) not show "C" as the name of the third element? I did 
>> mess up the data frame (and this was a mistake on my part), but finding the 
>> bug was harder because print(x) didn't show the C any longer.
> 
> y[1] is a dataframe with one column, i.e. it is identical to y.  To get the 
> result you expected, you should have used y[[1]], to extract column 1.
> 
> Since dataframes are lists, you can assign them as columns of other 
> dataframes, and you'll create a single column in the result whose rows are 
> the columns of the dataframe you're assigning.  This means that
> 
> x$C <- y[1]
> 
> replaces the C column of x with a dataframe.  It retains the name C (you can 
> see this if you print names(x) ), but since the column contains a dataframe, 
> it chooses to use the column name of y when printing.
> 
> If you try
> 
> x$D <- x
> 
> you'll see it generate new names when printing, but the names within x remain 
> as A, B, C, D.
> 
> This is a situation where tibbles do a better job than dataframes:  if you 
> created x and y as tibbles instead of dataframes and executed your code, 
> you'd see this:
> 
>  library(tibble)
>  x <- tibble(A = 1, B = 2, C = 3)
>  y <- tibble(A = 1)
>  x$C <- y[1]
>  x
>  #> # A tibble: 1 × 3
>  #>   A B   C$A
>  #> 
>  #> 1 1 2 1
> 
> 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.

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

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


Re: [R] weights vs. offset (negative binomial regression)

2023-11-02 Thread peter dalgaard
t;
>> >
>> >
>> > I have a dataset that includes five variables.
>> >
>> > - Catch: the catch number counted in some species (ind.)
>> >
>> > - Effort: fishing effort (the number of fishing vessels)
>> >
>> > - xx1, xx2, xx3: some environmental factors
>> >
>> > As an overdispersion test on the “Catch” variable, I modeled with
>>negative
>> > binomial distribution using a GLM. The “Effort” variable showed a
>>gradually
>> > decreasing trend during the study period. I was able to get the
>>results I
>> > wanted when considered “Effort” function as a weights function in the
>> > negative binomial regression as follows:
>> >
>> >
>> >
>> > library(qcc)
>> >
>> >
>>
>> Catch=c(25,2,7,6,75,5,1,4,66,15,9,25,40,8,7,4,36,11,1,14,141,9,74,38,126,3)
>> >
>> >
>>
>> Effort=c(258,258,258,258,258,258,258,254,252,252,252,252,252,252,252,252,252,252,252,248,246,246,246,246,246,246)
>> >
>> >
>>
>> xx1=c(0.8,0.5,1.2,0.5,1.1,1.1,1.0,0.6,0.9,0.5,1.2,0.6,1.2,0.7,1.0,0.6,1.6,0.7,0.8,0.6,1.7,0.9,1.1,0.5,1.4,0.5)
>> >
>> >
>>
>> xx2=c(1.7,1.6,2.7,2.6,1.5,1.5,2.8,2.5,1.7,1.9,2.2,2.4,1.6,1.4,3.0,2.4,1.4,1.5,2.2,2.3,1.7,1.7,1.9,1.9,1.4,1.4)
>> >
>> >
>>
>> xx3=c(188,40,2,10,210,102,117,14,141,28,48,15,220,115,10,14,320,20,3,10,400,150,145,160,460,66)
>> >
>> > #
>> >
>> > edata <- data.frame(Catch, Effort, xx1, xx2, xx3)
>> >
>> > #
>> >
>> > qcc.overdispersion.test(edata$Catch, type="poisson")
>> >
>> > #
>> >
>> > summary(glm.nb(Catch~xx1+xx2+xx3, weights=Effort, data=edata))
>> >
>> > summary(glm.nb(Catch~xx1+xx2+xx3+offset(log(Effort)), data=edata))
>> >
>> >
>> >
>> > I am not sure the application of the weights function to the negative
>> > binomial regression is correct. Also I wonder if there is a
>>better way
>> > doing this. Can anyone help?
>> >
>> >   [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>>-- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>><https://stat.ethz.ch/mailman/listinfo/r-help>
>> > PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>><http://www.R-project.org/posting-guide.html>
>> > and provide commented, minimal, self-contained, reproducible code.
>>__
>>R-help@r-project.org <mailto:R-help@r-project.org> mailing list --
>>To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/r-help
>><https://stat.ethz.ch/mailman/listinfo/r-help>
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>><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.

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

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


[R] [Rd] R 4.3.2 is released

2023-10-31 Thread Peter Dalgaard via R-help
The build system rolled up R-4.3.2.tar.gz (codename "Eye Holes") this morning.

This is a minor update, with a few bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 97a3ddc25aab502a70bfb1a79ab6f862
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = b9ad3b7a9f54856444ec9849a69b18e3
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = 4108ab429e768e29b1c3b418c224246e
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = 3217f2606bbde5a76fe4deaa4b4d3321
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = 8d6576e0a33475e8b6dcb61f8e49a2b4
MD5 (R-4/R-4.3.2.tar.gz) = 3217f2606bbde5a76fe4deaa4b4d3321

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
3a47bca1e2a7db27c0ca12be388c238e2608ff2f768e627650a71a0ffc826038  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
ec6844344589b717144d51ca3d5d1dbe5bc453d69287c06430f9bb2263abe01f  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
5de7657c5e58e481403c0dd1a74a5c090b3ef481ce75a91dfe05d4b03f63163f  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
b3f5760ac2eee8026a3f0eefcb25b47723d978038eee8e844762094c860c452a  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
f3acaa77b0034a44c9c9b02767a2d383a7c2c2e2a3e7fec929fa20c5102304c5  
VERSION-INFO.dcf
b3f5760ac2eee8026a3f0eefcb25b47723d978038eee8e844762094c860c452a  
R-4/R-4.3.2.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.3.2:

  NEW FEATURES:

* The default initialization of the "repos" option from the
  repositories file at startup can be skipped by setting
  environment variable R_REPOSITORIES to NULL such that
  getOption("repos") is empty if not set elsewhere.

* qr.X() is now an implicit S4 generic in methods.

* iconv(to = "ASCII//TRANSLIT") is emulated using substitution on
  platforms which do not support it (notably Alpine Linux).  This
  should give a human-readable conversion in ASCII on all platforms
  (rather than NA_character_).

* trans3d() gains options continuous and verbose addressing the
  problem of possible "wrap around" when projecting too long
  curves, as reported by Achim Zeileis in PR#18537.

* tools::showNonASCII() has been rewritten to work better on macOS
  14 (which has a changed implementation of iconv()).

* tiff(type = "quartz") (the default on macOS) now warns if
  compression is specified: it continues to be ignored.

  INSTALLATION on a UNIX-ALIKE:

* There is some support for building with Intel's LLVM-based
  compilers on x86_64 Linux, such as (C) icx, (C++) ipcx and
  (Fortran) ifx from oneAPI 2023.x.y.

* There is support for using LLVM's flang-new as the Fortran
  compiler from LLVM 16.0.x (preferably 17.0.0 or later).

  UTILITIES:

* R CMD check reports the use of the Fortran 90 random number
  generator RANDOM_NUMBER() and the subroutines to initialize it.

  'Writing R Extensions' has example code to use R's RNGs from
  Fortran.

  BUG FIXES:

* substr(x, n, L) <- cc now works (more) correctly for multibyte
  UTF-8 strings x when L > nchar(x), thanks to a report and patch
  by 'Architect 95'.

* contrib.url(character()) now returns 0-length character() as
  documented, which also avoids spurious warnings from
  available.packages() et al. in the edge case of an empty vector
  of repository URLs.

* readChar(., 4e8) no longer fails, thanks to Kodi Arfer's report
  (PR#18557).

* lapply(, as.data.frame) no longer warns falsely for some
  base vector components.

* Communication between parent and child processes in the multicore
  part of parallel could fail on platforms that do not s

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread peter dalgaard
Also,

> aggregate(cbind(OD, ODnorm) ~ Time + Target + Conc, data = df, FUN = "mean")
  Time Target Conc   ODODnorm
11   BACT1 765. 108.3
21   BACT2 745.  88.3
31   BACT3 675.  18.0

(You might wish for "cbind(OD,ODnorm) ~ . - Well", but aggregate.formula is not 
smart enough for that.)

-pd

> On 24 Oct 2023, at 14:40 , Sarah Goslee  wrote:
> 
> Hi,
> 
> I think you're misunderstanding which set of variables go on either
> side of the formula.
> 
> Is this what you're looking for?
> 
>> aggregate(OD ~ Time + Target + Conc, data = df, FUN = "mean")
>  Time Target Conc   OD
> 11   BACT1 765.
> 21   BACT2 745.
> 31   BACT3 675.
>> aggregate(ODnorm ~ Time + Target + Conc, data = df, FUN = "mean")
>  Time Target ConcODnorm
> 11   BACT1 108.3
> 21   BACT2  88.3
> 31   BACT3  18.0
> 
> Or using a different form, that might be more straightforward to you:
> 
>> aggregate(df[, c("OD", "ODnorm")], by = df[, c("Time", "Target", "Conc")], 
>> data = df, FUN = "mean")
>  Time Target Conc   ODODnorm
> 11   BACT1 765. 108.3
> 21   BACT2 745.  88.3
> 31   BACT3 675.  18.0
> 
> Sarah
> 
> On Tue, Oct 24, 2023 at 8:31 AM Luigi Marongiu  
> wrote:
>> 
>> Hello,
>> I have a data frame with different groups (Time, Target, Conc) and
>> each entry has a triplicate value of the measurements OD and ODnorm.
>> How can I merge the triplicates into a single mean value?
>> I tried the following:
>> ```
>> df = data.frame(Time=rep(1, 9), Well=paste("A", 1:9, sep=""),
>>OD=c(666, 815, 815, 702, 739, 795, 657, 705, 663),
>>Target=rep("BACT", 9),
>>Conc=c(1,1,1,2,2,2,3,3,3),
>>ODnorm=c(9, 158, 158,  45,  82, 138,   0,  48,   6),
>>stringsAsFactors = FALSE)
>> aggregate(.~ODnorm, df, mean)
>> 
>>> aggregate(.~ODnorm, df, mean)
>>  ODnorm Time Well OD Target Conc
>> 1  0   NA   NA NA NA   NA
>> 2  6   NA   NA NA NA   NA
>> 3  9   NA   NA NA NA   NA
>> 4 45   NA   NA NA NA   NA
>> 5 48   NA   NA NA NA   NA
>> 6 82   NA   NA NA NA   NA
>> 7138   NA   NA NA NA   NA
>> 8158   NA   NA NA NA   NA
>> 
>> aggregate(cbind(Time, Target, Conc) ~ ODnorm, df, mean)
>>  ODnorm Time Target Conc
>> 1  0   NA NA   NA
>> 2  6   NA NA   NA
>> 3  9   NA NA   NA
>> 4 45   NA NA   NA
>> 5 48   NA NA   NA
>> 6 82   NA NA   NA
>> 7138   NA NA   NA
>> 8158   NA NA   NA
>> ```
>> 
>> Thank you.
>> 
>> __
>> 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.
> 
> 
> 
> -- 
> Sarah Goslee (she/her)
> http://www.numberwright.com
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Create new data frame with conditional sums

2023-10-24 Thread peter dalgaard
This seems to work. A couple of fine points, including handling duplicated Pct 
values right, which is easier if you do the reversed cumsum.

> dd2 <- dummydata[order(dummydata$Pct),]
> dd2$Cum <- rev(cumsum(rev(dd2$Totpop)))
> use <- !duplicated(dd2$Pct)
> approx(dd2$Pct[use], dd2$Cum[use], ctof, method="constant", f=1, rule=2)
$x
 [1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14
[16] 0.15

$y
 [1] 43800 43800 39300 39300 31000 26750 22750 17800 12700 12700  8000  8000
[13]  8000  3900  3900  3900


> On 14 Oct 2023, at 17:10 , Bert Gunter  wrote:
> 
> Well, here's one way to do it:
> (dat is your example data frame)
> 
> Cutoff <- seq(0, .15, .01)
> Pop <- with(dat, sapply(Cutoff, \(p)sum(Totpop[Pct >= p])))
> 
> I think there must be a more efficient way to do it with cumsum(), though.
> 
> Cheers,
> Bert
> 
> On Sat, Oct 14, 2023 at 12:53 AM Jason Stout, M.D.  
> wrote:
>> 
>> This seems like it should be simple but I can't get it to work properly.  
>> I'm starting with a data frame like this:
>> 
>> Tract  Pct  Totpop
>> 1  0.054000
>> 2  0.033500
>> 3  0.014500
>> 4  0.124100
>> 5  0.213900
>> 6  0.044250
>> 7  0.075100
>> 8  0.094700
>> 9  0.064950
>> 10   0.034800
>> 
>> And I want to end up with a data frame with two columns, a "Cutoff" column 
>> that is a simple sequence of equally spaced cutoffs (let's say in this case 
>> from 0-0.15 by 0.01) and a "Pop" column which equals the sum of "Totpop" in 
>> the prior data frame in which "Pct" is greater than or equal to "cutoff."  
>> So in this toy example, this is what I want for a result:
>> 
>>   Cutoff   Pop
>> 10.00 43800
>> 20.01 43800
>> 30.02 39300
>> 40.03 39300
>> 50.04 31000
>> 60.05 26750
>> 70.06 22750
>> 80.07 17800
>> 90.08 12700
>> 10   0.09 12700
>> 11   0.10  8000
>> 12   0.11  8000
>> 13   0.12  8000
>> 14   0.13  3900
>> 15   0.14  3900
>> 16   0.15  3900
>> 
>> I can do this with a for loop but it seems there should be an easier, 
>> vectorized way that would be more efficient.  Here is a reproducible example:
>> 
>> dummydata<-data.frame(Tract=seq(1,10,by=1),Pct=c(0.05,0.03,0.01,0.12,0.21,0.04,0.07,0.09,0.06,0.03),Totpop=c(4000,3500,4500,4100,
>>  
>>3900,4250,5100,4700,
>>  
>>4950,4800))
>> dfrm<-data.frame(matrix(ncol=2,nrow=0,dimnames=list(NULL,c("Cutoff","Pop"
>> for (i in seq(0,0.15,by=0.01)) {
>> temp<-sum(dummydata[dummydata$Pct>=i,"Totpop"])
>> dfrm[nrow(dfrm)+1,]<-c(i,temp)
>> }
>> 
>> Jason Stout, MD, MHS
>> Division of Infectious Diseases
>> Dept of Medicine
>> Duke University
>> Box 102359-DUMC
>> Durham, NC 27710
>> FAX 919-681-7494
>> 
>> 
>>[[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.

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

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


[R] [Rd] R 4.3.2 scheduled for October 31

2023-10-13 Thread Peter Dalgaard via R-help
Full schedule available on developer.r-project.org in a short while.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Odd result

2023-09-29 Thread peter dalgaard
Yes. Also notice that something fishy seems to be going on in columns 2 and 3 
(assuming that the date/time is 1 column). 
They appear to be read as character data, even though the content is numeric?

-pd

> On 24 Sep 2023, at 11:58 , Michael Dewey  wrote:
> 
> Dear David
> 
> To get the first 46 rows just do KurtzData[1:43,]
> 
> However really you want to find out why it happened. It looks as though the 
> .csv file you read has lots of blank lines at the end. I would open it in an 
> editor to check that.
> 
> Michael
> 
> On 23/09/2023 23:55, Parkhurst, David wrote:
>> With help from several people, I used file.choose() to get my file name, and 
>> read.csv() to read in the file as KurtzData.  Then when I print KurtzData, 
>> the last several lines look like this:
>> 39   5/31/22  16.0  3411.75525 0.0201 0.0214   7.00
>> 40   6/28/22  2:00 PM  0.0  2150.67950 0.0156 0.0294 NA
>> 41   7/25/22 11:00 AM  11.9   1943.5NA NA 0.0500   7.80
>> 42   8/31/22  0220.5NA NA 0.0700  30.50
>> 43   9/28/22  0.067 10.9NA NA 0.0700  10.20
>> 44  10/26/22  0.086  237NA NA 0.1550  45.00
>> 45   1/12/23  1:00 PM 36.2624196NA NA 0.7500 283.50
>> 46   2/14/23  1:00 PM 20.71   55NA NA 0.0500   2.40
>> 47  NA NA NA NA
>> 48  NA NA NA NA
>> 49  NA NA NA NA
>> Then the NA�s go down to one numbered 973.  Where did those extras likely 
>> come from, and how do I get rid of them?  I assume I need to get rid of all 
>> the lines after #46,  to do calculations and graphics, no?
>> David
>>  [[alternative HTML version deleted]]
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> -- 
> Michael
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] prop.trend.test question

2023-09-28 Thread peter dalgaard
In a word: Yes.

We discussed this about 2w ago. Basically, the lm() fits a local Linear 
Probability Model and the coef to "score" gives you the direction of the effect.

In the same thread it was discussed (well, readable between the lines, maybe) 
that if you change the lm() to a Gaussian glm() and use summary(..., 
dispersion=1), you can extract the z-test version of the trend test. (I think 
that the reason for using the chisquare version was to match the example in 
Altman: Practical Statistics for Medical Research.)

Arguably the code should be updated to use the z and at the same time include 
alternative=c("two.sided", "less", "greater") like other 1df tests have. Just a 
matter of these darn little round tuits that you seem never to be able to 
get... Also slightly tricky whether/how to make it backwards compatible.

- pd

> On 25 Sep 2023, at 04:10 , tgs77m--- via R-help  wrote:
> 
> Colleagues,
> 
> The code for prop.trend.test is given by:
> 
> function (x, n, score = seq_along(x)) 
> {
>method <- "Chi-squared Test for Trend in Proportions"
>dname <- paste(deparse1(substitute(x)), "out of",
> deparse1(substitute(n)), 
>",\n using scores:", paste(score, collapse = " "))
>x <- as.vector(x)
>n <- as.vector(n)
>p <- sum(x)/sum(n)
>w <- n/p/(1 - p)
>a <- anova(lm(freq ~ score, data = list(freq = x/n, score =
> as.vector(score)), 
>weights = w))
>chisq <- c(`X-squared` = a["score", "Sum Sq"])
>structure(list(statistic = chisq, parameter = c(df = 1), 
>p.value = pchisq(as.numeric(chisq), 1, lower.tail = FALSE), 
>method = method, data.name = dname), class = "htest")
> }
> 
> It seems to me that the direction of the trend is found using the weighted
> regression lm(freq ~ score, data = list(freq = x/n, score =
> as.vector(score)), 
>weights = w))
> 
> Am I on the right track here?
> 
> Thomas Subia
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Print hypothesis warning- Car package

2023-09-18 Thread peter dalgaard
Also, I would guess that the code precedes the use of backticks in 
non-syntactic names. Could they be deployed here?

- Peter

> On 17 Sep 2023, at 16:43 , John Fox  wrote:
> 
> Dear Robert,
> 
> Anova() calls linearHypothesis(), also in the car package, to compute sums of 
> squares and df, supplying appropriate hypothesis matrices. linearHypothesis() 
> usually tries to express the hypothesis matrix in symbolic equation form for 
> printing, but won't do this if coefficient names include arithmetic 
> operators, in your case - and +, which can confuse it.
> 
> The symbolic form of the hypothesis isn't really relevant for Anova(), which 
> doesn't use the printed representation of each hypothesis, and so, despite 
> the warnings, you get the correct ANOVA table. In your case, where the data 
> are balanced, with 4 cases per cell, Anova(mod) and summary(mod) are 
> equivalent, which makes me wonder why you would use Anova() in the first 
> place.
> 
> To elaborate a bit, linearHypothesis() does tolerate arithmetic operators in 
> coefficient names if you specify the hypothesis symbolically rather than as a 
> hypothesis matrix. For example, to test, the interaction:
> 
> --- snip 
> 
> > linearHypothesis(mod,
> +  c("TreatmentDabrafenib:ExpressionCD271+ = 0",
> +"TreatmentTrametinib:ExpressionCD271+ = 0",
> +"TreatmentCombination:ExpressionCD271+ = 0"))
> Linear hypothesis test
> 
> Hypothesis:
> TreatmentDabrafenib:ExpressionCD271+ = 0
> TreatmentTrametinib:ExpressionCD271+ = 0
> TreatmentCombination:ExpressionCD271+ = 0
> 
> Model 1: restricted model
> Model 2: Viability ~ Treatment * Expression
> 
>  Res.Df   RSS Df Sum of Sq F Pr(>F)
> 1 27 18966
> 2 24 16739  32226.3 1.064 0.3828
> 
> --- snip 
> 
> Alternatively:
> 
> --- snip 
> 
> > H <- matrix(0, 3, 8)
> > H[1, 6] <- H[2, 7] <- H[3, 8] <- 1
> > H
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
> [1,]00000100
> [2,]00000010
> [3,]00000001
> 
> > linearHypothesis(mod, H)
> Linear hypothesis test
> 
> Hypothesis:
> 
> 
> Model 1: restricted model
> Model 2: Viability ~ Treatment * Expression
> 
>  Res.Df   RSS Df Sum of Sq F Pr(>F)
> 1 27 18966
> 2 24 16739  32226.3 1.064 0.3828
> Warning message:
> In printHypothesis(L, rhs, names(b)) :
>  one or more coefficients in the hypothesis include
> arithmetic operators in their names;
>  the printed representation of the hypothesis will be omitted
> 
> --- snip 
> 
> There's no good reason that linearHypothesis() should try to express each 
> hypothesis symbolically for Anova(), since Anova() doesn't use that 
> information. When I have some time, I'll arrange to avoid the warning.
> 
> Best,
> John
> 
> -- 
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://www.john-fox.ca/
> On 2023-09-16 4:39 p.m., Robert Baer wrote:
>> Caution: External email.
>> When doing Anova using the car package,  I get a print warning that is
>> unexpected.  It seemingly involves have my flow cytometry factor levels
>> named CD271+ and CD171-.  But I am not sure this warning should be
>> intended behavior.  Any explanation about whether I'm doing something
>> wrong? Why can't I have CD271+ and CD271- as factor levels?  Its legal
>> text isn't it?
>> library(car) mod = aov(Viability ~ Treatment*Expression, data = dat1)
>> Anova(mod, type =2) Anova Table (Type II tests) Response: Viability Sum
>> Sq Df F value Pr(>F) Treatment 19447.3 3 9.2942 0.0002927 *** Expression
>> 2669.8 1 3.8279 0.0621394 . Treatment:Expression 2226.3 3 1.0640
>> 0.3828336 Residuals 16739.3 24 --- Signif. codes: 0 ‘***’ 0.001 ‘**’
>> 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Warning messages: 1: In printHypothesis(L,
>> rhs, names(b)) : one or more coefficients in the hypothesis include
>> arithmetic operators in their names; the printed representation of the
>> hypothesis will be omitted 2: In printHypothesis(L, rhs, names(b)) : one
>> or more coefficients in the hypothesis include arithmetic operators in
>> their names; the printed representation of the hypothesis will be
>> omitted 3: In printHypothesis(L, rhs, names(b)) : one or more
>> coefficients in the hypothesis include arithmetic operators in their
>> names; the printed representation of the hypothesis will be omitted
>> The code to reproduce:
&

Re: [R] graph in R with grouping letters from the turkey test with agricolae package

2023-09-13 Thread peter dalgaard
Yes. Old John T. must be turning on his skewer...er, in his grave, I mean.

(I gather he was actually more amicable than that, though.)

- pd

> On 13 Sep 2023, at 16:20 , Ben Bolker  wrote:
> 
>  As a side note, I'm curious how often "Tukey test" is misspelled as "Turkey 
> test".
> 
> 
> Googling '"turkey test" mean comparison' gives 36.1K results (vs 14.3M for 
> '"tukey test" mean comparison" ...
> 
> 
> 
> On 2023-09-13 10:02 a.m., Richard O'Keefe wrote:
>>> d <- read.table("data.txt", TRUE)
>>> cor(d[, 3:6])
>>  VAR1 VAR2 VAR3 VAR4
>> VAR11111
>> VAR21111
>> VAR31111
>> VAR41111
>> VAR1 to VAR4 are, up to linear scaling,
>> exactly the same variable.  Why is that?
>> On Wed, 13 Sept 2023 at 07:38, Loop Vinyl  wrote:
>>> I would like to produce the attached graph (graph1) with the R package
>>> agricolae, could someone give me an example with the attached data (data)?
>>> 
>>> I expect an adapted graph (graph2) with the data (data)
>>> 
>>> Best regards
>>> __
>>> 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.
> 
> -- 
> Dr. Benjamin Bolker
> Professor, Mathematics & Statistics and Biology, McMaster University
> Director, School of Computational Science and Engineering
> (Acting) Graduate chair, Mathematics & Statistics
> > E-mail is sent at my convenience; I don't expect replies outside of working 
> > hours.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] prop.trend.test

2023-09-12 Thread peter dalgaard
Argh, yes, drats, thanks. 

There will be a matter of an estimated residual error.

So

> coef(summary(ht$lmfit))["score","t value"]*sigma(ht$lmfit)
[1] -2.867913

matches the signes square root of the Chi-square.

Or, likely better (avoid 0 df cases), switch to a Gaussian glm fit and use the 
z stat

> coef(summary(ht$glmfit, dispersion = 1))
   Estimate Std. Error   z value  Pr(>|z|)
(Intercept)  1.02187141 0.03199737 31.936102 8.425506e-224
score   -0.03341563 0.01165155 -2.867913  4.131897e-03

The Estimate (-0.0334) should still make sense as the LPM estimate of the 
regression slope.

- Peter D.


> On 8 Sep 2023, at 12:53 , Rui Barradas  wrote:
> 
> Às 10:06 de 08/09/2023, peter dalgaard escreveu:
>> Yes, this was written a bit bone-headed (as I am allowed to say...)
>> If you look at the code, you will see inside:
>> a <- anova(lm(freq ~ score, data = list(freq = x/n, score = 
>> as.vector(score)),
>> weights = w))
>> and the lm() inside should give you the direction via the sign of the 
>> regression coefficient on "score".
>>  So, at least for now, you could just doctor a copy of the code for your own 
>> purposes, as in
>>  fit <- lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)),
>> weights = w)
>>  a <- anova(fit)
>>  and arrange to return coef(fit)["score"] at the end. Something like 
>> structure(... estimate=c(lpm.slope=coef(fit)["score"]) )
>> (I expect that you might also extract the t-statistic from 
>> coef(summary(fit)) and find that it is the signed square root of the 
>> Chi-square, but I won't have time to test that just now.)
>> -pd
>>> On 8 Sep 2023, at 07:22 , Thomas Subia via R-help  
>>> wrote:
>>> 
>>> Colleagues,
>>> 
>>> Thanks all for the responses.
>>> 
>>> I am monitoring the daily total number of defects per sample unit.
>>> I need to know whether this daily defect proportion is trending upward (a 
>>> bad thing for a manufacturing process).
>>> 
>>> My first thought was to use either a u or a u' control chart for this.
>>> As far as I know, u or u' charts are poor to detect drifts.
>>> 
>>> This is why I chose to use prop.trend.test to detect trends in proportions.
>>> 
>>> While prop.trend.test can confirm the existence of a trend, as far as I 
>>> know, it is left to the user
>>> to determine what direction that trend is.
>>> 
>>> One way to illustrate trending is of course to plot the data and use 
>>> geom_smooth and method lm
>>> For the non-statisticians in my group, I've found that using this method 
>>> along with the p-value of prop.trend.test, makes it easier for the users to 
>>> determine the existence of trending and its direction.
>>> 
>>> If there are any other ways to do this, please let me know.
>>> 
>>> Thomas Subia
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas 
>>>  wrote:
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Às 14:23 de 07/09/2023, Thomas Subia via R-help escreveu:
>>>> 
>>>> Colleagues
>>>> 
>>>>Consider
>>>> smokers  <- c( 83, 90, 129, 70 )
>>>> patients <- c( 86, 93, 136, 82 )
>>>> 
>>>>prop.trend.test(smokers, patients)
>>>> 
>>>>Output:
>>>> 
>>>>Chi-squared Test for Trend inProportions
>>>> 
>>>>data:  smokers out of patients ,
>>>> 
>>>> using scores: 1 2 3 4
>>>> 
>>>> X-squared = 8.2249, df = 1, p-value = 0.004132
>>>> 
>>>># trend test for proportions indicates proportions aretrending.
>>>> 
>>>>How does one identify the direction of trending?
>>>># prop.test indicates that the proportions are unequal but doeslittle 
>>>> to indicate trend direction.
>>>> All the best,
>>>> Thomas Subia
>>>> 
>>>> 
>>>> [[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 pos

Re: [R] prop.trend.test

2023-09-08 Thread peter dalgaard
Yes, this was written a bit bone-headed (as I am allowed to say...)

If you look at the code, you will see inside:

a <- anova(lm(freq ~ score, data = list(freq = x/n, score = 
as.vector(score)), 
weights = w))

and the lm() inside should give you the direction via the sign of the 
regression coefficient on "score".
 
So, at least for now, you could just doctor a copy of the code for your own 
purposes, as in

 fit <- lm(freq ~ score, data = list(freq = x/n, score = as.vector(score)), 
weights = w)
 a <- anova(fit)
 
and arrange to return coef(fit)["score"] at the end. Something like 
structure(... estimate=c(lpm.slope=coef(fit)["score"]) )

(I expect that you might also extract the t-statistic from coef(summary(fit)) 
and find that it is the signed square root of the Chi-square, but I won't have 
time to test that just now.)

-pd

> On 8 Sep 2023, at 07:22 , Thomas Subia via R-help  
> wrote:
> 
> Colleagues,
> 
> Thanks all for the responses. 
> 
> I am monitoring the daily total number of defects per sample unit. 
> I need to know whether this daily defect proportion is trending upward (a bad 
> thing for a manufacturing process).
> 
> My first thought was to use either a u or a u' control chart for this.
> As far as I know, u or u' charts are poor to detect drifts. 
> 
> This is why I chose to use prop.trend.test to detect trends in proportions.
> 
> While prop.trend.test can confirm the existence of a trend, as far as I know, 
> it is left to the user
> to determine what direction that trend is. 
> 
> One way to illustrate trending is of course to plot the data and use 
> geom_smooth and method lm
> For the non-statisticians in my group, I've found that using this method 
> along with the p-value of prop.trend.test, makes it easier for the users to 
> determine the existence of trending and its direction.
> 
> If there are any other ways to do this, please let me know.
> 
> Thomas Subia
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas 
>  wrote: 
> 
> 
> 
> 
> 
> Às 14:23 de 07/09/2023, Thomas Subia via R-help escreveu:
>> 
>> Colleagues
>> 
>>Consider
>> smokers  <- c( 83, 90, 129, 70 )
>> patients <- c( 86, 93, 136, 82 )
>> 
>>prop.trend.test(smokers, patients)
>> 
>>Output:
>> 
>>Chi-squared Test for Trend inProportions
>> 
>>data:  smokers out of patients ,
>> 
>> using scores: 1 2 3 4
>> 
>> X-squared = 8.2249, df = 1, p-value = 0.004132
>> 
>># trend test for proportions indicates proportions aretrending.
>> 
>>How does one identify the direction of trending?
>># prop.test indicates that the proportions are unequal but doeslittle to 
>> indicate trend direction.
>> All the best,
>> Thomas Subia
>> 
>> 
>> [[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.
> Hello,
> 
> By visual inspection it seems that there is a decreasing trend.
> Note that the sample estimates of prop.test and smokers/patients are equal.
> 
> 
> smokers  <- c( 83, 90, 129, 70 )
> patients <- c( 86, 93, 136, 82 )
> 
> prop.test(smokers, patients)$estimate
> #>prop 1prop 2prop 3prop 4
> #> 0.9651163 0.9677419 0.9485294 0.8536585
> 
> smokers/patients
> 
> #> [1] 0.9651163 0.9677419 0.9485294 0.8536585
> 
> plot(smokers/patients, type = "b")
> 
> 
> 
> Hope this helps,
> 
> Rui Barradas
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Why install.packages(repos = X) does not override the 'repos' R option?

2023-06-19 Thread peter dalgaard
Yes. Specifically, RStudio overrides utils::install.packages() with their own 

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


which is paved with good intentions, but does deflect blame towards R Core 
things go wrong.

-pd


> On 15 Jun 2023, at 19:42 , Duncan Murdoch  wrote:
> 
> (Sorry, forgot "Reply all" last time.)
> 
> That's an RStudio bug.  It doesn't happen if you use install.packages()
> from R.
> 
> Duncan Murdoch
> 
> On 14/06/2023 9:22 a.m., Dean Attali wrote:
>> There is a default R option for which repos to install from -
>> `getOption("repos")`.
>> When installing a package using install.packages(), you can provide a
>> `repos` parameter. The default value of that parameter is
>> `getOption("repos")`. I assumed that this parameter would override the R
>> option. In other words, I assumed that if the parameter is provided, then
>> the R option would not even be looked at. But after testing this, it seems
>> this is not the case.
>> For example, running the following two lines in an R session:
>> options(repos=c(CRAN="https://BADNAME.com;))
>> install.packages("vctrs", repos = "https://cloud.R-project.org;)
>> I would have expected the first line to be rendered meaningless, but in
>> fact after running the second line I see errors about the BADNAME
>> repository. This feels like a bug to me, but I'm sure there's a reason
>> behind this. Does anyone know why this is the case?
>>  [[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.

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

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


[R] [Rd] R 4.3.1 is released

2023-06-16 Thread Peter Dalgaard via R-help
The build system rolled up R-4.3.1.tar.gz (codename "Beagle Scouts") this 
morning.

This is a minor update, with a few bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.3.1.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 97a3ddc25aab502a70bfb1a79ab6f862
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 7ea998dffa2b8d4f5a6aee84c45a383a
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = 4108ab429e768e29b1c3b418c224246e
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = b83cee497046d4aef649eb79e6df83e8
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = 3d4c6bf5bf44d34766f90ed67d05c34a
MD5 (R-4/R-4.3.1.tar.gz) = b83cee497046d4aef649eb79e6df83e8

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
3a47bca1e2a7db27c0ca12be388c238e2608ff2f768e627650a71a0ffc826038  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
a8167cfe28e748b67476d4a21a968cfa24d0935da89cd4514c483f45f3f2a83b  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
5de7657c5e58e481403c0dd1a74a5c090b3ef481ce75a91dfe05d4b03f63163f  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
8dd0bf24f1023c6f618c3b317383d291b4a494f40d73b983ac22ffea99e4ba99  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
032260f31c56c011a9724930e356eac4d7ddfcaa63c559f95986063ede3bf91a  
VERSION-INFO.dcf
8dd0bf24f1023c6f618c3b317383d291b4a494f40d73b983ac22ffea99e4ba99  
R-4/R-4.3.1.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.3.1:

  C-LEVEL FACILITIES:

* The C-level API version of R's integrate(), Rdqags() in Applic.h,
  now returns the correct number of integrand evaluations neval,
  fixing PR#18515 reported and diagnosed by Stephen Wade.

* The C prototypes for LAPACK calls dspgv and dtptrs in
  R_exts/Lapack.h had one too many and one too few character length
  arguments - but this has not caused any known issues. To get the
  corrected prototypes, include

  #include  // for PR18534fixed
  #ifdef PR18534fixed
  # define usePR18534fix 1
  #endif
  #include 
  
  in your C/C++ code (PR#18534).

  INSTALLATION:

* Many of the checks of esoteric Internet operations and those
  using unreliable external sites have been moved to a new target
  that is not run by default and primarily intended for the core
  developers.  To run them use

  cd tests; make test-Internet-dev
  
  BUG FIXES:

* .S3methods(), typically called from methods(), again marks
  methods from package base as visible.

  Also, the visibility of non-base methods is again determined by
  the method's presence in search().

* tools::Rdiff() is now more robust against invalid strings, fixing
  installation tests on Windows without Rtools installed
  (PR#18530).

* Fix (new) bug in hcl.colors(2, *), by Achim Zeileis (PR#18523).

* head(., ) and tail(..) now produce more useful "Error in
  " error messages, fixing PR#18362.

* Package code syntax on Windows is checked in UTF-8 when UTF-8 is
  the native encoding.

* na.contiguous(x) now also returns the first run, when it is at
  the beginning and there is a later one of the same length;
  reported to R-devel, including a fix, by Georgi Boshnakov.
  Further, by default, it modifies only an existing attr(*,"tsp")
  but otherwise no longer sets one.

* chol(, pivot = ) now gives a correct error or
  warning message (depending on pivot), thanks to Mikael Jagan's
  (PR#18541).

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

[R] [Rd] R 4.3.1 scheduled for June 16

2023-05-25 Thread Peter Dalgaard via R-help
Full schedule available on developer.r-project.org in a short while.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] [Rd] R 4.3.0 is released

2023-04-21 Thread Peter Dalgaard via R-help


The build system rolled up R-4.3.0.tar.gz (codename "Already Tomorrow") this 
morning.

This is a major update, containing many new features and bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.3.0.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 3f5d6539d3c4878cbbb74dcbee74447f
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = a63858aea2a450900edf8c965cac1efa
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = 4108ab429e768e29b1c3b418c224246e
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = f8f409fa66b82dbc79ddc5706f19638f
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = cf5eba51ce402edaaa26eacdd4af55b5
MD5 (R-4/R-4.3.0.tar.gz) = f8f409fa66b82dbc79ddc5706f19638f

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
8c396b0db6b1b072e66ea78deab8c89f71150744420ad9f74de6505aacee9a80  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
be75619066603438a01d75f6f9ed741bc4fe15981eac900dd6dd0b1a4861dbb2  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
5de7657c5e58e481403c0dd1a74a5c090b3ef481ce75a91dfe05d4b03f63163f  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
45dcc48b6cf27d361020f77fde1a39209e997b81402b3663ca1c010056a6a609  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
3281640b70d461113ecb20020f3ed760bd30411c51657354bc3b322fa457fc49  
VERSION-INFO.dcf
45dcc48b6cf27d361020f77fde1a39209e997b81402b3663ca1c010056a6a609  
R-4/R-4.3.0.tar.gz


This is the relevant part of the NEWS file

CHANGES IN R 4.3.0:

  SIGNIFICANT USER-VISIBLE CHANGES:

* Calling && or || with LHS or (if evaluated) RHS of length greater
  than one is now always an error, with a report of the form

  'length = 4' in coercion to 'logical(1)'
  
  Environment variable _R_CHECK_LENGTH_1_LOGIC2_ no longer has any
  effect.

  NEW FEATURES:

* The included BLAS sources have been updated to those shipped with
  LAPACK version 3.10.1.  (This caused some platform-dependent
  changes to package check output.)  And then to the sources from
  LAPACK version 3.11.0 (with changes only to double complex
  subroutines).

* The included LAPACK sources have been updated to include the four
  Fortran 90 routines rather than their Fortran 77 predecessors.
  This may give some different signs in SVDs or
  eigendecompositions..  (This completes the transition to LAPACK
  3.10.x begun in R 4.2.0.)

* The LAPACK sources have been updated to version 3.11.0.  (No new
  subroutines have been added, so this almost entirely bug fixes:
  Those fixes do affect some computations with NaNs, including R's
  NA.)

* The parser now signals _classed_ errors, notably in case of the
  pipe operator |>.  The error object and message now give line and
  column numbers, mostly as proposed and provided by Duncan Murdoch
  in PR#18328.

* toeplitz() is now generalized for asymmetric cases, with a
  toeplitz2() variant.

* xy.coords() and xyz.coords() and consequently, e.g., plot(x,y,
  log = "y") now signal a _classed_ warning about negative values
  of y (where log(.) is NA).  Such a warning can be specifically
  suppressed or caught otherwise.

* Regular expression functions now check more thoroughly whether
  their inputs are valid strings (in their encoding, e.g. in
  UTF-8).

* The performance of grep(), sub(), gsub() and strsplit() has been
  improved, particularly with perl = TRUE and fixed = TRUE.  Use of
  useBytes = TRUE for performance reasons should no longer be
  needed and is discouraged: it may lead to incorrect results.

* apropos() gains an argument dot_internals which is used by the
  completion (help(rcompgen)) engine to also see base i

[R] [R-pkgs] DNAmixturesLite and KinMixLite

2023-04-12 Thread Peter Green

Dear all,

We are pleased to announce that CRAN now hosts our packages 
DNAmixturesLite and KinMixLite.


These are fully R-based versions of our packages DNAmixtures and KinMix, 
which rely on a commercial software, HUGIN, for performing efficient 
computations in Bayesian networks. The lite versions rely instead on 
gRain for such computations.


DNAmixtures provides statistical methods for DNA mixture analysis and 
has been used to provide statistical evidence pertaining to DNA in 
several criminal cases in the UK and Denmark. The purpose of the newly 
released lite version is to allow users without a HUGIN software license 
to experiment with the statistical methodology. While the lite version 
aims to provide full functionality, it is noticeably less efficient than 
the original DNAmixtures package. For details on implementation and 
methodology see <https://dnamixtures.r-forge.r-project.org/>.


KinMix builds upon DNAmixtures and is a toolbox of methods for inference 
about relationships between contributors to a DNA mixture and other 
individuals of known genotype: a basic example would be testing whether 
a contributor to a mixture is the father of a child of known genotype. 
KinMixLite builds upon DNAmixturesLite and provides most of the 
functionality of the KinMix package, but with some loss of efficiency. 
The package implements the methods introduced in Green, P. J. and 
Mortera, J. (2017)  and Green, P. J. 
and Mortera, J. (2021) .


Regards,
Therese Graversen and Peter Green

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

__
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] "prob" package alternative

2023-04-06 Thread peter murage
Which package in R replaced package prob?

Sent from Mail for Windows


[[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] Count matrix of GSE146049

2023-04-02 Thread Peter Langfelder
It's a microarray data set, so I don't think you would want to apply
an RNA-seq pipeline. You'd be better off applying a normalization
appropriate for this type of microarray data.

HTH,

Peter

On Sun, Apr 2, 2023 at 11:09 PM Anas Jamshed  wrote:
>
> I want to get the count matrix of genes from
> https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE146049. Is it
> possible for GSE146049? After getting counts, I want to do TMM
> normalization.
>
> [[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.


[R] [Rd] R 4.3.0 scheduled for April 21

2023-03-21 Thread peter dalgaard
Full schedule is available on developer.r-project.org (pending update from SVN).

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] [Rd] R 4.2.3 is released

2023-03-15 Thread peter dalgaard
The build system rolled up R-4.2.3.tar.gz (codename "Shortstop Beagle") this 
morning.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.2.3.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 3f5d6539d3c4878cbbb74dcbee74447f
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 4a300bf9bd24e704614f036452355d23
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = 4108ab429e768e29b1c3b418c224246e
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = ebfc90b1552581f2b7c9a50f934e6bb0
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = d08f0c8f65c2a021be36324081440dd9
MD5 (R-4/R-4.2.3.tar.gz) = ebfc90b1552581f2b7c9a50f934e6bb0

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
8c396b0db6b1b072e66ea78deab8c89f71150744420ad9f74de6505aacee9a80  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
be3cd8a6d7220726d2cbdf1b929e6b75c09101214b1b006e29ce97dab4450553  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
5de7657c5e58e481403c0dd1a74a5c090b3ef481ce75a91dfe05d4b03f63163f  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
55e4a9a6d43be314e2c03d0266a6fa5444afdce50b303bfc3b82b3979516e074  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
4701c6802bf3f31e6f8ad66d47909eef0985f8af97b0a28fd391c68a7d3ffc18  
VERSION-INFO.dcf
55e4a9a6d43be314e2c03d0266a6fa5444afdce50b303bfc3b82b3979516e074  
R-4/R-4.2.3.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.2.3:

  C-LEVEL FACILITIES:

* The definition of DL_FUNC in R_ext/Rdynload.h has been changed to
  be fully C-compliant.  This means that functions loaded _via_ for
  example R_GetCCallable need to be cast to an appropriate type if
  they have any arguments.

* .Machine has a new element sizeof.time_t to identify old systems
  with a 32-bit type and hence a limited range of date-times (and
  limited support for dates millions of years from present).

  PACKAGE INSTALLATION:

* (Windows) The default C++ standard had accidentally been left at
  C++11 when it was changed to C++14 on Unix.

  BUG FIXES:

* As "POSIXlt" objects may be "partially filled" and their list
  components meant to be recycled, length() now is the length of
  the longest component.

* as.POSIXlt.Date() could underflow for dates in the far past (more
  than half a million years BCE).

* as.Date.POSIXlt(x) would return "1970-01-01" instead of NA in R
  4.2.2, e.g., for

  x <- as.POSIXlt(c("2019-01-30","2001-1-1"))
  x$mon <- c(0L, NA); as.Date(x)
  
* R CMD check failed to apply enabled _R_CHECK_SUGGESTS_ONLY_ to
  examples and vignettes (regression in R 4.2.0).

* R CMD check did not re-build vignettes in separate processes by
  default (regression in R 4.2.0).

* Running examples from HTML documentation now restores previous
  knitr settings and options (PR#18420).

* Quartz: fonts are now located using Core Graphics API instead of
  deprecated ATS which is no longer supported in the macOS 13 SDK
  (PR#18426).  This also addresses an issue where the currently
  used font in the Quartz device context was not correctly
  retained.

* (Windows) Math symbols in text drawing functions are again
  rendered correctly (PR#18440).  This fixes a regression in R
  4.2.1 caused by a fix in PR#18382 which uncovered an issue in
  GraphApp due to which the symbol charset was not used with TT
  Symbol font face.

* (Windows) Installing a package with a src/Makefile.{win,ucrt}
  file includes ~/.R/Makevars.win64 in the search for user
  makevars, as documented in "R Installation and Administration"
  and done for packages with a src/Makevars.{win,ucrt} f

[R] [Rd] R 4.2.3 scheduled for March 15

2023-03-01 Thread Peter Dalgaard via R-help
Full schedule available on developer.r-project.org in a short while.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Problem of intercept?

2023-02-22 Thread peter dalgaard
Not sure what you are trying to do here.

The immediate issue is that you are getting 'y' on the RHS, because that is the 
1st column in Dataset. So "for (i in 2:3)" might be closer to intention. 

However, a 0/1 regresson with no intercept implies that the mean for the "0" 
group is zero, and with two regressors that the mean is zero for the (0,0) 
group. Looking at the data, this is quite clearly not the case.

I suppose you may have intended to fit the models _with_ the intercept and then 
_ignore_ the intercept for plotting purposes, i.e. lm(y~x11+x12, 
Dataset)$coef[-1], etc.?

(Also, I suspect that you don't actually have y=7 and y=867 in the dataset.)

-pd
 
> On 21 Feb 2023, at 22:33 , varin sacha via R-help  
> wrote:
> 
> Dear R-experts,
> 
> Here below my R code working with quite a few warnings. 
> x11 and x12 are dichotomous variable (0=no and 1=yes). I substract 1 to 
> ignore intercept.
> I would like not to ignore intercept. How to modify my R code because if I 
> just remove -1 it does not work?
> 
> 
> y= c(32,45,65,34,23,43,65,76,87,98,7,867,56,45,65,76,88,34,55,66)
> x11=c(0,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,0,1)
> x12=c(0,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,1,0,0)
>  
> Dataset=data.frame(y,x11,x12)
>  
> a=lm(y~x11+x12-1,Dataset)$coef
> b=NULL
> for(i in c(1:2)) {
>   f=formula(paste('y~',names(Dataset)[i],-1))
>   b=c(b,lm(f,Dataset)$coef)
> }
> coef=data.frame(rbind(a,b))
> coef$Model=c('Multi','Single')
> library(reshape2)
> coef.long<-melt(coef,id.vars="Model")
>  
> library(ggplot2)
> ggplot(coef.long,aes(x=variable,y=value,fill=Model))+
>   geom_bar(stat="identity",position="dodge")+
>   scale_fill_discrete(name="Model",
>   labels=c("Multiple", "Simple"))+
>   labs(title =paste('La différences des coefficients
>   entre la régression multiple et simple'),
>   x="Models",y="Coefficient")+
>   coord_flip()
>  
>  
>  
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] MLE Estimation of Gamma Distribution Parameters for data with 'zeros'

2023-01-19 Thread peter dalgaard
Not necessarily homework, Bert. There's a generic issue with MLE and rounded 
data, in that gamma densities may be 0 at the boundary but small numbers are 
represented as 0, making the log-likelihood -Inf. 

The cleanest way out is to switch to a discretized distribution in the 
likelihood, so that instead of log(dgamma(0,...)) you use log(pgamma(.005,..) - 
pgamma(0,...)) == pgamma(.005,..., log=TRUE). (For data rounded to nearest .01, 
that is). Cruder techniques would be to just add, like, .0025 to all the zeros. 

-pd

> On 10 Jan 2023, at 18:42 , Bert Gunter  wrote:
> 
> Is this homework? This list has a no-homework policy.
> 
> 
> -- Bert
> 
> On Tue, Jan 10, 2023 at 8:13 AM Nyasha  wrote:
>> 
>> Please how can one go about this one? I don't know how to go about it.
>> 
>>[[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.

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

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


[R] [R-pkgs] gRaven package - Bayes Nets: 'RHugin' Emulation with 'gRain'

2023-01-09 Thread Peter Green

Dear all,

I am pleased to announce that CRAN now hosts my package gRaven.

This provides wrappers for functions in the 'gRain' package to emulate 
some 'RHugin' functionality, allowing the building of Bayesian networks 
consisting of discrete chance nodes incrementally - through adding 
nodes, edges and conditional probability tables, the setting of 
evidence, whether 'hard' (boolean) or 'soft' (likelihoods), and querying 
marginal joint probabilities and normalizing constants.


Computations will typically not be so fast as they are with 'RHugin', 
but this package should assist users without access to the commercial 
package 'Hugin' to use existing code written to use 'RHugin'.


I am open to extending the functionality of the package in future, in 
response to user demand.


regards,

Peter Green

--
Peter Green, p.j.gr...@bristol.ac.uk
--
Emeritus Professor of Statistics & Professorial Research Fellow
University of Bristol, Bristol BS8 1UG, UK
T: +44 117 455 2611; W: https://petergreenweb.wordpress.com/

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

__
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] library(tseries) - spellng error in output

2022-12-15 Thread peter dalgaard
And normalTest is not in tseries, but in fBasics.

- pd

> On 15 Dec 2022, at 04:11 , Jeff Newmiller  wrote:
> 
> Contact the package maintainer. See maintainer().
> 
> On December 14, 2022 7:04:28 PM PST, roslinazairimah zakaria 
>  wrote:
>> Hi R-users,
>> 
>> Just to inform that there is one spelling error in the output for 
>> *Jarque-Bera
>> test in R.*
>> 
>> *library(tseries)*
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> *> #Jarque-Bera normality test> normalTest(dt_i, method='jb')Title: Jarque
>> - Bera Normalality TestTest Results:  STATISTIC:X-squared: 16.8853  P
>> VALUE:Asymptotic p Value: 0.0002155 *
>> 
> 
> -- 
> 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.

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

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


Re: [R] confusion about dev.prev()

2022-12-05 Thread Peter Langfelder
Ah, thanks, got it. Misread the help again...

Peter

On Mon, Dec 5, 2022 at 9:38 PM Ivan Krylov  wrote:
>
> В Mon, 5 Dec 2022 21:28:16 +0800
> Peter Langfelder  пишет:
>
> > Open two devices, plot a plot, call dev.prev() and plot again. I
> > would expect the second plot to appear in the first device, but that
> > is not what happens; both plots appear in the second device.
>
> Unfortunately, dev.prev() and dev.next() only return the number of the
> respective device. You need dev.set() to actually make the change.
>
> --
> Best regards,
> Ivan

__
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] confusion about dev.prev()

2022-12-05 Thread Peter Langfelder
Hi all,

I'm either confused about dev.prev() or there's a bug in it. Open two
devices, plot a plot, call dev.prev() and plot again. I would expect
the second plot to appear in the first device, but that is not what
happens; both plots appear in the second device. Is this expected
behavior or a bug?
Example (in linux):

x11()
par(mfrow = c(1,2));
x11()
par(mfrow = c(1,2));
plot(1:10)
dev.prev()
plot(10:20)

This happens both in R-4.2.0 (patched) and R-devel from 2022-09-13
(sorry, don't have a newer one handy).

sessionInfo() from the R-devel session:

R Under development (unstable) (2022-09-13 r82849)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Fedora Linux 36 (Thirty Six)

Matrix products: default
BLAS:   /usr/local/lib64/R-devel/lib/libRblas.so
LAPACK: /usr/local/lib64/R-devel/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.3.0

__
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] [Rd] R 4.2.2 is released

2022-10-31 Thread Peter Dalgaard via R-help
The build system rolled up R-4.2.2.tar.gz (codename "Innocent and Trusting") 
this morning.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.2.2.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 1ff069b3d34234bb6df71298380da3a8
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = df3c0a29151cfbc40e6a07a5ad398de1
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = b154500667b5ebb480f1086dd817f017
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = 7c5057ff5958b2312a88556487fae295
MD5 (R-4/R-4.2.2.tar.gz) = b154500667b5ebb480f1086dd817f017

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
d8cfbd44efe3311bc2d4a71a0850c50aebc18a21affac951898a3b6b45dfe777  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
f9700348b098129906da3489ce7299f86ded993aac2a8861349b1935652f8f6d  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
0ff62b42ec51afa5713caee7c4fde7a0c45940ba39bef8c5c9487fef0c953df5  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
4bf8efc154e3f48800a9ddd1dd5bf333d3cf4f7e943876372699dab76e693318  
VERSION-INFO.dcf
0ff62b42ec51afa5713caee7c4fde7a0c45940ba39bef8c5c9487fef0c953df5  
R-4/R-4.2.2.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.2.2:

  NEW FEATURES:

* tools::Rdiff(useDiff = TRUE) checks for the presence of an
  external diff command and switches to useDiff = FALSE if none is
  found.  This allows R CMD Rdiff to always work.

* On Windows, environment variable R_LIBCURL_SSL_REVOKE_BEST_EFFORT
  can be used to switch to only 'best-effort' SSL certificate
  revocation checks with the default "libcurl" download method.
  This reduces security, but may be needed for downloads to work
  with MITM proxies (PR#18379).

* (macOS) The run-time check for libraries from XQuartz for X11 and
  Tcl/Tk no longer uses otool from the Apple Developer Tools
  (PR#18400).

* The LaTeX style for producing the PDF manuals, Rd.sty, now loads
  the standard amsmath, amsfonts and amssymb packages for greater
  coverage of math commands in the Rd \eqn and \deqn macros.  The
  \mathscr LaTeX command is also provided (via the mathrsfs
  package, if available, or the amsfonts bundle otherwise),
  fulfilling the wish of PR#18398.

* (Windows) The default format of readClipboard() and
  writeClipboard() has been changed to 13 (CF_UNICODETEXT).

  INSTALLATION on a UNIX-ALIKE:

* The PDF manuals (if built) can be compacted by the new target
  make compact-pdf (at the top level or in directory doc/manual).

* There is now configure support for LLVM clang 15 on Linux, which
  defaults to position-independent (PIE) executables whereas
  gfortran does not.

* Many small changes to ease compilation (and suppress warnings)
  with LLVM clang 15.

  BUG FIXES:

* Rscript -e would fail if stdin were closed (Reported by Henrik
  Bengtsson.)

* qt(*, log.p=TRUE) in outer tails no longer produces NaN in its
  final steps, thus fixing PR#18360.

* tools::Rd2latex() now escapes hashes and ampersands when writing
  URLs, fixing LaTeX errors with such URLs in \tabular.

* When isGeneric(f, fdef=*) is used with mismatching names, the
  warning is better understandable; reported (with fix) in PR#18370
  by Gabe Becker.

* poly(x, n) now works again (and is now documented) when x is a
  "Date" or "POSIXct" object, or of another class while fulfilling
  mode(x) == "numeric".  This also enables poly(x, *, raw=TRUE) for
  such 

Re: [R] Subsetting a vector using an index with all missing values

2022-07-02 Thread Peter Langfelder
Ah, thanks, that makes sense.

Peter

On Fri, Jul 1, 2022 at 10:01 PM Bill Dunlap  wrote:
>
> This has to do with the mode of the subscript - logical subscripts are 
> repeated to the length of x and integer/numeric ones are not.  NA is logical, 
> NA_integer_ is integer, so we get
>
> > x <- 1:10
> > x[ rep(NA_integer_, 3) ]
> [1] NA NA NA
> > x[ rep(NA, 3) ]
>  [1] NA NA NA NA NA NA NA NA NA NA
>
> -Bill
>
>
> On Fri, Jul 1, 2022 at 8:31 PM Peter Langfelder  
> wrote:
>>
>> Hi all,
>>
>> I stumbled on subsetting behavior that seems counterintuitive and
>> perhaps is a bug. Here's a simple example:
>>
>> > x = 1:10
>> > x[ rep(NA, 3)]
>>  [1] NA NA NA NA NA NA NA NA NA NA
>>
>> I would have expected 3 NAs (the length of the index), not 10 (all
>> values in x). Looked at the documentation for the subsetting operator
>> `[` but found nothing indicating that if the index contains all
>> missing data, the result is the entire vector.
>>
>> I can work around the issue for a general 'index' using a somewhat
>> clunky but straightforward construct along the lines of
>>
>> > index = rep(NA, 3)
>> > x[c(1, index)][-1]
>> [1] NA NA NA
>>
>> but I'm wondering if the behaviour above is intended.
>>
>> Thanks,
>>
>> Peter
>>
>> __
>> 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] Checking a function for undeclared variables

2022-04-05 Thread Peter Langfelder
Thanks!

Peter

On Tue, Apr 5, 2022 at 6:01 PM Jeff Newmiller  wrote:
>
> ?codetools::findGlobals
>
> On April 5, 2022 5:36:54 PM PDT, Peter Langfelder 
>  wrote:
> >Hi all,
> >
> >I'd like to check a function for undeclared global variables using
> >something similar to what R CMD check does when "checking R code for
> >possible problems". My search came up empty but I hope there is way to
> >do it without building a package just for this purpose, isn't there?
> >
> >Thanks!
> >
> >Peter
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.

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


[R] [R-pkgs] Nmix package - Bayesian inference about univariate Gaussian mixtures with an unknown number of components

2022-04-02 Thread Peter Green
This package is now on CRAN in version 2.0.2, and anyone interested in 
inference on mixture models, or more generally in Bayesian inference for 
"trans-dimensional" problems, is encouraged to try it out. The 
methodology is that presented by Richardson and Green in our 1997 
article in the Journal of the Royal Statistical Society, using 
Reversible jump Markov chain Monte Carlo. The package is based on the 
Fortran code used in the research for that paper, which is available now 
to the R user for the first time. A rich variety of outputs from the 
MCMC sample path is available, optionally, and many features of the 
posterior distribution are presented graphically. Apart from its direct 
use in analysing data, the package might be useful in supporting 
learning about Bayesian computation.


Feedback is most welcome, and I may be open to extending the 
functionality of the package in response to concrete suggestions.


regards,

Peter Green

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

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


Re: [R] How to convert category (or range/group) into continuous ?

2022-01-17 Thread peter dalgaard
Depends on what was meant. If you just want the interval midpoints for 
plotting, you can do something like

endp <- c(0,.01, .025, .05, ... 2.5) # some manual assembly required here
mid <- (head(endp, -1) + tail(endp, -1))/2
groupmid <- mid[group]
plot(groupmid, VALUE)

-pd

> On 17 Jan 2022, at 16:34 , Bert Gunter  wrote:
> 
> IMO, this is a bad idea. You are asking how to fabricate information that
> isn't there. You lost the information when you created the categories. Why
> can you not just go back to your original data?
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Sun, Jan 16, 2022 at 11:06 PM Marna Wagley 
> wrote:
> 
>> Hi R users,
>> I first categorized the continuous data into groups (ranges or category)
>> but now I would like to change the category into a continuous data and
>> plot it. For example I have attached the data in which you can see two
>> columns named "group" and "value". The group column contains a range
>> (group, for example ), I am wondering how I can change the category data
>> (for example: "0,0.01]" )into continuous data with a 0.1 interval.
>> Thank you for your suggestions.
>> 
>> daT<-structure(list(group = c("(0,0.01]", "(0.01,0.025]", "(0.025,0.05]",
>> "(0.05,0.075]", "(0.075,0.1]", "(0.1,0.2]", "(0.2,0.3]", "(0.3,0.4]",
>> "(0.4,0.5]", "(0.5,0.6]", "(0.6,0.7]", "(0.7,0.8]", "(0.8,0.9]",
>> "(0.9,1]", "(1,1.1]", "(1.1,1.5]", "(1.5,2]", "(2,2.5]"), VALUE = c(1,
>> 1, 1, 1, 1, 1, 0.9, 0.91667, 0.9, 0.85778,
>> 0.82667, 0.66, 0.439090909, 0.328636364, 0.273409091, 0.245795455,
>> 0.218181818, 0.084848485)), class = "data.frame", row.names = c(NA,
>> -18L))
>> thanks,
>> MW
>> 
>>[[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.

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

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


Re: [R] Sum every n (4) observations by group

2021-12-19 Thread Peter Langfelder
I'm not sure I understand the task, but if I do, assuming your data
frame is assigned to a variable named df, I would do something like

sumNs = function(x, n)
{
   if (length(x) %%n !=0) stop("Length of 'x' must be a multiple of 'n'.")
   n1 = length(x)/n
   ind = rep(1:n1, each = n)
   tapply(x, ind, sum)
}
sums = tapply(df$Value, df$ID, sumNs, 4)

Peter

On Sun, Dec 19, 2021 at 10:32 AM Miluji Sb  wrote:
>
> Dear all,
>
> I have a dataset (below) by ID and time sequence. I would like to sum every
> four observations by ID.
>
> I am confused how to combine the two conditions. Any help will be highly
> appreciated. Thank you!
>
> Best.
>
> Milu
>
> ## Dataset
> structure(list(ID = c("A", "A", "A", "A", "A", "A", "A", "A",
> "B", "B", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C",
> "C", "C", "C"), Date = c(4140L, 4141L, 4142L, 4143L, 4144L, 4145L,
> 4146L, 4147L, 4140L, 4141L, 4142L, 4143L, 4144L, 4145L, 4146L,
> 4147L, 4140L, 4141L, 4142L, 4143L, 4144L, 4145L, 4146L, 4147L
> ), Value = c(0.000207232, 0.000240141, 0.000271414, 0.000258384,
> 0.00024364, 0.00027148, 0.000280585, 0.000289691, 0.000298797,
> 0.000307903, 0.000317008, 0.000326114, 0.00033522, 0.000344326,
> 0.000353431, 0.000362537, 0.000371643, 0.000380749, 0.000389854,
> 0.00039896, 0.000408066, 0.000417172, 0.000426277, 0.000435383
> )), class = "data.frame", row.names = c(NA, -24L))
>
> [[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] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-23 Thread peter dalgaard
It reads other formats _if you specify them_. After all, no computer (or human) 
can tell whether 11/03/1959 is November 3 or March 11 without further hinting. 
So it tries the two ISO-like formats and leaves other cases for the user.

-pd

> On 20 Nov 2021, at 21:22 , Philip Monk  wrote:
> 
> Thanks, Andrew.  I didn't realise as.Date *only* read two formats, I
> think I was tripped up by using %y instead of %Y, 

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

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


[R] [Rd] R 4.1.2 is released

2021-11-01 Thread Peter Dalgaard
The build system rolled up R-4.1.2.tar.gz (codename "Bird Hippie") this morning.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.1.2.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard

These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 320967884b547734d6279dedbc739dd4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = ade6a3d38fe5e6a456929cae2b94d568
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 924e68decbf327f538a09afb1838506b
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = a767f7809324c73c49eaff47d14bce81
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = 6e28db9d02c6d3dae51a149b8e261ab1
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = a72a49578a254b9163f0f10322a3eecc
MD5 (R-4/R-4.1.2.tar.gz) = 6e28db9d02c6d3dae51a149b8e261ab1

60a0d150e6fc1f424be76ad7b645d236b56e747692a4679f81ce6536c550e949  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
e84c67931e9b925abb9142d4a6b4ef03b7605948bbf384d7e3d2401823c7f1fe  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
73d5bfb8711bb7833ce8fe7a1359566d48001d13cd32affbd800d759f0b3232a  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
ba74618bc3f4c0e336dca13d472402a1863d12ba6f7f91a1782bc469ee986f6d  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
2036225e9f7207d4ce097e54972aecdaa8b40d7d9911cd26491fac5a0fab38af  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
1e74ef089b526538bbb658dc189bc3d34d931839e9933415fb2f267fd57b0b69  
VERSION-INFO.dcf
2036225e9f7207d4ce097e54972aecdaa8b40d7d9911cd26491fac5a0fab38af  
R-4/R-4.1.2.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.1.2:

  C-LEVEL FACILITIES:

* The workaround in headers R.h and Rmath.h (using namespace std;)
  for the Oracle Developer Studio compiler is no longer needed now
  C++11 is required so has been removed.  A couple more usages of
  log() (which should have been std::log()) with an int argument
  are reported on Solaris.

* The undocumented limit of 4095 bytes on messages from the
  S-compatibility macros PROBLEM and MESSAGE is now documented and
  longer messages will be silently truncated rather than
  potentially causing segfaults.

* If the R_NO_SEGV_HANDLER environment variable is non-empty, the
  signal handler for SEGV/ILL/BUS signals (which offers recovery
  user interface) is not set. This allows more reliable debugging
  of crashes that involve the console.

  DEPRECATED AND DEFUNCT:

* The legacy S-compatibility macros PROBLEM, MESSAGE, ERROR, WARN,
  WARNING, RECOVER, ... are deprecated and will be hidden in R
  4.2.0. R's native interface of Rf_error and Rf_warning has long
  been preferred.

  BUG FIXES:

* .mapply(F, dots, .) no longer segfaults when dots is not a list
  and uses match.fun(F) as always documented; reported by Andrew
  Simmons in PR#18164.

* hist(, ...) and hist(, ...)  no longer pass
  arguments for rect() (such as col and density) to axis().
  (Thanks to Sebastian Meyer's PR#18171.)

* \Sexpr{ch} now preserves Encoding(ch). (Thanks to report and
  patch by Jeroen Ooms in PR#18152.)

* Setting the RNG to "Marsaglia-Multicarry" e.g., by RNGkind(), now
  warns in more places, thanks to Andr'e Gillibert's report and
  patch in PR#18168.

* gray(numeric(), alpha=1/2) no longer segfaults, fixing PR#18183,
  reported by Till Krenz.

* Fixed dnbinom(x, size=, .., log=TRUE) regression,
  reported by Martin Morgan.

* as.Date.POSIXlt(x) now keeps names(x), thanks to Davis Vaughan's
  report and patch in PR#18188.

* model.response() now strips an "AsIs" class typically, thanks to
  Duncan Murdoch's report and other discussants in PR#18190.

* try() is considerably faster in case of an error and long call,
  as e.g., from some do.call().  Thanks to Alexander Kaever's
  suggestion posted to R-devel.

* qqline(y = ) such as y=I(.), now works, see also
  PR#181

Re: [R] [Rd] R 4.1.2 scheduled for November 1

2021-10-03 Thread peter dalgaard
Schedule should appear on developer.r-project.org when it gets updated from SVN.

> On 3 Oct 2021, at 18:40 , peter dalgaard  wrote:
> 
> (Just a quick heads-up for developers.)
> 
> Full schedule to be made available soon.
> 

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] [Rd] R 4.1.2 scheduled for November 1

2021-10-03 Thread peter dalgaard
(Just a quick heads-up for developers.)
 
Full schedule to be made available soon.

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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


Re: [R] How to globally convert NaN to NA in dataframe?

2021-09-03 Thread peter dalgaard
>>> instances?
>>>>> I have seen from
>>>>> https://stackoverflow.com/questions/18142117/how-to-replace-nan-
>>> value
>>>>> -with-zero-in-a-huge-data-frame/18143097#18143097
>>>>> that once could use:
>>>>> ```
>>>>> 
>>>>> is.nan.data.frame <- function(x)
>>>>> do.call(cbind, lapply(x, is.nan))
>>>>> 
>>>>> data123[is.nan(data123)] <- 0
>>>>> ```
>>>>> replacing o with NA, but I got
>>>>> ```
>>>>> str(df)
>>>>>> logi NA
>>>>> ```
>>>>> when modifying my dataframe df.
>>>>> What would be the correct syntax?
>>>>> Thank you
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Best regards,
>>>>> Luigi
>>>>> 
>>>>> __
>>>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>> PLEASE do read the posting guide
>>>>> http://www.R-project.org/posting-guide.html
>>>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>>> 
>>> 
>>> --
>>> Best regards,
>>> Luigi
>>> 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-
>>> guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> -- 
> Best regards,
> Luigi
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] [Rd] R 4.1.1 is released

2021-08-10 Thread Peter Dalgaard
The build system rolled up R-4.1.1.tar.gz (codename "Kick Things") this morning.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.1.1.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard

These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = da5e7c699a83608d0f1e39c458d9fc56
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 6094024214a482c0d01d2ab2adca4b3f
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = fbc4810ff26ebcec514ebaa1c1909ad7
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = a767f7809324c73c49eaff47d14bce81
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = c278cfeb85b1564540ab214e45fe68d9
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = 34443dff7fcea700c8ec4740e5804374
MD5 (R-4/R-4.1.1.tar.gz) = c278cfeb85b1564540ab214e45fe68d9

9704a7d96c350a48417ef215888a29f1993ee5dec1b73cb95755e8625b860200  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
2894e7a88634a08c05bfafb8a694a26b635e4042160aab46fa6a0f4eb68ea91e  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
e8bdaf546cf65fdc5bf2a81fa5334572886ff2f1317ec6cdc9e61d6de3532dd4  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
ba74618bc3f4c0e336dca13d472402a1863d12ba6f7f91a1782bc469ee986f6d  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
515e03265752257d0b7036f380f82e42b46ed8473f54f25c7b67ed25bbbdd364  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
02686ea05e64304a755bf776cdeeadafd2c5017a13f9203f1db9278287c81aa6  
VERSION-INFO.dcf
515e03265752257d0b7036f380f82e42b46ed8473f54f25c7b67ed25bbbdd364  
R-4/R-4.1.1.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.1.1:

  NEW FEATURES:

* require(pkg, quietly = TRUE) is quieter and in particular does
  not warn if the package is not found.

  DEPRECATED AND DEFUNCT:

* Use of ftp:// URIs should be regarded as deprecated, with
  on-going support confined to method = "libcurl" and not routinely
  tested.  (Nowadays no major browser supports them.)

* The non-default method = "internal" is deprecated for http:// and
  ftp:// URIs for both download.file and url.

* On Windows, method = "wininet" is deprecated for http://,
  https:// and ftp:// URIs for both download.file and url.  (A
  warning is only given for ftp://.)

  For ftp:// URIs the default method is now "libcurl" if available
  (which it is on CRAN builds).

  method = "wininet" remains the default for http:// and https://
  URIs but if libcurl is available, using method = "libcurl" is
  preferred.

  INSTALLATION:

* make check now works also without a LaTeX installation.  (Thanks
  to Sebastian Meyer's PR#18103.)

  BUG FIXES:

* make check-devel works again in an R build configured with
  --without-recommended-packages.

* qnbinom(p, size, mu) for large size/mu is correct now in a range
  of cases (PR#18095); similarly for the (size, prob)
  parametrization of the negative binomial.  Also qpois() and
  qbinom() are better and or faster for extreme cases.  The
  underlying C code has been modularized and is common to all four
  cases of discrete distributions.

* gap.axis is now part of the axis() arguments which are passed
  from bxp(), and hence boxplot().  (Thanks to Martin Smith's
  report and suggestions in PR#18109.)

* .First and .Last can again be set from the site profile.

* seq.int(from, to, *) and seq.default(..) now work better in large
  range cases where from-to is infinite where the two boundaries
  are finite.

* all.equal(x,y) now returns TRUE correctly also when several
  entries of abs(x) and abs(y) are close to .Machine$double.xmax,
  the largest finite numeric.

* model.frame() now clears the object bit when removing the class
  attribute of a value via na.action (PR#18100).

* charClass() now works with multi-character strings on Windows
  (PR#18104, fixed by Bill Dunlap)

[R] [Rd] R 4.1.1 scheduled for August 10

2021-07-10 Thread Peter Dalgaard via R-help
Full schedule is available on developer.r-project.org.

(This comes somewhat late this year, partly because we needed to squeeze in 
4.0.5 before 4.1.0 could be released.)

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

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] checksums for R src file

2021-06-24 Thread peter dalgaard
Yes, these are in the release announcements. They are deliberately not kept 
with the actual files due to security considerations. The easiest source is

https://stat.ethz.ch/pipermail/r-announce/2021/date.html

(because that mailing list doesn't contain much other than release 
announcements).

- Peter D.

> On 24 Jun 2021, at 17:47 , kap4lin  wrote:
> 
> When I download the file,
> https://cran.r-project.org/src/base/R-4/R-4.1.0.tar.gz (or anything
> similar) is there a checksum for the file I can compare it to?
> 
> Thanks
> PK
> 
>   [[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.

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

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


[R] [Rd] R 4.1.0 is released

2021-05-20 Thread Peter Dalgaard


The build system rolled up R-4.1.0.tar.gz (codename "Camp Pontanezen") this 
morning.

This is a major update, notably containing the new native pipe operator "|>" 
and 
shorthand inline functions "\(x) x+1".

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.1.0.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 639fbbba9998cae70ef058be42b80a52
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = b02805558a8315f1a93c7f7d7cd879c1
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = a767f7809324c73c49eaff47d14bce81
MD5 (NEWS.3) = e55ed2c8a547b827b46e08eb7137ba23
MD5 (R-latest.tar.gz) = bd80f97d0e46a71408f5bc25652a0203
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = 1f3cf39735afb48fea434bca2b7bf483
MD5 (R-4/R-4.1.0.tar.gz) = bd80f97d0e46a71408f5bc25652a0203

2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
0dce85f38b9d6351a1b63f057dfbc7f572966245add12946482e57e60d41547c  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
20e7185fb5af0f2ac825b27c16afd57ff206726117c6ac5cf7c6f230337af093  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
ba74618bc3f4c0e336dca13d472402a1863d12ba6f7f91a1782bc469ee986f6d  NEWS.2
1910a2405300b9bc7c76beeb0753a5249cf799afe175ce28f8d782fab723e012  NEWS.3
e8e68959d7282ca147360fc9644ada9bd161bab781bab14d33b8999a95182781  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
2f834a058dcfcdfb7eedf45aa0d897ea1a7c43a9460ffd22f73b60919cb1bf57  
VERSION-INFO.dcf
e8e68959d7282ca147360fc9644ada9bd161bab781bab14d33b8999a95182781  
R-4/R-4.1.0.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.1.0:

  FUTURE DIRECTIONS:

* It is planned that the 4.1.x series will be the last to support
  32-bit Windows, with production of binary packages for that
  series continuing until early 2023.

  SIGNIFICANT USER-VISIBLE CHANGES:

* Data set esoph in package datasets now provides the correct
  numbers of controls; previously it had the numbers of cases added
  to these.  (Reported by Alexander Fowler in PR#17964.)

  NEW FEATURES:

* www.omegahat.net is no longer one of the repositories known by
  default to setRepositories().  (Nowadays it only provides source
  packages and is often unavailable.)

* Function package_dependencies() (in package tools) can now use
  different dependency types for direct and recursive dependencies.

* The checking of the size of tarball in R CMD check --as-cran
   may be tweaked via the new environment variable
  _R_CHECK_CRAN_INCOMING_TARBALL_THRESHOLD_, as suggested in
  PR#1 by Jan Gorecki.

* Using c() to combine a factor with other factors now gives a
  factor, an ordered factor when combining ordered factors with
  identical levels.

* apply() gains a simplify argument to allow disabling of
  simplification of results.

* The format() method for class "ftable" gets a new option justify.
  (Suggested by Thomas Soeiro.)

* New ...names() utility.  (Proposed by Neal Fultz in PR#17705.)

* type.convert() now warns when its as.is argument is not
  specified, as the help file always said it _should_.  In that
  case, the default is changed to TRUE in line with its change in
  read.table() (related to stringsAsFactor) in R 4.0.0.

* When printing list arrays, classed objects are now shown _via_
  their format() value if this is a short enough character string,
  or by giving the first elements of their class vector and their
  length.

* capabilities() gets new entry "Rprof" which is TRUE when R has
  been configured with the equivalent of --enable-R-profiling (as
  it is by default).  (Related to Michael Orlitzky's report
  PR#17836.)

* str(xS4) now also shows extraneous attributes of an S4 object
  xS4.

[R] [Rd] R 4.1.0 scheduled for May 18

2021-04-16 Thread Peter Dalgaard via R-help
Full schedule is available on developer.r-project.org.

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Random Forest: OOB performance = test set performance?

2021-04-10 Thread Peter Langfelder
I think the only thing you are doing wrong is not setting the random
seed (set.seed()) so your results are not reproducible. Depending on
the random sample used to select the training and test sets, you get
slightly varying accuracy for both, sometimes one is better and
sometimes the other.

HTH,

Peter

On Sat, Apr 10, 2021 at 8:49 PM  wrote:
>
> Hi ML,
>
> For random forest, I thought that the out-of-bag performance should be
> the same (or at least very similar) to the performance calculated on a
> separated test set.
>
> But this does not seem to be the case.
>
> In the following code, the accuracy computed on out-of-bag sample is
> 77.81%, while the one computed on a separated test set is 81%.
>
> Can you please check what I am doing wrong?
>
> Thanks in advance and best regards.
>
> library(randomForest)
> library(ISLR)
>
> Carseats$High <- ifelse(Carseats$Sales<=8,"No","Yes")
> Carseats$High <- as.factor(Carseats$High)
>
> train = sample(1:nrow(Carseats), 200)
>
> rf = randomForest(High~.-Sales,
>data=Carseats,
>subset=train,
>mtry=6,
>importance=T)
>
> acc <- (rf$confusion[1,1] + rf$confusion[2,2]) / sum(rf$confusion)
> print(paste0("Accuracy OOB: ", round(acc*100,2), "%"))
>
> yhat <- predict(rf, newdata=Carseats[-train,])
> y <- Carseats[-train,]$High
> conftest <- table(y, yhat)
> acctest <- (conftest[1,1] + conftest[2,2]) / sum(conftest)
> print(paste0("Accuracy test set: ", round(acctest*100,2), "%"))
>
> __
> 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] [Rd] R 4.0.5 is released

2021-03-31 Thread Peter Dalgaard
The build system rolled up R-4.0.5.tar.gz (codename "Shake and Throw") this 
morning.

This is a very minor update, mostly to fix the annoyance with East Asian 
character sets.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.0.5.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard

These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 639fbbba9998cae70ef058be42b80a52
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 553381d79675220a90cf9b264997e458
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = 496062c138e2def06cebccddfb814ac6
MD5 (NEWS.3) = 012e7f4a80cc8ec947bf3f0ff6117ec8
MD5 (R-latest.tar.gz) = eb8fb47cc91ff287005c1633ef8599e6
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = 62b1389bc9fed2bf5857c0c99ef490f2
MD5 (R-4/R-4.0.5.tar.gz) = eb8fb47cc91ff287005c1633ef8599e6


2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
0dce85f38b9d6351a1b63f057dfbc7f572966245add12946482e57e60d41547c  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
bbee124ddbd6682ecbaa5193d5ffc35aa090fcf29b30a9ad6f1498074a720388  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
e80de410c77f05ff2012fa70051b89119845f734a7fa5c55857e61e4ed7d5f6e  NEWS.2
7201d139947afa52b5e09d26dc01445edf444506264355b2185122bc1ed3dce0  NEWS.3
0a3ee079aa772e131fe5435311ab627fcbccb5a50cabc54292e6f62046f1ffef  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
6f7663cb7813af1228978d9ef356fb6e6dad131fab9bbed507b657b48e2df6bd  
VERSION-INFO.dcf
0a3ee079aa772e131fe5435311ab627fcbccb5a50cabc54292e6f62046f1ffef  
R-4/R-4.0.5.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.0.5:

  BUG FIXES:

* The change to the internal table in R 4.0.4 for iswprint has been
  reverted: it contained some errors in printability of 'East
  Asian' characters.

* For packages using LazyData, R CMD build ignored the
  --resave-data option and the BuildResaveData field of the
  DESCRIPTION file (in R versions 4.0.0 to 4.0.4).

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] [Rd] R 4.0.5 scheduled for March 31

2021-03-22 Thread Peter Dalgaard via R-help
Full schedule is available on https://developer.r-project.org (or 
https://svn.r-project.org/R-dev-web/trunk/index.html for the impatient).

(This is a fast-track release, to resolve an issue with Asian character sets 
and another issue with R CMD build, before R 4.1.0)

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] about a p-value < 2.2e-16

2021-03-18 Thread Peter Langfelder
I thinnk the answer is much simpler. The print method for hypothesis
tests (class htest) truncates the p-values. In the above example,
instead of using

wilcox.test(rnorm(100), rnorm(100, 2), exact=TRUE)

and copying the output, just print the p-value:

tst = wilcox.test(rnorm(100), rnorm(100, 2), exact=TRUE)
tst$p.value

[1] 2.988368e-32


I think this value is what the journal asks for.

HTH,

Peter

On Thu, Mar 18, 2021 at 10:05 PM Spencer Graves
 wrote:
>
>I would push back on that from two perspectives:
>
>
>  1.  I would study exactly what the journal said very
> carefully.  If they mandated "wilcox.test", that function has an
> argument called "exact".  If that's what they are asking, then using
> that argument gives the exact p-value, e.g.:
>
>
>  > wilcox.test(rnorm(100), rnorm(100, 2), exact=TRUE)
>
>  Wilcoxon rank sum exact test
>
> data:  rnorm(100) and rnorm(100, 2)
> W = 691, p-value < 2.2e-16
>
>
>  2.  If that's NOT what they are asking, then I'm not
> convinced what they are asking makes sense:  There is is no such thing
> as an "exact p value" except to the extent that certain assumptions
> hold, and all models are wrong (but some are useful), as George Box
> famously said years ago.[1]  Truth only exists in mathematics, and
> that's because it's a fiction to start with ;-)
>
>
>Hope this helps.
>Spencer Graves
>
>
> [1]
> https://en.wikipedia.org/wiki/All_models_are_wrong
>
>
> On 2021-3-18 11:12 PM, Bogdan Tanasa wrote:
> >   <https://meta.stackexchange.com/questions/362285/about-a-p-value-2-2e-16>
> > Dear all,
> >
> > i would appreciate having your advice on the following please :
> >
> > in R, the wilcox.test() provides "a p-value < 2.2e-16", when we compare
> > sets of 1000 genes expression (in the genomics field).
> >
> > however, the journal asks us to provide the exact p value ...
> >
> > would it be legitimate to write : "p-value = 0" ? thanks a lot,
> >
> > -- bogdan
> >
> >   [[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.

__
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] [Rd] R 4.0.4 is released

2021-02-15 Thread Peter Dalgaard
The build system rolled up R-4.0.4.tar.gz (codename "Lost Library Book") this 
morning.

The list below details the changes in this release.

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.0.4.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard

These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = a5596520508b8749aa18baea2cf8ff80
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = eeb2d15f39e0a38935de2c419b4263f7
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = 496062c138e2def06cebccddfb814ac6
MD5 (NEWS.3) = 012e7f4a80cc8ec947bf3f0ff6117ec8
MD5 (R-latest.tar.gz) = e205f000947f99eeba0fb6311bd61970
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = 6a5ad95f3b708ce0dc19bab8bbfc3bc0
MD5 (R-4/R-4.0.4.tar.gz) = e205f000947f99eeba0fb6311bd61970


2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
e9783551b3724b368a42c1300a8e5795ae84add34823c4eb9d8054a0e76f592c  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
2227d48d78c4d70d07c367ecd4c5ba60a04a699ed0391fabac3da6edffdaa5db  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
e80de410c77f05ff2012fa70051b89119845f734a7fa5c55857e61e4ed7d5f6e  NEWS.2
7201d139947afa52b5e09d26dc01445edf444506264355b2185122bc1ed3dce0  NEWS.3
523f27d69744a08c8f0bd5e1e6c3d89a4db29ed983388ba70963a3cd3a4a802e  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
6c5117e36f4e69f0cd90f3bab6e7fd47ec90b0047e2aaed145300ad4ece20ede  
VERSION-INFO.dcf
523f27d69744a08c8f0bd5e1e6c3d89a4db29ed983388ba70963a3cd3a4a802e  
R-4/R-4.0.4.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.0.4:

  NEW FEATURES:

* File share/texmf/tex/latex/jss.cls has been updated to work with
  LaTeX versions since Oct 2020.

* Unicode character width tables (as used by nchar(, type = "w"))
  have been updated to Unicode 12.1 by Brodie Gaslam (PR#17781),
  including many emoji.

* The internal table for iswprint (used on Windows, macOS and AIX)
  has been updated to include many recent Unicode characters.

  INSTALLATION on a UNIX-ALIKE:

* If an external BLAS is specified by --with-blas=foo or _via_
  environment variable BLAS_LIBS is not found, this is now a
  configuration error.  The previous behaviour was not clear from
  the documentation: it was to continue the search as if
  --with-blas=yes was specified.

  BUG FIXES:

* all.equal(x,y) now "sees" the two different NAs in factors,
  thanks to Bill Dunlap and others in PR#17897.

* (~ NULL)[1] and similar formula subsetting now works, thanks to a
  report and patch by Henrik Bengtsson in PR#17935.  Additionally,
  subsetting leaving an empty formula now works too, thanks to
  suggestions by Suharto Anggono.

* .traceback(n) keeps source references again, as before R 4.0.0,
  fixing a regression; introduced by the PR#17580, reported
  including two patch proposals by Brodie Gaslam.

* unlist(plst, recursive=FALSE) no longer drops content for
  pairlists with list components, thanks to the report and patch by
  Suharto Anggono in PR#17950.

* iconvlist() now also works on MUSL based (Linux) systems, from a
  report and patch suggestion by Wesley Chan in PR#17970.

* round() and signif() no longer tolerate wrong argument names,
  notably in 1-argument calls; reported by Shane Mueller on R-devel
  (mailing list); later reported as PR#17976.

* .Machine has longdouble.* elements only if
  capabilities("long.double") is true, as documented.  (Previously
  they were included if the platform had long double identical to
  double, as ARM does.)

* p.adjust(numeric(), n=0) now works, fixing PR#18002.

* identical(x,y) no longer prints "Unknown Type .." for typeof(x)
  == "..." objects.

* Fix (auto-)print()ing of named complex vectors, see PR#17868 and
  PR#18019.

* all.equal(, <...>) now works,

[R] [Rd] R 4.0.4 scheduled for February 15

2021-01-21 Thread Peter Dalgaard via R-help
Full schedule is available on https://developer.r-project.org (or 
https://svn.r-project.org/R-dev-web/trunk/index.html for the impatient).

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] Converting "day of year" to "year", "month" and "day"

2021-01-16 Thread peter dalgaard
04.
> 1998  70  0  530.
> 1998  71  0  525.
> 1998  72  0  484.
> 1998  73  0  430.
> 1998  74  0  388.
> 1998  75  0  347.
> 1998  76  0  337.
> 1998  77  0  342.
> 1998  78  0  305.
> 1998  79  0  329.
> 1998  80  0  420.
> 1998  81  0  564.
> 1998  82  0  483.
> 1998  83  0  385.
> 1998  84  0  393.
> 1998  85  0  437.
> 1998  86  0  441.
> 1998  87  0  434.
> 1998  88  0  471.
> 1998  89  0  429.
> 1998  90  0  412.
> 1998  91  0  370.
> 1998  92  0  326.
> 1998  93  0  357.
> 1998  94  0  338.
> 1998  95  0  380.
> 1998  96  0  339.
> 1998  97  0  312.
> 1998  98  0  313.
> 1998  99  0  327.
> 1998 100  0  362.
> 1998 101  0  358.
> 1998 102  0  387.
> 1998 103  0  397.
> 1998 104  0  375.
> 1998 105  0  350.
> 1998 106  0  357.
> 1998 107  0  472.
> 1998 108  0  526.
> 1998 109  0  396.
> 1998 110  0  374.
> 1998 111  0  376.
> 1998 112  0  355.
> 1998 113  0  343.
> 1998 114  0  425.
> 1998 115  0  426.
> 1998 116  0  479.
> 1998 117  0  469.
> 1998 118  0  425.
> 1998 119  0  344.
> 1998 120  0  341.
> 1998 121  0  426.
> 1998 122  0  601.
> 1998 123  0  476.
> 1998 124  0  670.
> 1998 125  0  585.
> 1998 126  0  496.
> 1998 127  0  479.
> 1998 128  0  569.
> 1998 129  0  531.
> 1998 130  0  489.
> 1998 131  0  484.
> 1998 132  0  480.
> 1998 133  0  393.
> 1998 134  0  332.
> 1998 135  0  327.
> 1998 136  0  493.
> 1998 137  0  493.
> 1998 138  0  430.
> 1998 139  0  396.
> 1998 140  0  408.
> 1998 141  0  416.
> 1998 142  0  376.
> 1998 143  0  375.
> 1998 144  0  415.
> 1998 145  0  407.
> 1998 146  0  398.
> 1998 147  0  352.
> 1998 148  0  349.
> 1998 149  0  517.
> 1998 150  0  597.
> 1998 151  0  480.
> 1998 152  0  435.
> 1998 153  0  408.
> 1998 154  0  441.
> 1998 155  0  397.
> 1998 156  0  374.
> 1998 157  0  413.
> 1998 158  0  582.
> 1998 159  0  513.
> 1998 160  0  459.
> 1998 161  0  466.
> 1998 162  0  414.
> 1998 163  0  354.
> 1998 164  0  341.
> 1998 165  0  343.
> 1998 166  0  369.
> 1998 167  0  411.
> 1998 168  0  355.
> Thanks
> Jibrin
> 
> On Fri, Jan 15, 2021 at 7:15 PM Rui Barradas  wrote:
> 
>> Hello,
>> 
>> No dataset was attached. Like the posting guide says,
>> 
>> No binary attachments except for PS, PDF, and some image and archive
>> formats (others are automatically stripped off because they can contain
>> malicious software). Files in other formats and larger ones should
>> rather be put on the web and have only their URLs posted. This way a
>> reader has the option to download them or not.
>> 
>> 
>> Can you post sample data? Please post the output of `dput(df)`. Or, if
>> it is too big the output of `dput(head(df, 20))`. (`df` is the name of
>> your dataset.)
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> Às 11:30 de 15/01/21, Jibrin Alhassan escreveu:
>>> Dear R users,
>>> I am very new to R software. I have solar wind speed data needed for my
>>> work. How do I convert day in the year to year, month, and day with R
>>> software? I have used this code
>>> as.Date(0, origin = "1998-01-01")
>>> but it can only convert one day of the year at a time. Meanwhile, I have
>> up
>>> to the 1998-2002 data set. Attached is my data.
>>> Kindly help, please.
>>> Jibrin Alhassan
>>> __
>>> 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.

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

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


Re: [R] Does anyone have any use for this?

2021-01-01 Thread Peter Langfelder
This would certainly simplify and make more readable some of my code where
I create multiple versions of the same plot calling the same function with
minor variations of a few of many arguments. Thanks!

Peter

On Fri, Jan 1, 2021 at 12:20 PM Bert Gunter  wrote:

> Hi all:
>
> In the course of playing around with other issues, I wrote the following
> little function that allows functions to keep state
> and easily replay and update their state.(see comments after):
>
> memify <- function(f)
> {
>if (is.primitive(f)) {
>   cat("Cannot memify primitive functions.\n")
>   return(NULL)
>}
>if (!inherits(f, "function"))
>   stop("Argument must inherit from class 'function'")
>arglist <- list()
>structure(
>   function(...) {
>  m <- tryCatch(
> as.list(match.call(f)[-1]),
> error = function(e) {
>warning("Bad function call; cannot update arguments\n")
>return(NULL)
> }
>  )
>  nm <- names(m)
>  hasname <- nm != "" #logical index of named values
>  if (any(hasname)) {
> if (anyDuplicated(nm, incomparables = ""))
>warning("Duplicated names in call; only the first will be
> used.")
> arglist <<- modifyList(arglist, m[hasname]) ## this is what
> does the job
>  }
>  do.call(f, modifyList(m, arglist))
>   },
>   class = c("memified", class(f)))
> }
>
> Examples:
>
>  x <- 1:9; y <- runif(9)
>  plt <- memify(plot)
>  x <- 1:9; y <- runif(9)
>  plt(x,y, col = "blue")  ## plt "remembers" these arguments; i.e. keeps
> state
>  plt( type = "b") ## all other arguments as previous
>  plt(col = "red") ## ditto
>
> So my question is: Beyond allowing one to easily change/add argument values
> and replay when there are lots of arguments floating around, which we often
> use an IDE's editor to do, is there any real use for this? I confess that,
> like Pygmalion, I have been charmed by this idea, but it could well be
> useless, By all means feel free to chastise me if so.
>
> 1. I am aware that many functions already have "update" methods to "update"
> their results without re-entering all arguments -- e.g. lattice graphics,
> glm, etc.
> 2. Several packages -- rlang and R6 anyway -- but very likely more, do this
> sort of thing and way more; the price is added complexity, of course.
> 3. I realize also that keeping state would be a bad idea in many
> circumstances, e.g. essentially changing documented defaults.
>
> Reply privately to praise or bury if you do not think this is of any
> interest to readers of this list. Publicly is fine, too. If it's dumb it's
> dumb.
>
> Cheers and best wishes for a better new year for us all,
>
> Bert Gunter
>
> [[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] Error pvclust package: Error in hclust(distance, method = method.hclust)

2020-12-14 Thread Peter Langfelder
I don't use pvclust but from a cursory reading and from the error
indicating bootstrap I am guessing that pvclust carries out some sort of a
sampling of the features on which you cluster. Since you only retain two
features (coordinates), the sampling necessarily results in just one
feature being retained, leading to an error. Just my guess though;
understanding what pvclust does would help you diagnose the problem.

Peter

On Mon, Dec 14, 2020 at 2:48 PM Jovani T. de Souza 
wrote:

> This question was also made in
>
> https://stackoverflow.com/questions/65290436/error-pvclust-package-error-in-hclustdistance-method-method-hclust-must
>
> Question:
>
> Could you help me resolve the following error:
>
> Error in hclust(distance, method = method.hclust) :
>   must have n >= 2 objects to cluster
>
> I'm trying to use the `pvclust` package, but I'm not able to generate the
> dendogram. If I use all data from the df database, I can generate it, but
> as I am restricting only to the coordinates (Latitude and Longitude), it is
> not working, it gives the error that I mentioned. Below, I entered an
> executable code.
>
> Thank you so much!
>
>
> ###USING PVCLUST
>
> library(rdist)
> library(pvclust)
> library(geosphere)
>
> df <- structure(
>   list(Industries = c(1,2,3,4,5,6,7), Latitude = c(-24.779225,
> -24.789635, -24.763461, -24.794394, -24.747102,-24.781307,-24.761081),
>Longitude = c(-49.934816, -49.922324, -49.911616, -49.906262,
> -49.890796,-49.8875254,-49.8875254),
>Waste = c(526, 350, 526, 469, 285, 433, 456)),class =
> "data.frame", row.names = c(NA, -7L))
>
> mat <- as.data.frame.matrix(df)
> mat <- t(mat)
> fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
> fit
> plot(fit)
> pvrect(fit)
>
>
> # RESTRICTING ONLY TO COORDINATES
> coordinates<-subset(df,select=c("Latitude","Longitude"))
> mat <- as.data.frame.matrix(coordinates)
> mat <- t(mat)
> fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
> > fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
> Bootstrap (r = 0.5)... Error in hclust(distance, method =
> method.hclust) :
>   must have n >= 2 objects to cluster*
>
>
>
>
> [image: Mailtrack]
> <
> https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;
> >
> Remetente
> notificado por
> Mailtrack
> <
> https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;
> >
> 14/12/20
> 19:37:37
>
> [[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] newdata for predict.lm() ??

2020-11-04 Thread peter dalgaard
Don't use $ notation in lm() formulas. Use lm(w ~ h, data=DAT).

-pd

> On 4 Nov 2020, at 10:50 , Boris Steipe  wrote:
> 
> Can't get data from a data frame into predict() without a detour that seems 
> quite unnecessary ...
> 
> Reprex:
> 
> # Data frame with simulated data in columns "h" (independent) and "w" 
> (dependent)
> DAT <- structure(list(h = c(2.174, 2.092, 2.059, 1.952, 2.216, 2.118, 
>1.755, 2.060, 2.136, 2.126, 1.792, 1.574,
>2.117, 1.741, 2.295, 1.526, 1.666, 1.581,
>1.522, 1.995), 
>  w = c(90.552, 89.518, 84.124, 94.685, 94.710, 82.429,
>87.176, 90.318, 76.873, 84.183, 57.890, 62.005,
>84.258, 78.317,101.304, 64.982, 71.237, 77.124,
>65.010, 81.413)),
> row.names = c( "1",  "2",  "3",  "4",  "5",  "6",  "7", 
>"8",  "9", "10", "11", "12", "13", "14",
>   "15", "16", "17", "18", "19", "20"),
> class = "data.frame")
> 
> 
> myFit <- lm(DAT$w ~ DAT$h)
> coef(myFit)
> 
> # (Intercept)   DAT$h 
> #   11.7647535.92002 
> 
> 
> # Create 50 x-values with seq() to plot confidence intervals
> myNew <- data.frame(seq(min(DAT$h), max(DAT$h), length.out = 50))
> 
> pc <- predict(myFit, newdata = myNew, interval = "confidence")
> 
> # Warning message:
> # 'newdata' had 50 rows but variables found have 20 rows 
> 
> # Problem: predict() was not able to take the single column in myNew
> # as the independent variable.
> 
> # Ugly workaround: but with that everything works as expected.
> xx <- DAT$h
> yy <- DAT$w
> myFit <- lm(yy ~ xx)
> coef(myFit)
> 
> myNew <- data.frame(seq(min(DAT$h), max(DAT$h), length.out = 50))
> colnames(myNew) <- "xx"  # This fixes it!
> 
> pc <- predict(myFit, newdata = myNew, interval = "confidence")
> str(pc)
> 
> # So: specifying the column in newdata to have same name as the coefficient
> # name should work, right?
> # Back to the original ...
> 
> myFit <- lm(DAT$w ~ DAT$h)
> colnames(myNew) <- "`DAT$h`"
> # ... same error
> 
> colnames(myNew) <- "h"
> # ... same error again.
> 
> Bottom line: how can I properly specify newdata? The documentation is opaque. 
> It seems the algorithm is trying to EXACTLY match the text of the RHS of the 
> formula, which is unlikely to result in a useful column name, unless I assign 
> to an intermediate variable. There must be a better way ...
> 
> 
> 
> Thanks!
> Boris
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


[R] [Rd] R 4.0.3 is released

2020-10-10 Thread Peter Dalgaard
The build system rolled up R-4.0.3.tar.gz (codename "Bunny-Wunnies Freak Out") 
this morning.

The list below details the changes in this release.

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.0.3.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard

These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 5be656453b81e9393e2a0c42688b04b8
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 71728ef32a09c5b9df36b496b52d5c8e
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801
MD5 (NEWS.2) = 496062c138e2def06cebccddfb814ac6
MD5 (NEWS.3) = 012e7f4a80cc8ec947bf3f0ff6117ec8
MD5 (R-latest.tar.gz) = 8ecf46afa36c9aff9904aad5ca422c6d
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435
MD5 (THANKS) = 251d20510bfc3cc93b82c5a99f7efcc6
MD5 (VERSION-INFO.dcf) = bfbcfb2f4ef4416b635087160f965904
MD5 (R-4/R-4.0.3.tar.gz) = 8ecf46afa36c9aff9904aad5ca422c6d

2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
4390543804392e072378b2d75cd3fb0d57e9885f9dc38ddd5a2ff780487b9d97  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
895ba3f810fd33d3be63deb6c4588be1f7ba3f5bf80e10ffeafc194221dd5ba9  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01  NEWS.1
e80de410c77f05ff2012fa70051b89119845f734a7fa5c55857e61e4ed7d5f6e  NEWS.2
7201d139947afa52b5e09d26dc01445edf444506264355b2185122bc1ed3dce0  NEWS.3
09983a8a78d5fb6bc45d27b1c55f9ba5265f78fa54a55c13ae691f87c5bb9e0d  
R-latest.tar.gz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9  RESOURCES
c9c7cb32308b4e560a22c858819ade9de524a602abd4e92d1c328c89f8037d73  THANKS
cd9666c09064b120655598c1ac792266ad20adb57c36aab4d094dedc7e480fa6  
VERSION-INFO.dcf
09983a8a78d5fb6bc45d27b1c55f9ba5265f78fa54a55c13ae691f87c5bb9e0d  
R-4/R-4.0.3.tar.gz

This is the relevant part of the NEWS file

CHANGES IN R 4.0.3:

  NEW FEATURES:

* On platforms using configure option --with-internal-tzcode,
  additional values "internal" and (on macOS only) "macOS" are
  accepted for the environment variable TZDIR.  (See ?TZDIR.)

  On macOS, "macOS" is used by default if the system timezone
  database is a newer version than that in the R installation.

* When install.packages(type = "source") fails to find a package in
  a repository it mentions package versions which are excluded by
  their R version requirement and links to hints on why a package
  might not be found.

* The default value for options("timeout") can be set from
  enviromnent variable R_DEFAULT_INTERNET_TIMEOUT, still defaulting
  to 60 (seconds) if that is not set or invalid.

  This may be needed when child R processes are doing downloads,
  for example during the installation of source packages which
  download jars or other forms of data.

  LINK-TIME OPTIMIZATION on a UNIX-ALIKE:

* There is now support for parallelized Link-Time Optimization
  (LTO) with GCC and for 'thin' LTO with clang _via_ setting the
  LTO macro.

* There is support for setting a different LTO flag for the Fortran
  compiler, including to empty when mixing clang and gfortran (as
  on macOS).  See file config.site.

* There is a new LTO_LD macro to set linker options for LTO
  compilation, for example to select an alternative linker or to
  parallelize thin LTO.

  DEPRECATED AND DEFUNCT:

* The LINPACK argument to chol.default(), chol2inv(),
  solve.default() and svd() has been defunct since R 3.1.0.  Using
  it now gives a warning which will become an error in R 4.1.0.

  BUG FIXES:

* The code mitigating stack overflow with PCRE regexps on very long
  strings is enabled for PCRE2 < 10.30 also when JIT is enabled,
  since stack overflows have been seen in that case.

* Fix to correctly show the group labels in dotchart() (which where
  lost in the ylab improvement for R 4.0.0).

* addmargins(*, ..) now also works when fn() is a local function,
  thanks to bug report and patch PR#17124 from Alex Bertram.

* rank(x) and hence sort(x) now work when x is an object (as per
  is.object(x)) of type "raw" _

Re: [R] RStudio question

2020-10-08 Thread peter dalgaard
This list has a no-homework policy. I assume that your teaching material has 
examples that are sufficiently similar so that you should be able to modify 
them.

-pd

> On 8 Oct 2020, at 10:10 , Xavier Garcia via R-help  
> wrote:
> 
> I'm solving the following problem: Create a variable (column) in the “wf”
> dataframe named “Zone” that takes value of “tropic” if Latitude is less
> than or equal to 30, or “non-tropic” for Latitude greater than 30. Show you
> Zone variable. Latitude is a column of my dataframe. I don't know the
> sintaxis and the process to create the column.
> 
>   [[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.

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

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


Re: [R] understanding as.list(substitute(...()))

2020-10-06 Thread peter dalgaard



> On 6 Oct 2020, at 09:22 , Dénes Tóth  wrote:
> 
> > foo <- function(...) substitute({...()})
> > foo(abc$de, fg[h], i)
> {
>   pairlist(abc$de, fg[h], i)
> }
> > foo(abc$de, fg[h], , i) # add a missing argument for extra fun
> {
>   as.pairlist(alist(abc$de, fg[h], , i))
> }
> 

The 2nd one here is actually an artifact of deparse(). The result is still a 
pairlist, just one that pairlist() cannot reproduce:

> e <- foo(abc$de, fg[h], , i) 
> e[[2]]
[[1]]
abc$de

[[2]]
fg[h]

[[3]]


[[4]]
i

> deparse(e[[2]])
[1] "as.pairlist(alist(abc$de, fg[h], , i))"
> dput(e[[2]])
as.pairlist(alist(abc$de, fg[h], , i))
> mode(e[[2]])
[1] "pairlist"
> mode(e[[2]][[3]])
[1] "name"

I.e. the list in e[2] contains the missing indicator (an empty name). (I'm 
slightly puzzled why we need the curlies to trigger a deparse, though) 



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

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


[R] [Rd] R 4.0.3 scheduled for October 10

2020-10-05 Thread Peter Dalgaard via R-help
[Oops, this apparently got omitted during release scheduling]

Full schedule is available on developer.r-project.org.

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

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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


Re: [R] (no subject)

2020-10-01 Thread Peter Dalgaard
Then please follow the link in the footer. Other recipients can't help you.


> On 1 Oct 2020, at 09:30 , Marte Lilleeng  wrote:
> 
> I want to unsubscribe from this list.
> 
> -- 
> Mvh Marte Synnøve Lilleeng
> tlf 97 74 38 12
> 
>   [[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.

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

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


[R] help to create a simulated dataset

2020-09-29 Thread Peter Wagey
Hi R User,
I was trying to create a data matrix with four columns: height, locations
(three locations), temperature (three levels) and slope (three classes) and
used the following code, but it did not work.  I basically wanted to have
20 rows for each class (I have a total of 9 classes). Can you help me to
fix the following code so that I can create the data frame?

daT<-data.frame(height=c(5:15))

minHeight=min(daT$height)

maxHeight=max(daT$height)

height.value= minHeight +(0:20)*(maxHeight-minHeight)/20


daT<-data.frame(height=height.value, location=rep(c("SiteA", "SiteB",
"SiteC"), 20), temperature=rep(c(10,20,30)), slope=rep(c("5deg", "10deg",
"15deg")))


Thanks

[[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] open file on R GUI results in spinning wheel and frozen R - Mac OS

2020-09-23 Thread Peter Dalgaard
...or try R-patched, which I'm told has the newer GUI.

-pd

> On 21 Sep 2020, at 21:43 , Berend Hasselman  wrote:
> 
> 
> 
>> On 21 Sep 2020, at 20:24, Gonçalo Ferraz  wrote:
>> 
>> Hello,
>> 
>> I’ve been using R-studio for a while and today I needed to try something 
>> directly on the R-GUI.
>> 
>> But when I try to open any *.R file I get a spinning wheel and R freezes. I 
>> can only shut it down with ‘force quit’.
>> 
>> I have deleted and re-installed R three times, each time trying to run a 
>> more thorough uninstall, but the problem persists.
>> 
>> I am using Mac OS Catalina 10.15.6 and the latest version of R ->  R 4.0.2 
>> GUI 1.72 Catalina build (7847)
>> 
>> Strangely, as this problem was happening on the R GUI, I was still able to 
>> open R scripts on RStudio. But now I uninstalled RStudio as well, in the 
>> latest attempt to start from scratch.
>> 
>> Is this problem familiar to anyone?
>> 
> 
> See this thread on the R-SIG-Mac list: 
> https://stat.ethz.ch/pipermail/r-sig-mac/2020-June/013575.html
> and her for a solution (sequel of above): 
> https://stat.ethz.ch/pipermail/r-sig-mac/2020-July/013641.html
> 
> Go to https://mac.r-project.org/ and get the latest revision of the R GUI 
> which is noe 
> https://mac.r-project.org/high-sierra/R-4.0-branch/R-GUI-7884-4.0-high-sierra-Release.dmg
> 
> I have revision 7849; if the above does not work I can mail you the dmg of 
> revision 7849.
> 
> Berend
> 
> 
> 
>> Thanks for any help,
>> 
>> Gonçalo
>> __
>> 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.

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

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


[R] How can we get a predicted value that are used to plot the figure using a plot_model function of sjPlot?

2020-09-19 Thread Peter Wagey
Hi R users,
I was trying to create a figure of three-way-interactions. There is a
function "plot-model" but I was wondering whether we can extract the
predicted value before we run the "plot-model" function.
For example:
in this example,
plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]",
"c161sex"))
How can we see the predicted values that are used to plot the figure? If we
can see the data (predicted values), we could use other functions to create
another type of figures.
Thank you very much for your suggestions.

Thanks,

Peter
#
library(sjPlot)
library(sjmisc)
library(ggplot2)
data(efc)
theme_set(theme_sjplot())

# make categorical
efc$c161sex <- to_factor(efc$c161sex)

# fit model with 3-way-interaction
fit <- lm(neg_c_7 ~ c12hour * barthtot * c161sex, data = efc)

# select only levels 30, 50 and 70 from continuous variable Barthel-Index
plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]",
"c161sex"))

How can we get the predicted value that is used to plot the graph? we would
like to see the predicted value using three groups of barthtot
[30,50,70].Is there any way we can extract the data (predicted value) so
that we can use other graphic functions to create figures?

[[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] Assigning cores

2020-09-03 Thread Peter Langfelder
The big question is whether each worker or thread uses parallel
processing itself, or whether it uses resources like cache in which
case 20 threads fighting over the cache would slow you down
substantially. If your simulations use operations implemented in BLAS
or LAPACK, be aware that some R installations use custom fast BLAS
that can use multiple cores and the processor cache. You can see some
of it in sessionInfo().

The other issue is memory usage - if you exhaust your physical RAM,
your computer will slow down not so much because of CPU load but
rather because of memory management (swapping to and from disk).

I would run some smaller experimental runs that take just a minute or
two to finish with say 4, 8 and 12 workers and see how fast these go -
you may find no or very little speed up past 8 or perhaps even 4-6
workers.

HTH,

Peter

On Thu, Sep 3, 2020 at 10:45 AM Leslie Rutkowski
 wrote:
>
> Hi all,
>
> I'm working on a large simulation and I'm using the doParallel package to
> parallelize my work. I have 20 cores on my machine and would like to
> preserve some for day-to-day activities - word processing, sending emails,
> etc.
>
> I started by saving 1 core and it was clear that *everything* was so slow
> as to be nearly unusable.
>
> Any suggestions on how many cores to hold back (e.g., not to put to work on
> the parallel process)?
>
> Thanks,
> Leslie
>
> [[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] Odd Results when generating predictions with nnet function

2020-09-02 Thread peter dalgaard
The problem seems to be the fit rather than the predictions. Looks like nnet is 
happier with data between 0 and 1, witness

Fit <- nnet(y/max(y) ~ x, a, size = 5, maxit = 1000, lineout = T, decay = 0.001)
plot(y/max(y)~x,a)
lines(fitted(Fit)~x,a)


> On 2 Sep 2020, at 16:21 , Paul Bernal  wrote:
> 
> Dear Dr. Martin and Dr. Peter, 
> 
> Hope you are doing well. Thank you for your kind feedback. I also tried 
> fitting the nnet using y ~ x, but the model kept on generating odd 
> predictions. If I understand correctly, from what Dr. Martin said, it would 
> be a good idea to try modeling sqrt(y) ~ x and then backtransform raising 
> both y and x to 0.5?
> 
> I was looking at a video where the guy modeled count data without doing any 
> kind of transformation and didn't get odd results, which is rather extrange.
> 
> Cheers,
> 
> Paul
> 
> 
> 
> El mié., 2 sept. 2020 a las 2:37, Martin Maechler 
> () escribió:
> >>>>> peter dalgaard 
> >>>>> on Wed, 2 Sep 2020 08:41:09 +0200 writes:
> 
> > Generically, nnet(a$y ~ a$x, a ...) should be nnet(y ~ x,
> > data=a, ...) otherwise predict will go looking for a$x, no
> > matter what is in xnew.  
> 
> > But more importantly, nnet() is a _classifier_, 
> > so the LHS should be a class, not a numeric variable.
> 
> > -pd
> 
> Well, nnet() can be used for both classification *and* regression,
> which is quite clear from the MASS book, but indeed, not from
> its help page, which indeed mentions one formula  'class ~ ...'
> and then only has classification examples.
> 
> So, indeed, the  ?nnet  help page could improved.
> 
> In his case, y are counts,  so  John Tukey's good old
> "first aid transformation" principle would suggest to model
> 
> sqrt(y) ~ ..   in a *regression* model which nnet() can do.
> 
> Martin Maechler
> ETH Zurich  and  R Core team
> 
> 
> 
> >> On 1 Sep 2020, at 22:19 , Paul Bernal
> >>  wrote:
> >> 
> >> Dear friends,
> >> 
> >> Hope you are all doing well. I am currently using R
> >> version 4.0.2 and working with the nnet package.
> >> 
> >> My dataframe consists of three columns, FECHA which is
> >> the date, x, which is a sequence from 1 to 159, and y,
> >> which is the number of covid cases (I am also providing
> >> the dput for this data frame below).
> >> 
> >> I tried fitting a neural net model using the following
> >> code:
> >> 
> >> xnew = 1:159 Fit <- nnet(a$y ~ a$x, a, size = 5, maxit =
> >> 1000, lineout = T, decay = 0.001)
> >> 
> >> Finally, I attempted to generate predictions with the
> >> following code:
> >> 
> >> predictions <- predict(Fit, newdata = list(x = xnew),
> >> type = "raw")
> >> 
> >> But obtained extremely odd results: As you can see,
> >> instead of obtaining numbers, more or less in the range
> >> of the last observations of a$y, I end up getting a bunch
> >> of 1s, which doesn´t make any sense (if anyone could help
> >> me understand what could be causing this):
> >> dput(predictions) structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim
> >> = c(159L, 1L), .Dimnames = list(c("1", "2", "3", "4",
> >> "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
> >> "15", "16", "17", "18", "19", "20", "21", "22", "23",
> >> "24", "25", "26", "27", "28", "29", "30", "31", "32",
> >> "33", "34", "35", "36", "37", "38", "39", "40", "41&qu

Re: [R] Odd Results when generating predictions with nnet function

2020-09-02 Thread peter dalgaard
50, 18351,
> 18352, 18353, 18354, 18355, 18356, 18357, 18358, 18359, 18360,
> 18361, 18362, 18363, 18364, 18365, 18366, 18367, 18368, 18369,
> 18370, 18371, 18372, 18373, 18374, 18375, 18376, 18377, 18378,
> 18379, 18380, 18381, 18382, 18383, 18384, 18385, 18386, 18387,
> 18388, 18389, 18390, 18391, 18392, 18393, 18394, 18395, 18396,
> 18397, 18398, 18399, 18400, 18401, 18402, 18403, 18404, 18405,
> 18406, 18407, 18408, 18409, 18410, 18411, 18412, 18413, 18414,
> 18415, 18416, 18417, 18418, 18419, 18420, 18421, 18422, 18423,
> 18424, 18425, 18426, 18427, 18428, 18429, 18430, 18431, 18432,
> 18433, 18434, 18435, 18436, 18437, 18438, 18439, 18440, 18441,
> 18442, 18443, 18444, 18445, 18446, 18447, 18448, 18449, 18450,
> 18451, 18452, 18453, 18454, 18455, 18456, 18457, 18458, 18459,
> 18460, 18461, 18462, 18463, 18464, 18465, 18466, 18467, 18468,
> 18469, 18470, 18471, 18472, 18473, 18474, 18475, 18476, 18477,
> 18478, 18479, 18480, 18481, 18482, 18483, 18484, 18485, 18486,
> 18487, 18488), class = "Date"), x = 1:159, y = c(1, 8, 14, 27,
> 36, 43, 55, 69, 86, 109, 137, 200, 245, 313, 345, 443, 558, 674,
> 786, 901, 989, 1075, 1181, 1317, 1475, 1673, 1801, 1988, 2100,
> 2249, 2528, 2752, 2974, 3234, 3400, 3472, 3574, 3751, 4016, 4210,
> 4273, 4467, 4658, 4821, 4992, 5166, 5338, 5538, 5779, 6021, 6200,
> 6378, 6532, 6720, 7090, 7197, 7387, 7523, 7731, 7868, 8070, 8282,
> 8448, 8616, 8783, 8944, 9118, 9268, 9449, 9606, 9726, 9867, 9977,
> 10116, 10267, 10577, 10926, 11183, 11447, 11728, 12131, 12531,
> 13015, 13463, 13837, 14095, 14609, 15044, 15463, 16004, 16425,
> 16854, 17233, 17889, 18586, 19211, 20059, 20686, 21422, 21962,
> 22597, 23351, 24274, 25222, 26030, 26752, 27314, 28030, 29037,
> 29905, 30658, 31686, 32785, 33550, 34463, 35237, 35995, 36983,
> 38149, 39334, 40291, 41251, 42216, 43257, 44352, 45633, 47177,
> 48096, 49243, 50373, 51408, 52261, 53468, 54426, 55153, 55906,
> 56817, 57993, 58864, 60296, 61442, 62223, 63269, 64191, 65256,
> 66383, 67453, 68456, 69424, 70231, 71418, 72560, 73651, 74492,
> 75394, 76464, 77377, 78446, 79402)), row.names = c(NA, 159L), class =
> "data.frame")
> Any help and/or guidance will be greatly appreciated,
> 
> Cheers,
> 
> Paul
> 
>   [[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.

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

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


Re: [R] Can I use "mcnemar.test" for 3*3 tables (or is there a bug in the command?)

2020-08-31 Thread peter dalgaard



> On 30 Aug 2020, at 20:11 , Kyungmin Ko  wrote:
> 
>> 2) The second one is to produce a 3 by 3 table, with the rows indicating
>> what the kids answered to setting 1 of the experiment, and the columns
>> indicating the kids answers to setting 2.
>> Now the question is:
>> was there marginal homogenity? if not, then that is an indicator that the
>> general response to the experimental settings was different for the kids.
> 
>> 1) can I use "mcnemar.test" for 3*3 (or more) tables ?
> As Peter Dalgaard and jchavez12 (on Nabble) pointed out,

Um, that was on July 19, 2009.

> "mcnemar.test" does McNemar-Bowker test (Bowker's test) which tests
> symmetry, not marginal homogeneity.
> Marginal homogeneity and symmetry are equivalent in 2x2 matrices but
> not for larger tables.
> I also was confused because many resources (for example Wikipedia
> accessed 2020-08-30) introduce McNemar's test as a test of marginal
> homogeneity (which it is only for 2x2 matrices).
> The R Reference Manual entry for mcnemar.test states that it tests for 
> symmetry.
> The code for mcnemar.test is also consistent with the McNemar-Bowker
> test for symmetry.
> 
>> Is there a bug in the command?
> Since the function does what the manual states it does, I would not
> call this a bug.
> Although, I would like it if the result of mcnemar.test would print
> "McNemar's Chi-squared test of symmetry" rather than just "McNemar's
> Chi-squared test."
> 
>> Is the one necessarily better then the other? (for example for
>> sparser matrices ?)
> mcnemar.test often fails for sparse matrices, because symmetric zeros
> produce a NaN due to division by zero in the following line of
> mcnemar.test code:
> STATISTIC <- sum(y[upper.tri(x)]^2/x[upper.tri(x)])
> The McNemar-Bowker test uses Chi-squared approximation, which would
> not be good for small counts (and sparse matrices).
> mcnemar.test does not perform continuity correction for matrices
> larger than 2x2.
> Is there an exact test for symmetry of matrices larger than 2x2?
> I could not find one.

The exact test for the 2x2 case is isomorphic to a binomial test of the two 
off-diagonal elements (conditioning on the sum).

The natural way of constructing a test for the k x k case would be based on the 
Cartesian product of k(k-1)/2 binomials with p=.5, (one for each 
i,j-combination). This shouldn't be too hard if k is small, but of course it 
explodes combinatorially as k increases.

-pd

> 
>> Is there a bug in the command?
> I would not call this a bug.
> This behavior of giving "NA" due to a division by zero seems to be
> consistent across statistical tests in R.
> For example chisq.test(matrix(c(0, 0, 1, 2), nrow = 2) gives NA.
> 
>> So which one is "right" ?
> You have the option of the McNemar-Bowker test for symmetry
> (mcnemar.test), and Stuart-Maxwell test (mh_test).
> As an "indicator that the general response to the experimental
> settings was different for the kids,"
> I would think that if marginal homogeneity is rejected, the two tests
> are not equivalent.
> I would run mh_test with distribution = "exact" .
> The relationship between symmetry and equivalence of two tests is not
> as clear to me.
> I suppose if the two experimental settings are equivalent and the
> distribution of random error for each test are also the same the
> resulting matrix would be symmetric?
> 
> R 4.0.2 . coin 1.3.1 .
> 
> ______
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] How to obtain individual log-likelihood value from glm?

2020-08-29 Thread peter dalgaard
Briefly, you shouldn't. One way of seeing it is if you switch the model to y~1, 
you still get logLik==0.

The root cause is the rounding in binomial()$aic:

> binomial()$aic
function (y, n, mu, wt, dev) 
{
m <- if (any(n > 1)) 
n
else wt
-2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * y), 
round(m), mu, log = TRUE))
}

which, if wt is small enough ends up calculating dbinom(0, 0, p, log=TRUE) 
which is zero. 

(Not rounding gives you NaN, because you're trying to fit a model with a 
non-integer number of observations.)

-pd

> On 29 Aug 2020, at 03:28 , John Smith  wrote:
> 
> If the weights < 1, then we have different values! See an example below. How  
> should I interpret logLik value then?
> 
> set.seed(135)
>  y <- c(rep(0, 50), rep(1, 50))
>  x <- rnorm(100)
>  data <- data.frame(cbind(x, y))
>  weights <- c(rep(1, 50), rep(2, 50))
>  fit <- glm(y~x, data, family=binomial(), weights/10)
>  res.dev <- residuals(fit, type="deviance")
>  res2 <- -0.5*res.dev^2
>  cat("loglikelihood value", logLik(fit), sum(res2), "\n")
> 
> On Tue, Aug 25, 2020 at 11:40 AM peter dalgaard  wrote:
> If you don't worry too much about an additive constant, then half the 
> negative squared deviance residuals should do. (Not quite sure how weights 
> factor in. Looks like they are accounted for.)
> 
> -pd
> 
> > On 25 Aug 2020, at 17:33 , John Smith  wrote:
> > 
> > Dear R-help,
> > 
> > The function logLik can be used to obtain the maximum log-likelihood value
> > from a glm object. This is an aggregated value, a summation of individual
> > log-likelihood values. How do I obtain individual values? In the following
> > example, I would expect 9 numbers since the response has length 9. I could
> > write a function to compute the values, but there are lots of
> > family members in glm, and I am trying not to reinvent wheels. Thanks!
> > 
> > counts <- c(18,17,15,20,10,20,25,13,12)
> > outcome <- gl(3,1,9)
> > treatment <- gl(3,3)
> > data.frame(treatment, outcome, counts) # showing data
> > glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
> > (ll <- logLik(glm.D93))
> > 
> >   [[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.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
> 

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

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


Re: [R] How to obtain individual log-likelihood value from glm?

2020-08-29 Thread peter dalgaard



> On 25 Aug 2020, at 18:40 , peter dalgaard  wrote:
> 
> If you don't worry too much about an additive constant, then half the 
> negative squared deviance residuals should do. (Not quite sure how weights 
> factor in. Looks like they are accounted for.)
> 
> -pd
> 
>> On 25 Aug 2020, at 17:33 , John Smith  wrote:
>> 
>> Dear R-help,
>> 
>> The function logLik can be used to obtain the maximum log-likelihood value
>> from a glm object. This is an aggregated value, a summation of individual
>> log-likelihood values. How do I obtain individual values? In the following
>> example, I would expect 9 numbers since the response has length 9. I could
>> write a function to compute the values, but there are lots of
>> family members in glm, and I am trying not to reinvent wheels. Thanks!
>> 
>> counts <- c(18,17,15,20,10,20,25,13,12)
>>outcome <- gl(3,1,9)
>>treatment <- gl(3,3)
>>data.frame(treatment, outcome, counts) # showing data
>>glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
>>(ll <- logLik(glm.D93))
>> 
>>  [[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.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
> 

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

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


Re: [R] Importing data using Foreign

2020-08-26 Thread peter dalgaard
It is because you don't know whether you want it or not. 

It is a bit more obvious with integer indexing, as in color[race]: if race is 
NA you don't know what color to put in, but the result should be the same 
length as race. 

With logical indices, the behaviour is a bit annoying, but ultimately follows 
from the coercion rules: You might think that you could treat NA as FALSE (& 
the subset() function does just that), but then you'd get the problem that 
x[NA] would differ from x[as.integer(NA)] because NA is of mode "logical", 
lowest in the coercion hierarchy.

-pd

> On 26 Aug 2020, at 17:06 , Elham Daadmehr  wrote:
> 
> Thanks guys. but I'm a bit confused. the input is the first column (z[,1] and 
> z1[,1]).
> How is it possible that a subset of a non-NA vector, contains NA?
> 
> On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:
> Good point! :-)
> 
> 
> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
> Offhand, I suspect that the NAs are in the 8th column.
> 
> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> > 
> > Hi all,
> > 
> > I have a simple problem. I get stuck in using the imported spss data (.sav)
> > using "read.spss".
> > I imported data (z) without any problem. After importing, the first column
> > doesn't contain any "NA". but when I choose a subset of it (like:
> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> > first column).
> > 
> > The (.sav) file is the output of Compustat (WRDS).
> > 
> > It is terrible, I can't find the mistake.
> > 
> > Thank you in advance for your help,
> > Elham
> > 
> >   [[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.
> 
> -- 
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Importing data using Foreign

2020-08-26 Thread peter dalgaard
Offhand, I suspect that the NAs are in the 8th column.

> On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> 
> Hi all,
> 
> I have a simple problem. I get stuck in using the imported spss data (.sav)
> using "read.spss".
> I imported data (z) without any problem. After importing, the first column
> doesn't contain any "NA". but when I choose a subset of it (like:
> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> first column).
> 
> The (.sav) file is the output of Compustat (WRDS).
> 
> It is terrible, I can't find the mistake.
> 
> Thank you in advance for your help,
> Elham
> 
>   [[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.

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

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


Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
To be honest, I've only used the hex values as that was the format in which the 
patterns were passed to me. 

However from your explanation, I now understand what's going on. I didn't 
appreciate that the characters were passed to another layer and not seeing the 
hex code as the raw backslash. 

Many thanks for the explanation. 

> On 25 Aug 2020, at 20:53, Jeff Newmiller  wrote:
> 
> In my opinion, using hexadecimal ASCII is much more obscure than simply 
> using the escape character properly... that is, you are doing no-one any 
> favors by using them. But to attain clarity here, you need to envision what 
> the various software layers are doing.
> 
> In your case, SQLServer may not utilize escape character, but it is passing 
> your R code to the R interpreter, which does use the escape character to 
> convert source code into strings in memory, which are then passed into the 
> regex parser, which is the final layer that also handles the same escape 
> character. 
> 
> What may be confusing you is the distinction between what is in memory that 
> the regex parser sees:
> 
> ["',?\\`]
> 
> and what the R string literal looks like that you should type to get this 
> string into memory:
> 
> "[\"',?`]"
> 
> When you pass the latter literal to the cat() function, it will show you the 
> former version. When you have the literal stored in memory, you can use the 
> print() function to see what you have to type as a literal string to get the 
> in-memory version. I use this trick (cat) to help me zero in on what is 
> actually getting passed to the regex engine when I have difficulty 
> envisioning what is going on.
> 
> The regex engine needs that doubled backslash to recognize that _it_ should 
> not give special treatment to the \ there, and should look for it in the 
> input data.
> 
>> On August 25, 2020 12:16:35 PM PDT, Peter Bishop  
>> wrote:
>> The feed is coming from a SQL table and this is using the embedded
>> support for R which comes with SQL 2016. The source is therefore a
>> SELECT statement.
>> 
>> 
>> As an aside, I found a workaround by changing the pattern from:
>> 
>> 
>> "[\x22\x27\x2c\x3f\x5c\x60]"
>> 
>> 
>> to:
>> 
>> 
>> "[\x22\x27\x2c\x3f\x5c\x5c\x60]"
>> 
>> 
>> This seems to be escaping the backslash in the R script rather than in
>> the data - which confuses me.
>> 
>> 
>> From: Bert Gunter 
>> Sent: Wednesday, 26 August 2020 4:26 AM
>> To: Peter Bishop 
>> Cc: r-help@r-project.org 
>> Subject: Re: [R] Matching backslash in a table's column using R
>> language
>> 
>> 1. I am far from an expert on such matters
>> 2. It is unclear to me what your input is -- I assume a file.
>> 
>> The problem, as you indicate, is that R's parser sees "\B" as an
>> incorrect escape character, so, for example:
>>> cat("\B")
>> Error: '\B' is an unrecognized escape in character string starting
>> ""\B"
>> 
>> In any case, I think you should look at ?scan. Here is an example where
>> I scan from the keyboard first and then remove the "\". You may have to
>> scan from a file to do this.
>> 
>>> z <-scan(file = "", what = "character")
>> 1: A\BCDEFG
>> 2: #CR terminates input
>> Read 1 item
>> 
>>> cat(z)
>> A\BCDEFG
>> 
>>> nchar(z)
>> [1] 8  ## scan read in the "\" as a single character from the console.
>> 
>>> sub("","",z)  ## Yes, 4 backslashes
>> [1] "ABCDEFG"
>> 
>> There may be better ways to do this, but as I said, I'm no expert.
>> 
>> BTW, in posting here, please post in *plain text,* as the server can
>> mangle html.
>> 
>> Cheers,
>> Bert
>> 
>> 
>> Bert Gunter
>> 
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> 
>> 
>> On Tue, Aug 25, 2020 at 9:02 AM Peter Bishop
>> mailto:bishop_pet...@hotmail.com>> wrote:
>> In SQL, I'm using R as a way to filter data based on:
>>   - 20 characters in the range  to 
>> - excluding , , , ,
>> , 
>> 
>> Given a SQL column containing the data:
>> 
>>   code
>>   
>>   A\BCDEFG
>> 
>> and the T-SQL script:
>> 
>>   EXEC [sys].[sp_execute_external_script]
>

Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
The feed is coming from a SQL table and this is using the embedded support for 
R which comes with SQL 2016. The source is therefore a SELECT statement.


As an aside, I found a workaround by changing the pattern from:


"[\x22\x27\x2c\x3f\x5c\x60]"


to:


"[\x22\x27\x2c\x3f\x5c\x5c\x60]"


This seems to be escaping the backslash in the R script rather than in the data 
- which confuses me.


From: Bert Gunter 
Sent: Wednesday, 26 August 2020 4:26 AM
To: Peter Bishop 
Cc: r-help@r-project.org 
Subject: Re: [R] Matching backslash in a table's column using R language

1. I am far from an expert on such matters
2. It is unclear to me what your input is -- I assume a file.

The problem, as you indicate, is that R's parser sees "\B" as an incorrect 
escape character, so, for example:
> cat("\B")
Error: '\B' is an unrecognized escape in character string starting ""\B"

In any case, I think you should look at ?scan. Here is an example where I scan 
from the keyboard first and then remove the "\". You may have to scan from a 
file to do this.

> z <-scan(file = "", what = "character")
1: A\BCDEFG
2: #CR terminates input
Read 1 item

> cat(z)
A\BCDEFG

> nchar(z)
[1] 8  ## scan read in the "\" as a single character from the console.

> sub("","",z)  ## Yes, 4 backslashes
[1] "ABCDEFG"

There may be better ways to do this, but as I said, I'm no expert.

BTW, in posting here, please post in *plain text,* as the server can mangle 
html.

Cheers,
Bert


Bert Gunter

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


On Tue, Aug 25, 2020 at 9:02 AM Peter Bishop 
mailto:bishop_pet...@hotmail.com>> wrote:
In SQL, I'm using R as a way to filter data based on:
- 20 characters in the range  to 
- excluding , , , , , 


Given a SQL column containing the data:

code

A\BCDEFG

and the T-SQL script:

EXEC [sys].[sp_execute_external_script]
@language=N'R',
@script=N'
pattern1 = "^[\x20-\x7e]{1,20}$"
pattern2 = "[\x22\x27\x2c\x3f\x5c\x60]"

outData <- subset(inData, grepl(pattern1, code, perl=TRUE) & 
!grepl(pattern2, code, perl=TRUE))',
@input_data_1 = N'SELECT [code] FROM [dbo].[products]',
@input_data_1_name = N'inData',
@output_data_1_name = N'outData'
WITH
RESULT SETS (AS OBJECT [dbo].[products]);
GO

why does the row detailed above get returned? I know that backslash is a 
special character but not in the SQL table. Consequently, the T-SQL code:

SELECT ASCII(SUBSTRING([value], 2, 1)) FROM [table]

returns 92 (the ASCII code for ) which shows that this is being 
recognised as a backslash character and not as an escape indicator for the 
following "B".

Can anyone advise how I can filter out the  in the way that the 
other identified characters are being successfully filtered? As the data is 
being retrieved from a table, I can�t ask the data provider to use �\\� instead 
of �\� as that will be invalid for other uses.

Thanks.

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=02%7C01%7C%7C21350c4700bf48cb035008d849245d6c%7C84df9e7fe9f640afb435%7C1%7C0%7C637339767813946809=v79GeIK6IXhKuF4q0qJ3uopMdJeYzKKvdi5a4NqgdeM%3D=0>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=02%7C01%7C%7C21350c4700bf48cb035008d849245d6c%7C84df9e7fe9f640afb435%7C1%7C0%7C637339767813956802=iKgAGe23wPBrIK4iI3q0Vqk19q%2B%2FgSgiRUV858XOU3A%3D=0>
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


Re: [R] How to obtain individual log-likelihood value from glm?

2020-08-25 Thread peter dalgaard
If you don't worry too much about an additive constant, then half the negative 
squared deviance residuals should do. (Not quite sure how weights factor in. 
Looks like they are accounted for.)

-pd

> On 25 Aug 2020, at 17:33 , John Smith  wrote:
> 
> Dear R-help,
> 
> The function logLik can be used to obtain the maximum log-likelihood value
> from a glm object. This is an aggregated value, a summation of individual
> log-likelihood values. How do I obtain individual values? In the following
> example, I would expect 9 numbers since the response has length 9. I could
> write a function to compute the values, but there are lots of
> family members in glm, and I am trying not to reinvent wheels. Thanks!
> 
> counts <- c(18,17,15,20,10,20,25,13,12)
> outcome <- gl(3,1,9)
> treatment <- gl(3,3)
> data.frame(treatment, outcome, counts) # showing data
> glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
> (ll <- logLik(glm.D93))
> 
>   [[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.

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

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


[R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
In SQL, I'm using R as a way to filter data based on:
- 20 characters in the range  to 
- excluding , , , , , 


Given a SQL column containing the data:

code

A\BCDEFG

and the T-SQL script:

EXEC [sys].[sp_execute_external_script]
@language=N'R',
@script=N'
pattern1 = "^[\x20-\x7e]{1,20}$"
pattern2 = "[\x22\x27\x2c\x3f\x5c\x60]"

outData <- subset(inData, grepl(pattern1, code, perl=TRUE) & 
!grepl(pattern2, code, perl=TRUE))',
@input_data_1 = N'SELECT [code] FROM [dbo].[products]',
@input_data_1_name = N'inData',
@output_data_1_name = N'outData'
WITH
RESULT SETS (AS OBJECT [dbo].[products]);
GO

why does the row detailed above get returned? I know that backslash is a 
special character but not in the SQL table. Consequently, the T-SQL code:

SELECT ASCII(SUBSTRING([value], 2, 1)) FROM [table]

returns 92 (the ASCII code for ) which shows that this is being 
recognised as a backslash character and not as an escape indicator for the 
following "B".

Can anyone advise how I can filter out the  in the way that the 
other identified characters are being successfully filtered? As the data is 
being retrieved from a table, I can�t ask the data provider to use �\\� instead 
of �\� as that will be invalid for other uses.

Thanks.

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


  1   2   3   4   5   6   7   8   9   10   >