[R] Building Packages.

2024-03-20 Thread Jorgen Harmse via R-help
I have a source file with oxygen-style comments (and description & licence 
files), and I’m trying to build a package. oxygen & devtools seem to work, and 
the tarball exists, but install.packages balks. Does anyone know what’s 
happening?

Regards,
Jorgen Harmse.


> roxygenise(package.dir,clean=TRUE)

Setting `RoxygenNote` to "7.3.1"

✖ roxygen2 requires "Encoding: UTF-8"

ℹ Current encoding is NA

ℹ Loading jhBase

Warning: ── Conflicts 
──
 jhBase conflicts

──

✖ `andNotNA` masks `jhBase::andNotNA()`.

✖ `array.named` masks `jhBase::array.named()`.

✖ `arrayInd.inv` masks `jhBase::arrayInd.inv()`.

  … and more.

ℹ Did you accidentally source a file rather than using `load_all()`?

  Run `rm(list = c("andNotNA", "array.named", "arrayInd.inv", 
"as.POSIXct_orig", "build.package", "colon", "file.info", "file.path", 
"files.removeDup", "fprintf", "grepi", "grepiv", "grepv", "grepvi", "ifelses", 
"index", "load.env", "load.list", "matrix.sq", "merges", "mm", "orNA", 
"pattern.NA", "plots", "printf",

  "save.env", "subs", "symmDiff", "vector.named", "width"))` to remove the 
conflicts.

Writing NAMESPACE

Writing printf.Rd

Writing width.Rd

Writing pattern.NA.Rd

Writing ddply.ns.Rd

Writing as.POSIXct_orig.Rd

Writing mm.Rd

Writing orNA.Rd

Writing merges.Rd

Writing index.Rd

Writing save.env.Rd

Writing build.package.Rd

Writing plots.Rd

Writing ifelses.Rd

Writing subs.Rd

Writing array.named.Rd

Writing grepv.Rd

Writing symmDiff.Rd

Writing file.info.Rd

Writing file.path.Rd

Writing files.removeDup.Rd

Writing arrayInd.inv.Rd

> tar <- devtools::build(package.dir)

── R CMD build 


✔  checking for file 
‘/Users/jharmse/Library/CloudStorage/OneDrive-RokuInc/jhBase/DESCRIPTION’ ...

─  preparing ‘jhBase’:

✔  checking DESCRIPTION meta-information ...

─  checking for LF line-endings in source and make files and shell scripts

─  checking for empty or unneeded directories

─  building ‘jhBase_1.0.1.tar.gz’



> file.info(tar)

  size 
isdir mode   mtime   ctime   atime uid gid  
 uname grname

/Users/jharmse/Library/CloudStorage/OneDrive-RokuInc/jhBase_1.0.1.tar.gz 14030 
FALSE  644 2024-03-20 10:49:10 2024-03-20 10:49:10 2024-03-20 10:49:10 503  20 
jharmse  staff

> install.packages(tar,type='source',repos=NULL)

Error in library(jhBase) : there is no package called ‘jhBase’

Execution halted

Warning in install.packages(tar, type = "source", repos = NULL) :

  installation of package 
‘/Users/jharmse/Library/CloudStorage/OneDrive-RokuInc/jhBase_1.0.1.tar.gz’ had 
non-zero exit status


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


[ESS] Where does ESS saves ESSR environment information

2024-03-20 Thread Iago Giné Vázquez via ESS-help
Hi all,

I have included a line such as the following in my .emacs file:
(add-hook 'ess-r-post-run-hook (lambda () (ess-load-file "~/startR.r")))

I have restarted Emacs, tried to start R and get an error due to that R did not 
find the file.  I realized that I put ~ thinking in home path for Emacs, not 
home path for R, so I updated the path address to the correct one in my .emacs 
file:
(add-hook 'ess-r-post-run-hook (lambda () (ess-load-file 
"C:/Users/.../startR.r")))

Again, restarted Emacs, tried starting R..., but I got the same error, which 
through a traceback I get

 base::as.environment("ESSR")$.ess.source("~/startR.r", visibly = FALSE,
   output = TRUE)

So, at some point the address "~/startR.r" was saved, but I cannot find it. How 
may I remove it and update the ESS configuration?

Thank you for your help.

Best regards,
Iago

[[alternative HTML version deleted]]

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


[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
2 things:

1) utils::install.packages() sometimes helps if the Rstudio version got 
wedged somehow.

2) You seem to be missing several Recommended packages (lattice, MASS, Matrix, 
nlme, cluster,). Did you install R without those?


-pd

> On 16 Mar 2024, at 05:09 , javad bayat  wrote:
> 
> Dear Rui;
> Many thanks for your reply. I have installed Rtools (rtools43-5958-5975) on
> my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
> installed Rstudio through Anaconda Navigator.
> But I do not know how to use Rtools for installing the R packages. I would
> be more than happy if you help me.
> Sincerely yours
> 
> 
> 
>> Dear Rui;
>> I hope this email finds you well. I have a problem installing packages in
>> Rstudio and R software. When I try to install a package, the software
> tries
>> to download but after downloading, it gives some errors and does not work.
>> I would be more than happy if you please help me to solve this issue.
>> Warm regards.
>> 
>> 
>>> install.packages("openair", type = "source")Installing package into
> ‘C:/R_Libs’
>> (as ‘lib’ is unspecified)Warning in install.packages :
>>   dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
>> dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
>> ‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
>> ‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
>> ‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
>> trying URL '
> https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content
>> type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content
>> type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
>> MB
>> trying URL 'https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content
>> type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
>> KB
>> trying URL 'https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content
>> type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content
>> type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content
>> type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content
>> type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content
>> type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content
>> type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content
>> type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
>> KB
>> trying URL 'https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content
>> type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content
>> type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content
>> type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content
>> type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
>> KB
>> trying URL 'https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content
>> type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content
>> type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content
>> type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content
>> type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
>> KB
>> trying URL '
> https://cran.rstudio.com/src/contrib/dplyr_1.1.4.tar.gz'Content
>> type 'application/x-gzip' length 1207521 bytes (1.2 MB)downloaded 1.2
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/hexbin_1.28.3.tar.gz'Content
>> type 'application/x-gzip' length 1199967 bytes (1.1 MB)downloaded 1.1
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/latticeExtra_0.6-30.tar.gz'Content
>> type 'application/x-gzip' length 1292936 bytes (1.2 MB)downloaded 1.2
>> MB
>> trying URL '
> https://cran.rstudio.com/src/contrib/lubridate_1.9.3.tar.gz'Content
>> type 'application/x-gzip' length 428043 

Re: [R] Problem when trying to install packages

2024-03-16 Thread Uwe Ligges



On 16.03.2024 10:48, javad bayat wrote:

Dear all;
I found a useful video on youtube that has explained how to install Rtools.
I followed the instructions and the problem was solved.
" Installing R version 4.0 + RTools 4.0 + RStudio For Data Science (#R


??
A recent set of released software would be Rtools43 + R-4.3.3

Best,
Uwe Ligges





#RTools #RStudio #DataScience) - YouTube
 "
Sincerely

On Sat, Mar 16, 2024 at 10:15 AM Bert Gunter  wrote:


Though Navigator may mess up any Rtools stuff because it handles the
directory trees where packages and dependencies are located, does it not?
If so, maybe just reinstall RStudio directly from its website to proceed.
Just a guess obviously.

Bert

On Sat, Mar 16, 2024, 05:09 javad bayat  wrote:


  Dear Rui;
Many thanks for your reply. I have installed Rtools (rtools43-5958-5975)
on
my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
installed Rstudio through Anaconda Navigator.
But I do not know how to use Rtools for installing the R packages. I would
be more than happy if you help me.
Sincerely yours




Dear Rui;
I hope this email finds you well. I have a problem installing packages

in

Rstudio and R software. When I try to install a package, the software

tries

to download but after downloading, it gives some errors and does not

work.

I would be more than happy if you please help me to solve this issue.
Warm regards.



install.packages("openair", type = "source")Installing package into

‘C:/R_Libs’

(as ‘lib’ is unspecified)Warning in install.packages :
dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
trying URL '

https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content

type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
KB
trying URL '

https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content

type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
MB
trying URL '

https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content

type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
KB
trying URL '

https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content

type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
KB
trying URL '

https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content

type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
KB
trying URL '

https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content

type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
KB
trying URL '

https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content

type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
KB
trying URL '

https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content

type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
KB
trying URL '

https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content

type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
KB
trying URL '

https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content

type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
KB
trying URL '

https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content

type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
trying URL '

https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content

type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
trying URL '

https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content

type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
MB
trying URL '

https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content

type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
KB
trying URL '

https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content

type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
MB
trying URL '

https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content

type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
KB
trying URL '

https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content

type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
MB
trying URL '

https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content

type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
KB
trying URL '

https://cran.rstudio.com/src/contrib/dplyr_1.1.4.tar.gz'Content

type 'application/x-gzip' length 1207521 bytes (1.2 MB)downloaded 1.2
MB
trying URL '

https://cran.rstudio.com/src/contrib/hexbin_1.28.3.tar.gz'Content

type 'application/x-gzip' length 1199967 bytes (1.1 MB)downloaded 1.1
MB
trying URL '


Re: [R] Problem when trying to install packages

2024-03-16 Thread javad bayat
Dear all;
I found a useful video on youtube that has explained how to install Rtools.
I followed the instructions and the problem was solved.
" Installing R version 4.0 + RTools 4.0 + RStudio For Data Science (#R
#RTools #RStudio #DataScience) - YouTube
 "
Sincerely

On Sat, Mar 16, 2024 at 10:15 AM Bert Gunter  wrote:

> Though Navigator may mess up any Rtools stuff because it handles the
> directory trees where packages and dependencies are located, does it not?
> If so, maybe just reinstall RStudio directly from its website to proceed.
> Just a guess obviously.
>
> Bert
>
> On Sat, Mar 16, 2024, 05:09 javad bayat  wrote:
>
>>  Dear Rui;
>> Many thanks for your reply. I have installed Rtools (rtools43-5958-5975)
>> on
>> my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
>> installed Rstudio through Anaconda Navigator.
>> But I do not know how to use Rtools for installing the R packages. I would
>> be more than happy if you help me.
>> Sincerely yours
>>
>>
>>
>> > Dear Rui;
>> > I hope this email finds you well. I have a problem installing packages
>> in
>> > Rstudio and R software. When I try to install a package, the software
>> tries
>> > to download but after downloading, it gives some errors and does not
>> work.
>> > I would be more than happy if you please help me to solve this issue.
>> > Warm regards.
>> >
>> >
>> >> install.packages("openair", type = "source")Installing package into
>> ‘C:/R_Libs’
>> > (as ‘lib’ is unspecified)Warning in install.packages :
>> >dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
>> > dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
>> > ‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
>> > ‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
>> > ‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content
>> > type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content
>> > type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
>> > MB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content
>> > type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content
>> > type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content
>> > type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content
>> > type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content
>> > type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content
>> > type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content
>> > type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content
>> > type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content
>> > type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content
>> > type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content
>> > type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
>> > MB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content
>> > type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content
>> > type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
>> > MB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content
>> > type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
>> > KB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content
>> > type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
>> > MB
>> > trying URL '
>> https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content
>> > type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
>> > KB
>> > trying URL '
>> 

Re: [R] Problem when trying to install packages

2024-03-16 Thread Bert Gunter
Though Navigator may mess up any Rtools stuff because it handles the
directory trees where packages and dependencies are located, does it not?
If so, maybe just reinstall RStudio directly from its website to proceed.
Just a guess obviously.

Bert

On Sat, Mar 16, 2024, 05:09 javad bayat  wrote:

>  Dear Rui;
> Many thanks for your reply. I have installed Rtools (rtools43-5958-5975) on
> my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
> installed Rstudio through Anaconda Navigator.
> But I do not know how to use Rtools for installing the R packages. I would
> be more than happy if you help me.
> Sincerely yours
>
>
>
> > Dear Rui;
> > I hope this email finds you well. I have a problem installing packages in
> > Rstudio and R software. When I try to install a package, the software
> tries
> > to download but after downloading, it gives some errors and does not
> work.
> > I would be more than happy if you please help me to solve this issue.
> > Warm regards.
> >
> >
> >> install.packages("openair", type = "source")Installing package into
> ‘C:/R_Libs’
> > (as ‘lib’ is unspecified)Warning in install.packages :
> >dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
> > dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
> > ‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
> > ‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
> > ‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
> > trying URL '
> https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content
> > type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content
> > type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content
> > type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content
> > type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content
> > type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content
> > type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content
> > type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content
> > type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content
> > type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content
> > type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content
> > type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content
> > type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content
> > type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content
> > type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content
> > type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content
> > type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content
> > type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content
> > type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/dplyr_1.1.4.tar.gz'Content
> > type 'application/x-gzip' length 1207521 bytes (1.2 MB)downloaded 1.2
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/hexbin_1.28.3.tar.gz'Content
> > type 'application/x-gzip' length 1199967 bytes (1.1 MB)downloaded 1.1
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/latticeExtra_0.6-30.tar.gz'Content
> > type 'application/x-gzip' length 1292936 bytes (1.2 MB)downloaded 1.2
> > MB
> > trying URL '
> 

Re: [R] Problem when trying to install packages

2024-03-16 Thread Bert Gunter
? Google it!  "How to install packages using Rtools"

Bert

On Sat, Mar 16, 2024, 05:09 javad bayat  wrote:

>  Dear Rui;
> Many thanks for your reply. I have installed Rtools (rtools43-5958-5975) on
> my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
> installed Rstudio through Anaconda Navigator.
> But I do not know how to use Rtools for installing the R packages. I would
> be more than happy if you help me.
> Sincerely yours
>
>
>
> > Dear Rui;
> > I hope this email finds you well. I have a problem installing packages in
> > Rstudio and R software. When I try to install a package, the software
> tries
> > to download but after downloading, it gives some errors and does not
> work.
> > I would be more than happy if you please help me to solve this issue.
> > Warm regards.
> >
> >
> >> install.packages("openair", type = "source")Installing package into
> ‘C:/R_Libs’
> > (as ‘lib’ is unspecified)Warning in install.packages :
> >dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
> > dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
> > ‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
> > ‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
> > ‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
> > trying URL '
> https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content
> > type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content
> > type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content
> > type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content
> > type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content
> > type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content
> > type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content
> > type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content
> > type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content
> > type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content
> > type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content
> > type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content
> > type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content
> > type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content
> > type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content
> > type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content
> > type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content
> > type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content
> > type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
> > KB
> > trying URL '
> https://cran.rstudio.com/src/contrib/dplyr_1.1.4.tar.gz'Content
> > type 'application/x-gzip' length 1207521 bytes (1.2 MB)downloaded 1.2
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/hexbin_1.28.3.tar.gz'Content
> > type 'application/x-gzip' length 1199967 bytes (1.1 MB)downloaded 1.1
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/latticeExtra_0.6-30.tar.gz'Content
> > type 'application/x-gzip' length 1292936 bytes (1.2 MB)downloaded 1.2
> > MB
> > trying URL '
> https://cran.rstudio.com/src/contrib/lubridate_1.9.3.tar.gz'Content
> > type 'application/x-gzip' length 428043 bytes (418 KB)downloaded 418
> > KB
> > trying URL '
> 

Re: [R] Problem when trying to install packages

2024-03-15 Thread javad bayat
 Dear Rui;
Many thanks for your reply. I have installed Rtools (rtools43-5958-5975) on
my PC and I have R version 4.3.3 and 4.3.2 to install. Also I have
installed Rstudio through Anaconda Navigator.
But I do not know how to use Rtools for installing the R packages. I would
be more than happy if you help me.
Sincerely yours



> Dear Rui;
> I hope this email finds you well. I have a problem installing packages in
> Rstudio and R software. When I try to install a package, the software
tries
> to download but after downloading, it gives some errors and does not work.
> I would be more than happy if you please help me to solve this issue.
> Warm regards.
>
>
>> install.packages("openair", type = "source")Installing package into
‘C:/R_Libs’
> (as ‘lib’ is unspecified)Warning in install.packages :
>dependencies ‘lattice’, ‘MASS’ are not availablealso installing the
> dependencies ‘deldir’, ‘RcppEigen’, ‘cli’, ‘glue’, ‘lifecycle’,
> ‘pillar’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’, ‘png’, ‘jpeg’,
> ‘interp’, ‘timechange’, ‘maps’, ‘nlme’, ‘Matrix’, ‘cluster’, ‘dplyr’,
> ‘hexbin’, ‘latticeExtra’, ‘lubridate’, ‘mapproj’, ‘mgcv’, ‘purrr’
> trying URL '
https://cran.rstudio.com/src/contrib/deldir_2.0-4.tar.gz'Content
> type 'application/x-gzip' length 103621 bytes (101 KB)downloaded 101
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/RcppEigen_0.3.4.0.0.tar.gz'Content
> type 'application/x-gzip' length 1765714 bytes (1.7 MB)downloaded 1.7
> MB
> trying URL 'https://cran.rstudio.com/src/contrib/cli_3.6.2.tar.gz'Content
> type 'application/x-gzip' length 569771 bytes (556 KB)downloaded 556
> KB
> trying URL 'https://cran.rstudio.com/src/contrib/glue_1.7.0.tar.gz'Content
> type 'application/x-gzip' length 105420 bytes (102 KB)downloaded 102
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/lifecycle_1.0.4.tar.gz'Content
> type 'application/x-gzip' length 107656 bytes (105 KB)downloaded 105
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/pillar_1.9.0.tar.gz'Content
> type 'application/x-gzip' length 444528 bytes (434 KB)downloaded 434
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/rlang_1.1.3.tar.gz'Content
> type 'application/x-gzip' length 763765 bytes (745 KB)downloaded 745
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/tibble_3.2.1.tar.gz'Content
> type 'application/x-gzip' length 565982 bytes (552 KB)downloaded 552
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/tidyselect_1.2.1.tar.gz'Content
> type 'application/x-gzip' length 103591 bytes (101 KB)downloaded 101
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/vctrs_0.6.5.tar.gz'Content
> type 'application/x-gzip' length 969066 bytes (946 KB)downloaded 946
> KB
> trying URL 'https://cran.rstudio.com/src/contrib/png_0.1-8.tar.gz'Content
> type 'application/x-gzip' length 24880 bytes (24 KB)downloaded 24 KB
> trying URL '
https://cran.rstudio.com/src/contrib/jpeg_0.1-10.tar.gz'Content
> type 'application/x-gzip' length 18667 bytes (18 KB)downloaded 18 KB
> trying URL '
https://cran.rstudio.com/src/contrib/interp_1.1-6.tar.gz'Content
> type 'application/x-gzip' length 1112116 bytes (1.1 MB)downloaded 1.1
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/timechange_0.3.0.tar.gz'Content
> type 'application/x-gzip' length 103439 bytes (101 KB)downloaded 101
> KB
> trying URL 'https://cran.rstudio.com/src/contrib/maps_3.4.2.tar.gz'Content
> type 'application/x-gzip' length 2278051 bytes (2.2 MB)downloaded 2.2
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/nlme_3.1-164.tar.gz'Content
> type 'application/x-gzip' length 836832 bytes (817 KB)downloaded 817
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/Matrix_1.6-5.tar.gz'Content
> type 'application/x-gzip' length 2883851 bytes (2.8 MB)downloaded 2.8
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/cluster_2.1.6.tar.gz'Content
> type 'application/x-gzip' length 369050 bytes (360 KB)downloaded 360
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/dplyr_1.1.4.tar.gz'Content
> type 'application/x-gzip' length 1207521 bytes (1.2 MB)downloaded 1.2
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/hexbin_1.28.3.tar.gz'Content
> type 'application/x-gzip' length 1199967 bytes (1.1 MB)downloaded 1.1
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/latticeExtra_0.6-30.tar.gz'Content
> type 'application/x-gzip' length 1292936 bytes (1.2 MB)downloaded 1.2
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/lubridate_1.9.3.tar.gz'Content
> type 'application/x-gzip' length 428043 bytes (418 KB)downloaded 418
> KB
> trying URL '
https://cran.rstudio.com/src/contrib/mapproj_1.2.11.tar.gz'Content
> type 'application/x-gzip' length 25544 bytes (24 KB)downloaded 24 KB
> trying URL 'https://cran.rstudio.com/src/contrib/mgcv_1.9-1.tar.gz'Content
> type 'application/x-gzip' length 1083217 bytes (1.0 MB)downloaded 1.0
> MB
> trying URL '
https://cran.rstudio.com/src/contrib/purrr_1.0.2.tar.gz'Content
> type 

Re: [R] write.xlsx error message

2024-03-15 Thread Subia Thomas OI-US-LIV5
Good point, indeed it should have been read.xlsx.



Mit freundlichen Gruessen  / Cordialement / Best regards
Thomas Subia
Lean Six Sigma Senior Practitioner

DRÄXLMAIER Group
DAA Draexlmaier Automotive of America LLC
801 Challenger Street
Livermore CA 94551

Ph: 925-978-8111

mailto:thomas.su...@draexlmaier.com
http://www.draexlmaier.com

“Nous croyons en Dieu.
Tous les autres doivent apporter des données.
Edward Deming


Public
-Original Message-
From: gernop...@gmx.net 
Sent: Friday, March 15, 2024 1:07 AM
To: Subia Thomas OI-US-LIV5 ; r-help@r-project.org
Subject: Aw: Re: [R] write.xlsx error message

[You don't often get email from gernop...@gmx.net. Learn why this is important 
at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This email originated from outside the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

I think remember this error from trying to write an Excel file that already 
existed. If this file already exists, try to delete it and see, if this solves 
the issue.

Besides that you're writing that you are "Using write.xlsx to extract data from 
an Excel file", write.xlsx() is to write an Excel file, not to read from it. 
Should be read.xlsx() then iirc.




Gesendet: Freitag, 15. März 2024 um 08:38 Uhr
Von: "Ivan Krylov via R-help" 
An: "Subia Thomas OI-US-LIV5" 
Cc: "r-help@r-project.org" 
Betreff: Re: [R] write.xlsx error message В Thu, 14 Mar 2024 14:12:12 + 
Subia Thomas OI-US-LIV5  пишет:

> Using write.xlsx to extract data from an Excel file, I get this error
> message.
>
>
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod",
> cl, : java.lang.OutOfMemoryError: GC overhead limit exceeded

There seems to be a default limit of 512 megabytes for the Java heap
size:

library(rJava)
getOption('java.parameters')
# [1] "-Xmx512m"

Does if help if you set options(java.parameters = '-Xmx2048m') (or as much as 
you feel comfortable with) before loading XLConnect?

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


[R] [R-pkgs] clusterMI: Cluster Analysis with Missing Values by Multiple Imputation

2024-03-15 Thread Vincent Audigier via R-packages

Dear all,

I am pleased to announce the release of a new package named 'clusterMI' on CRAN.

clusterMI allows clustering of incomplete observations by addressing missing 
values using multiple imputation.

For achieving this goal, the methodology consists in three steps:

1. missing data imputation using tailored imputation models: four multiple 
imputation methods are proposed, two are based on joint modelling (JM-GL and 
JM-DP) and two are fully sequential methods (FCS-homo and FCS-hetero).
2. cluster analysis of imputed data sets: six clustering methods are available 
(kmeans, pam, clara, hierarchical clustering, fuzzy c-means and gaussian 
mixture), but custom methods can also be easily used.
3. partition pooling: the set of partitions is aggregated using NMF based 
method. An associated instability measure is computed by bootstrap. Among 
applications, this instability measure can be used to choose a number of 
clusters with missing values.

The package also offers several diagnostic tools for tuning the number of 
imputed data sets, for checking convergence in sequential imputation, for 
checking the fit of imputation models, etc.

This is the first version of the package, your feedback and suggestions are 
welcome!

Please find more details and download the package from the following 
link:https://cran.r-project.org/package=clusterMI

Best regards,

V. Audigier

--
Vincent AUDIGIER
Associate Professor, CNAM
2 rue Conté 75003 Paris
Office 35.3.21
Tel: 01 40 27 27 19
Website:http://vincentaudigier.weebly.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] write.xlsx error message

2024-03-15 Thread gernophil--- via R-help


I think remember this error from trying to write an Excel file that already 
existed. If this file already exists, try to delete it and see, if this solves 
the issue.

Besides that you're writing that you are "Using write.xlsx to extract data from 
an Excel file", write.xlsx() is to write an Excel file, not to read from it. 
Should be read.xlsx() then iirc.

 
 

Gesendet: Freitag, 15. März 2024 um 08:38 Uhr
Von: "Ivan Krylov via R-help" 
An: "Subia Thomas OI-US-LIV5" 
Cc: "r-help@r-project.org" 
Betreff: Re: [R] write.xlsx error message
В Thu, 14 Mar 2024 14:12:12 +
Subia Thomas OI-US-LIV5  пишет:

> Using write.xlsx to extract data from an Excel file, I get this error
> message.
>
>
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod",
> cl, : java.lang.OutOfMemoryError: GC overhead limit exceeded

There seems to be a default limit of 512 megabytes for the Java heap
size:

library(rJava)
getOption('java.parameters')
# [1] "-Xmx512m"

Does if help if you set options(java.parameters = '-Xmx2048m') (or
as much as you feel comfortable with) before loading XLConnect?

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


Re: [R] write.xlsx error message

2024-03-15 Thread Ivan Krylov via R-help
В Thu, 14 Mar 2024 14:12:12 +
Subia Thomas OI-US-LIV5  пишет:

> Using write.xlsx to extract data from an Excel file, I get this error
> message.
> 
> 
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod",
> cl,  : java.lang.OutOfMemoryError: GC overhead limit exceeded

There seems to be a default limit of 512 megabytes for the Java heap
size:

library(rJava)
getOption('java.parameters')
# [1] "-Xmx512m"

Does if help if you set options(java.parameters = '-Xmx2048m') (or
as much as you feel comfortable with) before loading XLConnect?

-- 
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] write.xlsx error message

2024-03-15 Thread Subia Thomas OI-US-LIV5
Colleagues,

Using write.xlsx to extract data from an Excel file, I get this error message.


Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.OutOfMemoryError: GC overhead limit exceeded

I was thinking that this might be a RAM issue but with 16 GB RAM, I wasn't 
expecting this error message.

Any guidance would be appreciated.

Mit freundlichen Gruessen  / Cordialement / Best regards
Thomas Subia
Lean Six Sigma Senior Practitioner

DR�XLMAIER Group
DAA Draexlmaier Automotive of America LLC


mailto:thomas.su...@draexlmaier.com
http://www.draexlmaier.com

"Nous croyons en Dieu.
Tous les autres doivent apporter des donn�es.
Edward Deming



Public

[[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] CADFtest difference between max.lag.y with criterion and without criterion

2024-03-15 Thread José Dias Curto via R-help
Dear Professor Bernhard,

Sorry for take your time, but I found something strange that I am not able to 
explain/understand.

Suppose that I compute the ADF test by using the criterion="BIC" to select the 
lags:

summary(CADFtest(y, max.lag.y = 20, type = "drift", criterion="BIC"))

Suppose that 2 lags are selected.

Next, if I set the lags to 2: summary(CADFtest(y, max.lag.y = 2, type = 
"drift"))
the ADF test result is different... You can confirm down, please. I think the 
reason is the number of included observations after adjustments... 8533 in the 
first case and 8551 in the second case.
What am I doing wrong?
Thank you very much for your help.
Best regards,
Jos� Dias Curto

> summary(CADFtest(y, max.lag.y = 20, type = "drift", criterion="BIC"))
Augmented DF test
ADF test
t-test statistic:  0.1070651
p-value:   0.9663296
Max lag of the diff. dependent variable:   2.000

Call:
dynlm(formula = formula(model), start = obs.1, end = obs.T)

Residuals:
 Min   1Q   Median   3Q  Max
-116.646   -3.7190.1634.444  110.891

Coefficients:
  Estimate Std. Error t value Pr(>|t|)
(Intercept)  2.758e-01  2.649e-01   1.041 0.297853
L(y, 1)  2.256e-05  2.107e-04   0.107 0.966330
L(d(y), 1)  -5.086e-02  1.085e-02  -4.689 2.78e-06 ***
L(d(y), 2)  -4.030e-02  1.086e-02  -3.710 0.000209 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 12.73 on 8529 degrees of freedom
Multiple R-squared:  0.003998, Adjusted R-squared:  0.003648
F-statistic: 17.12 on 2 and 8529 DF,  p-value: 3.809e-08


> summary(CADFtest(y, max.lag.y = 2, type = "drift"))

Augmented DF test

   ADF test

t-test statistic:  0.111863

p-value:   0.966685

Max lag of the diff. dependent variable:   2.00



Call:

dynlm(formula = formula(model), start = obs.1, end = obs.T)



Residuals:

 Min   1Q   Median   3Q  Max

-116.647   -3.7060.1554.438  110.890



Coefficients:

  Estimate Std. Error t value Pr(>|t|)

(Intercept)  0.2743714  0.2638699   1.040 0.298463

L(y, 1)  0.235  0.0002101   0.112 0.966685

L(d(y), 1)  -0.0508659  0.0108353  -4.694 2.71e-06 ***

L(d(y), 2)  -0.0403022  0.0108507  -3.714 0.000205 ***

---

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1



Residual standard error: 12.72 on 8547 degrees of freedom

Multiple R-squared:  0.003999, Adjusted R-squared:  0.003649

F-statistic: 17.16 on 2 and 8547 DF,  p-value: 3.662e-08



[[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] Rtools and things dependent on it

2024-03-14 Thread Tomas Kalibera



On 2/24/24 01:01, David Winsemius wrote:

On 2/23/24 14:34, avi.e.gr...@gmail.com wrote:

This may be a dumb question and the answer may make me feel dumber.
   
I have had trouble for years with R packages wanting Rtools on my machine

and not being able to use it. Many packages are fine as binaries are
available. I have loaded Rtools and probably need to change my PATH or
something.


I suppose making sure that whatever directory holds your Rtools code is
on your path would be a good idea. I wondered if there's an environment
variable that could be set, but reading the page on using Rtools did not
mention one until I got down to the section on building R from source
which is surely NOT what you want to do.. You should read the
information on installation and building packages from source.
https://cran.r-project.org/bin/windows/base/howto-R-devel.html which
includes this sentence:

"It is recommended to use the defaults and install into|c:/rtools43|.
When done that way, Rtools43 may be used in the same R session which
installed it or which was started before Rtools43 was installed."
Yes, for regular users, who just want to install R packages on Windows 
from source (packages that include C, C++ of Fortran code), all that is 
needed is to:


- install R from the official installer provided by CRAN

- install Rtools (also from CRAN) for that version of R (so Rtools42 for 
R 4.2, Rtools43 for R 4.3, Rtools44 for R-devel/to become R 4.4)


If both is done accepting the defaults, no additional configuration is 
needed. R will automatically find Rtools when it needs it. One can have 
multiple versions of R and multiple versions of Rtools installed on the 
system, R will find and use the version of Rtools it needs.


Tomas



   
But I recently suggested to someone that they might want to use the tabyl()

function in the janitor package that I find helpful. I get a warning when I
install it about Rtools but it works fine. When they install it, it fails. I
assumed they would get it from CRAN the same way I did as we are both using
Windows and from within RSTUDIO.
   
In the past, I have run into other packages I could not use and just moved

on but it seems like time to see if this global problem has a work-around.
   
And, in particular, I have the latest versions of both R and RSTUDIO which

can be a problem when other things are not as up-to-date.
   
Or, maybe some people with R packages could be convinced to make binaries

available in the first place?

Binaries are automatically produced by CRAN but perhaps you are trying
to install from some other source? It would help if you could be
specific about several missing pieces of information: Operating system,
R version, Rtools version, current location of Rtools, names of packages
and where they were obtained.


Regards and good luck;

David (a.k.a IRTFM)


Avi

[[alternative HTML version deleted]]

Rhelp is a plain text mailing list. You should configure your email
client to send only plain-text and NOT html.
[[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] refresh.console() function?

2024-03-13 Thread Deepayan Sarkar
Perhaps you mean

https://search.r-project.org/R/refmans/utils/html/flush.console.html

Best,
Deepayan


On Wed, 13 Mar, 2024, 8:59 pm Christofer Bogaso, <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> I run a lengthy for loop and I want to display loop status for each
> step in my loop.
>
> I previously heard of a R function namely refresh.console() which
> would print the status within the loop as it progresses.
>
> However I see this
>
> > help.search("refresh.console")
>
> No vignettes or demos or help files found with alias or concept or
>
> title matching ‘refresh.console’ using regular expression matching.
>
> Could you please help me find the correct function name?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] refresh.console() function?

2024-03-13 Thread Enrico Schumann
On Wed, 13 Mar 2024, Christofer Bogaso writes:

> Hi,
>
> I run a lengthy for loop and I want to display loop status for each
> step in my loop.
>
> I previously heard of a R function namely refresh.console() which
> would print the status within the loop as it progresses.
>
> However I see this
>
>> help.search("refresh.console")
>
> No vignettes or demos or help files found with alias or concept or
>
> title matching ‘refresh.console’ using regular expression matching.
>
> Could you please help me find the correct function name?
>

?flush.console

... but you'll need to print/message/cat/... explicitly in the
loop, or the output won't be shown.  [Also, options(warn=1) might
be useful.]


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] refresh.console() function?

2024-03-13 Thread Christofer Bogaso
Hi,

I run a lengthy for loop and I want to display loop status for each
step in my loop.

I previously heard of a R function namely refresh.console() which
would print the status within the loop as it progresses.

However I see this

> help.search("refresh.console")

No vignettes or demos or help files found with alias or concept or

title matching ‘refresh.console’ using regular expression matching.

Could you please help me find the correct function name?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Generating mouse click and hold using R

2024-03-13 Thread Jeff Newmiller via R-help
No idea if the package below would work. This package is MSWindows only. Since 
this was readily found using a search engine, you should have mentioned that 
you already found this and why it didn't work for you when you posted.

https://cran.r-project.org/web/packages/KeyboardSimulator/readme/README.html
https://stat.ethz.ch/R-manual/R-devel/library/base/html/Sys.sleep.html


On March 13, 2024 6:31:59 AM PDT, Christofer Bogaso 
 wrote:
>Hi,
>
>I wonder if R can provide any functionality where I need simulate
>mouse click in windows machine at certain coordinate on screen and
>hold the click for certain seconds e.g. for 5 seconds
>
>Really appreciate if I can have someone suggestion how above can be
>simulated with R
>
>Thanks and 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.

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

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


Re: [R] Generating mouse click and hold using R

2024-03-13 Thread Ivan Krylov via R-help
В Wed, 13 Mar 2024 19:01:59 +0530
Christofer Bogaso  пишет:

> I need simulate mouse click in windows machine at certain coordinate
> on screen and hold the click for certain seconds e.g. for 5 seconds

There's no interface for this in base R. It's always possible to write
some Windows API code to do that and call it from R using .Call()
(SendInput() is relatively easy to use [*]), but that takes effort and
knowledge of C.

What I suggest to do instead is to write an AutoHotKey script, making
use of the Click function [**] and taking arguments from the command
line [***], and then launch that script using system2(). AutoHotKey is
free software (GPLv2), designed specifically to automate other programs
and should be much easier to use correctly than C.

-- 
Best regards,
Ivan

[*]
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput

[**]
https://www.autohotkey.com/docs/v2/lib/Click.htm

[***]
https://www.autohotkey.com/docs/v2/Scripts.htm#cmd

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Generating mouse click and hold using R

2024-03-13 Thread Christofer Bogaso
Hi,

I wonder if R can provide any functionality where I need simulate
mouse click in windows machine at certain coordinate on screen and
hold the click for certain seconds e.g. for 5 seconds

Really appreciate if I can have someone suggestion how above can be
simulated with R

Thanks and 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.


Re: [R] Problem with R coding

2024-03-12 Thread Ivan Krylov via R-help
В Tue, 12 Mar 2024 14:57:28 +
CALUM POLWART  пишет:

> That's almost certainly going to be either the utf-8 character in the
> path

The problem, as diagnosed by Maria in the first post of the thread, is
that the user home directory as known to R is stored in the ANSI
encoding instead of UTF-8, despite the session charset should be UTF-8
as Maria's Windows is sufficiently new [*]. As soon as any bit of R
tries to perform an encoding conversion using this path (for example,
file.exists() converting it from UTF-8 to UCS-2 in order to interact
with Windows filesystem APIs), the conversion fails. Since tcltk2 uses
file.exists('~/...') in its .onLoad, the package and any of its hard
dependencies are now broken.

Normally, this path is determined automatically to be something like
C:\Users\username\Documents. With OneDrive taking over, it turns out to
be something else and for some reason in the wrong encoding (ANSI but
marked as native == UTF-8).

The function that determines this path lives in src/gnuwin32/shext.c
(char *getRUser(void)). It starts by looking at the environment
variable R_USER, which is why in order to override OneDrive, the user
has to set it first (in the command line or system settings). If that
fails, R tries the environment variable HOME (which is usually set on
Windows, isn't it?), consults SHGetKnownFolderPath(FOLDERID_Documents)
(which returns the result as a wchar_t[] to be manually converted to
UTF-8 by R), consults a few more environment variables, and finally
tries to use the current directory. There is likely no easy way to use
`subst` to give a different home drive to R.

If I set %HOME% or even %R_USER% to a non-ASCII path without setting up
OneDrive, R works normally, so getenv() must be able to return
UTF-8-encoded variables. I don't see how ShellGetPersonalDirectory()
could fail in this manner. My remaining hypothesis is that OneDrive
somehow causes getenv("HOME") to return "C:\\Users\\marga\\OneDrive
- Fundación Universitaria San Pablo CEU\\Documentos" in ANSI instead of
UTF-8.

If anyone here has OneDrive set up in this manner and can debug R,
a trace of what getRUser() actually does would be very useful.

-- 
Best regards,
Ivan

[*]
https://blog.r-project.org/2020/05/02/utf-8-support-on-windows/index.html
https://blog.r-project.org/2022/11/07/issues-while-switching-r-to-utf-8-and-ucrt-on-windows/index.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 with R coding

2024-03-12 Thread Iris Simmons
Hi Maria,


I had something similar on my Windows work laptop at some point where the
home directory was something containing non ASCII characters. The easy
solution is to copy said directly from the file explorer into
utils::shortPathName, and then set that as the home directory. In my case,

> writeLines(utils::shortPathName(r"(C:\Users\iris\OneDrive - Organization
Name Non ASCII\Documents)"))
C:\Users\iris\ONEDRI~1\DOCUME~1

and then in the control panel, then user accounts (twice), then Change My
Environment Variables, enter the variable name HOME and the directory that
was produced by R. Now the HOME directory contains all ASCII characters so
everything works as expected.


I hope this helps!



On Tue, Mar 12, 2024, 04:49 Maria Del Mar García Zamora <
mar.garc...@alumnos.uchceu.es> wrote:

> Hello,
>
> This is the error that appears when I try to load library(Rcmdr). I am
> using R version 4.3.3. I have tried to upload the packages, uninstall them
> and intalling them again and nothing.
> Loading required package: splines
> Loading required package: RcmdrMisc
> Loading required package: car
> Loading required package: carData
> Loading required package: sandwich
> Loading required package: effects
> lattice theme set by effectsTheme()
> See ?effectsTheme for details.
> Error: package or namespace load failed for ‘Rcmdr’:
>  .onLoad failed in loadNamespace() for 'tcltk2', details:
>   call: file.exists("~/.Rtk2theme")
>   error: file name conversion problem -- name too long?
>
> Once this appears I use path.expand('~') and this is R's answer:
> [1] "C:\\Users\\marga\\OneDrive - Fundaci\xf3n Universitaria San Pablo
> CEU\\Documentos"
>
> The thing is that in spanish we use accents, so this word (Fundaci\xf3n)
> really is Fundación, but I can't change it.
>
> I have tried to start R from CDM using: C:\Users\marga>set
> R_USER=C:\Users\marga\R_USER
>
> C:\Users\marga>"C:\Users\marga\Desktop\R-4.3.3\bin\R.exe" CMD Rgui
>
> At the beginning this worked but right now a message saying that this app
> cannot be used and that I have to ask the software company (photo attached)
>
> What should I do?
>
> Thanks,
>
> Mar
>
>
> [https://www.uchceu.es/img/externos/correo/ceu_uch.gif]<
> https://www.uchceu.es/>
>
> Maria Del Mar García Zamora
> Alumno UCHCEU -
> Universidad CEU Cardenal Herrera
> -
> Tel.
> www.uchceu.es
>
> [https://www.uchceu.es/img/logos/wur.jpg]
> [https://www.uchceu.es/img/externos/correo/medio_ambiente.gif] Por favor,
> piensa en el medio ambiente antes de imprimir este contenido
>
>
>
> [http://www.uchceu.es/img/externos/correo/ceu_uch.gif]<
> http://www.uchceu.es/>
>
> Maria Del Mar García Zamora
>
> www.uchceu.es
>
> [http://www.uchceu.es/img/externos/correo/medio_ambiente.gif] Por favor,
> piensa en el medio ambiente antes de imprimir este contenido
>
>
>
>
> Este mensaje y sus archivos adjuntos, enviados desde FUNDACIÓN
> UNIVERSITARIA SAN PABLO-CEU, pueden contener información confidencial y
> está destinado a ser leído sólo por la persona a la que va dirigido, por lo
> que queda prohibida la difusión, copia o utilización de dicha información
> por terceros. Si usted lo recibiera por error, por favor, notifíquelo al
> remitente y destruya el mensaje y cualquier documento adjunto que pudiera
> contener. Cualquier información, opinión, conclusión, recomendación, etc.
> contenida en el presente mensaje no relacionada con la actividad de
> FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU, y/o emitida por persona no
> autorizada para ello, deberá considerarse como no proporcionada ni aprobada
> por FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU, que pone los medios a su alcance
> para garantizar la seguridad y ausencia de errores en la correspondencia
> electrónica, pero no puede asegurar la inexistencia de virus o la no
> alteración de los documentos transmitidos electrónicamente, por lo que
> declina cualquier responsabilidad a este respecto.
>
> This message and its attachments, sent from FUNDACIÓN UNIVERSITARIA SAN
> PABLO-CEU, may contain confidential information and is intended to be read
> only by the person it is directed. Therefore any disclosure, copying or use
> by third parties of this information is prohibited. If you receive this in
> error, please notify the sender and destroy the message and any attachments
> may contain. Any information, opinion, conclusion, recommendation,...
> contained in this message and which is unrelated to the business activity
> of FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU and/or issued by unauthorized
> personnel, shall be considered unapproved by FUNDACIÓN UNIVERSITARIA SAN
> PABLO-CEU. FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU implements control
> measures to ensure, as far as possible, the security and reliability of all
> its electronic correspondence. However, FUNDACIÓN UNIVERSITARIA SAN
> PABLO-CEU does not guarantee that emails are virus-free or that documents
> have not be altered, and does not take responsibility in this 

Re: [R] Problem with R coding

2024-03-12 Thread CALUM POLWART
That's almost certainly going to be either the utf-8 character in the path
OR the use of one drive which isn't really a subfolder as I understand it.

When I've had these issues in the past, I've been able to mount a drive
(say U:/ ) which sites further down /up the folder tree so that R just
called "U:/RCodeFolder/Rfile.R"

Is that possible with an C drive?

On Tue, 12 Mar 2024, 10:40 Ivan Krylov via R-help, 
wrote:

> Dear Maria,
>
> I'm sorry for somehow completely missing the second half of your
> message where you say that you've already tried the workaround.
>
> В Tue, 12 Mar 2024 07:43:08 +
> Maria Del Mar García Zamora  пишет:
>
> > I have tried to start R from CDM using: C:\Users\marga>set
> > R_USER=C:\Users\marga\R_USER
> >
> > C:\Users\marga>"C:\Users\marga\Desktop\R-4.3.3\bin\R.exe" CMD Rgui
> >
> > At the beginning this worked but right now a message saying that this
> > app cannot be used and that I have to ask the software company (photo
> > attached)
>
> Glad to know the workaround helped. It sounds like your Windows
> 10 is set up in a user-hostile way.
>
> It may help to visit the Windows Security settings and make an
> exception for C:\Users\marga\Desktop\R-4.3.3\bin\R.exe. An approximate
> instruction can be found at
> , but it
> might be the case that your university IT must take a look at it before
> allowing you to run R on your computer.
>
> Feel free to disregard this advice if someone with more Windows
> experience shows up.
>
> --
> 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.
>

[[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] Problem with R coding

2024-03-12 Thread Ivan Krylov via R-help
Dear Maria,

I'm sorry for somehow completely missing the second half of your
message where you say that you've already tried the workaround.

В Tue, 12 Mar 2024 07:43:08 +
Maria Del Mar García Zamora  пишет:

> I have tried to start R from CDM using: C:\Users\marga>set
> R_USER=C:\Users\marga\R_USER
> 
> C:\Users\marga>"C:\Users\marga\Desktop\R-4.3.3\bin\R.exe" CMD Rgui  
> 
> At the beginning this worked but right now a message saying that this
> app cannot be used and that I have to ask the software company (photo
> attached)

Glad to know the workaround helped. It sounds like your Windows
10 is set up in a user-hostile way.

It may help to visit the Windows Security settings and make an
exception for C:\Users\marga\Desktop\R-4.3.3\bin\R.exe. An approximate
instruction can be found at
, but it
might be the case that your university IT must take a look at it before
allowing you to run R on your computer.

Feel free to disregard this advice if someone with more Windows
experience shows up.

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


Re: [R] Problem with R coding

2024-03-12 Thread Ivan Krylov via R-help
В Tue, 12 Mar 2024 07:43:08 +
Maria Del Mar García Zamora  пишет:

> Error: package or namespace load failed for ‘Rcmdr’:
>  .onLoad failed in loadNamespace() for 'tcltk2', details:
>   call: file.exists("~/.Rtk2theme")
>   error: file name conversion problem -- name too long?
> 
> Once this appears I use path.expand('~') and this is R's answer:
> [1] "C:\\Users\\marga\\OneDrive - Fundaci\xf3n Universitaria San
> Pablo CEU\\Documentos"

We've seen this problem before:
https://stat.ethz.ch/pipermail/r-help/2023-December/478732.html

The workaround that should help is to set the R_USER environment
variable to C:\Users\marga before launching R.

Please let me know if you're willing to debug R. (This will likely
involve compiling R from source with debugging symbols enabled and
stepping through the code.) There are no places in the Windows code
where R gets the conversion obviously wrong. I don't have OneDrive and I
wasn't able to convince R to return an invalid R_USER path without it.
I'm halfway convinced this is due to a bug in OneDrive itself.

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


Re: [R] Problem with R coding

2024-03-12 Thread Rui Barradas

Às 07:43 de 12/03/2024, Maria Del Mar García Zamora escreveu:

Hello,

This is the error that appears when I try to load library(Rcmdr). I am using R 
version 4.3.3. I have tried to upload the packages, uninstall them and 
intalling them again and nothing.
Loading required package: splines
Loading required package: RcmdrMisc
Loading required package: car
Loading required package: carData
Loading required package: sandwich
Loading required package: effects
lattice theme set by effectsTheme()
See ?effectsTheme for details.
Error: package or namespace load failed for ‘Rcmdr’:
  .onLoad failed in loadNamespace() for 'tcltk2', details:
   call: file.exists("~/.Rtk2theme")
   error: file name conversion problem -- name too long?

Once this appears I use path.expand('~') and this is R's answer:
[1] "C:\\Users\\marga\\OneDrive - Fundaci\xf3n Universitaria San Pablo 
CEU\\Documentos"

The thing is that in spanish we use accents, so this word (Fundaci\xf3n) really 
is Fundación, but I can't change it.

I have tried to start R from CDM using: C:\Users\marga>set 
R_USER=C:\Users\marga\R_USER

C:\Users\marga>"C:\Users\marga\Desktop\R-4.3.3\bin\R.exe" CMD Rgui

At the beginning this worked but right now a message saying that this app 
cannot be used and that I have to ask the software company (photo attached)

What should I do?

Thanks,

Mar


[https://www.uchceu.es/img/externos/correo/ceu_uch.gif]

Maria Del Mar García Zamora
Alumno UCHCEU -
Universidad CEU Cardenal Herrera
-
Tel.
www.uchceu.es

[https://www.uchceu.es/img/logos/wur.jpg]
[https://www.uchceu.es/img/externos/correo/medio_ambiente.gif] Por favor, 
piensa en el medio ambiente antes de imprimir este contenido



[http://www.uchceu.es/img/externos/correo/ceu_uch.gif]

Maria Del Mar García Zamora

www.uchceu.es

[http://www.uchceu.es/img/externos/correo/medio_ambiente.gif] Por favor, piensa 
en el medio ambiente antes de imprimir este contenido




Este mensaje y sus archivos adjuntos, enviados desde FUNDACIÓN UNIVERSITARIA 
SAN PABLO-CEU, pueden contener información confidencial y está destinado a ser 
leído sólo por la persona a la que va dirigido, por lo que queda prohibida la 
difusión, copia o utilización de dicha información por terceros. Si usted lo 
recibiera por error, por favor, notifíquelo al remitente y destruya el mensaje 
y cualquier documento adjunto que pudiera contener. Cualquier información, 
opinión, conclusión, recomendación, etc. contenida en el presente mensaje no 
relacionada con la actividad de FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU, y/o 
emitida por persona no autorizada para ello, deberá considerarse como no 
proporcionada ni aprobada por FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU, que pone 
los medios a su alcance para garantizar la seguridad y ausencia de errores en 
la correspondencia electrónica, pero no puede asegurar la inexistencia de virus 
o la no alteración de los documentos transmitidos electrónicamente, por lo que 
declina cualquier responsabilidad a este respecto.

This message and its attachments, sent from FUNDACIÓN UNIVERSITARIA SAN 
PABLO-CEU, may contain confidential information and is intended to be read only 
by the person it is directed. Therefore any disclosure, copying or use by third 
parties of this information is prohibited. If you receive this in error, please 
notify the sender and destroy the message and any attachments may contain. Any 
information, opinion, conclusion, recommendation,... contained in this message 
and which is unrelated to the business activity of FUNDACIÓN UNIVERSITARIA SAN 
PABLO-CEU and/or issued by unauthorized personnel, shall be considered 
unapproved by FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU. FUNDACIÓN UNIVERSITARIA 
SAN PABLO-CEU implements control measures to ensure, as far as possible, the 
security and reliability of all its electronic correspondence. However, 
FUNDACIÓN UNIVERSITARIA SAN PABLO-CEU does not guarantee that emails are 
virus-free or that documents have not be altered, and does not take 
responsibility in this respect.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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,

First of all, try running Rgui only, no R.exe CMD. Just Rgui.exe or
C:\Users\marga\Desktop\R-4.3.3\bin\Rgui.exe
Then, in Rgui, try loading Rcmdr

library(Rcmdr)


Also, do you have R in your Windows PATH variable? The directory to put 
in PATH should be


C:\Users\marga\Desktop\R-4.3.3\bin

so that Windows can find R.exe and Rgui.exe without the full path name.

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
__

Re: [R] [External] Function environments serialize to a lot of data until they don't

2024-03-11 Thread Ivan Krylov via R-help
Dear Luke,

Thank you for the detailed explanation of the power of force()! It does
solve my problem in a much more reliable manner than setting function
environments manually.

On Fri, 8 Mar 2024 15:46:52 -0600 (CST)
luke-tier...@uiowa.edu wrote:

> Having a reference to a large environment is not much of an issue
> within a single process, but can be in a distributed memory parallel
> computing context.  To avoid this you can force evaluation of the
> promises:
> 
>  mkLL1 <- function(m, s) {
>   force(m)
>   force(s)
>   function(x) sum(dnorm(x, m, s, log = TRUE))
>  }
>  ll <- f(1e7)
>  length(serialize(ll, NULL))
>  ## [1] 2146

I think this also illustrates the danger of letting side effects come
near function arguments. A promise to read a file could survive on a
cluster node and result in a lot of head-scratching. A promise to write
to the connection number N, which coincides with a connection open on
the cluster node, could even do some damage. This is definitely
something to remember when creating closures.

> A very simple tool available in the snow package for snow clusters is
> snow.time(), which can produce some summary times and a Gantt chart
> (patterned after ones produced by xpvm and xmpi).

I can see the snow.time() plot being useful. Thank you for letting me
know about it!

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


[ESS] Error installing on Mac

2024-03-09 Thread Sparapani, Rodney via ESS-help
Hi Liz:

I would just echo Martin�s remarks.  Start with
Vincent�s great resource at
https://emacs-modified.gitlab.io
And then install ESS 24.01.1 over it with make.
That�s what I do.  Thanks

--
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

If this is outside of working hours, then please respond when convenient.

[[alternative HTML version deleted]]

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


Re: [R] [External] Function environments serialize to a lot of data until they don't

2024-03-08 Thread luke-tierney--- via R-help

On Fri, 8 Mar 2024, Ivan Krylov via R-help wrote:


Hello R-help,

I've noticed that my 'parallel' jobs take too much memory to store and
transfer to the cluster workers. I've managed to trace it to the
following:

# `payload` is being written to the cluster worker.
# The function FUN had been created as a closure inside my package:
payload$data$args$FUN
# function (l, ...)
# withCallingHandlers(fun(l$x, ...), error = .wraperr(l$name))
# 
# 

# The function seems to bring a lot of captured data with it.
e <- environment(payload$data$args$FUN)
length(serialize(e, NULL))
# [1] 738202878
parent.env(e)
# 

# The parent environment has a name, so it all must be right here.
# What is it?

ls(e, all.names = TRUE)
# [1] "fun"
length(serialize(e$fun, NULL))
# [1] 317

# The only object in the environment is small!
# Where is the 700 megabytes of data?

length(serialize(e, NULL))
# [1] 536
length(serialize(payload$data$args$FUN, NULL))
# [1] 1722

And once I've observed `fun`, the environment becomes very small and
now can be serialized in a very compact manner.

I managed to work around it by forcing the promise and explicitly
putting `fun` in a small environment when constructing the closure:

.wrapfun <- function(fun) {
e <- new.env(parent = loadNamespace('mypackage'))
e$fun <- fun
# NOTE: a naive return(function(...)) could serialize to 700
# megabytes due to `fun` seemingly being a promise (?). Once the
# promise is resolved, suddenly `fun` is much more compact.
ret <- function(l, ...) withCallingHandlers(
 fun(l$x, ...),
 error = .wraperr(l$name)
)
environment(ret) <- e
ret
}


Creating and setting environments is brittle and easy to get wrong. I
prefer to use a combination of proper lexical scoping, regular
assignments, and force() as I do below.


Is this analysis correct? Could a simple f <- force(fun) have sufficed?
Where can I read more about this type of problems?


Just force(fun), without the assignment, should be enough, or even
just fun, as in

   function(fun) { fun;  }

Using force() make the intent clearer.

Closures or formulas capturing large amount of data is something you
have to be careful about with serialization in general and distributed
memory computing in R in particular. There is a little on it in the
parallel vignette. I know I have talked and written about it in
various places but can't remember a specific reference right now.

I usually define a top level function to create any closures I want to
transmit and make sure they only capture what they need. A common
pattern is provided by a simple function for creating a normal
log-likelihood:

mkLL <- function(x) {
m <- mean(x)
s <- sd(x)
function(y) sum(dnorm(y, m, s, log = TRUE))
}

This avoids recomputing the mean and sd on every call. It is fine for
use within a single process, and the fact that the original data is
available in the environment might even be useful for debugging:

ll <- mkLL(rnorm(10))
environment(ll)$x
##  [1] -0.09202453  0.78901912 -0.66744232  1.36061149  1.50768816
##  [6] -2.60754997  0.68727212  0.31557476  2.02027688 -1.42361769

But it does prevent the data from being garbage-collected until
the returned result is no longer reachable. A more GC-friendly, and
serialization-friendly definition is

mkLL <- function(x) {
m <- mean(x)
s <- sd(x)
x <- NULL  ## not needed anymore; remove from the result's enclosing env
function(y) sum(dnorm(y, m, s, log = TRUE))
}

ll <- mkLL(rnorm(1e7))
length(serialize(ll, NULL))
## [1] 734

If you prefer to calculate the mean and sd yourself you could use

mkLL1 <- function(m, s) function(x) sum(dnorm(x, m, s, log = TRUE))

Until the result is called for the first time the evaluation of the
arguments will be delayed, i.e. encoded in promises that record the
expression to evaluate and the environment in which to evaluate
it:

f <- function(n) {
x <- rnorm(n)
mkLL1(mean(x), sd(x))
}
ll <- f(1e7)
length(serialize(ll, NULL))
## [1] 80002223

Once the arguments are evaluated, the expressions are still needed for
substitute() and such, but the environment is not, so it is dropped,
and if the promise environment can no longer be reached it can be
garbage-collected, It will also no longer appear in a serialization:

ll(1)
## [1] -1.419588
length(serialize(ll, NULL))
## [1] 3537

Having a reference to a large environment is not much of an issue
within a single process, but can be in a distributed memory parallel
computing context.  To avoid this you can force evaluation of the
promises:

mkLL1 <- function(m, s) {
force(m)
force(s)
function(x) sum(dnorm(x, m, s, log = TRUE))
}
ll <- f(1e7)
length(serialize(ll, NULL))
## [1] 2146

The possibility of inadvertently transferring too much data is an
issue in distributed memory computing in general, so there are various
tools that help. A very 

[R] Function environments serialize to a lot of data until they don't

2024-03-08 Thread Ivan Krylov via R-help
Hello R-help,

I've noticed that my 'parallel' jobs take too much memory to store and
transfer to the cluster workers. I've managed to trace it to the
following:

# `payload` is being written to the cluster worker.
# The function FUN had been created as a closure inside my package:
payload$data$args$FUN
# function (l, ...) 
# withCallingHandlers(fun(l$x, ...), error = .wraperr(l$name))
# 
# 

# The function seems to bring a lot of captured data with it.
e <- environment(payload$data$args$FUN)
length(serialize(e, NULL))
# [1] 738202878  
parent.env(e)
# 

# The parent environment has a name, so it all must be right here.
# What is it?

ls(e, all.names = TRUE)
# [1] "fun"
length(serialize(e$fun, NULL))
# [1] 317

# The only object in the environment is small!
# Where is the 700 megabytes of data?

length(serialize(e, NULL))
# [1] 536
length(serialize(payload$data$args$FUN, NULL))
# [1] 1722

And once I've observed `fun`, the environment becomes very small and
now can be serialized in a very compact manner.

I managed to work around it by forcing the promise and explicitly
putting `fun` in a small environment when constructing the closure:

.wrapfun <- function(fun) {
 e <- new.env(parent = loadNamespace('mypackage'))
 e$fun <- fun
 # NOTE: a naive return(function(...)) could serialize to 700
 # megabytes due to `fun` seemingly being a promise (?). Once the
 # promise is resolved, suddenly `fun` is much more compact.
 ret <- function(l, ...) withCallingHandlers(
  fun(l$x, ...),
  error = .wraperr(l$name)
 )
 environment(ret) <- e
 ret
}

Is this analysis correct? Could a simple f <- force(fun) have sufficed?
Where can I read more about this type of problems?

If this really is due to promises, what would be the downsides of
forcing them during serialization?

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


Re: [ESS] Error installing on Mac

2024-03-08 Thread Martin Maechler via ESS-help
> Liz Hare via ESS-help 
> on Thu, 7 Mar 2024 09:49:12 -0500 writes:
> Liz Hare via ESS-help 
> on Thu, 7 Mar 2024 09:49:12 -0500 writes:

> Hi all,

> I'm updating ESS by installing from source. I uncommented the MacOS 
related lines from makeconfig, but I get this error:

I think you mean  ess/Makeconf, right?

In there, indeed it uses things like

PREFIX=/Applications/Emacs.app/Contents/Resources
EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs

>> make
> /bin/sh: /Applications/Emacs.app/Contents/MacOS/Emacs: No such file or 
directory

and obviously your Emacs is not at the above 'EMACS=' location.
I have no make at disposal, but maybe a Mac user can help:

Where is your Emacs installing into?

> * VERSIONS **

> ESS 24.01.1
> ESSR 1.8
> sed: 1: "lisp/ess-custom.el": extra characters at the end of l command
> make: *** [version] Error 1

> This error appears to be related to the fact that the BSD sed on Mac is 
different than the GNU sed.

hmm.. our Makefile only uses pretty basic  'sed' calls; hence I'm not sure.
Also strange that the error messages end with "end of l command"
-- in the few sed uses in our Makefile/Makeconf  I only see
versions of  sed s/.../  or  sed "s| ...|p"  i.e., not  "l command"..

> I looked for a similar issue on GitHub but didn't find anything.

Would installing the whole bundle   Emacs+ESS+{more}
from Vincent Goulet's website, mentioned
at   https://ess.r-project.org/  i.e.
 https://ess.r-project.org/index.php?Section=download

be an option: For a few years now  it's been
as   https://emacs-modified.gitlab.io/  then for macOS
at   https://emacs-modified.gitlab.io/macos/

however that currently is not using the latest ESS version (but
something quite close to it).

Still agree that would be a workaround,  and we should try to
ensure that macOS users can install ESS from the sources.

I have started to recommend installing the 'ess' package


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

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


[ESS] Error installing on Mac

2024-03-07 Thread Liz Hare via ESS-help
Hi all,

I'm updating ESS by installing from source. I uncommented the MacOS related 
lines from makeconfig, but I get this error:

> make
/bin/sh: /Applications/Emacs.app/Contents/MacOS/Emacs: No such file or directory
* VERSIONS **

ESS 24.01.1
ESSR 1.8
sed: 1: "lisp/ess-custom.el": extra characters at the end of l command
make: *** [version] Error 1

This error appears to be related to the fact that the BSD sed on Mac is 
different than the GNU sed.

I looked for a similar issue on GitHub but didn't find anything.

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


Re: [R] How to invert axis within defined range with ggplot2 scale_y_reverse?

2024-03-05 Thread Luigi Marongiu
Thank you. I though the values would have been reversed automatically.
Case closed then

On Tue, Mar 5, 2024 at 2:43 PM Duncan Murdoch  wrote:
>
> On 05/03/2024 7:16 a.m., Luigi Marongiu wrote:
> > A <- rep(c(0, 3, 6, 12, 24), 3)
> > B <- c(rep(0,5), rep(1,5), rep(2,5))
> > V <- c(27.5,27.01,27.75,27.98,27.4,25.69,
> > 26.17,27.78,26.08,
> > 24.97,23.18,21.78,22.49,21.85,22.2)
> > df <- data.frame(Conc = A, Time = B, Value = V)
> > df$Conc = as.factor(df$Conc)
> > df$Time = as.factor(df$Time)
> > library(ggplot2)
> >
> > ggplot(df, aes(x=Time, y=Value, colour=Conc, group=Conc)) +
> >geom_line() +
> >scale_y_reverse(limits = c(20,30)) +
> >geom_point(size=6) +
> >scale_colour_manual(values = COLS)
>
> The limits should be `c(30,20)`.
>
> Duncan Murdoch



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


Re: [R] How to invert axis within defined range with ggplot2 scale_y_reverse?

2024-03-05 Thread Duncan Murdoch

On 05/03/2024 7:16 a.m., Luigi Marongiu wrote:

A <- rep(c(0, 3, 6, 12, 24), 3)
B <- c(rep(0,5), rep(1,5), rep(2,5))
V <- c(27.5,27.01,27.75,27.98,27.4,25.69,
26.17,27.78,26.08,
24.97,23.18,21.78,22.49,21.85,22.2)
df <- data.frame(Conc = A, Time = B, Value = V)
df$Conc = as.factor(df$Conc)
df$Time = as.factor(df$Time)
library(ggplot2)

ggplot(df, aes(x=Time, y=Value, colour=Conc, group=Conc)) +
   geom_line() +
   scale_y_reverse(limits = c(20,30)) +
   geom_point(size=6) +
   scale_colour_manual(values = COLS)


The limits should be `c(30,20)`.

Duncan Murdoch

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


[R] How to invert axis within defined range with ggplot2 scale_y_reverse?

2024-03-05 Thread Luigi Marongiu
Hello,
I am drawing some data with ggplot2 and would like to reverse the
order of the y axis and set a custom range for it.
I can do the former but when I add the key `limits` to
`scale_y_reverse` I get an error as shows below and, worse, no data
shown in the plot.
How can I properly set a reverse y scale with a defined range in ggplot2?
Thank you

```
A <- rep(c(0, 3, 6, 12, 24), 3)
B <- c(rep(0,5), rep(1,5), rep(2,5))
V <- c(27.5,27.01,27.75,27.98,27.4,25.69,
26.17,27.78,26.08,
   24.97,23.18,21.78,22.49,21.85,22.2)
df <- data.frame(Conc = A, Time = B, Value = V)
df$Conc = as.factor(df$Conc)
df$Time = as.factor(df$Time)
library(ggplot2)

ggplot(df, aes(x=Time, y=Value, colour=Conc, group=Conc)) +
  geom_line() +
  scale_y_reverse(limits = c(20,30)) +
  geom_point(size=6) +
  scale_colour_manual(values = COLS)

> Warning messages:
1: Removed 15 rows containing missing values (`geom_line()`).
2: Removed 15 rows containing missing values (`geom_point()`).
```

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Default t test in R is Welch's test, not Student's, and can be very problematic

2024-03-04 Thread Curtis, David
Hi all.

I'm just writing to draw your attention to this paper, which is Open Access:

Curtis, D. Welch�s t test is more sensitive to real world violations of 
distributional assumptions than student�s t test but logistic regression is 
more robust than either. Stat Papers (2024). 
https://doi.org/10.1007/s00362-024-01531-7
https://link.springer.com/article/10.1007/s00362-024-01531-7?utm_source=rct_congratemailt_medium=email_campaign=oa_20240304_content=10.1007/s00362-024-01531-7

I hadn't really noticed that the default implementation of the t test in R uses 
Welch's method rather than Student's. I know some people prefer Welch's method 
but the paper describes how it can be systematically biased and produce 
extremely low p values in real world scenarios.

If you agree with me, you might want to consider generally using Student's test 
instead, by using t.test(x, y, var.equal = TRUE).

Code to demonstrate the problem and play around with different scenarios, as 
described in the paper, is at: 
https://github.com/davenomiddlenamecurtis/TestTTest

Regards


  *   Dave Curtis

--
Professor David Curtis MD PhD
UCL Genetics Institute
University College London



[[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] Initializing vector and matrices

2024-03-02 Thread Jeff Newmiller via R-help
To be fair, these replies no longer include the original question, which was 
IMO really quite clear (if misguided), and was actually targeted at 
understanding pre-allocation for better performance. Richard's suggestion to 
store the along-the-way constructed vectors in a list and examine the lengths 
of the elements of that list after it is completely constructed if it is really 
desired to force vectors of varying lengths into a matrix seems appropriate. 
The possibly-misguided part is in the thought that vectors of different lengths 
belong in a matrix at all... leaving them in a list seems more likely to be 
appropriate.

OP: Avoid mis-using NA to "fill out" the end of uniform-length vectors. Each 
index position in a vector should represent some information... if you are 
throwing NAs or zeros in willy-nilly then you are not taking care to assign 
meaning to those positions, and likely wasting memory and time doing so. If you 
were taking such care, then any appropriate NAs would already be present in the 
vectors before you put them into the matrix, and the original question would 
not have crossed OPs mind because the vectors world already be of the same 
length. NA means that information for a specific position is "unknown", not 
"space filler".

Now if OP wants better guidance on restructuring their analysis, then certainly 
sharing those details would help the discussion move away from the original 
misguided question... but that would be another thread to answer the question 
that should have been asked.

On March 2, 2024 9:53:41 AM PST, Bert Gunter  wrote:
>"It would be really really helpful to have a clearer idea of what you
>are trying to do."
>
>Amen!
>
>But in R, "constructing" objects by extending them piece by piece is
>generally very inefficient (e.g.
>https://r-craft.org/growing-objects-and-loop-memory-pre-allocation/),
>although sometimes?/often? unavoidable (hence the relevance of your
>comment above). R generally prefers to take a "whole object" point of
>view ( see R books by Chambers, et. al.) and provides code for basic
>operations like vector/matrix, etc. construction to do so. When this
>is not possible, I suspect "optimal" efficient strategies for
>allocating space to build objects gets you into the weeds of how R
>works.
>
>Cheers,
>Bert
>
>
>
>
>On Sat, Mar 2, 2024 at 1:02 AM Richard O'Keefe  wrote:
>>
>> The matrix equivalent of
>>   x <- ...
>>   v <- ...
>>   x[length(x)+1] <- v
>> is
>>   m <- ...
>>   r <- ...
>>   m <- rbind(m, r)
>> or
>>   m <- ...
>>   k <- ...
>>   m <- cbind(m, c)
>>
>> A vector or matrix so constructed never has "holes" in it.
>> It's better to think of CONSTRUCTING vectors and matrices rather than
>> INITIALISING them,
>> because always being fully defined is important.
>>
>> It would be really really helpful to have a clearer idea of what you
>> are trying to do.
>>
>> On Fri, 1 Mar 2024 at 03:31, Ebert,Timothy Aaron  wrote:
>> >
>> > You could declare a matrix much larger than you intend to use. This works 
>> > with a few megabytes of data. It is not very efficient, so scaling up may 
>> > become a problem.
>> > m22 <- matrix(NA, 1:60, ncol=6)
>> >
>> > It does not work to add a new column to the matrix, as in you get an error 
>> > if you try m22[ , 7] but convert to data frame and add a column
>> >
>> > m23 <- data.frame(m22)
>> > m23$x7 <- 12
>> >
>> > The only penalty that I know of to having unused space in a matrix is the 
>> > amount of memory it takes. One side effect is that your program may have a 
>> > mistake that you would normally catch with a subscript out of bounds error 
>> > but with the extra space it now runs without errors.
>> >
>> > Tim
>> >
>> >
>> >
>> > -Original Message-
>> > From: R-help  On Behalf Of Richard O'Keefe
>> > Sent: Thursday, February 29, 2024 5:29 AM
>> > To: Steven Yen 
>> > Cc: R-help Mailing List 
>> > Subject: Re: [R] Initializing vector and matrices
>> >
>> > [External Email]
>> >
>> > x <- numeric(0)
>> > for (...) {
>> > x[length(x)+1] <- ...
>> > }
>> > works.
>> > You can build a matrix by building a vector one element at a time this 
>> > way, and then reshaping it at the end.  That only works if you don't need 
>> > it to be a matrix at all times.
>> > Another approach is to build a list of rows.  It's not a matrix, but a 
>> > list of rows can be a *ragged* matrix with rows of varying length.
>> >
>> > On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:
>> > >
>> > > Is there as way to initialize a vector (matrix) with an unknown length
>> > > (dimension)? NULL does not seem to work. The lines below work with a
>> > > vector of length 4 and a matrix of 4 x 4. What if I do not know
>> > > initially the length/dimension of the vector/matrix?
>> > >
>> > > All I want is to add up (accumulate)  the vector and matrix as I go
>> > > through the loop.
>> > >
>> > > Or, are there other ways to accumulate such vectors and matrices?
>> > >
>> > >  > x<-rep(0,4)  # this works but I like 

Re: [R] Initializing vector and matrices

2024-03-02 Thread Bert Gunter
"It would be really really helpful to have a clearer idea of what you
are trying to do."

Amen!

But in R, "constructing" objects by extending them piece by piece is
generally very inefficient (e.g.
https://r-craft.org/growing-objects-and-loop-memory-pre-allocation/),
although sometimes?/often? unavoidable (hence the relevance of your
comment above). R generally prefers to take a "whole object" point of
view ( see R books by Chambers, et. al.) and provides code for basic
operations like vector/matrix, etc. construction to do so. When this
is not possible, I suspect "optimal" efficient strategies for
allocating space to build objects gets you into the weeds of how R
works.

Cheers,
Bert




On Sat, Mar 2, 2024 at 1:02 AM Richard O'Keefe  wrote:
>
> The matrix equivalent of
>   x <- ...
>   v <- ...
>   x[length(x)+1] <- v
> is
>   m <- ...
>   r <- ...
>   m <- rbind(m, r)
> or
>   m <- ...
>   k <- ...
>   m <- cbind(m, c)
>
> A vector or matrix so constructed never has "holes" in it.
> It's better to think of CONSTRUCTING vectors and matrices rather than
> INITIALISING them,
> because always being fully defined is important.
>
> It would be really really helpful to have a clearer idea of what you
> are trying to do.
>
> On Fri, 1 Mar 2024 at 03:31, Ebert,Timothy Aaron  wrote:
> >
> > You could declare a matrix much larger than you intend to use. This works 
> > with a few megabytes of data. It is not very efficient, so scaling up may 
> > become a problem.
> > m22 <- matrix(NA, 1:60, ncol=6)
> >
> > It does not work to add a new column to the matrix, as in you get an error 
> > if you try m22[ , 7] but convert to data frame and add a column
> >
> > m23 <- data.frame(m22)
> > m23$x7 <- 12
> >
> > The only penalty that I know of to having unused space in a matrix is the 
> > amount of memory it takes. One side effect is that your program may have a 
> > mistake that you would normally catch with a subscript out of bounds error 
> > but with the extra space it now runs without errors.
> >
> > Tim
> >
> >
> >
> > -Original Message-
> > From: R-help  On Behalf Of Richard O'Keefe
> > Sent: Thursday, February 29, 2024 5:29 AM
> > To: Steven Yen 
> > Cc: R-help Mailing List 
> > Subject: Re: [R] Initializing vector and matrices
> >
> > [External Email]
> >
> > x <- numeric(0)
> > for (...) {
> > x[length(x)+1] <- ...
> > }
> > works.
> > You can build a matrix by building a vector one element at a time this way, 
> > and then reshaping it at the end.  That only works if you don't need it to 
> > be a matrix at all times.
> > Another approach is to build a list of rows.  It's not a matrix, but a list 
> > of rows can be a *ragged* matrix with rows of varying length.
> >
> > On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:
> > >
> > > Is there as way to initialize a vector (matrix) with an unknown length
> > > (dimension)? NULL does not seem to work. The lines below work with a
> > > vector of length 4 and a matrix of 4 x 4. What if I do not know
> > > initially the length/dimension of the vector/matrix?
> > >
> > > All I want is to add up (accumulate)  the vector and matrix as I go
> > > through the loop.
> > >
> > > Or, are there other ways to accumulate such vectors and matrices?
> > >
> > >  > x<-rep(0,4)  # this works but I like to leave the length open  >
> > > for (i in 1:3){
> > > +  x1<-1:4
> > > +  x<-x+x1
> > > + }
> > >  > x
> > > [1]  3  6  9 12
> > >
> > >  > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to
> > > leave the dimension open
> > >   [,1] [,2] [,3] [,4]
> > > [1,]0000
> > > [2,]0000
> > > [3,]0000
> > > [4,]0000
> > >  > for (i in 1:3){
> > > +   y1<-matrix(17:32, nrow = 4, ncol = 4)
> > > +   y<-y+y1
> > > + }
> > >  > y
> > >   [,1] [,2] [,3] [,4]
> > > [1,]   51   63   75   87
> > > [2,]   54   66   78   90
> > > [3,]   57   69   81   93
> > > [4,]   60   72   84   96
> > >  >
> > >
> > > __
> > > 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
> > > %7Cdbccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84
> > > %7C0%7C0%7C638447993707432549%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> > > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
> > > PtWjcDOnwO7PArVOSdgYbpz8ksjDPK%2Bn9ySyhwQC0gE%3D=0
> > > PLEASE do read the posting guide
> > > http://www.r/
> > > -project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7Cdb
> > > ccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> > > 7C0%7C638447993707438911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> > > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=Igb16
> > > CBYgG21HLEDH4I4gfjjFBa3KjDFK8yEZUmBo8s%3D=0
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > 

Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-02 Thread Benjamin Tyner

Thank you Ivan and Richard...

Short version: a simple "sudo apt install texlive" fixed it.

Longer version (attempt at a post-mortem): previously (back on 
2023-11-05) on this same system I built R version 4.3.2; and 
/home/btyner/R432/lib/R/doc/NEWS.pdf does exist (and is a valid pdf with 
48 pages) from that same install. Likewise before that on 2023-07-02 I 
built R version 4.3.1 and the NEWS.pdf is fine (47 pages) there too.


Still not sure how it happened that my system lost track of the 
necessary texlive add-ons at some point between 2023-11-05 and now, but 
running "sudo apt install texlive" made it clear that 
texlive-latex-recommended was indeed one of the culprits as suggested by 
Richard.


   The following additional packages will be installed:
  fonts-texgyre tex-gyre texlive-fonts-recommended
   texlive-latex-recommended tipa
   Suggested packages:
  texlive-fonts-recommended-doc texlive-latex-recommended-doc
   texlive-luatex texlive-pstricks tipa-doc
   The following NEW packages will be installed:
  fonts-texgyre tex-gyre texlive texlive-fonts-recommended
   texlive-latex-recommended tipa

In an attempt to figure out what might have happened after 2023-11-05,

   zgrep texlive /var/log/dpkg.log.*.gz

revealed some texlive related activity back on 2023-11-23 but no 
indication that anything was removed...


   /var/log/dpkg.log.4.gz:2023-11-23 11:02:55 install
   texlive-binaries:amd64  2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:02:55 status half-installed
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:02:56 status unpacked
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:02:56 install texlive-base:all
2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:02:56 status half-installed
   texlive-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:02 status unpacked
   texlive-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:02 install
   texlive-latex-base:all  2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:02 status half-installed
   texlive-latex-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:04 status unpacked
   texlive-latex-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 configure
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1 
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 status unpacked
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 status half-configured
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 status installed
   texlive-binaries:amd64 2021.20210626.59705-1ubuntu0.1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 configure
   texlive-base:all 2021.20220204-1 
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 status unpacked
   texlive-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:05 status half-configured
   texlive-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:09 status installed
   texlive-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:09 configure
   texlive-latex-base:all 2021.20220204-1 
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:09 status unpacked
   texlive-latex-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:09 status half-configured
   texlive-latex-base:all 2021.20220204-1
   /var/log/dpkg.log.4.gz:2023-11-23 11:03:09 status installed
   texlive-latex-base:all 2021.20220204-1

One more thing:

   HISTTIMEFORMAT="%Y-%m-%d %T " history | grep texlive

revealed that I ran "sudo apt install texlive-latex-base" back on 
2024-02-19, so maybe that had something to do with it. Sadly the shell 
history does not exist prior to that date.



On 3/2/24 02:42, Ivan Krylov wrote:

В Fri, 1 Mar 2024 10:46:53 -0500
Benjamin Tyner  пишет:


my platform info:

 Platform: x86_64-pc-linux-gnu (64-bit)
 Running under: Ubuntu 22.04.4 LTS

Quick things first: have you installed all the build-dependencies? apt
build-dep r-base (maybe with --install-suggests? haven't tried that in
a while) should do that. In particular, the build dependencies include
texlive-fonts-extra and texlive-latex-extra. That's a lot of packages,
but some of them are required to compile LaTeX documents produced by R.


 you should 'make docs' now ...
 make[1]: Entering directory '/home/btyner/R-4.3.3/doc'
 creating doc/NEWS
 creating doc/NEWS.pdf
 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
 quiet, :
 unable to run pdflatex on 'NEWS.tex'
 LaTeX errors:
 ! LaTeX Error: File `pdftexcmds.sty' not found.

Can you compile a minimal LaTeX document? Something like:

\documentclass{article}
\begin{document}
\[ \mathbf{y} = \mathbf{X} \beta \]
\end{document}

Does tools::texi2pdf('THISFILE.tex') fail with a similar error 

Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-02 Thread Richard O'Keefe
On my system, pdftexcmds.sty can be found in
/usr/share/texlive/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
A quick poking around with 'apt' and 'dpkg-query -L' told me that this
comes from the
texlive-latex-recommended
Ubuntu package.  So on my system, if I didn't already have this,
sudo apt install texlive-latex-recommended
should fix the problem.

On Sat, 2 Mar 2024 at 04:47, Benjamin Tyner  wrote:
>
>
> A kind member of R-core suggested this is due to a misconfiguration on
> my system, and to post it to the mailing list for troubleshooting.
>
> When trying to build R version 4.3.3, in at least two places during the
> process it gives LaTeX errors of the form:
>
> (example 1)
>
> you should 'make docs' now ...
> make[1]: Entering directory '/home/btyner/R-4.3.3/doc'
> creating doc/NEWS
> creating doc/NEWS.pdf
> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
> quiet, :
> unable to run pdflatex on 'NEWS.tex'
> LaTeX errors:
> ! LaTeX Error: File `pdftexcmds.sty' not found.
>
> Type X to quit or  to proceed,
> or enter new name. (Default extension: sty)
>
> ! Emergency stop.
> 
>
> l.108 RequirePackage{pdftexcmds}[2018/09/10]
> ^^M
> ! ==> Fatal error occurred, no output PDF file produced!
> Calls:  -> texi2pdf -> texi2dvi
> Execution halted
> make[1]: /*/ [Makefile:74: NEWS.pdf] Error 1
> make[1]: Leaving directory '/home/btyner/R-4.3.3/doc'
> make: [Makefile:73: docs] Error 2 (ignored)
>
> (example 2)
>
> make[1]: Entering directory '/home/btyner/R-4.3.3/src/library'
> building/updating vignettes for package 'grid' ...
> building/updating vignettes for package 'parallel' ...
> building/updating vignettes for package 'utils' ...
> building/updating vignettes for package 'stats' ...
> processing 'reshape.Rnw'
> Error: compiling TeX file 'reshape.tex' failed with message:
> unable to run pdflatex on 'reshape.tex'
> LaTeX errors:
> ! LaTeX Error: File `pdftexcmds.sty' not found.
>
> Type X to quit or  to proceed,
> or enter new name. (Default extension: sty)
>
> ! Emergency stop.
> 
>
> l.108 RequirePackage{pdftexcmds}[2018/09/10]
> ^^M
> ! ==> Fatal error occurred, no output PDF file produced!
> Execution halted
> make[1]: ** [Makefile:103: vignettes] Error 1
> make[1]: Leaving directory '/home/btyner/R-4.3.3/src/library'
> make: ** [Makefile:81: vignettes] Error 2
>
> here is my |pdflatex --version| info:
>
> pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
> kpathsea version 6.3.4/dev
> Compiled with libpng 1.6.37; using libpng 1.6.37
> Compiled with zlib 1.2.11; using zlib 1.2.11
> Compiled with xpdf version 4.03
>
> my platform info:
>
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 22.04.4 LTS
>
> I installed from this file with corresponding md5sum
>
> R-4.3.3.tar.xz 5602f5996107c346dba12a16e866d2e2
>
> The specific commands I ran which led to the error were:
>
> wget https://cran.r-project.org/src/base/R-4/R-4.3.3.tar.xz
> mkdir R433
> tar xJf R-4.3.3.tar.xz
> cd R-4.3.3
> ./configure --prefix=/home/btyner/R433
> make
>
> Happy to provide any additional information needed.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Initializing vector and matrices

2024-03-02 Thread Richard O'Keefe
The matrix equivalent of
  x <- ...
  v <- ...
  x[length(x)+1] <- v
is
  m <- ...
  r <- ...
  m <- rbind(m, r)
or
  m <- ...
  k <- ...
  m <- cbind(m, c)

A vector or matrix so constructed never has "holes" in it.
It's better to think of CONSTRUCTING vectors and matrices rather than
INITIALISING them,
because always being fully defined is important.

It would be really really helpful to have a clearer idea of what you
are trying to do.

On Fri, 1 Mar 2024 at 03:31, Ebert,Timothy Aaron  wrote:
>
> You could declare a matrix much larger than you intend to use. This works 
> with a few megabytes of data. It is not very efficient, so scaling up may 
> become a problem.
> m22 <- matrix(NA, 1:60, ncol=6)
>
> It does not work to add a new column to the matrix, as in you get an error if 
> you try m22[ , 7] but convert to data frame and add a column
>
> m23 <- data.frame(m22)
> m23$x7 <- 12
>
> The only penalty that I know of to having unused space in a matrix is the 
> amount of memory it takes. One side effect is that your program may have a 
> mistake that you would normally catch with a subscript out of bounds error 
> but with the extra space it now runs without errors.
>
> Tim
>
>
>
> -Original Message-
> From: R-help  On Behalf Of Richard O'Keefe
> Sent: Thursday, February 29, 2024 5:29 AM
> To: Steven Yen 
> Cc: R-help Mailing List 
> Subject: Re: [R] Initializing vector and matrices
>
> [External Email]
>
> x <- numeric(0)
> for (...) {
> x[length(x)+1] <- ...
> }
> works.
> You can build a matrix by building a vector one element at a time this way, 
> and then reshaping it at the end.  That only works if you don't need it to be 
> a matrix at all times.
> Another approach is to build a list of rows.  It's not a matrix, but a list 
> of rows can be a *ragged* matrix with rows of varying length.
>
> On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:
> >
> > Is there as way to initialize a vector (matrix) with an unknown length
> > (dimension)? NULL does not seem to work. The lines below work with a
> > vector of length 4 and a matrix of 4 x 4. What if I do not know
> > initially the length/dimension of the vector/matrix?
> >
> > All I want is to add up (accumulate)  the vector and matrix as I go
> > through the loop.
> >
> > Or, are there other ways to accumulate such vectors and matrices?
> >
> >  > x<-rep(0,4)  # this works but I like to leave the length open  >
> > for (i in 1:3){
> > +  x1<-1:4
> > +  x<-x+x1
> > + }
> >  > x
> > [1]  3  6  9 12
> >
> >  > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to
> > leave the dimension open
> >   [,1] [,2] [,3] [,4]
> > [1,]0000
> > [2,]0000
> > [3,]0000
> > [4,]0000
> >  > for (i in 1:3){
> > +   y1<-matrix(17:32, nrow = 4, ncol = 4)
> > +   y<-y+y1
> > + }
> >  > y
> >   [,1] [,2] [,3] [,4]
> > [1,]   51   63   75   87
> > [2,]   54   66   78   90
> > [3,]   57   69   81   93
> > [4,]   60   72   84   96
> >  >
> >
> > __
> > 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
> > %7Cdbccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84
> > %7C0%7C0%7C638447993707432549%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
> > PtWjcDOnwO7PArVOSdgYbpz8ksjDPK%2Bn9ySyhwQC0gE%3D=0
> > PLEASE do read the posting guide
> > http://www.r/
> > -project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7Cdb
> > ccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> > 7C0%7C638447993707438911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=Igb16
> > CBYgG21HLEDH4I4gfjjFBa3KjDFK8yEZUmBo8s%3D=0
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.r-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-01 Thread Ivan Krylov via R-help
В Fri, 1 Mar 2024 10:46:53 -0500
Benjamin Tyner  пишет:

> my platform info:
> 
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 22.04.4 LTS

Quick things first: have you installed all the build-dependencies? apt
build-dep r-base (maybe with --install-suggests? haven't tried that in
a while) should do that. In particular, the build dependencies include
texlive-fonts-extra and texlive-latex-extra. That's a lot of packages,
but some of them are required to compile LaTeX documents produced by R.

> you should 'make docs' now ...
> make[1]: Entering directory '/home/btyner/R-4.3.3/doc'
> creating doc/NEWS
> creating doc/NEWS.pdf
> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
> quiet, :
> unable to run pdflatex on 'NEWS.tex'
> LaTeX errors:
> ! LaTeX Error: File `pdftexcmds.sty' not found.

Can you compile a minimal LaTeX document? Something like:

\documentclass{article}
\begin{document}
\[ \mathbf{y} = \mathbf{X} \beta \]
\end{document}

Does tools::texi2pdf('THISFILE.tex') fail with a similar error message?

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


Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-01 Thread Jeff Newmiller via R-help
This really is all LaTeX errors, not R errors. Both examples complain that 
pdftexcmds.sty is not installed. Most "sty" files are in LaTeX packages. Each 
LaTeX distribution has its own way to install packages ... but the difficulty 
is usually on the same order of difficulty as installing R packages from 
CRAN... that is, pretty easy. But you need to read about _your_ TeX system for 
details. I use Google to figure out which package has the given file in it... 
it is usually the same as whatever comes before ".sty", but not always.

On March 1, 2024 7:46:53 AM PST, Benjamin Tyner  wrote:
>
>A kind member of R-core suggested this is due to a misconfiguration on my 
>system, and to post it to the mailing list for troubleshooting.
>
>When trying to build R version 4.3.3, in at least two places during the 
>process it gives LaTeX errors of the form:
>
>(example 1)
>
>   you should 'make docs' now ...
>   make[1]: Entering directory '/home/btyner/R-4.3.3/doc'
>   creating doc/NEWS
>   creating doc/NEWS.pdf
>   Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
>   quiet, :
>   unable to run pdflatex on 'NEWS.tex'
>   LaTeX errors:
>   ! LaTeX Error: File `pdftexcmds.sty' not found.
>
>   Type X to quit or  to proceed,
>   or enter new name. (Default extension: sty)
>
>   ! Emergency stop.
>   
>
>   l.108 RequirePackage{pdftexcmds}[2018/09/10]
>   ^^M
>   ! ==> Fatal error occurred, no output PDF file produced!
>   Calls:  -> texi2pdf -> texi2dvi
>   Execution halted
>   make[1]: /*/ [Makefile:74: NEWS.pdf] Error 1
>   make[1]: Leaving directory '/home/btyner/R-4.3.3/doc'
>   make: [Makefile:73: docs] Error 2 (ignored)
>
>(example 2)
>
>   make[1]: Entering directory '/home/btyner/R-4.3.3/src/library'
>   building/updating vignettes for package 'grid' ...
>   building/updating vignettes for package 'parallel' ...
>   building/updating vignettes for package 'utils' ...
>   building/updating vignettes for package 'stats' ...
>   processing 'reshape.Rnw'
>   Error: compiling TeX file 'reshape.tex' failed with message:
>   unable to run pdflatex on 'reshape.tex'
>   LaTeX errors:
>   ! LaTeX Error: File `pdftexcmds.sty' not found.
>
>   Type X to quit or  to proceed,
>   or enter new name. (Default extension: sty)
>
>   ! Emergency stop.
>   
>
>   l.108 RequirePackage{pdftexcmds}[2018/09/10]
>   ^^M
>   ! ==> Fatal error occurred, no output PDF file produced!
>   Execution halted
>   make[1]: ** [Makefile:103: vignettes] Error 1
>   make[1]: Leaving directory '/home/btyner/R-4.3.3/src/library'
>   make: ** [Makefile:81: vignettes] Error 2
>
>here is my |pdflatex --version| info:
>
>   pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
>   kpathsea version 6.3.4/dev
>   Compiled with libpng 1.6.37; using libpng 1.6.37
>   Compiled with zlib 1.2.11; using zlib 1.2.11
>   Compiled with xpdf version 4.03
>
>my platform info:
>
>   Platform: x86_64-pc-linux-gnu (64-bit)
>   Running under: Ubuntu 22.04.4 LTS
>
>I installed from this file with corresponding md5sum
>
>   R-4.3.3.tar.xz 5602f5996107c346dba12a16e866d2e2
>
>The specific commands I ran which led to the error were:
>
>   wget https://cran.r-project.org/src/base/R-4/R-4.3.3.tar.xz
>   mkdir R433
>   tar xJf R-4.3.3.tar.xz
>   cd R-4.3.3
>   ./configure --prefix=/home/btyner/R433
>   make
>
>Happy to provide any additional information needed.
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] dput(..., file = stderr())

2024-03-01 Thread Ivan Krylov via R-help
В Fri, 1 Mar 2024 10:54:08 -0500
Benjamin Tyner  пишет:

>  > dput(letters, file = stderr())  
> c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
> "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
> "z")
> Warning message:
> In dput(letters, file = stderr()) : wrote too few characters

Sounds like a bug.

This is where the warning is produced:

int res = Rconn_printf(con, "%s\n", CHAR(STRING_ELT(tval, i)));
if(!havewarned &&
   res < strlen(CHAR(STRING_ELT(tval, i))) + 1) {
warning(_("wrote too few characters"));
havewarned = TRUE;
}

At this point, `res` is 0, and CHAR(STRING_ELT(tval, i)) is what you'd
expect:

(gdb) x /s (void*)(STRING_ELT(tval, i))+48
0x561bf0a8: "c(\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\",
\"h\", \"i\", \"j\", \"k\", \"l\", "

`res` is 0 because that's what (con->vfprintf)(...) returns:

2813static int stderr_vfprintf(Rconnection con, const char *format, va_list 
ap)
2814{
2815REvprintf(format, ap);
2816return 0;
2817}

Why doesn't it warn for stdout()? Doesn't stdout_vfprintf(...) behave
the same? That's because stdout() (connection #1) is special for dput(),
and instead of going through the connection system, it goes straight for
Rprintf():

426 else { // ifile == 1 : "Stdout"
427 for (int i = 0; i < LENGTH(tval); i++)
428 Rprintf("%s\n", CHAR(STRING_ELT(tval, i)));
429 }

Not sure what the right fix is. There may be code depending on
(con->vfprintf)(...) returning 0.

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


Re: [R] [External] dput(..., file = stderr())

2024-03-01 Thread Richard M. Heiberger
I see the same thing in a fresh R session

> dput(letters, file = stderr())
c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", 
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", 
"z")
Warning message:
In dput(letters, file = stderr()) : wrote too few characters
> dput(letters, file = stdout())
c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", 
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", 
"z")
> version
   _  
platform   aarch64-apple-darwin20 
arch   aarch64
os darwin20   
system aarch64, darwin20  
status Patched
major  4  
minor  3.2
year   2024   
month  01 
day23 
svn rev85822  
language   R  
version.string R version 4.3.2 Patched (2024-01-23 r85822)
nickname   Eye Holes  
> 



> On Mar 1, 2024, at 10:54, Benjamin Tyner  wrote:
> 
> dput(letters, file = stderr())

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
Oh, wait a second. I misread your original post. Please ignore my
truly incorrect suggestion.

-- Bert

On Fri, Mar 1, 2024 at 7:57 AM Bert Gunter  wrote:
>
> Here's another *incorrect* way to do it -- incorrect because it will
> not always work, unlike Iris's correct solution. But it does not
> require PERL type matching. The idea: separate the two vowels in the
> regex by a character that you know cannot appear (if there is such)
> and match it optionally, e.g. with '*" repetition specifier. I used
> "?" for the optional character below (which must be escaped).
>
> >gsub("([aeiouAEIOU])\\?*([aeiouAEIOU])", "\\1_\\2", "aerioue")
> [1] "a_eri_ou_e"
>
> Cheers,
> Bert
>
>
> On Fri, Mar 1, 2024 at 3:59 AM Iago Giné Vázquez  wrote:
> >
> > Hi Iris,
> >
> > Thank you. Further, very nice solution.
> >
> > Best,
> >
> > Iago
> >
> > On 01/03/2024 12:49, Iris Simmons wrote:
> > > Hi Iago,
> > >
> > >
> > > This is not a bug. It is expected. Patterns may not overlap. However, 
> > > there
> > > is a way to get the result you want using perl:
> > >
> > > ```R
> > > gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> > > ```
> > >
> > > The specific change I made is called a positive lookahead, you can read
> > > more about it here:
> > >
> > > https://www.regular-expressions.info/lookaround.html
> > >
> > > It's a way to check for a piece of text without consuming it in the match.
> > >
> > > Also, since you don't care about character case, it might be more legible
> > > to add ignore.case = TRUE and remove the upper case characters:
> > >
> > > ```R
> > > gsub("([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE, ignore.case =
> > > TRUE)
> > >
> > > ## or
> > >
> > > gsub("(?i)([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE)
> > > ```
> > >
> > > I hope this helps!
> > >
> > >
> > > On Fri, Mar 1, 2024, 06:37 Iago Giné Vázquez  wrote:
> > >
> > >> Hi all,
> > >>
> > >> I tested next command:
> > >>
> > >> gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
> > >>
> > >> with the following output:
> > >>
> > >> [1] "a_eri_ou_e"
> > >>
> > >> So, there are two consecutive vowels where an underscore is not added.
> > >>
> > >> May it be a bug? Is it expected (bug or not)? Is there any chance to get
> > >> what I want (an underscore between each pair of consecutive vowels)?
> > >>
> > >>
> > >> Thank you!
> > >>
> > >> 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.
> > >>
> > [[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] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
Here's another *incorrect* way to do it -- incorrect because it will
not always work, unlike Iris's correct solution. But it does not
require PERL type matching. The idea: separate the two vowels in the
regex by a character that you know cannot appear (if there is such)
and match it optionally, e.g. with '*" repetition specifier. I used
"?" for the optional character below (which must be escaped).

>gsub("([aeiouAEIOU])\\?*([aeiouAEIOU])", "\\1_\\2", "aerioue")
[1] "a_eri_ou_e"

Cheers,
Bert


On Fri, Mar 1, 2024 at 3:59 AM Iago Giné Vázquez  wrote:
>
> Hi Iris,
>
> Thank you. Further, very nice solution.
>
> Best,
>
> Iago
>
> On 01/03/2024 12:49, Iris Simmons wrote:
> > Hi Iago,
> >
> >
> > This is not a bug. It is expected. Patterns may not overlap. However, there
> > is a way to get the result you want using perl:
> >
> > ```R
> > gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> > ```
> >
> > The specific change I made is called a positive lookahead, you can read
> > more about it here:
> >
> > https://www.regular-expressions.info/lookaround.html
> >
> > It's a way to check for a piece of text without consuming it in the match.
> >
> > Also, since you don't care about character case, it might be more legible
> > to add ignore.case = TRUE and remove the upper case characters:
> >
> > ```R
> > gsub("([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE, ignore.case =
> > TRUE)
> >
> > ## or
> >
> > gsub("(?i)([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE)
> > ```
> >
> > I hope this helps!
> >
> >
> > On Fri, Mar 1, 2024, 06:37 Iago Giné Vázquez  wrote:
> >
> >> Hi all,
> >>
> >> I tested next command:
> >>
> >> gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
> >>
> >> with the following output:
> >>
> >> [1] "a_eri_ou_e"
> >>
> >> So, there are two consecutive vowels where an underscore is not added.
> >>
> >> May it be a bug? Is it expected (bug or not)? Is there any chance to get
> >> what I want (an underscore between each pair of consecutive vowels)?
> >>
> >>
> >> Thank you!
> >>
> >> 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.
> >>
> [[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] dput(..., file = stderr())

2024-03-01 Thread Benjamin Tyner
Curious to know if this warning is expected behavior, and if so, what is 
the recommended way instead:


> dput(letters, file = stderr())
   c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
   "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
   "z")
   Warning message:
   In dput(letters, file = stderr()) : wrote too few characters

(I ask because it doesn't happen when using file = stdout())

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-01 Thread Benjamin Tyner



A kind member of R-core suggested this is due to a misconfiguration on 
my system, and to post it to the mailing list for troubleshooting.


When trying to build R version 4.3.3, in at least two places during the 
process it gives LaTeX errors of the form:


(example 1)

   you should 'make docs' now ...
   make[1]: Entering directory '/home/btyner/R-4.3.3/doc'
   creating doc/NEWS
   creating doc/NEWS.pdf
   Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
   quiet, :
   unable to run pdflatex on 'NEWS.tex'
   LaTeX errors:
   ! LaTeX Error: File `pdftexcmds.sty' not found.

   Type X to quit or  to proceed,
   or enter new name. (Default extension: sty)

   ! Emergency stop.
   

   l.108 RequirePackage{pdftexcmds}[2018/09/10]
   ^^M
   ! ==> Fatal error occurred, no output PDF file produced!
   Calls:  -> texi2pdf -> texi2dvi
   Execution halted
   make[1]: /*/ [Makefile:74: NEWS.pdf] Error 1
   make[1]: Leaving directory '/home/btyner/R-4.3.3/doc'
   make: [Makefile:73: docs] Error 2 (ignored)

(example 2)

   make[1]: Entering directory '/home/btyner/R-4.3.3/src/library'
   building/updating vignettes for package 'grid' ...
   building/updating vignettes for package 'parallel' ...
   building/updating vignettes for package 'utils' ...
   building/updating vignettes for package 'stats' ...
   processing 'reshape.Rnw'
   Error: compiling TeX file 'reshape.tex' failed with message:
   unable to run pdflatex on 'reshape.tex'
   LaTeX errors:
   ! LaTeX Error: File `pdftexcmds.sty' not found.

   Type X to quit or  to proceed,
   or enter new name. (Default extension: sty)

   ! Emergency stop.
   

   l.108 RequirePackage{pdftexcmds}[2018/09/10]
   ^^M
   ! ==> Fatal error occurred, no output PDF file produced!
   Execution halted
   make[1]: ** [Makefile:103: vignettes] Error 1
   make[1]: Leaving directory '/home/btyner/R-4.3.3/src/library'
   make: ** [Makefile:81: vignettes] Error 2

here is my |pdflatex --version| info:

   pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
   kpathsea version 6.3.4/dev
   Compiled with libpng 1.6.37; using libpng 1.6.37
   Compiled with zlib 1.2.11; using zlib 1.2.11
   Compiled with xpdf version 4.03

my platform info:

   Platform: x86_64-pc-linux-gnu (64-bit)
   Running under: Ubuntu 22.04.4 LTS

I installed from this file with corresponding md5sum

   R-4.3.3.tar.xz 5602f5996107c346dba12a16e866d2e2

The specific commands I ran which led to the error were:

   wget https://cran.r-project.org/src/base/R-4/R-4.3.3.tar.xz
   mkdir R433
   tar xJf R-4.3.3.tar.xz
   cd R-4.3.3
   ./configure --prefix=/home/btyner/R433
   make

Happy to provide any additional information needed.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Interactions in regression

2024-03-01 Thread Jacek Kownacki
 Hi Rolf,
No it is not.
I don't know to which question did you want to respond ?
I desribed everything in my first email and  attached links from SO with
pictures included, which are quite understandable.

Cheers,
Jacek

śr., 28 lut 2024 o 19:42 Jacek Kownacki  napisał(a):

> Hi Rolf,
> No it is not.
> I don't know to which question did you want to respond ?
> I desribed everything in my first email and  attached links from SO with
> pictures included, which are quite understandable.
>
> Cheers,
> Jacek
>
> wt., 27 lut 2024 o 02:29 Rolf Turner  napisał(a):
>
>>
>> I have no real idea what you are trying to do, but if a table is
>> what you want, you can probably get it using the table() function.
>> Or, more likely, the xtabs() function.
>>
>> Using your example from an earlier post (adjusted to make it
>> comprehensible to the human mind):
>>
>> set.seed(1000)
>> time  <- factor(rep(c("Pre","Post"),each=200))
>> treatment <- factor(rep(rep(c("Control","Treatment"),each=100),2))
>> mu<- rep(rep(1:2,each=100),2)
>> response  <- rnorm(400,mean=mu)
>> xmpldata  <- data.frame(time=time,treatment=treatment,response)
>> mod   <- lm(response~time*treatment,data=xmpldata)
>> yhat  <- fitted(mod)
>> xtb   <- with(xmpldata,xtabs(yhat ~ time+treatment))
>>
>> print(xtb)
>>
>> >   treatment
>> > time Control Treatment
>> >   Post  94.10501 201.99112
>> >   Pre  101.63792 210.04248
>>
>> Is that (something like) what you want?
>>
>> cheers,
>>
>> Rolf Turner
>>
>> P.S. You said:  "I usually use GUI software".  Now *there* lies your
>> problem.  A GUI is a black box that removes all control over what is
>> going on, from your hands.
>>
>> R. T.
>>
>>
>>
>>
>> --
>> 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
>>
>

[[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] Interactions in regression

2024-03-01 Thread Jacek Kownacki
Hi Rolf,
No it is not.
I don't know to which question did you want to respond ?
I desribed everything in my first email and  attached links from SO with
pictures included, which are quite understandable.

Cheers,
Jacek

wt., 27 lut 2024 o 02:29 Rolf Turner  napisał(a):

>
> I have no real idea what you are trying to do, but if a table is
> what you want, you can probably get it using the table() function.
> Or, more likely, the xtabs() function.
>
> Using your example from an earlier post (adjusted to make it
> comprehensible to the human mind):
>
> set.seed(1000)
> time  <- factor(rep(c("Pre","Post"),each=200))
> treatment <- factor(rep(rep(c("Control","Treatment"),each=100),2))
> mu<- rep(rep(1:2,each=100),2)
> response  <- rnorm(400,mean=mu)
> xmpldata  <- data.frame(time=time,treatment=treatment,response)
> mod   <- lm(response~time*treatment,data=xmpldata)
> yhat  <- fitted(mod)
> xtb   <- with(xmpldata,xtabs(yhat ~ time+treatment))
>
> print(xtb)
>
> >   treatment
> > time Control Treatment
> >   Post  94.10501 201.99112
> >   Pre  101.63792 210.04248
>
> Is that (something like) what you want?
>
> cheers,
>
> Rolf Turner
>
> P.S. You said:  "I usually use GUI software".  Now *there* lies your
> problem.  A GUI is a black box that removes all control over what is
> going on, from your hands.
>
> R. T.
>
>
>
>
> --
> 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
>

[[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] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi Iris,

Thank you. Further, very nice solution.

Best,

Iago

On 01/03/2024 12:49, Iris Simmons wrote:
> Hi Iago,
>
>
> This is not a bug. It is expected. Patterns may not overlap. However, there
> is a way to get the result you want using perl:
>
> ```R
> gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> ```
>
> The specific change I made is called a positive lookahead, you can read
> more about it here:
>
> https://www.regular-expressions.info/lookaround.html
>
> It's a way to check for a piece of text without consuming it in the match.
>
> Also, since you don't care about character case, it might be more legible
> to add ignore.case = TRUE and remove the upper case characters:
>
> ```R
> gsub("([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE, ignore.case =
> TRUE)
>
> ## or
>
> gsub("(?i)([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE)
> ```
>
> I hope this helps!
>
>
> On Fri, Mar 1, 2024, 06:37 Iago Giné Vázquez  wrote:
>
>> Hi all,
>>
>> I tested next command:
>>
>> gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
>>
>> with the following output:
>>
>> [1] "a_eri_ou_e"
>>
>> So, there are two consecutive vowels where an underscore is not added.
>>
>> May it be a bug? Is it expected (bug or not)? Is there any chance to get
>> what I want (an underscore between each pair of consecutive vowels)?
>>
>>
>> Thank you!
>>
>> 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.
>>
[[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] gsub issue with consecutive pattern finds

2024-03-01 Thread Iris Simmons
Hi Iago,


This is not a bug. It is expected. Patterns may not overlap. However, there
is a way to get the result you want using perl:

```R
gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
```

The specific change I made is called a positive lookahead, you can read
more about it here:

https://www.regular-expressions.info/lookaround.html

It's a way to check for a piece of text without consuming it in the match.

Also, since you don't care about character case, it might be more legible
to add ignore.case = TRUE and remove the upper case characters:

```R
gsub("([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE, ignore.case =
TRUE)

## or

gsub("(?i)([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE)
```

I hope this helps!


On Fri, Mar 1, 2024, 06:37 Iago Giné Vázquez  wrote:

> Hi all,
>
> I tested next command:
>
> gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
>
> with the following output:
>
> [1] "a_eri_ou_e"
>
> So, there are two consecutive vowels where an underscore is not added.
>
> May it be a bug? Is it expected (bug or not)? Is there any chance to get
> what I want (an underscore between each pair of consecutive vowels)?
>
>
> Thank you!
>
> 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.
>

[[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] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi all,

I tested next command:

gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")

with the following output:

[1] "a_eri_ou_e"

So, there are two consecutive vowels where an underscore is not added.

May it be a bug? Is it expected (bug or not)? Is there any chance to get 
what I want (an underscore between each pair of consecutive vowels)?


Thank you!

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.


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

2024-03-01 Thread Martin Maechler
> Berwin A Turlach 
> on Wed, 28 Feb 2024 17:42:27 +0800 writes:

> On Tue, 27 Feb 2024 13:51:25 -0800 Jeff Newmiller via
> R-help  wrote:

>> The fundamental data type in Matlab is a matrix... they
>> don't have vectors, they have Nx1 matrices and 1xM
>> matrices.

> Also known as column vectors and row vectors.  :)
 
>> Vectors don't have any concept of "row" vs. "column".

> They do in (numerical) linear algebra.  And MATLAB was
> written by numerical analysts for numerical analysts. :-)
> So they distinguish between row and column vectors.

> GAUSS also distinguishes between row and column vectors.

There are *vectors* and they belong to a vector space and that's it.
(and yes, arrays of a given rank and dimensions also are
 elements of a vector space, and hence matrices are, and then
 indeed, a 3x1 matrix and a 1x3 matrix are *not* members of the
 same vector space -- even though the two vector spaces are
 isomorphic to each other)

The matlab induced --> applied linear algebra / math
"column- and row-vectors"  have been convenient because then
everything is a matrix (or scalar), and that fits well with a
product called "matlab" which is short for "matrix lab(oratory)".
BUT they are  mathematically confusing and therefore in my view
very undesirable terminology.

I'm very very strongly with Jeff that "the only" consistent
language would be to call them 1-row matrix and 1-column matrix,
because that's what they are, well defined and perfect within 
the well defined math realm of linear algebra.

Yes, matrix-vector calculus , scalar products, bilinear forms, ...
can be generalized in such ways that 1-row matrices and 1-column
matrices can be treated equivalently to vectors and vice versa
.. and that is sometimes convenient. 

Still, the "column-vector"  and "row-vector"  terms have
lead to much confusion in my view,
because really  Nx1  or  1xM  are dimensions of matrices and
*not* of any vectors  ..


> R (and S) does not distinguish between row and column
> vectors, and is in this aspect quite unique among the
> groups of vector-oriented programming languages (AFAICT).

I agree. And that's good -- because "vectors are vectors" aka
"a rank-1 array is a rank-1 array is a rank-1 array" (Richard O'Keefe)

> But treating every vector as a column vector, together
> with the recycling rule, allows for the easy coding of the
> matrix/vector calculations that one (mostly) comes across
> in statistical computing.  For the rare occasion when this
> is not true the sweep() command is provided, typically
> remembered once one was bitten by the lack of distinction
> between row and column vectors. :)

> Cheers,
>   Berwin

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.


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

2024-02-29 Thread Evan Cooch
Very interesting - thanks! Most of my problems are not limited by 
compute speed, but its clear that for some sorts of compute-intensive 
problems, sweep might be a limiting approach.

On 2/29/2024 6:12 PM, Richard M. Heiberger wrote:
> I decided to do a direct comparison of transpose and sweep.
>
>
> library(microbenchmark)
>
> NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)  # Example matrix
> lambda <- c(2, 3, 4)  # Example vector
> colNN <- t(NN)
>
> microbenchmark(
>sweep = sweep(NN, 2, lambda, "/"),
>transpose = t(t(NN)/lambda),
>colNN = colNN/lambda
> )
>
>
> Unit: nanoseconds
>expr   minlq mean median  uq   max neval cld
>   sweep 13817 14145 15115.06  14350 14657.5 75932   100 a
>   transpose  1845  1927  2151.68   2132  2214.0  7093   100  b
>   colNN82   123   141.86123   164.0   492   100   c
>
> Note that transpose is much faster than sweep because it is doing less work,
> I believe essentially just changing the order of indexing.
>
> Using the natural sequencing for column-ordered matrices is much much faster.
>
>> On Feb 28, 2024, at 18:43, peter dalgaard  wrote:
>>
>>> rbind(1:3,4:6)/t(matrix(c(2,3,4), 3,2))
>

[[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] [External] converting MATLAB -> R | element-wise operation

2024-02-29 Thread Richard M. Heiberger
I added two more rows

library(microbenchmark)

NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)  # Example matrix
lambda <- c(2, 3, 4)  # Example vector
colNN <- t(NN)
matlam <- matrix(lambda, byrow=TRUE, nrow=2, ncol=3)

microbenchmark(
  sweep = sweep(NN, 2, lambda, "/"),
  transpose = t(t(NN)/lambda),
  colNN = colNN/lambda,
  fullsize  = NN / matrix(lambda, byrow=TRUE, nrow=2, ncol=3),
  rowlam  = NN / matlam
)

Unit: nanoseconds
  expr   minlq mean  median  uq   max neval cld
 sweep 12546 12792 13919.91 12997.0 13325.0 85608   100 a
 transpose  1640  1763  1986.04  1947.5  2050.0  7462   100  b
 colNN8282   161.13   123.0   123.0  3854   100   c
  fullsize   738   820   932.34   881.5   963.5  2829   100  bc
rowlam82   123   168.92   164.0   164.0   820   100   c

reshaping the denominator to the correct size in advance is very helpful if you 
will be doing this division more than once.



> On Feb 29, 2024, at 18:12, Richard M. Heiberger  wrote:
>
> I decided to do a direct comparison of transpose and sweep.
>
>
> library(microbenchmark)
>
> NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)  # Example matrix
> lambda <- c(2, 3, 4)  # Example vector
> colNN <- t(NN)
>
> microbenchmark(
>  sweep = sweep(NN, 2, lambda, "/"),
>  transpose = t(t(NN)/lambda),
>  colNN = colNN/lambda
> )
>
>
> Unit: nanoseconds
>  expr   minlq mean median  uq   max neval cld
> sweep 13817 14145 15115.06  14350 14657.5 75932   100 a
> transpose  1845  1927  2151.68   2132  2214.0  7093   100  b
> colNN82   123   141.86123   164.0   492   100   c
>
> Note that transpose is much faster than sweep because it is doing less work,
> I believe essentially just changing the order of indexing.
>
> Using the natural sequencing for column-ordered matrices is much much faster.
>
>> On Feb 28, 2024, at 18:43, peter dalgaard  wrote:
>>
>>> rbind(1:3,4:6)/t(matrix(c(2,3,4), 3,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.


Re: [R] Clustering Functions used by Reverse-Dependencies

2024-02-29 Thread Leo Mada via R-help
Dear Ivan,

Thank you very much for this interesting information.

Regarding:
"For well-behaved packages that declare their dependencies correctly,
parsing the NAMESPACE for importFrom() and import() calls should give
you the explicit imports."

I did learn something new (I am not very experienced in package writing). 
Unfortunately, Roxygen2 as of the current version still suggests to use the 
pkg::fname approach:
"If you are using just a few functions from another package, we recommending 
adding the package to the Imports: field of the DESCRIPTION file and calling 
the functions explicitly using ::, e.g., pkg::fun()."
https://roxygen2.r-lib.org/articles/namespace.html

Regarding analysing the actual code: it is good to know that CMD check has also 
some functionality. I will look into it, when I find some free time.

tools:::.check_packages_used is a few pages of code. On the other hand, the 
help page for codetools::checkUsage is quite cryptic. But it's good to know at 
least where to look.

Sincerely,

Leonard


From: Ivan Krylov 
Sent: Wednesday, February 28, 2024 10:36 AM
To: Leo Mada via R-help 
Cc: Leo Mada 
Subject: Re: [R] Clustering Functions used by Reverse-Dependencies

� Sat, 24 Feb 2024 03:08:26 +
Leo Mada via R-help  �:

> Are there any tools to extract the function names called by
> reverse-dependencies?

For well-behaved packages that declare their dependencies correctly,
parsing the NAMESPACE for importFrom() and import() calls should give
you the explicit imports. (What if the package imports the whole
dependency? The safe assumption is that all functions are used, but it
comes with false positives. You could also walk the package code
looking for function names that may belong to the imported package, but
that may involve both false positives and false negatives.)

For the rest of the imports and uses of weak dependencies, you'll have
to walk the package code looking for the uses of the `::` operator. See
how R CMD check walks the package code in functions
tools:::.check_packages_used and codetools::checkUsage.

A less-well-behaved package can always load a namespace during runtime
and choose the functions to call depending on the phase of the moon or
weather on Jupiter. For these, like for the halting problem, there's no
general solution: the package could be written to say, "if Leonard's
function says I'm about to call foo::bar, I won't do it, otherwise I
will".

--
Best regards,
Ivan

[[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] [External] converting MATLAB -> R | element-wise operation

2024-02-29 Thread Richard M. Heiberger
I decided to do a direct comparison of transpose and sweep.


library(microbenchmark)

NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE)  # Example matrix
lambda <- c(2, 3, 4)  # Example vector
colNN <- t(NN)

microbenchmark(
  sweep = sweep(NN, 2, lambda, "/"),
  transpose = t(t(NN)/lambda),
  colNN = colNN/lambda
)


Unit: nanoseconds
  expr   minlq mean median  uq   max neval cld
 sweep 13817 14145 15115.06  14350 14657.5 75932   100 a  
 transpose  1845  1927  2151.68   2132  2214.0  7093   100  b 
 colNN82   123   141.86123   164.0   492   100   c

Note that transpose is much faster than sweep because it is doing less work,
I believe essentially just changing the order of indexing.

Using the natural sequencing for column-ordered matrices is much much faster.

> On Feb 28, 2024, at 18:43, peter dalgaard  wrote:
> 
>> rbind(1:3,4:6)/t(matrix(c(2,3,4), 3,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] 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
  "Greek" and "Cyrilllic" was missing (although the corresponding
  

[ESS] Error installing on Mac

2024-02-29 Thread Liz Hare via ESS-help
Hi all,

I'm updating ESS by installing from source. I uncommented the MacOS related 
lines from makeconfig, but I get this error:

>make
/bin/sh: /Applications/Emacs.app/Contents/MacOS/Emacs: No such file or directory
* VERSIONS **

ESS 24.01.1
ESSR 1.8
sed: 1: "lisp/ess-custom.el": extra characters at the end of l command
make: *** [version] Error 1

This error appears to be related to the fact that the BSD sed on Mac is 
different than the GNU sed.

I looked for a similar issue on GitHub but didn't find anything.

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


Re: [R] Initializing vector and matrices

2024-02-29 Thread Steven Yen
Thanks to all. Great ideas. I found Eik Vettorazzi's suggesstion easy to 
implrment:


ebarm<-vbarm<-NULL
...

if (is.null(ebarm)) ebarm<-ame.00$ei/k else ebarm<-ebarm+ame.00$ei/k
if (is.null(vbarm)) vbarm<-ame.00$vi/k else vbarm<-vbarm+ame.00$vi/k
...

Steven Yen

On 2/29/2024 10:31 PM, Ebert,Timothy Aaron wrote:


You could declare a matrix much larger than you intend to use. This works with 
a few megabytes of data. It is not very efficient, so scaling up may become a 
problem.
m22 <- matrix(NA, 1:60, ncol=6)

It does not work to add a new column to the matrix, as in you get an error if 
you try m22[ , 7] but convert to data frame and add a column

m23 <- data.frame(m22)
m23$x7 <- 12

The only penalty that I know of to having unused space in a matrix is the 
amount of memory it takes. One side effect is that your program may have a 
mistake that you would normally catch with a subscript out of bounds error but 
with the extra space it now runs without errors.

Tim



-Original Message-
From: R-help  On Behalf Of Richard O'Keefe
Sent: Thursday, February 29, 2024 5:29 AM
To: Steven Yen 
Cc: R-help Mailing List 
Subject: Re: [R] Initializing vector and matrices

[External Email]

x <- numeric(0)
for (...) {
 x[length(x)+1] <- ...
}
works.
You can build a matrix by building a vector one element at a time this way, and 
then reshaping it at the end.  That only works if you don't need it to be a 
matrix at all times.
Another approach is to build a list of rows.  It's not a matrix, but a list of 
rows can be a *ragged* matrix with rows of varying length.

On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:

Is there as way to initialize a vector (matrix) with an unknown length
(dimension)? NULL does not seem to work. The lines below work with a
vector of length 4 and a matrix of 4 x 4. What if I do not know
initially the length/dimension of the vector/matrix?

All I want is to add up (accumulate)  the vector and matrix as I go
through the loop.

Or, are there other ways to accumulate such vectors and matrices?

  > x<-rep(0,4)  # this works but I like to leave the length open  >
for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
  > x
[1]  3  6  9 12

  > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to
leave the dimension open
   [,1] [,2] [,3] [,4]
[1,]0000
[2,]0000
[3,]0000
[4,]0000
  > for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
  > y
   [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
  >

__
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
%7Cdbccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84
%7C0%7C0%7C638447993707432549%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
PtWjcDOnwO7PArVOSdgYbpz8ksjDPK%2Bn9ySyhwQC0gE%3D=0
PLEASE do read the posting guide
http://www.r/
-project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7Cdb
ccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
7C0%7C638447993707438911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=Igb16
CBYgG21HLEDH4I4gfjjFBa3KjDFK8yEZUmBo8s%3D=0
and provide commented, minimal, self-contained, reproducible code.

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


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


Re: [R] Initializing vector and matrices

2024-02-29 Thread Ebert,Timothy Aaron
You could declare a matrix much larger than you intend to use. This works with 
a few megabytes of data. It is not very efficient, so scaling up may become a 
problem.
m22 <- matrix(NA, 1:60, ncol=6)

It does not work to add a new column to the matrix, as in you get an error if 
you try m22[ , 7] but convert to data frame and add a column

m23 <- data.frame(m22)
m23$x7 <- 12

The only penalty that I know of to having unused space in a matrix is the 
amount of memory it takes. One side effect is that your program may have a 
mistake that you would normally catch with a subscript out of bounds error but 
with the extra space it now runs without errors.

Tim



-Original Message-
From: R-help  On Behalf Of Richard O'Keefe
Sent: Thursday, February 29, 2024 5:29 AM
To: Steven Yen 
Cc: R-help Mailing List 
Subject: Re: [R] Initializing vector and matrices

[External Email]

x <- numeric(0)
for (...) {
x[length(x)+1] <- ...
}
works.
You can build a matrix by building a vector one element at a time this way, and 
then reshaping it at the end.  That only works if you don't need it to be a 
matrix at all times.
Another approach is to build a list of rows.  It's not a matrix, but a list of 
rows can be a *ragged* matrix with rows of varying length.

On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:
>
> Is there as way to initialize a vector (matrix) with an unknown length
> (dimension)? NULL does not seem to work. The lines below work with a
> vector of length 4 and a matrix of 4 x 4. What if I do not know
> initially the length/dimension of the vector/matrix?
>
> All I want is to add up (accumulate)  the vector and matrix as I go
> through the loop.
>
> Or, are there other ways to accumulate such vectors and matrices?
>
>  > x<-rep(0,4)  # this works but I like to leave the length open  >
> for (i in 1:3){
> +  x1<-1:4
> +  x<-x+x1
> + }
>  > x
> [1]  3  6  9 12
>
>  > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to
> leave the dimension open
>   [,1] [,2] [,3] [,4]
> [1,]0000
> [2,]0000
> [3,]0000
> [4,]0000
>  > for (i in 1:3){
> +   y1<-matrix(17:32, nrow = 4, ncol = 4)
> +   y<-y+y1
> + }
>  > y
>   [,1] [,2] [,3] [,4]
> [1,]   51   63   75   87
> [2,]   54   66   78   90
> [3,]   57   69   81   93
> [4,]   60   72   84   96
>  >
>
> __
> 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
> %7Cdbccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638447993707432549%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
> PtWjcDOnwO7PArVOSdgYbpz8ksjDPK%2Bn9ySyhwQC0gE%3D=0
> PLEASE do read the posting guide
> http://www.r/
> -project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7Cdb
> ccaccf29674b10b17308dc39114d38%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> 7C0%7C638447993707438911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=Igb16
> CBYgG21HLEDH4I4gfjjFBa3KjDFK8yEZUmBo8s%3D=0
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Initializing vector and matrices

2024-02-29 Thread Richard O'Keefe
x <- numeric(0)
for (...) {
x[length(x)+1] <- ...
}
works.
You can build a matrix by building a vector one element at a time this way,
and then reshaping it at the end.  That only works if you don't need it to be
a matrix at all times.
Another approach is to build a list of rows.  It's not a matrix, but a list of
rows can be a *ragged* matrix with rows of varying length.

On Wed, 28 Feb 2024 at 21:57, Steven Yen  wrote:
>
> Is there as way to initialize a vector (matrix) with an unknown length
> (dimension)? NULL does not seem to work. The lines below work with a
> vector of length 4 and a matrix of 4 x 4. What if I do not know
> initially the length/dimension of the vector/matrix?
>
> All I want is to add up (accumulate)  the vector and matrix as I go
> through the loop.
>
> Or, are there other ways to accumulate such vectors and matrices?
>
>  > x<-rep(0,4)  # this works but I like to leave the length open
>  >  for (i in 1:3){
> +  x1<-1:4
> +  x<-x+x1
> + }
>  > x
> [1]  3  6  9 12
>
>  > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to
> leave the dimension open
>   [,1] [,2] [,3] [,4]
> [1,]0000
> [2,]0000
> [3,]0000
> [4,]0000
>  > for (i in 1:3){
> +   y1<-matrix(17:32, nrow = 4, ncol = 4)
> +   y<-y+y1
> + }
>  > y
>   [,1] [,2] [,3] [,4]
> [1,]   51   63   75   87
> [2,]   54   66   78   90
> [3,]   57   69   81   93
> [4,]   60   72   84   96
>  >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] [EXT] Re: Initializing vector and matrices

2024-02-29 Thread Eik Vettorazzi

Dear Steven,
I used "sample" just to generate a non-trivial example, you could insert 
your code of generating the real xi at this point :-)


If you want to stick to for-loops for some reasons, something like this 
could work


x<-NULL
for (i in 1:5){
   xi<-1:5
  if (is.null(x)) x<-xi else x<-x+xi
}


cheers

Am 29.02.2024 um 09:23 schrieb Steven Yen:

Hello Eik:

Thanks. I do not need to sample. Essentially, I have a do loop which 
produces 24 vectors of length of some length (say k=300) and 24 matrices 
of 300x300. Then, I simply need to  take the averages of these 24 
vectors and matrices:


x=(x1+x2+...+x24)/k

y=(y1+y2+...+y24)/k

I am just looking for ways to do this in a do loop, which requires 
initialization (to 0's) of x and y. My struggle is not knowning length 
of x until x1 is produced in the first of the loop. Thanks.


Steven

On 2/28/2024 6:22 PM, Eik Vettorazzi wrote:

Hi Steven,
It's not entirely clear what you actually want to achieve in the end.

As soon as you "know" x1, and assuming that the different "xi" do not 
differ in length in the real application, you know the length of the 
target vector.
Instead of the loop, you can use 'Reduce' without having to initialize 
a starting vector.


# generate sample vectors, put them in a list

xi<-lapply(1:5, \(x)sample(5))

# look at xi
xi

# sum over xi
Reduce("+",xi)

this works also for matrices

# generate sample matrices, put them in a list
Xi<-lapply(1:3, \(x)matrix(sample(16), nrow=4))

# look at them
Xi

# sum over Xi
Reduce("+",Xi)

Hope that helps

Eik


Am 28.02.2024 um 09:56 schrieb Steven Yen:
Is there as way to initialize a vector (matrix) with an unknown 
length (dimension)? NULL does not seem to work. The lines below work 
with a vector of length 4 and a matrix of 4 x 4. What if I do not 
know initially the length/dimension of the vector/matrix?


All I want is to add up (accumulate)  the vector and matrix as I go 
through the loop.


Or, are there other ways to accumulate such vectors and matrices?

 > x<-rep(0,4)  # this works but I like to leave the length open
 >  for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
 > x
[1]  3  6  9 12

 > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to 
leave the dimension open

  [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0
 > for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
 > y
  [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
 >

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

and provide commented, minimal, self-contained, reproducible code.




--
Eik Vettorazzi

Universitätsklinikum Hamburg-Eppendorf
Institut für Medizinische Biometrie und Epidemiologie

Christoph-Probst-Weg 1
4. Obergeschoss, Raum 04.1.021.1

20246 Hamburg

Telefon: +49 (0) 40 7410 - 58243
Fax: +49 (0) 40 7410 - 57790

Web: www.uke.de/imbe

Webex: https://webteaching-uke.webex.com/meet/e.vettorazzi


--

_

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Prölß, 
Prof. Dr. Blanche Schwappach-Pignataro, Matthias Waldmann (komm.)
_

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


Re: [R] [EXT] Initializing vector and matrices

2024-02-29 Thread Steven Yen

Hello Eik:

Thanks. I do not need to sample. Essentially, I have a do loop which 
produces 24 vectors of length of some length (say k=300) and 24 matrices 
of 300x300. Then, I simply need to  take the averages of these 24 
vectors and matrices:


x=(x1+x2+...+x24)/k

y=(y1+y2+...+y24)/k

I am just looking for ways to do this in a do loop, which requires 
initialization (to 0's) of x and y. My struggle is not knowning length 
of x until x1 is produced in the first of the loop. Thanks.


Steven

On 2/28/2024 6:22 PM, Eik Vettorazzi wrote:

Hi Steven,
It's not entirely clear what you actually want to achieve in the end.

As soon as you "know" x1, and assuming that the different "xi" do not 
differ in length in the real application, you know the length of the 
target vector.
Instead of the loop, you can use 'Reduce' without having to initialize 
a starting vector.


# generate sample vectors, put them in a list

xi<-lapply(1:5, \(x)sample(5))

# look at xi
xi

# sum over xi
Reduce("+",xi)

this works also for matrices

# generate sample matrices, put them in a list
Xi<-lapply(1:3, \(x)matrix(sample(16), nrow=4))

# look at them
Xi

# sum over Xi
Reduce("+",Xi)

Hope that helps

Eik


Am 28.02.2024 um 09:56 schrieb Steven Yen:
Is there as way to initialize a vector (matrix) with an unknown 
length (dimension)? NULL does not seem to work. The lines below work 
with a vector of length 4 and a matrix of 4 x 4. What if I do not 
know initially the length/dimension of the vector/matrix?


All I want is to add up (accumulate)  the vector and matrix as I go 
through the loop.


Or, are there other ways to accumulate such vectors and matrices?

 > x<-rep(0,4)  # this works but I like to leave the length open
 >  for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
 > x
[1]  3  6  9 12

 > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to 
leave the dimension open

  [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0
 > for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
 > y
  [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
 >

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Richard O'Keefe
The first vector-oriented programming language I ever learned or used
was APL, and APL makes *no* distinction between row vectors and column
vectors.  It has rank-0 (scalar), rank-1 (vector), rank-2 (matrix),
rank-3 ... and so on arrays.   A rank-1 array is a rank-1 array is a
rank-1 array and there is an algebra of arrays to go with it.   I
learned PL/I around the same time, which also has array expressions
(but at least back then it did not have matrix product).  Again, a 1D
array is a 1D array is a 1D array.  Since 1990, Fortran has been an
array-processing language, and there has never been any distinction
between row vectors and column vectors in Fortran and isn't any such
distinction now.  One thing that these three languages have in common
is the view that a rank-N array and a rank-(N+1) array are not the
same kind of thing.

I can understand MATLAB distinguishing between row and column vectors,
although nothing in my undergraduate numerical analysis education
prepared me to expect or even like it.  But from an APL perspective it
is confusing and limiting.  And for that matter S and R are confusing
in their own way.  But to call R's approach "unique" within the family
of array-oriented programming languages is an exaggeration.  The BASIS
system from Lawrence Livermore does not make any distinction between
row and column vectors; a 1D array is a 1D array is a 1D array.  Most
notably in modern times, Julia belongs to the
a-1D-array-is-a-1D-array-is-a-1D-array and
a-1D-array-is-not-a-2D-array camp.  As one person writing ina Julia
thread put it,

Back when I wrote everything in Matlab, those years were characterized
by a series of mild annoyances of always having to worry about whether
a was a row vector or a column vector, and sprinkling a(:) and a(:)'
like pixie dust to fix problems. It’s a huge relief to have real
one-dimensional objects.


On Wed, 28 Feb 2024 at 22:43, Berwin A Turlach  wrote:
>
> On Tue, 27 Feb 2024 13:51:25 -0800
> Jeff Newmiller via R-help  wrote:
>
> > The fundamental data type in Matlab is a matrix... they don't have
> > vectors, they have Nx1 matrices and 1xM matrices.
>
> Also known as column vectors and row vectors.  :)
>
> > Vectors don't have any concept of "row" vs. "column".
>
> They do in (numerical) linear algebra.  And MATLAB was written by
> numerical analysts for numerical analysts. :-)  So they distinguish
> between row and column vectors.
>
> GAUSS also distinguishes between row and column vectors.
>
> R (and S) does not distinguish between row and column vectors, and is
> in this aspect quite unique among the groups of vector-oriented
> programming languages (AFAICT).  But  treating every vector as a column
> vector, together with the recycling rule, allows for the easy coding of
> the matrix/vector calculations that one (mostly) comes across in
> statistical computing.  For the rare occasion when this is not true the
> sweep() command is provided, typically remembered once one was bitten
> by the lack of distinction between row and column vectors. :)
>
> Cheers,
>
> Berwin
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] 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] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Yea, that worked. Thank you. :)

From: jim holtman 
Sent: Wednesday, February 28, 2024 12:52 PM
To: Ebert,Timothy Aaron 
Cc: r-help@r-project.org
Subject: Re: [R] Trouble reading a UTF-16LE file

[External Email]
Try this:


> x <- file("C:\\Users\\Jim\\Downloads\\PV2-ch2 - R_Help.ANA",

+   encoding = "UTF-16")

> y <- readLines(x)

> head(y)

[1] "1\t36,74\t0"  "2\t269,02\t-44"   "1\t326,62\t29""2\t354,52\t24"

[5] "8\t390,75\t1838"  "2\t395,11\t-1053"

>
>

Thanks

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Wed, Feb 28, 2024 at 9:23 AM Ebert,Timothy Aaron 
mailto:teb...@ufl.edu>> wrote:
The earlier post had an attached text file that did not go through.
I hope this link works. I tested it with a coworker, but that is no guarantee.

https://uflorida-my.sharepoint.com/:u:/g/personal/tebert_ufl_edu/EXf5u_CtTwJCrhdfTBIPr7wBefZHx4P_suj4wAWb8i8HFA?e=iQawhh


Regards,
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.

[[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] Trouble reading a UTF-16LE file

2024-02-28 Thread jim holtman
Try this:


> x <- file("C:\\Users\\Jim\\Downloads\\PV2-ch2 - R_Help.ANA",+   
> encoding = "UTF-16")> y <- readLines(x)> head(y)[1] "1\t36,74\t0"  
> "2\t269,02\t-44"   "1\t326,62\t29""2\t354,52\t24"
[5] "8\t390,75\t1838"  "2\t395,11\t-1053">

>

Thanks

Jim Holtman
*Data Munger Guru*


*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*


On Wed, Feb 28, 2024 at 9:23 AM Ebert,Timothy Aaron  wrote:

> The earlier post had an attached text file that did not go through.
> I hope this link works. I tested it with a coworker, but that is no
> guarantee.
>
>
> https://uflorida-my.sharepoint.com/:u:/g/personal/tebert_ufl_edu/EXf5u_CtTwJCrhdfTBIPr7wBefZHx4P_suj4wAWb8i8HFA?e=iQawhh
>
>
> Regards,
> 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.
>

[[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] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
The earlier post had an attached text file that did not go through.
I hope this link works. I tested it with a coworker, but that is no guarantee.

https://uflorida-my.sharepoint.com/:u:/g/personal/tebert_ufl_edu/EXf5u_CtTwJCrhdfTBIPr7wBefZHx4P_suj4wAWb8i8HFA?e=iQawhh


Regards,
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.


[R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Dear R-help,
I am having trouble reading a UTF-16LE formatted file. The issue appears to 
be a byte order mark at the beginning of the file. I have tried readLines(file, 
encoding='utf-16LE') but that got me 

[1]"\xff\xfe1"  ""  ""  ""  ""  ""


This is a tab delimited text file, despite the ANA extension. It is created by 
a custom software program that interfaces with some specialized scientific 
equipment.

Thank you for your help.


Regards,
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.


Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Jeff Newmiller via R-help
When you specify LE you are overriding any useful information that the BOM 
could convey... see 
https://softwareengineering.stackexchange.com/questions/370088/is-the-bom-optional-for-utf-16-and-utf-32.

?Encoding

On February 28, 2024 5:44:49 AM PST, "Ebert,Timothy Aaron"  
wrote:
>Dear R-help,
>I am having trouble reading a UTF-16LE formatted file. The issue appears 
> to be a byte order mark at the beginning of the file. I have tried 
> readLines(file, encoding='utf-16LE') but got me 
>
>[1]"\xff\xfe1" ""  ""  ""  ""  ""
>
>
>
>Regards,
>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.

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

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


Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ivan Krylov via R-help
В Wed, 28 Feb 2024 13:44:49 +
"Ebert,Timothy Aaron"  пишет:

> readLines(file, encoding='utf-16LE')

There are two ways you could encounter an encoding in R.

First are encoding markers placed on every string object, which declare
the string to be encoded in UTF-8, Latin-1, the native locale encoding,
or ASCII or "bytes". No other encodings are supported. The "encoding"
argument of readLines() sets this marker.

In order to support other encodings, R is able to convert the text as
part of the input/output connections. help(readLines) points you
towards that: you need to set the UTF-16LE encoding on the connection
object.

con <- file(file, encoding = 'UTF16LE')
lines <- readLines(con)
close(con)

"UTF16LE" is not guaranteed to be supported, so see iconvlist() for the
encodings that should work with your build of R.

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


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

2024-02-28 Thread Evan Cooch
Many thanks for the collective answers -- consider this a thank you to 
the group. I had 'guessed' it had something to do with 'columns then 
rows' or vice versa (MATLAB convention vs R convention), but had never 
heard about 'sweep' before. Most of the time when I run into 'matrix 
orientation' issues, I simply transpose as needed, but that can get 
clunky. 'sweep' has some utility I'll tuck away if needed in future.

Cheers - and thanks again.

On 2/27/2024 4:37 PM, Richard M. Heiberger wrote:
>> t(t(NN)/lambda)
>   [,1]  [,2] [,3]
> [1,]  0.5 0.667 0.75
> [2,]  2.0 1.667 1.50
> R  matrices are column-based. MATLAB matrices are row-based.
>
>> On Feb 27, 2024, at 14:54, 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 guidehttp://www.r-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


[R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Dear R-help,
I am having trouble reading a UTF-16LE formatted file. The issue appears to 
be a byte order mark at the beginning of the file. I have tried readLines(file, 
encoding='utf-16LE') but got me 

[1]"\xff\xfe1"  ""  ""  ""  ""  ""



Regards,
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.


Re: [R] [EXT] Initializing vector and matrices

2024-02-28 Thread Eik Vettorazzi

Hi Steven,
It's not entirely clear what you actually want to achieve in the end.

As soon as you "know" x1, and assuming that the different "xi" do not 
differ in length in the real application, you know the length of the 
target vector.
Instead of the loop, you can use 'Reduce' without having to initialize a 
starting vector.


# generate sample vectors, put them in a list

xi<-lapply(1:5, \(x)sample(5))

# look at xi
xi

# sum over xi
Reduce("+",xi)

this works also for matrices

# generate sample matrices, put them in a list
Xi<-lapply(1:3, \(x)matrix(sample(16), nrow=4))

# look at them
Xi

# sum over Xi
Reduce("+",Xi)

Hope that helps

Eik


Am 28.02.2024 um 09:56 schrieb Steven Yen:
Is there as way to initialize a vector (matrix) with an unknown length 
(dimension)? NULL does not seem to work. The lines below work with a 
vector of length 4 and a matrix of 4 x 4. What if I do not know 
initially the length/dimension of the vector/matrix?


All I want is to add up (accumulate)  the vector and matrix as I go 
through the loop.


Or, are there other ways to accumulate such vectors and matrices?

 > x<-rep(0,4)  # this works but I like to leave the length open
 >  for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
 > x
[1]  3  6  9 12

 > y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to 
leave the dimension open

  [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0
 > for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
 > y
  [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
 >

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

and provide commented, minimal, self-contained, reproducible code.


--
Eik Vettorazzi

Universitätsklinikum Hamburg-Eppendorf
Institut für Medizinische Biometrie und Epidemiologie

Christoph-Probst-Weg 1
4. Obergeschoss, Raum 04.1.021.1

20246 Hamburg

Telefon: +49 (0) 40 7410 - 58243
Fax: +49 (0) 40 7410 - 57790

Web: www.uke.de/imbe

Webex: https://webteaching-uke.webex.com/meet/e.vettorazzi


--

_

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Christian Gerloff (Vorsitzender), Joachim Prölß, 
Prof. Dr. Blanche Schwappach-Pignataro, Matthias Waldmann (komm.)
_

SAVE PAPER - THINK BEFORE PRINTING
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 14:54:26 -0500
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.

On 

https://cran.r-project.org/other-docs.html

the documents:

“Matlab® / R Reference” by David Hiebeler (PDF, 2010-05-25, 52 pages)

and

“R and Octave” by Robin Hankin (Text), a reference sheet translating
between the most common Octave (or Matlab) and R commands

might be useful.  IIRC, I once used them when I had to do something in
Matlab/Octave and used them as reverse-lookup (I know how to do it in
R, how is it done in Matlab??). :-)

Cheers,

Berwin

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 13:51:25 -0800
Jeff Newmiller via R-help  wrote:

> The fundamental data type in Matlab is a matrix... they don't have
> vectors, they have Nx1 matrices and 1xM matrices.

Also known as column vectors and row vectors.  :)
 
> Vectors don't have any concept of "row" vs. "column". 

They do in (numerical) linear algebra.  And MATLAB was written by
numerical analysts for numerical analysts. :-)  So they distinguish
between row and column vectors.

GAUSS also distinguishes between row and column vectors.

R (and S) does not distinguish between row and column vectors, and is
in this aspect quite unique among the groups of vector-oriented
programming languages (AFAICT).  But  treating every vector as a column
vector, together with the recycling rule, allows for the easy coding of
the matrix/vector calculations that one (mostly) comes across in
statistical computing.  For the rare occasion when this is not true the
sweep() command is provided, typically remembered once one was bitten
by the lack of distinction between row and column vectors. :)

Cheers,

Berwin

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Initializing vector and matrices

2024-02-28 Thread Steven Yen
OK. I initialize real large vector and matrix and then shrink them when 
I use them in the loop. The following lines worked. I'd glad to know of 
better approaches.


bsum<-rep(0,1000); bsum
vsum<-matrix(rep(0,100),nrow=1000); vsum
for (ind in 1:3) { mydata <- read.csv(paste0("midata", ind, ".csv"))
...
k<-length(ame.00$bame)
bsum<-bsum[1:k]+ame.00$bame
vsum<-vsum[1:k,1:k]+ame.00$vame
}

On 2/28/2024 4:56 PM, Steven Yen wrote:
Is there as way to initialize a vector (matrix) with an unknown length 
(dimension)? NULL does not seem to work. The lines below work with a 
vector of length 4 and a matrix of 4 x 4. What if I do not know 
initially the length/dimension of the vector/matrix?


All I want is to add up (accumulate)  the vector and matrix as I go 
through the loop.


Or, are there other ways to accumulate such vectors and matrices?

> x<-rep(0,4)  # this works but I like to leave the length open
>  for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
> x
[1]  3  6  9 12

> y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to 
leave the dimension open

 [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0
> for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
> y
 [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
>




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [External] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 21:37:52 +
"Richard M. Heiberger"  wrote:

> > t(t(NN)/lambda)  
>  [,1]  [,2] [,3]
> [1,]  0.5 0.667 0.75
> [2,]  2.0 1.667 1.50
> >  
> 
> R  matrices are column-based. MATLAB matrices are row-based.

It might depend on what you mean with this statement, but I would be
very surprised if MATLAB is not storing matrices in column-major form,
just as R does.

NN = [1, 2, 3; 4, 5, 6];

and 

NN = [ [1, 4]' , [2, 5]', [3, 6]' ];

produce the same matrix in MATLAB.

So the default filling of matrices is by row, and there is no
convenient argument to change that. 

Cheers,

Berwin

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Initializing vector and matrices

2024-02-28 Thread Steven Yen
Is there as way to initialize a vector (matrix) with an unknown length 
(dimension)? NULL does not seem to work. The lines below work with a 
vector of length 4 and a matrix of 4 x 4. What if I do not know 
initially the length/dimension of the vector/matrix?


All I want is to add up (accumulate)  the vector and matrix as I go 
through the loop.


Or, are there other ways to accumulate such vectors and matrices?

> x<-rep(0,4)  # this works but I like to leave the length open
>  for (i in 1:3){
+  x1<-1:4
+  x<-x+x1
+ }
> x
[1]  3  6  9 12

> y = 0*matrix(1:16, nrow = 4, ncol = 4); # this works but I like to 
leave the dimension open

 [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0
> for (i in 1:3){
+   y1<-matrix(17:32, nrow = 4, ncol = 4)
+   y<-y+y1
+ }
> y
 [,1] [,2] [,3] [,4]
[1,]   51   63   75   87
[2,]   54   66   78   90
[3,]   57   69   81   93
[4,]   60   72   84   96
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Clustering Functions used by Reverse-Dependencies

2024-02-28 Thread Ivan Krylov via R-help
В Sat, 24 Feb 2024 03:08:26 +
Leo Mada via R-help  пишет:

> Are there any tools to extract the function names called by
> reverse-dependencies?

For well-behaved packages that declare their dependencies correctly,
parsing the NAMESPACE for importFrom() and import() calls should give
you the explicit imports. (What if the package imports the whole
dependency? The safe assumption is that all functions are used, but it
comes with false positives. You could also walk the package code
looking for function names that may belong to the imported package, but
that may involve both false positives and false negatives.)

For the rest of the imports and uses of weak dependencies, you'll have
to walk the package code looking for the uses of the `::` operator. See
how R CMD check walks the package code in functions
tools:::.check_packages_used and codetools::checkUsage.

A less-well-behaved package can always load a namespace during runtime
and choose the functions to call depending on the phase of the moon or
weather on Jupiter. For these, like for the halting problem, there's no
general solution: the package could be written to say, "if Leonard's
function says I'm about to call foo::bar, I won't do it, otherwise I
will".

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


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

2024-02-27 Thread Bert Gunter
... and here is a more or less direct translation of the Matlab code that
should now be obvious given your previous responses:

> m <- matrix(1:6, nr=2, byrow = TRUE) ## Matlab order
> m
 [,1] [,2] [,3]
[1,]123
[2,]456
> sweep(m, 2, 2:4, "/")
 [,1]  [,2] [,3]
[1,]  0.5 0.667 0.75
[2,]  2.0 1.667 1.50

Cheers,
Bert

On Tue, Feb 27, 2024 at 1:03 PM 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.
>

[[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] converting MATLAB -> R | element-wise operation

2024-02-27 Thread Jeff Newmiller via R-help
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.


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

2024-02-27 Thread Richard M. Heiberger
> t(t(NN)/lambda)
 [,1]  [,2] [,3]
[1,]  0.5 0.667 0.75
[2,]  2.0 1.667 1.50
>

R  matrices are column-based. MATLAB matrices are row-based.

> On Feb 27, 2024, at 14:54, 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] converting MATLAB -> R | element-wise operation

2024-02-27 Thread Evan Cooch
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.


Re: [R] Interactions in regression

2024-02-26 Thread Rolf Turner


I have no real idea what you are trying to do, but if a table is
what you want, you can probably get it using the table() function.
Or, more likely, the xtabs() function.

Using your example from an earlier post (adjusted to make it
comprehensible to the human mind):

set.seed(1000)
time  <- factor(rep(c("Pre","Post"),each=200))
treatment <- factor(rep(rep(c("Control","Treatment"),each=100),2))
mu<- rep(rep(1:2,each=100),2)
response  <- rnorm(400,mean=mu)
xmpldata  <- data.frame(time=time,treatment=treatment,response)
mod   <- lm(response~time*treatment,data=xmpldata)
yhat  <- fitted(mod)
xtb   <- with(xmpldata,xtabs(yhat ~ time+treatment))

print(xtb)

>   treatment
> time Control Treatment
>   Post  94.10501 201.99112
>   Pre  101.63792 210.04248

Is that (something like) what you want?

cheers,

Rolf Turner

P.S. You said:  "I usually use GUI software".  Now *there* lies your
problem.  A GUI is a black box that removes all control over what is
going on, from your hands.

R. T.




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


Re: [R] igraph_vertex

2024-02-26 Thread Ivan Krylov via R-help
В Mon, 26 Feb 2024 11:52:13 +0100
 пишет:

> TIFFOpen: figures/AES_network_bymembership.tiff: Cannot open.

> Warning message:
> In dev.off() :
>   unable to open TIFF file 'figures/AES_network_bymembership.tiff'

In the current directory (see getwd()), is there a subdirectory named
"figures"? Do you have write access to this subdirectory? Is there a
file named "AES_network_bymembership.tiff" in the subdirectory named
"figures"? Could it be open by a different program and therefore
locked?

Unfortunately, libtiff doesn't seem to provide any more information
regarding why it couldn't open the file at this point.

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


Re: [R] igraph_vertex

2024-02-26 Thread SIBYLLE STÖCKLI via R-help
Dear Ivan

Thanks a lot.

I used:
windowsFonts(Helvetica = windowsFont("Helvetica"))
No warning now with Helvetica
Additionally I used "sans", similarly no warning  in the first part.

But still not able to open tiff with both versions:

Using "stress" as default layout
> dev.off()
TIFFOpen: figures/AES_network_bymembership.tiff: Cannot open.
RStudioGD 
2 
Warning message:
In dev.off() :
  unable to open TIFF file 'figures/AES_network_bymembership.tiff'

Kind regards
Sibylle

-Original Message-
From: Ivan Krylov  
Sent: Monday, February 26, 2024 10:15 AM
To: SIBYLLE STÖCKLI via R-help 
Cc: sibylle.stoec...@gmx.ch
Subject: Re: [R] igraph_vertex

В Mon, 26 Feb 2024 09:02:56 +0100
SIBYLLE STÖCKLI via R-help  пишет:

> In the following code, which loads the tiff file, I get the following 
> error

This warning is definitely worth investigating, but it shouldn't interrupt your 
code. Does the figure come out wrong after you see this warning?

> In doTryCatch(return(expr), name, parentenv, handler) : Character set 
> family not found in the Windows character set database
> 
> --> I am unsure if mySQL is the right solution. I have no experience
> how to change mySQL. 

I see you've tried to do the right thing and searched for the warning message. 
Unfortunately, the search engines are wrong; this doesn't seem related to MySQL.

A similarly-worded warning message exists in the Windows-related font functions 
inside R:

>> warning(_("font family not found in Windows font database"))

If running a sufficiently new version of R, try Sys.setLanguage('en') before 
reproducing the problem and searching for the exact warning message in double 
quotes. (Reset it back using
Sys.setLanguage(your_language_code) or restart R afterwards.) Translated error 
and warning messages are good for understanding, but they fragment the search 
engine results.

I see that a few messages back you set a font family:

>  vertex.label.family="Helvetica",

R probably doesn't know where to get it in order to render the plot as TIFF. If 
you have a copy of Helvetica installed in your system, try registering it using 
windowsFonts(Helvetica = windowsFont("how the font is named in the system")). 
(See help(windowsFonts) for more
information.) Otherwise you may be limited to R's predefined font families.

It's annoying that "Helvetica" exists for PDF plots and such seemingly without 
a problem, but if you change the output format to TIFF, the set of fonts 
available to you changes too. Unfortunately, there are multiple different font 
rendering engines in play, and their predefined lists of fonts also differ.

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


Re: [R] igraph_vertex

2024-02-26 Thread Ivan Krylov via R-help
В Mon, 26 Feb 2024 09:02:56 +0100
SIBYLLE STÖCKLI via R-help  пишет:

> In the following code, which loads the tiff file, I get the following
> error

This warning is definitely worth investigating, but it shouldn't
interrupt your code. Does the figure come out wrong after you see this
warning?

> In doTryCatch(return(expr), name, parentenv, handler) : Character set
> family not found in the Windows character set database
> 
> --> I am unsure if mySQL is the right solution. I have no experience
> how to change mySQL. 

I see you've tried to do the right thing and searched for the warning
message. Unfortunately, the search engines are wrong; this doesn't seem
related to MySQL.

A similarly-worded warning message exists in the Windows-related font
functions inside R:

>> warning(_("font family not found in Windows font database"))

If running a sufficiently new version of R, try Sys.setLanguage('en')
before reproducing the problem and searching for the exact warning
message in double quotes. (Reset it back using
Sys.setLanguage(your_language_code) or restart R afterwards.)
Translated error and warning messages are good for understanding, but
they fragment the search engine results.

I see that a few messages back you set a font family:

>  vertex.label.family="Helvetica",

R probably doesn't know where to get it in order to render the plot as
TIFF. If you have a copy of Helvetica installed in your system, try
registering it using windowsFonts(Helvetica = windowsFont("how the
font is named in the system")). (See help(windowsFonts) for more
information.) Otherwise you may be limited to R's predefined font
families.

It's annoying that "Helvetica" exists for PDF plots and such seemingly
without a problem, but if you change the output format to TIFF, the set
of fonts available to you changes too. Unfortunately, there are
multiple different font rendering engines in play, and their predefined
lists of fonts also differ.

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


Re: [R] Interactions in regression

2024-02-26 Thread Jacek Kownacki
Hi,
I do not want to make a plot, I try to make an output table in R, (in GUI
like Stata this is trivially easy task)
with regard to SO OP question. As I mentioned, in paper I would not do
this, but out of curiosity I use R this time trying to create it.
If in R this is trivial task as well, could you please show how to do it ?
After googling a lot I did not find solution.
regards,
Jacek

niedz., 25 lut 2024 o 17:00 Bert Gunter  napisał(a):

> It is trivial in R to add whatever decorations to a plot that you would
> like, but that requires that you go beyond point and click production of
> graphics and write actual code. If you are unwilling or unable to do this,
> you are stuck with whatever various packaged graphics functionality
> provides.So you might want to search on "interaction plots for linear
> models in R" or similar at rseek.org or in your favorite web search
> engine if you haven't already done so. My minimal efforts brought up lots
> of hits, though none may be useful for your concerns, especially, as has
> already been pointed out, as your query doesn't seem to make much sense
> statistically.
>
> Cheers,
> Bert
>
>
> On Sun, Feb 25, 2024 at 7:46 AM Jacek Kownacki 
> wrote:
>
>> Hi All,
>> I stumbled upon some topics regarding interactions in anova and regression
>> and packages for tabulating and visualizations the results of them.
>> Here we are:
>>
>> https://stackoverflow.com/questions/77933272/how-to-add-a-reference-level-for-interaction-in-gtsummary-and-sjplot/77935742#77935742
>> ,
>>
>> https://stackoverflow.com/questions/78016795/how-to-add-reference-levels-for-interaction-in-r?noredirect=1=1
>> .
>> I was wondering because I usually use GUI software and these questions did
>> not get answers, if from a technical point of view
>> how to do it, using these (sjPlot, gtsummary) or other ways to make such
>> tables, inserting the reference levels of these mentioned interactions.
>> This is not likely to be used in publications (including three base
>> levels), but from the point of view of solving the topics this questions
>> have interested me.
>> I tried myself to make it happen, but so far without success.
>> I recall this reprex based on SO:
>>
>> set.seed(1000)
>> my_data <- rbind(
>>   data.frame(time = "Pre", treatment = "Control", response =
>> rnorm(100, mean=1)),
>>   data.frame(time = "Pre", treatment = "Treatment", response =
>> rnorm(100, mean=2)),
>>   data.frame(time = "Post", treatment = "Control", response =
>> rnorm(100, mean=1)),
>>   data.frame(time = "Post", treatment = "Treatment", response =
>> rnorm(100, mean=2))
>> ) %>% mutate(time = factor(time, levels = c("Pre", "Post")))
>> %>%mutate(treatment = factor(treatment, levels = c("Control",
>> "Treatment")))
>> model3 <- lm(response ~ time * treatment, data = my_data)
>>
>> Thanks,
>> Jacek
>>
>> [[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] igraph_vertex

2024-02-26 Thread SIBYLLE STÖCKLI via R-help
Dear Kimmo

First of all many thanks for the valuable advice to publish code and csv. 
Noted. 
Yes, "edge.width= E(.)$weight" makes definitively sense.

In the following code, which loads the tiff file, I get the following error
tiff("figures/AES_network_bymembership.tiff", width=1000, height=700, res=120)
Warning message:
In doTryCatch(return(expr), name, parentenv, handler) : Character set family 
not found in the Windows character set database

--> I am unsure if mySQL is the right solution. I have no experience how to 
change mySQL.

Kind regards
Sibylle


tiff("figures/AES_network_bymembership.tiff", width=1000, height=700, res=120)
network %>%
  ggraph(., layout = "auto")+
  geom_edge_arc(curvature=0.3, aes(width=(E(network)$weight/10), color=from, 
alpha=0.5)) +
  geom_node_point(aes(size = V(network)$hub_score*200, color= 
as.factor(V(network)$community))) +
  geom_node_text(aes(label =  V(network)$name), size=5, color="white", repel=T)+
  scale_color_scico_d(palette = "batlow")+
  scale_edge_width(range = c(0.2,4))+
  scale_size(range = c(0.5,20)) +
  #scale_edge_color_manual(values = c(scico(21, palette="batlow")))+
  theme(plot.background = element_rect(fill = "black"),
legend.position = "right",
panel.background = element_rect(fill = "black"))
dev.off()





-Original Message-

From: R-help  On Behalf Of Kimmo Elo
Sent: Monday, February 26, 2024 8:10 AM
To: r-help@r-project.org
Subject: Re: [R] igraph_vertex


Hi,

a quick additional note: try

"edge.width= E(.)$weight"

instead of the current "edge.width= network". Seems to work and makes a visible 
difference...

HTH,
Kimmo

su, 2024-02-25 kello 19:11 +, Kimmo Elo kirjoitti:
> 
> Hi again,
> 
> your code is still not reproducible without modifications, but I 
> succeed in getting the data straight. All read.csv-command are missing 
> 'sep="\t"', it is need to read you tsv-data.
> 
> And it could be more reproducible if you used e.g.
> 
> --- snip ---
> aes<-read.csv(text="A.A B.B C.C D.D E.E F.F 
> A.A 0   0   5   5   5   5 B.B 4   0   
> 1   1   1   1 C.C 5   5   0   5   4   
> 2 D.D 5   0   5   0   5   3 E.E 5   1   
> 5   5   0   4 F.F 1   2   3   4   5   
> 5", sep="\t", row.names = 1)
> --- snip ---
> 
> This would save us from unnecessary copy-pasting :-)
> 
> However, the error is still the same I mentioned in my first reply,
> i.e.:
> 
> network %>% plot(
> vertex.color=clrs[V(.)$community],
> vertex.size=V(.)$hub_score*5,
> vertex.frame.color=V(.)$color,
> vertex.label.color="white",
> vertex.label.cex=0.5,
> vertex.label.family="Helvetica",
> vertex.label.font=1,
> edge.curved=0.5,
> HERE -->edge.width= network,  <-- HERE
> layout=layout_with_mds(.))
> 
> Try to comment out his line and see what happens. What network data 
> variable should be mapped to edge width?
> 
> Best,
> Kimmo
> 
> su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> > Dear coummunity
> > 
> > Thanks a lot to David and Kimmo. Yes I see now that I need to 
> > provide the two raw tables. Find here the reproducible example.
> > 
> > Kind regards
> > Sibylle
> > 
> > # R-labraries
> > library(circlize)
> > library(ggplot2)
> > library(igraph)
> > library(tidyverse)
> > library(RColorBrewer)
> > library(stringi)
> > library(scico)
> > library(plotly)
> > library(ggraph)
> > 
> > 
> > # Tables
> > aes<-read.csv("Test_adjac.csv", row.names = 1)
> > details<-read.csv("Test_cat.csv")
> > 
> > # Edge table, reorganisation
> > aes_collapsed<-aes %>%
> >   rownames_to_column(var='Names') %>%
> >   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
> >   dplyr::filter(weight != 0) %>%
> >   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 = 
> > negative values
> > 
> > write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> > edge_list<-read.csv("edges_table_Test.csv")
> > 
> > # Network attributes
> > network <- graph_from_data_frame(aes_collapsed, directed= FALSE,
> >  vertices = details)
> > 
> > 
> > temp<-cluster_optimal(network)
> > temp<-cbind(membership=temp$membership, Names=temp$name) 
> > aes_collapsed <- aes_collapsed %>%
> >   merge(temp, by="Names")
> > 
> > 
> > network <- network %>%
> >   set_edge_attr(name = "type", value = factor(aes_collapsed$Names,
> >  ordered =
> > is.ordered(V(network)$name))) %>%
> >   set_edge_attr(name = "membership", value =
> > aes_collapsed$membership) %>%
> >   set_edge_attr(name = "color",
> >   value = c(viridis::viridis(5))
> >   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
> >   set_vertex_attr(name = "trans_v_net", value = c(transitivity(., 
> > type = "local"))) %>%
> >   set_vertex_attr(name = "hub_score", value =
> > c(hub_score(.)$vector))
> 

Re: [R] igraph_vertex

2024-02-25 Thread Kimmo Elo

Hi,

a quick additional note: try

"edge.width= E(.)$weight"

instead of the current "edge.width= network". Seems to work and makes a
visible difference...

HTH,
Kimmo

su, 2024-02-25 kello 19:11 +, Kimmo Elo kirjoitti:
> 
> Hi again,
> 
> your code is still not reproducible without modifications, but I
> succeed in getting the data straight. All read.csv-command are
> missing
> 'sep="\t"', it is need to read you tsv-data.
> 
> And it could be more reproducible if you used e.g.
> 
> --- snip ---
> aes<-read.csv(text="    A.A B.B C.C D.D E.E F.F
> A.A 0   0   5   5   5   5
> B.B 4   0   1   1   1   1
> C.C 5   5   0   5   4   2
> D.D 5   0   5   0   5   3
> E.E 5   1   5   5   0   4
> F.F 1   2   3   4   5   5", 
> sep="\t", row.names = 1)
> --- snip ---
> 
> This would save us from unnecessary copy-pasting :-)
> 
> However, the error is still the same I mentioned in my first reply,
> i.e.:
> 
> network %>% plot(
>     vertex.color=clrs[V(.)$community], 
>     vertex.size=V(.)$hub_score*5, 
>     vertex.frame.color=V(.)$color, 
>     vertex.label.color="white", 
>     vertex.label.cex=0.5, 
>     vertex.label.family="Helvetica",
>     vertex.label.font=1,
>     edge.curved=0.5,
> HERE -->    edge.width= network,  <-- HERE
>     layout=layout_with_mds(.))
> 
> Try to comment out his line and see what happens. What network data
> variable should be mapped to edge width?
> 
> Best,
> Kimmo
> 
> su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> > Dear coummunity
> > 
> > Thanks a lot to David and Kimmo. Yes I see now that I need to
> > provide
> > the two raw tables. Find here the reproducible example.
> > 
> > Kind regards
> > Sibylle
> > 
> > # R-labraries
> > library(circlize)
> > library(ggplot2)
> > library(igraph)
> > library(tidyverse)
> > library(RColorBrewer)
> > library(stringi)
> > library(scico)
> > library(plotly)
> > library(ggraph)
> > 
> > 
> > # Tables
> > aes<-read.csv("Test_adjac.csv", row.names = 1)
> > details<-read.csv("Test_cat.csv")
> > 
> > # Edge table, reorganisation
> > aes_collapsed<-aes %>%
> >   rownames_to_column(var='Names') %>%
> >   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
> >   dplyr::filter(weight != 0) %>%
> >   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 =
> > negative values
> > 
> > write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> > edge_list<-read.csv("edges_table_Test.csv")
> > 
> > # Network attributes
> > network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
> >  vertices = details)
> > 
> > 
> > temp<-cluster_optimal(network)
> > temp<-cbind(membership=temp$membership, Names=temp$name)
> > aes_collapsed <- aes_collapsed %>%
> >   merge(temp, by="Names")
> > 
> > 
> > network <- network %>%
> >   set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
> >  ordered =
> > is.ordered(V(network)$name))) %>%
> >   set_edge_attr(name = "membership", value =
> > aes_collapsed$membership) %>%
> >   set_edge_attr(name = "color", 
> >   value = c(viridis::viridis(5))
> >   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
> >   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
> > type = "local"))) %>%
> >   set_vertex_attr(name = "hub_score", value =
> > c(hub_score(.)$vector))
> > %>%
> >   set_vertex_attr(name = "color", 
> >   value = c(viridis::viridis((5)))
> >   [match(V(.)$name, c(factor(V(.)$name)))]) %>%
> >   set_vertex_attr(name= "community",
> > value=cluster_optimal(.)$membership)
> > 
> > clrs<-scico(3, palette = "batlow")
> > 
> > par(bg="black")
> > network %>% plot(
> >  vertex.color=clrs[V(.)$community], 
> >  vertex.size=V(.)$hub_score*5, 
> >  vertex.frame.color=V(.)$color, 
> >  vertex.label.color="white", 
> >  vertex.label.cex=0.5, 
> >  vertex.label.family="Helvetica",
> >  vertex.label.font=1,
> >  edge.curved=0.5,
> >  edge.width= network,
> >  layout=layout_with_mds(.))
> > 
> > #error
> > Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
> >   Index größer als maximales 6
> > 
> > # Test_adjac.csv
> > A.A B.B C.C D.D E.E F.F
> > A.A 0   0   5   5   5   5
> > B.B 4   0   1   1   1   1
> > C.C 5   5   0   5   4   2
> > D.D 5   0   5   0   5   3
> > E.E 5   1   5   5   0   4
> > F.F 1   2   3   4   5   5
> > 
> > # Test_cat.csv
> > Names   corresponding-
> > NCP   CategorySubcategory_typesources.cytos
> > ou
> > rce  Factor
> > A.A 7   hydrologic attribute"A" A   1
> > B.B 6, 11   hydrologic 

Re: [R] igraph_vertex

2024-02-25 Thread Kimmo Elo

Hi again,

your code is still not reproducible without modifications, but I
succeed in getting the data straight. All read.csv-command are missing
'sep="\t"', it is need to read you tsv-data.

And it could be more reproducible if you used e.g.

--- snip ---
aes<-read.csv(text="A.A B.B C.C D.D E.E F.F
A.A 0   0   5   5   5   5
B.B 4   0   1   1   1   1
C.C 5   5   0   5   4   2
D.D 5   0   5   0   5   3
E.E 5   1   5   5   0   4
F.F 1   2   3   4   5   5", 
sep="\t", row.names = 1)
--- snip ---

This would save us from unnecessary copy-pasting :-)

However, the error is still the same I mentioned in my first reply,
i.e.:

network %>% plot(
vertex.color=clrs[V(.)$community], 
vertex.size=V(.)$hub_score*5, 
vertex.frame.color=V(.)$color, 
vertex.label.color="white", 
vertex.label.cex=0.5, 
vertex.label.family="Helvetica",
vertex.label.font=1,
edge.curved=0.5,
HERE -->edge.width= network,  <-- HERE
layout=layout_with_mds(.))

Try to comment out his line and see what happens. What network data
variable should be mapped to edge width?

Best,
Kimmo

su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> Dear coummunity
> 
> Thanks a lot to David and Kimmo. Yes I see now that I need to provide
> the two raw tables. Find here the reproducible example.
> 
> Kind regards
> Sibylle
> 
> # R-labraries
> library(circlize)
> library(ggplot2)
> library(igraph)
> library(tidyverse)
> library(RColorBrewer)
> library(stringi)
> library(scico)
> library(plotly)
> library(ggraph)
> 
> 
> # Tables
> aes<-read.csv("Test_adjac.csv", row.names = 1)
> details<-read.csv("Test_cat.csv")
> 
> # Edge table, reorganisation
> aes_collapsed<-aes %>%
>   rownames_to_column(var='Names') %>%
>   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
>   dplyr::filter(weight != 0) %>%
>   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 =
> negative values
> 
> write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> edge_list<-read.csv("edges_table_Test.csv")
> 
> # Network attributes
> network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
>  vertices = details)
> 
> 
> temp<-cluster_optimal(network)
> temp<-cbind(membership=temp$membership, Names=temp$name)
> aes_collapsed <- aes_collapsed %>%
>   merge(temp, by="Names")
> 
> 
> network <- network %>%
>   set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
>  ordered =
> is.ordered(V(network)$name))) %>%
>   set_edge_attr(name = "membership", value =
> aes_collapsed$membership) %>%
>   set_edge_attr(name = "color", 
>   value = c(viridis::viridis(5))
>   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
>   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
> type = "local"))) %>%
>   set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector))
> %>%
>   set_vertex_attr(name = "color", 
>   value = c(viridis::viridis((5)))
>   [match(V(.)$name, c(factor(V(.)$name)))]) %>%
>   set_vertex_attr(name= "community",
> value=cluster_optimal(.)$membership)
> 
> clrs<-scico(3, palette = "batlow")
> 
> par(bg="black")
> network %>% plot(
>  vertex.color=clrs[V(.)$community], 
>  vertex.size=V(.)$hub_score*5, 
>  vertex.frame.color=V(.)$color, 
>  vertex.label.color="white", 
>  vertex.label.cex=0.5, 
>  vertex.label.family="Helvetica",
>  vertex.label.font=1,
>  edge.curved=0.5,
>  edge.width= network,
>  layout=layout_with_mds(.))
> 
> #error
> Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
>   Index größer als maximales 6
> 
> # Test_adjac.csv
> A.A B.B C.C D.D E.E F.F
> A.A 0   0   5   5   5   5
> B.B 4   0   1   1   1   1
> C.C 5   5   0   5   4   2
> D.D 5   0   5   0   5   3
> E.E 5   1   5   5   0   4
> F.F 1   2   3   4   5   5
> 
> # Test_cat.csv
> Names   corresponding-
> NCP   CategorySubcategory_typesources.cytosou
> rce  Factor
> A.A 7   hydrologic attribute"A" A   1
> B.B 6, 11   hydrologic attribute"B" B   1
> C.C 1, 14, 15, 16, 17,
> 18   AES intrinsic   "C" C   0
> D.D 1, 14, 15, 16, 17,
> 18   AES intrinsic   "D" D   0
> E.E 1, 14, 15, 16, 17,
> 18   AES intrinsic   "E" E   0
> F.F 7   AES material"F" F   0
> 
> 
> # edges_tables_Test.csv
> Names   target  weight
> B.B A.A 4
> C.C A.A 5
> D.D A.A 5
> E.E A.A 5
> F.F A.A 1
> C.C B.B 5
> E.E B.B 

Re: [R] Interactions in regression

2024-02-25 Thread Bert Gunter
It is trivial in R to add whatever decorations to a plot that you would
like, but that requires that you go beyond point and click production of
graphics and write actual code. If you are unwilling or unable to do this,
you are stuck with whatever various packaged graphics functionality
provides.So you might want to search on "interaction plots for linear
models in R" or similar at rseek.org or in your favorite web search engine
if you haven't already done so. My minimal efforts brought up lots of hits,
though none may be useful for your concerns, especially, as has already
been pointed out, as your query doesn't seem to make much sense
statistically.

Cheers,
Bert


On Sun, Feb 25, 2024 at 7:46 AM Jacek Kownacki 
wrote:

> Hi All,
> I stumbled upon some topics regarding interactions in anova and regression
> and packages for tabulating and visualizations the results of them.
> Here we are:
>
> https://stackoverflow.com/questions/77933272/how-to-add-a-reference-level-for-interaction-in-gtsummary-and-sjplot/77935742#77935742
> ,
>
> https://stackoverflow.com/questions/78016795/how-to-add-reference-levels-for-interaction-in-r?noredirect=1=1
> .
> I was wondering because I usually use GUI software and these questions did
> not get answers, if from a technical point of view
> how to do it, using these (sjPlot, gtsummary) or other ways to make such
> tables, inserting the reference levels of these mentioned interactions.
> This is not likely to be used in publications (including three base
> levels), but from the point of view of solving the topics this questions
> have interested me.
> I tried myself to make it happen, but so far without success.
> I recall this reprex based on SO:
>
> set.seed(1000)
> my_data <- rbind(
>   data.frame(time = "Pre", treatment = "Control", response =
> rnorm(100, mean=1)),
>   data.frame(time = "Pre", treatment = "Treatment", response =
> rnorm(100, mean=2)),
>   data.frame(time = "Post", treatment = "Control", response =
> rnorm(100, mean=1)),
>   data.frame(time = "Post", treatment = "Treatment", response =
> rnorm(100, mean=2))
> ) %>% mutate(time = factor(time, levels = c("Pre", "Post")))
> %>%mutate(treatment = factor(treatment, levels = c("Control",
> "Treatment")))
> model3 <- lm(response ~ time * treatment, data = my_data)
>
> Thanks,
> Jacek
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Interactions in regression

2024-02-25 Thread Jacek Kownacki
Hi All,
I stumbled upon some topics regarding interactions in anova and regression
and packages for tabulating and visualizations the results of them.
Here we are:
https://stackoverflow.com/questions/77933272/how-to-add-a-reference-level-for-interaction-in-gtsummary-and-sjplot/77935742#77935742
,
https://stackoverflow.com/questions/78016795/how-to-add-reference-levels-for-interaction-in-r?noredirect=1=1
.
I was wondering because I usually use GUI software and these questions did
not get answers, if from a technical point of view
how to do it, using these (sjPlot, gtsummary) or other ways to make such
tables, inserting the reference levels of these mentioned interactions.
This is not likely to be used in publications (including three base
levels), but from the point of view of solving the topics this questions
have interested me.
I tried myself to make it happen, but so far without success.
I recall this reprex based on SO:

set.seed(1000)
my_data <- rbind(
  data.frame(time = "Pre", treatment = "Control", response =
rnorm(100, mean=1)),
  data.frame(time = "Pre", treatment = "Treatment", response =
rnorm(100, mean=2)),
  data.frame(time = "Post", treatment = "Control", response =
rnorm(100, mean=1)),
  data.frame(time = "Post", treatment = "Treatment", response =
rnorm(100, mean=2))
) %>% mutate(time = factor(time, levels = c("Pre", "Post")))
%>%mutate(treatment = factor(treatment, levels = c("Control",
"Treatment")))
model3 <- lm(response ~ time * treatment, data = my_data)

Thanks,
Jacek

[[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] Data consideration in executing pca

2024-02-25 Thread Jiji Sid
Dear R users,

 I have a txt file named 'data_1.txt' whose first column contains the names
of the individuals and the other columns contain the values of four
variables X_1,X_2,X_3 and X_4. I read it with R from its location and
called it data. I'd like to do a normalized principal component analysis. I
started by calculating the correlation matrix:
cor(data)
 I got the following message:
Error in cor(nnotes) : 'x' must be numeric.
I eliminated the first column of names, then read the modified data and
then added the names of individuals with rownames. I was able to run PCA
and obtain graphical representations of the variables, their coordinates,
contributions and cos2. However, when I used fviz_pca_ind to get the
graphical representation of the individuals, I got a graphic that considers
the variables as individuals. Can you please help me? I have attached the
file data_1 .txt file.

Many thanks in advance.
Name X_1  X_2X_3 X_4 
John10.2  10 65
Ricardo 14.75 13.5   10.5 9
Suzane  17.75 16.5  12.5 10
Monica   1514 13  9
Meriam   1619 14  13 
Philipps 17.75 17 12  12
Sonia2017 13  14__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


<    2   3   4   5   6   7   8   9   10   11   >