Re: [R] Problem with creating a PCA graph in a loop

2024-05-08 Thread Gavin Duley
> On 8 May 2024, at 09:16, Ivan Krylov  wrote:
> 
> В Tue, 7 May 2024 16:57:14 +0200
> gavin duley  пишет:
> 
>> aes(label=current_rownames,
>>colour=wine.data.filt$Treatment
>> )
> 
> As you've noticed, aes() remembers variables by their name and
> environment, not by value:

Yes, it was something I wasn’t aware of previously. I thought once I’d created 
a ggplot object, it was fairly static/unchanging.

That this is limited to aes() explains why the title set using ggtitle isn’t 
affected in the same way — thanks!

> One way to get around the problem is to ensure that the variables live
> in different environments. Instead of making it a for loop, write a
> function that would accept `i` and return a plot instead of assigning
> it by name:

Thanks, that does seem like a good option. I’m less familiar with writing 
functions, but it’s something I’m trying to learn about. I’ll try it and see 
how it goes.

> (In many languages, trying to use a variable as a variable name, while
> possible, usually means you need to consider some kind of nested data
> structure:
> https://perldoc.perl.org/perlfaq7#How-can-I-use-a-variable-as-a-variable-name?
> In R, this structure is a list.)

Ok, that’s useful to know, thanks. I don’t really have much programming 
experience beyond R, so there’s a lot I don’t know.

> Alternatively, supply a data= argument to geom_label_repel() and make
> your mapping = aes(...) reference variables from the data (which will
> be remembered), ignoring the environment (which is only referenced).
> Something like the following should work, untested:


Thanks, I’ll try that out too.

Many thanks for giving me a few suggestions. I was completely stuck, but these 
have given me a few good things to try!

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

2024-05-08 Thread Ivan Krylov via R-help
В Tue, 7 May 2024 16:57:14 +0200
gavin duley  пишет:

> aes(label=current_rownames,
> colour=wine.data.filt$Treatment
> )

As you've noticed, aes() remembers variables by their name and
environment, not by value:

str(ggplot2::aes(label = foo))
# List of 1
#  $ label: language ~foo # <-- variable name recorded here
   # and here is the environment
#   ..- attr(*, ".Environment")= 
#  - attr(*, "class")= chr "uneval"

One way to get around the problem is to ensure that the variables live
in different environments. Instead of making it a for loop, write a
function that would accept `i` and return a plot instead of assigning
it by name:

makeplot <- function(i) {
  print(i)
  wine.data.filt <- filter(wine.data,Time == i)
  current_rownames <- rownames(wine.data.filt)
  wine.data.filt.pca <- dudi.pca(wine.data.filt[3:11],
 nf=6,
 scannf=F)
  wine.data_quanti_sup <- wine.data.filt[,12, drop = FALSE]
  return(fviz_pca_ind(wine.data.filt.pca,
   # 
  )
}

individs <- lapply(levels(wine.data$Time), makeplot)
individs[[1]]

(In many languages, trying to use a variable as a variable name, while
possible, usually means you need to consider some kind of nested data
structure:
https://perldoc.perl.org/perlfaq7#How-can-I-use-a-variable-as-a-variable-name?
In R, this structure is a list.)

Why does this work? Calling a function creates a new environment every
time. The plots will all refer to the variable named current_rownames,
but the environments will be different:

attr((function() ggplot2::aes(label = foo))()$label, '.Environment')
# 
attr((function() ggplot2::aes(label = foo))()$label, '.Environment')
# 
attr((function() ggplot2::aes(label = foo))()$label, '.Environment')
# 

Alternatively, supply a data= argument to geom_label_repel() and make
your mapping = aes(...) reference variables from the data (which will
be remembered), ignoring the environment (which is only referenced).
Something like the following should work, untested:

geom_label_repel(
 mapping = aes(label = current_rownames, colour = Treatment),
 data = data.frame(
  current_rownames = current_rownames,
  Treatment = wine.data.filt$Treatment
 ),
 # more arguments here
)

-- 
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] Problem with creating a PCA graph in a loop

2024-05-07 Thread gavin duley
Hi all,

I am having enormous problems with a loop that iterates over different
levels in the factor wine.data$Time (levels T06, T09, and T12) and
creates a PCA and graph for individuals at that time only. These
graphs need to be accessible outside the loop, so I can combine them
using ggpubr::ggarrange to produce a figure for a paper.

The difficulty I am having is with the labels produced by
ggrepel::geom_label_repel. Since the loop uses the variable i to set
the level of wine.data$Time, when used outside the loop the labels
produced by geom_label_repel are always for T12 (i.e., the last level
run by the loop).

Oddly, this only affects the labels: the title, set using
ggtitle(paste0("PCA of wine.data observations at Time ", print(i))),
shows the correct time, and the datapoints are for the correct time.

Is there some way to get geom_label_repel to read current_rownames and
store the values in the ggplot object, rather than to reload them
every time I display or save the ggplot graph?

Thanks!
gavin,

Code for reference. I can provide a sample dataset for reproducibility
if needed.

for(i in levels(wine.data$Time)){
  print(i)
  wine.data.filt <- filter(wine.data,Time == i)
  current_rownames <- rownames(wine.data.filt)
  wine.data.filt.pca <- dudi.pca(wine.data.filt[3:11],
   nf=6,
   scannf=F)
  wine.data_quanti_sup <- wine.data.filt[,12, drop = FALSE]
  head(wine.data_quanti_sup)

  # Colour by Treatment
  assign(paste0("individ_", i),
 fviz_pca_ind(wine.data.filt.pca,
  geom.ind = "point",
  mean.point=F,
  col.ind = wine.data.filt$Treatment,
  ellipse.type = "confidence",
  legend.title = "Groups"
 )+ggtitle(paste0("PCA of wine.data observations at Time ", print(i)))
 +
   scale_colour_manual(
 values = c(
   "Control" = "#00A087FF",
   "Low" = "#3C5488FF",
   "High" = "#E64B35FF")
   ) + geom_label_repel(position =
ggpp::position_nudge_center(0.2, 0.1, 0, 0),
box.padding = 0.5,
max.overlaps = Inf,
aes(label=current_rownames,
colour=wine.data.filt$Treatment
)
   ) +
   scale_fill_manual(
 values = c(
   "Control" = "#00A087FF",
   "Low" = "#3C5488FF",
   "High" = "#E64B35FF")
   ))
}

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

2024-04-10 Thread Sigbert Klinke

Hi,

you are unfortunately right. Executing

x <- sample(c(1,2,NA), 26, replace=TRUE)
y <- sample(c(1,2,NA), 26, replace=TRUE)
o <- order(x, y, decreasing = c(T,F), na.last=c(F,T))
cbind(x[o], y[o])

shows that the second entry of na.last is ignored without warning.

Thanks Sigbert

Am 10.04.24 um 10:29 schrieb Ivan Krylov:

В Wed, 10 Apr 2024 09:33:19 +0200
Sigbert Klinke  пишет:


decreasing=c(F,F,F)


This is only documented to work with method = 'radix':


For the ‘"radix"’ method, this can be a vector of length equal to
the number of arguments in ‘...’ and the elements are recycled as
necessary.  For the other methods, it must be length one.



na.last=c(T,T,T),


I think this is supposed to be a scalar, no matter the sort method. At
the very least, I don't see it documented to accept a logical vector,
and the C code in both src/main/sort.c and src/main/radixsort.c treats
the argument as a scalar (using asLogical(...), not LOGICAL(...) on the
R value).



--
https://hu.berlin/sk
https://hu.berlin/mmstat
https://hu.berlin/mmstat-ar

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

2024-04-10 Thread Ivan Krylov via R-help
В Wed, 10 Apr 2024 09:33:19 +0200
Sigbert Klinke  пишет:

> decreasing=c(F,F,F)

This is only documented to work with method = 'radix':

>> For the ‘"radix"’ method, this can be a vector of length equal to
>> the number of arguments in ‘...’ and the elements are recycled as
>> necessary.  For the other methods, it must be length one.

> na.last=c(T,T,T), 

I think this is supposed to be a scalar, no matter the sort method. At
the very least, I don't see it documented to accept a logical vector,
and the C code in both src/main/sort.c and src/main/radixsort.c treats
the argument as a scalar (using asLogical(...), not LOGICAL(...) on the
R value).

-- 
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] Problem with base::order

2024-04-10 Thread Sigbert Klinke

Hi,

when I execute

order(letters, LETTERS, 1:26)

then everything is fine. But if I execute

order(letters, LETTERS, 1:26, na.last=c(T,T,T), decreasing=c(F,F,F))

I get the error message

Error in method != "radix" && !is.na(na.last) :
'length = 3' in constraint to 'logical(1)'

Shouldn't both give the same result?

Sigbert

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

2024-03-22 Thread Ivan Krylov via R-help
В Fri, 22 Mar 2024 16:11:14 +
MACHO Siegfried via R-help  пишет:

> If I type the command:
> Dir <- "C/Users/macho/Documents/_LVn/Experimentelle _bungen"
> in the R console there is no problem. However, if I put the same
> command into a source file (e.g. Test.r) and call this file from R
> (via the source command), I get the following error message:
> 
> > source("C:\\Users\\macho\\Documents\\_LVn\\Experimentelle
> > _bungen\\R-Scripts\\R-Dokumentation\\R_scripts zur
> > R_Dokumentation\\Kapitel 4 Erstellen eines
> > Balkendiagramms\\Test.R")  
> Fehler: invalid multibyte character in parser
> (C:\Users\macho\Documents\_LVn\Experimentelle
> _bungen\R-Scripts\R-Dokumentation\R_scripts zur
> R_Dokumentation\Kapitel 4 Erstellen eines Balkendiagramms\Test.R:1:54

A few versions ago, the R developers made the change of the encoding
used by R on Windows. Instead of the ANSI encoding, R now uses UTF-8:
https://blog.r-project.org/2020/05/02/utf-8-support-on-windows/index.html

This makes it possible to represent many more characters than the
256-byte range covered by CP1252, but the byte sequences are now
different. Also, non-ASCII characters will take more than one byte to
store.

Can you save the script using the UTF-8 encoding instead of CP1252?
Alternatively, try source(..., encoding = 'CP1252').

> In addition, text files saved with an older version of R (using the
> function write.table) containing mutated vowels are not read-in
> correctly by the function read.table.

In a similar manner, try read.table(..., fileEncoding = 'CP1252').
Setting encoding = 'latin1' may also work, even if it's technically a
different encoding.

-- 
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] Problem with new version of R: Mutated vocals

2024-03-22 Thread MACHO Siegfried via R-help
Dear ladies and gentlemen,

I have recently installed the latest version of R (4.3.3) for windows. Now I 
have the following problems with mutated vowels like �, �, etc. Here is an 
example:
If I type the command:
Dir <- "C/Users/macho/Documents/_LVn/Experimentelle �bungen"
in the R console there is no problem. However, if I put the same command into a 
source file (e.g. Test.r) and call this file from R (via the source command), I 
get the following error message:

> source("C:\\Users\\macho\\Documents\\_LVn\\Experimentelle 
> �bungen\\R-Scripts\\R-Dokumentation\\R_scripts zur R_Dokumentation\\Kapitel 4 
> Erstellen eines Balkendiagramms\\Test.R")
Fehler: invalid multibyte character in parser 
(C:\Users\macho\Documents\_LVn\Experimentelle 
�bungen\R-Scripts\R-Dokumentation\R_scripts zur R_Dokumentation\Kapitel 4 
Erstellen eines Balkendiagramms\Test.R:1:54

In addition, text files saved with an older version of R (using the function 
write.table) containing mutated vowels are not read-in correctly by the 
function read.table.
I would be glad, if someone could help me with this problem.

Kind regards,
Siegfried Macho.

--
PD Dr. Siegfried Macho
Psychological Department
University of Fribourg
Rue de Faucigny 2
CH-1700 Fribourg
Tel.: ++41-26-3007635
-




[[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 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] 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] Problem in R code

2023-11-09 Thread Ivan Krylov
В Wed, 8 Nov 2023 16:03:15 +0530
Crown Flame  пишет:

> for(i in 1:8)
> {
>   LST_city <- extract(LST, c(lon[i],lat[i]), fun = mean, buffer =
> 1, na.rm = TRUE)   #error
> }

Three things you might need to change:

1. You are trying to assign the output of extract() to the same
variable LST_city in all 8 iterations of the loop. You will probably
need to make it a list and assign to the list elements, e.g.
LST_city[[i]] <- ...

It will also help to learn about lapply() and other functions that
encapsulate loops, although that is more of a matter of taste.

2. You are giving a single vector c(lon[i], lat[i]) to extract() as the
y=... argument. According to help(extract), this is interpreted as
_numbers_ of cells inside x, not coordinates. You should probably
construct a spPolygons() object and use that as the `y` argument to
extract().

3. The description of the 'raster' package says that it's been
superseded by the 'terra' package. You don't have to rewrite all your
code now, but it may be beneficial to check whether 'terra' can
accomplish what you want.

> Error in optim(c(mu_x0, mu_y0, sigma_x0, sigma_y0, amp0), sse) :
>   non-finite value supplied by optim

This must be self-explanatory: your `sse` function returns something
that is not a real number. Try options(error = recover) to see which
arguments it is given when it fails in such a manner. See the free book
"The R Inferno" for more R debugging tips
. Consider
using the 'optimx' package which contains optimisation algorithms that
might work better for you.

-- 
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] Problem in R code

2023-11-09 Thread Crown Flame
Good afternoon,
I have been working on my thesis project on the topic "Urban Heat Island
Pattern in India". To achieve the results I am applying a* two-dimensional
Gaussian fit* on an LST raster of 1 km spatial resolution but I am facing
two errors in the following code.

library(raster)
LST <- raster("D:/Celsius_Day/MOD_01.tif")
gaussian2d <- function(x, y, mu_x, mu_y, sigma_x, sigma_y, amp)
{
  exp(-((x - mu_x)^2/(2*sigma_x^2) + (y - mu_y)^2/(2*sigma_y^2)))*amp
}

#define a function for the sum of squared errors between the data and the
Gaussian
sse <- function(p)
{ mu_x <- p
mu_y <- p
sigma_x <- p
sigma_y <- p
amp <- p[5]
fitted <- gaussian2d(x, y, mu_x, mu_y, sigma_x, sigma_y, amp)
sum((z - fitted)^2)
}

#loop over 8 cities
cities <-
c("Delhi","Jaipur","Kolkata","Mumbai","Pune","Hyderabad","Bangalore","Chennai")
lon <-
c(77.219934,75.793261,88.365394,72.900361,73.875199,78.47476,77.602114,80.192181)
lat <-
c(28.589256,26.892024,22.619754,19.110629,18.50269,17.422973,12.974087,13.044415)
results <- data.frame() #A data frame to store the results
for(i in 1:8)
{
  LST_city <- extract(LST, c(lon[i],lat[i]), fun = mean, buffer = 1,
na.rm = TRUE)   #error
}

# Fit a 2D Gaussian surface to the LST data
x <- coordinates(LST)[,1]
y <- coordinates(LST)[,2]
z <- values(LST)
mu_x0 <- mean(x)
mu_y0 <- mean(y)
sigma_x0 <- sd(x)/2
sigma_y0 <- sd(y)/2
amp0 <- max(z)
opt <- optim(c(mu_x0, mu_y0, sigma_x0, sigma_y0, amp0), sse) #error 2

#Calculate the footprint of SUHI effect (FP) by the Gaussian surface
FP <- which(gaussian2d(x, y, opt$par, opt$par, opt$par, opt$par,
opt$par[5]) >= threshold)

#store the results for each city in the data frame
results <- rbind(results, data.frame(city=cities[i], FP=mean(FP)))

#print the results
results


The two errors are in the row which are defining the variables "LST_city"
and "opt".
The first error is:
Error in .cellValues(x, y, ...) : unused arguments (fun =
new("standardGeneric", .Data = function (x, ...) standardGeneric("mean"),
generic = "mean", package = "base", group = list(), valueClass =
character(0), signature = "x", default = new("derivedDefaultMethod", .Data
= function (x, ...) UseMethod("mean"), target = new("signature", .Data =
"ANY", names = "x", package = "methods"), defined = new("signature", .Data
= "ANY", names = "x", package = "methods"), generic = "mean"), skeleton =
(new("derivedDefaultMethod", .Data = function (x, ...) UseMethod("mean"),
target = new("signature", .Data = "ANY", names = "x", package = "methods"),
defined = new("signature", .Data = "ANY", names = "x", package =
"methods"), generic = "mean"))(x, ...)), buffer = 2, na.rm = TRUE)


The second error is:

Error in optim(c(mu_x0, mu_y0, sigma_x0, sigma_y0, amp0), sse) :
  non-finite value supplied by optim



What could be the possible reason behind these errors and most
importantly how can I get rid of these errors?



Thank you


Regards

DD

[[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 compatible library versions

2023-10-13 Thread Sabine Braun
Thank you very much :-)), this worked! Now the loaded libraries are 
compatible with each other.

Best regards

Sabine Braun

Am 11.10.2023 um 14:08 schrieb Richard O'Keefe:
> There is a fairly straightforward way to load older versions
> of packages, and that is to use the 'groundhog' package.
> As the first sentence of https://groundhogr.com/ puts it:
>    Make your R scripts reproducible by replacing library(pkg)
>    with groundhog.library(pkg, date).
>
> pkg can be a vector of package names or a single name.
>
> On Wed, 11 Oct 2023 at 20:58, Uwe Ligges 
>  wrote:
> >
> >
> > On 10.10.2023 17:34, Sabine Braun wrote:
> > > On the github website I have reported several bugs with new 
> versions of
> > > the tidyverse group (probably dplyr) which prevent me from using R
> > > normally. I wanted to go back to older versions but this seems not 
> bo be
> > > easy. I downloaded R 4.1.2. and Rtools 40 but the library versions
> >
> > So this is on Windows.
> >
> > Actually, if you install R-4.1.2 and use a clean library and install
> > binaries, then you should get binary installation from CRAN that fit to
> > the R-4.1.x series.
> >
> > If you want to install older package versions, then you have to install
> > these one by one from sources, unfortunately.
> >
> > Best,
> > Uwe Ligges
> >
> >
> >
> > > installed are still the newest ones. I was able to install dplyr 
> 1.0.7.
> > > manually but there are error messages on incompatibility when loading
> > > this version. Is there a possibility to load older library versions
> > > which alre compatible ?
> > >
> > > Thank you very much!
> > >
> > > Best regards
> > >
> > > Sabine Braun
> > >
> > >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html 
> 
> > and provide commented, minimal, self-contained, reproducible code.
-- 


Dr. Sabine Braun
Leitung

www.iap.ch 

Institut für Angewandte Pflanzenbiologie (IAP) AG
Benkenstrasse 254a
CH-4108 Witterswil
++41 (0)61 485 50 71
++41 (0)79 696 69 85

[[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 compatible library versions

2023-10-12 Thread Richard O'Keefe
The purpose of 'groundhog' is to support reproducible research.
As Uwe Ligges pointed out, there are practical limits to that.
Since I am typing this on a 10-year-old machine, it's clearly
feasible in *some* instances, but as an illustration of Uwe's
point, Ubuntu still supports 32-bit applications, but it does
not support 32-bit x86 hardware (since 20.04 IIRC).

I think it is fair to say that 'groundhog' *supports*
reproducible research, but nothing can *guarantee* it.


On Thu, 12 Oct 2023 at 01:54, Ebert,Timothy Aaron  wrote:

> Is that a method where a program that I write today would still run
> without changes in 10 years?
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Richard O'Keefe
> Sent: Wednesday, October 11, 2023 8:08 AM
> To: Uwe Ligges 
> Cc: r-help@r-project.org
> Subject: Re: [R] Problem with compatible library versions
>
> [External Email]
>
> There is a fairly straightforward way to load older versions of packages,
> and that is to use the 'groundhog' package.
> As the first sentence of https://groundhogr.com/ puts it:
>Make your R scripts reproducible by replacing library(pkg)
>with groundhog.library(pkg, date).
>
> pkg can be a vector of package names or a single name.
>
> On Wed, 11 Oct 2023 at 20:58, Uwe Ligges 
> wrote:
> >
> >
> > On 10.10.2023 17:34, Sabine Braun wrote:
> > > On the github website I have reported several bugs with new versions
> > > of the tidyverse group (probably dplyr) which prevent me from using
> > > R normally. I wanted to go back to older versions but this seems not
> > > bo be easy. I downloaded R 4.1.2. and Rtools 40 but the library
> > > versions
> >
> > So this is on Windows.
> >
> > Actually, if you install R-4.1.2 and use a clean library and install
> > binaries, then you should get binary installation from CRAN that fit
> > to the R-4.1.x series.
> >
> > If you want to install older package versions, then you have to
> > install these one by one from sources, unfortunately.
> >
> > Best,
> > Uwe Ligges
> >
> >
> >
> > > installed are still the newest ones. I was able to install dplyr 1.0.7.
> > > manually but there are error messages on incompatibility when
> > > loading this version. Is there a possibility to load older library
> > > versions which alre compatible ?
> > >
> > > Thank you very much!
> > >
> > > Best regards
> > >
> > > Sabine Braun
> > >
> > >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat/
> > .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
> > %7C86c81ebb0b184971b4eb08dbca52d5b3%7C0d4da0f84a314d76ace60a62331e1b84
> > %7C0%7C0%7C638326229351781447%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> > ta=kEpdr7GlTQwcaKCMfI0NJfWXrgCshp5DVALyiu%2FHG4I%3D=0
> > PLEASE do read the posting guide
> http://www.r-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.r-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Problem with compatible library versions

2023-10-11 Thread Uwe Ligges

No.

In 10 years you may have different hardware and a different OS, so that 
the old R and old packages won't run on the new hardware or produce 
different results. This may even happen for some sort of containers and 
virtualizations.


To be really safe, you ideally need to keep the whole system as is (but 
then there are security updates etc).


Best,
Uwe Ligges




On 11.10.2023 14:54, Ebert,Timothy Aaron wrote:

Is that a method where a program that I write today would still run without 
changes in 10 years?
Tim

-Original Message-
From: R-help  On Behalf Of Richard O'Keefe
Sent: Wednesday, October 11, 2023 8:08 AM
To: Uwe Ligges 
Cc: r-help@r-project.org
Subject: Re: [R] Problem with compatible library versions

[External Email]

There is a fairly straightforward way to load older versions of packages, and 
that is to use the 'groundhog' package.
As the first sentence of https://groundhogr.com/ puts it:
Make your R scripts reproducible by replacing library(pkg)
with groundhog.library(pkg, date).

pkg can be a vector of package names or a single name.

On Wed, 11 Oct 2023 at 20:58, Uwe Ligges 
wrote:



On 10.10.2023 17:34, Sabine Braun wrote:

On the github website I have reported several bugs with new versions
of the tidyverse group (probably dplyr) which prevent me from using
R normally. I wanted to go back to older versions but this seems not
bo be easy. I downloaded R 4.1.2. and Rtools 40 but the library
versions


So this is on Windows.

Actually, if you install R-4.1.2 and use a clean library and install
binaries, then you should get binary installation from CRAN that fit
to the R-4.1.x series.

If you want to install older package versions, then you have to
install these one by one from sources, unfortunately.

Best,
Uwe Ligges




installed are still the newest ones. I was able to install dplyr 1.0.7.
manually but there are error messages on incompatibility when
loading this version. Is there a possibility to load older library
versions which alre compatible ?

Thank you very much!

Best regards

Sabine Braun




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat/
.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
%7C86c81ebb0b184971b4eb08dbca52d5b3%7C0d4da0f84a314d76ace60a62331e1b84
%7C0%7C0%7C638326229351781447%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
ta=kEpdr7GlTQwcaKCMfI0NJfWXrgCshp5DVALyiu%2FHG4I%3D=0
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] Problem with compatible library versions

2023-10-11 Thread Ebert,Timothy Aaron
Is that a method where a program that I write today would still run without 
changes in 10 years?
Tim

-Original Message-
From: R-help  On Behalf Of Richard O'Keefe
Sent: Wednesday, October 11, 2023 8:08 AM
To: Uwe Ligges 
Cc: r-help@r-project.org
Subject: Re: [R] Problem with compatible library versions

[External Email]

There is a fairly straightforward way to load older versions of packages, and 
that is to use the 'groundhog' package.
As the first sentence of https://groundhogr.com/ puts it:
   Make your R scripts reproducible by replacing library(pkg)
   with groundhog.library(pkg, date).

pkg can be a vector of package names or a single name.

On Wed, 11 Oct 2023 at 20:58, Uwe Ligges 
wrote:
>
>
> On 10.10.2023 17:34, Sabine Braun wrote:
> > On the github website I have reported several bugs with new versions
> > of the tidyverse group (probably dplyr) which prevent me from using
> > R normally. I wanted to go back to older versions but this seems not
> > bo be easy. I downloaded R 4.1.2. and Rtools 40 but the library
> > versions
>
> So this is on Windows.
>
> Actually, if you install R-4.1.2 and use a clean library and install
> binaries, then you should get binary installation from CRAN that fit
> to the R-4.1.x series.
>
> If you want to install older package versions, then you have to
> install these one by one from sources, unfortunately.
>
> Best,
> Uwe Ligges
>
>
>
> > installed are still the newest ones. I was able to install dplyr 1.0.7.
> > manually but there are error messages on incompatibility when
> > loading this version. Is there a possibility to load older library
> > versions which alre compatible ?
> >
> > Thank you very much!
> >
> > Best regards
> >
> > Sabine Braun
> >
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat/
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
> %7C86c81ebb0b184971b4eb08dbca52d5b3%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638326229351781447%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> ta=kEpdr7GlTQwcaKCMfI0NJfWXrgCshp5DVALyiu%2FHG4I%3D=0
> 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] Problem with compatible library versions

2023-10-11 Thread Richard O'Keefe
There is a fairly straightforward way to load older versions
of packages, and that is to use the 'groundhog' package.
As the first sentence of https://groundhogr.com/ puts it:
   Make your R scripts reproducible by replacing library(pkg)
   with groundhog.library(pkg, date).

pkg can be a vector of package names or a single name.

On Wed, 11 Oct 2023 at 20:58, Uwe Ligges 
wrote:
>
>
> On 10.10.2023 17:34, Sabine Braun wrote:
> > On the github website I have reported several bugs with new versions of
> > the tidyverse group (probably dplyr) which prevent me from using R
> > normally. I wanted to go back to older versions but this seems not bo be
> > easy. I downloaded R 4.1.2. and Rtools 40 but the library versions
>
> So this is on Windows.
>
> Actually, if you install R-4.1.2 and use a clean library and install
> binaries, then you should get binary installation from CRAN that fit to
> the R-4.1.x series.
>
> If you want to install older package versions, then you have to install
> these one by one from sources, unfortunately.
>
> Best,
> Uwe Ligges
>
>
>
> > installed are still the newest ones. I was able to install dplyr 1.0.7.
> > manually but there are error messages on incompatibility when loading
> > this version. Is there a possibility to load older library versions
> > which alre compatible ?
> >
> > Thank you very much!
> >
> > Best regards
> >
> > Sabine Braun
> >
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 compatible library versions

2023-10-11 Thread Uwe Ligges



On 10.10.2023 17:34, Sabine Braun wrote:

On the github website I have reported several bugs with new versions of
the tidyverse group (probably dplyr) which prevent me from using R
normally. I wanted to go back to older versions but this seems not bo be
easy. I downloaded R 4.1.2. and Rtools 40 but the library versions


So this is on Windows.

Actually, if you install R-4.1.2 and use a clean library and install 
binaries, then you should get binary installation from CRAN that fit to 
the R-4.1.x series.


If you want to install older package versions, then you have to install 
these one by one from sources, unfortunately.


Best,
Uwe Ligges




installed are still the newest ones. I was able to install dplyr 1.0.7.
manually but there are error messages on incompatibility when loading
this version. Is there a possibility to load older library versions
which alre compatible ?

Thank you very much!

Best regards

Sabine Braun




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

2023-10-10 Thread Sabine Braun
On the github website I have reported several bugs with new versions of 
the tidyverse group (probably dplyr) which prevent me from using R 
normally. I wanted to go back to older versions but this seems not bo be 
easy. I downloaded R 4.1.2. and Rtools 40 but the library versions 
installed are still the newest ones. I was able to install dplyr 1.0.7. 
manually but there are error messages on incompatibility when loading 
this version. Is there a possibility to load older library versions 
which alre compatible ?

Thank you very much!

Best regards

Sabine Braun


-- 


Dr. Sabine Braun
Leitung

www.iap.ch 

Institut für Angewandte Pflanzenbiologie (IAP) AG
Benkenstrasse 254a
CH-4108 Witterswil
++41 (0)61 485 50 71
++41 (0)79 696 69 85

[[alternative HTML version deleted]]

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


Re: [R] R - Problem retrieving memory used after gc() using arrow library

2023-08-16 Thread Ivan Krylov
On Wed, 16 Aug 2023 11:22:00 +0200
Kévin Pemonon  wrote:

> I'd like to understand why there's a difference in memory used
> between the Windows task manager and R's memory.size(max=F) function.

When R was initially ported to Windows, then-popular version of the
system memory allocator was not a good fit for R. R allocates and frees
lots of objects, sometimes small ones. The Windows 95-era allocator had
backwards-compatibility obligations to lots of incorrectly-written
programs that sometimes used memory after freeing it and poked at
undocumented implementation details a lot [*]. I don't know the exact
reasons (my family didn't even have a computer back then), but it seems
that R couldn't make full use of the computer memory without bringing
in its own memory allocator (a copy of Doug Lea's malloc).

It is this particular allocator that memory.size() has access to.
Nowadays, there are many ways for a Windows process to have memory
allocated for it, and not all of them are under control of R. Apache
Arrow, being "a platform for in-memory data", probably allocates its
own memory without asking R to do it. Meanwhile, the Windows
implementation of malloc() has improved, so R-4.2.0 got rid of its own
copy (which also means no more memory.size()).

You are welcome to trust the task manager.

-- 
Best regards,
Ivan

[*] See, e.g., the free bonus chapters to "The Old New Thing" by Raymond
Chen:
https://www.informit.com/content/images/9780321440303/samplechapter/Chen_bonus_ch01.pdf
https://www.informit.com/content/images/9780321440303/samplechapter/Chen_bonus_ch02.pdf

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 - Problem retrieving memory used after gc() using arrow library

2023-08-16 Thread Kévin Pemonon
Hello,

I'm using R versions 4.1.3 on Windows 10 and I'm having a problem with
memory usage.

Currently, I need to use the arrow and dplyr libraries in a program and
when I compare the memory used between the windows task manager and the
memory.size(max=F) function, the one given by the windows task manager is
much larger, 243.5 MB RAM Windows ,
than the one given by the memory.size(max=F) function, 75.77 MB.

However, I delete objects created with rm() and then use the gc() function
to recover the memory used by the object.

Attached is the R code, with and without output, that I used to present my
problem.

Do you think this memory difference is normal? Could it be caused by the
libraries used and/or by bad practices in using the R language?

I'd like to understand why there's a difference in memory used between the
Windows task manager and R's memory.size(max=F) function.

Thank you for your help, and I remain at your disposal for any further
information you may require.

Best regards,
> gc(verbose = TRUE)
Garbage collection 2 = 0+0+2 (level 2) ... 
14.2 Mbytes of cons cells used (41%)
3.9 Mbytes of vectors used (6%)
 used (Mb) gc trigger (Mb) max used (Mb)
Ncells 264908 14.2 648748 34.7   401965 21.5
Vcells 500529  3.98388608 64.0  1671274 12.8
> 
> # basic memory
> memory.size(max=F)
[1] 28.78
> 
> library(arrow, warn.conflicts = FALSE)
> 
> # Memory after loading the arrow library with memory.size
> memory.size(max=F)
[1] 51.01
> 
> # bytes_allocated after loading the arrow library
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after loading the arrow library
> default_memory_pool()$max_memory
[1] 0
> 
> library(dplyr)

Attachement du package : ‘dplyr’

Les objets suivants sont masqués depuis ‘package:stats’:

filter, lag

Les objets suivants sont masqués depuis ‘package:base’:

intersect, setdiff, setequal, union

> 
> # Memory after loading the dplyr library with memory.size
> memory.size(max=F)
[1] 90.74
> 
> # bytes_allocated after loading the dplyr library
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after loading the dplyr library
> default_memory_pool()$max_memory
[1] 0
> 
> df <- data.frame(
+   col1 = rnorm(100),
+   col2 = rnorm(100),
+   col3 = runif(100),
+   col4 = sample(1:999, size = 100, replace = T),
+   col5 = sample(c("GroupA", "GroupB"), size = 100, replace = T),
+   col6 = sample(c("TypeA", "TypeB"), size = 100, replace = T)
+ )
> 
> # Memory after df object creation
> memory.size(max=F)
[1] 133.23
> 
> # bytes_allocated after df object creation
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after df object creation
> default_memory_pool()$max_memory
[1] 0
> 
> arrow::write_dataset(
+   df,
+   paste0(Sys.getenv("USERPROFILE"),"/ExProblemeGc"),
+   format = "parquet"
+ )
> 
> # Memory after writing to disk
> memory.size(max=F)
[1] 120.07
> 
> # bytes_allocated after writing to disk
> default_memory_pool()$bytes_allocated
[1] 19000128
> 
> # max_memory after writing to disk
> default_memory_pool()$max_memory
[1] 27126592
> 
> rm(df)
> 
> # Memory after deletion df
> memory.size(max=F)
[1] 120.07
> 
> # bytes_allocated after deletion df
> default_memory_pool()$bytes_allocated
[1] 19000128
> 
> # max_memory after deletion df
> default_memory_pool()$max_memory
[1] 27126592
> 
> gc(verbose = TRUE)
Garbage collection 15 = 9+2+4 (level 2) ... 
45.0 Mbytes of cons cells used (61%)
38.0 Mbytes of vectors used (49%)
  used (Mb) gc trigger (Mb) max used (Mb)
Ncells  842008   451387691 74.2  1387691 74.2
Vcells 4975717   38   10146329 77.5  8388601 64.0
> 
> # Memory after gc(verbose = TRUE)
> memory.size(max=F)
[1] 101.29
> 
> # bytes_allocated after gc(verbose = TRUE)
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after gc(verbose = TRUE)
> default_memory_pool()$max_memory
[1] 27126592
> 
> gc(verbose = TRUE)
Garbage collection 16 = 9+2+5 (level 2) ... 
45.0 Mbytes of cons cells used (61%)
11.3 Mbytes of vectors used (15%)
  used (Mb) gc trigger (Mb) max used (Mb)
Ncells  841895 45.01387691 74.2  1387691 74.2
Vcells 1475542 11.3   10146329 77.5  8388601 64.0
> 
> # Memory after gc(verbose = TRUE)
> memory.size(max=F)
[1] 74.35
> 
> # bytes_allocated after gc(verbose = TRUE)
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after gc(verbose = TRUE)
> default_memory_pool()$max_memory
[1] 27126592
> 
> ds <- arrow::open_dataset(paste0(Sys.getenv("USERPROFILE"),"/ExProblemeGc"))
> 
> # Memory after ds creation
> memory.size(max=F)
[1] 79.01
> 
> # bytes_allocated after ds creation
> default_memory_pool()$bytes_allocated
[1] 0
> 
> # max_memory after ds creation
> default_memory_pool()$max_memory
[1] 27126592
> 
> req <-
+   ds %>%
+   collect()
> 
> # Memory after req creation
> memory.size(max=F)
[1] 84.46
> 
> # bytes_allocated after req creation
> default_memory_pool()$bytes_allocated
[1] 47504192
> 

Re: [R] Problem with filling dataframe's column

2023-06-14 Thread avi.e.gross
Richard, it is indeed possible for different languages to choose different 
approaches.
 
If your point is that an R  named list can simulate a Python dictionary (or for 
that manner, a set) there is some validity to that. You can also use 
environments similarly.
 
Arguably there are differences including in things like what notations are 
built into the language. If you look the other way, Python chose to make lists 
a major feature which can hold any combination of things and can even be used 
to emulate a matrix with sub-lists and also had a tuple version that is similar 
but immutable and initially neglected something as simple as a vector 
containing just one kind of content. If you look at it now, many people simply 
load numpy (and often pandas) to get functionality that is faster and comes by 
default in R.
 
I think this discussion was about my (amended) offhand remark suggesting R 
factors stored plain text in a vector attached to the variable and the offset 
was the number stored in the main factor vector. If that changed to internally 
use something hashed like a dictionary, fine. I have often made data structures 
such as in your example to store named items but did not call it a dictionary 
but simply a named list. In one sense, the two map into each other but I could 
argue there remain differences. For example, you can use something immutable 
like a tuple as a key in python. 
 
This is not an argument about which language is better. Each has developed to 
fill ideas and has been extended and quite a few things can now be done in 
either one. Still, it can be interesting to combine the two inside RSTUDIO so 
each does some of what it may do better or faster or in a way you find more 
natural.
 
 
From: Richard O'Keefe  
Sent: Wednesday, June 14, 2023 10:34 PM
To: avi.e.gr...@gmail.com
Cc: Bert Gunter ; R-help@r-project.org
Subject: Re: [R] Problem with filling dataframe's column
 
Consider
 
  m <- list(foo=c(1,2),"B'ar"=as.matrix(1:4,2,2),"!*#"=c(FALSE,TRUE))
 
It is a collection of elements of different types/structures, accessible
via string keys (and also by position).  Entries can be added:
 
  m[["fred"]] <- 47
 
Entries can be removed:
 
  m[["!*#"]] <- NULL
 
How much more like a Python dictionary do you need it to be?
 
 
 
On Wed, 14 Jun 2023 at 11:25, mailto:avi.e.gr...@gmail.com> > wrote:
Bert,

I stand corrected. What I said may have once been true but apparently the 
implementation seems to have changed at some level.

I did not factor that in.

Nevertheless, whether you use an index as a key or as an offset into an 
attached vector of labels, it seems to work the same and I think my comment 
applies well enough that changing a few labels instead of scanning lots of 
entries can sometimes be a good think. As far as I can tell, external interface 
seem the same for now. 

One issue with R for a long time was how they did not do something more like a 
Python dictionary and it looks like …

ABOVE

From: Bert Gunter mailto:bgunter.4...@gmail.com> > 
Sent: Tuesday, June 13, 2023 6:15 PM
To: avi.e.gr...@gmail.com <mailto:avi.e.gr...@gmail.com> 
Cc: javad bayat mailto:j.bayat...@gmail.com> >; 
R-help@r-project.org <mailto:R-help@r-project.org> 
Subject: Re: [R] Problem with filling dataframe's column

Below.


On Tue, Jun 13, 2023 at 2:18 PM mailto:avi.e.gr...@gmail.com>  <mailto:avi.e.gr...@gmail.com 
<mailto:avi.e.gr...@gmail.com> > > wrote:
>
>  
> Javad,
>
> There may be nothing wrong with the methods people are showing you and if it 
> satisfied you, great.
>
> But I note you have lots of data in over a quarter million rows. If much of 
> the text data is redundant, and you want to simplify some operations such as 
> changing some of the values to others I multiple ways, have you done any 
> learning about an R feature very useful for dealing with categorical data 
> called "factors"?
>
> If you have a vector or a column in a data.frame that contains text, then it 
> can be replaced by a factor that often takes way less space as it stores a 
> sort of dictionary of all the unique values and just records numbers like 
> 1,2,3 to tell which one each item is.

-- This is false. It used to be true a **long time ago**, but R has for quite a 
while used hashing/global string tables to avoid this problem. See here 
<https://stackoverflow.com/questions/50310092/why-does-r-use-factors-to-store-characters>
  for details/references.
As a result, I think many would argue that working with strings *as strings,* 
not factors, if often a better default, though of course there are still 
situations where factors are useful (e.g. in ordering results by factor levels 
where the desired level order is not alphabetical).

**I would appreciate correction/ clarification if my claims are wrong or 
misleading! **

In any case, please d

Re: [R] Problem with filling dataframe's column

2023-06-14 Thread Richard O'Keefe
Consider

  m <- list(foo=c(1,2),"B'ar"=as.matrix(1:4,2,2),"!*#"=c(FALSE,TRUE))

It is a collection of elements of different types/structures, accessible
via string keys (and also by position).  Entries can be added:

  m[["fred"]] <- 47

Entries can be removed:

  m[["!*#"]] <- NULL

How much more like a Python dictionary do you need it to be?



On Wed, 14 Jun 2023 at 11:25,  wrote:

> Bert,
>
> I stand corrected. What I said may have once been true but apparently the
> implementation seems to have changed at some level.
>
> I did not factor that in.
>
> Nevertheless, whether you use an index as a key or as an offset into an
> attached vector of labels, it seems to work the same and I think my comment
> applies well enough that changing a few labels instead of scanning lots of
> entries can sometimes be a good think. As far as I can tell, external
> interface seem the same for now.
>
> One issue with R for a long time was how they did not do something more
> like a Python dictionary and it looks like …
>
> ABOVE
>
> From: Bert Gunter 
> Sent: Tuesday, June 13, 2023 6:15 PM
> To: avi.e.gr...@gmail.com
> Cc: javad bayat ; R-help@r-project.org
> Subject: Re: [R] Problem with filling dataframe's column
>
> Below.
>
>
> On Tue, Jun 13, 2023 at 2:18 PM  avi.e.gr...@gmail.com> > wrote:
> >
> >
> > Javad,
> >
> > There may be nothing wrong with the methods people are showing you and
> if it satisfied you, great.
> >
> > But I note you have lots of data in over a quarter million rows. If much
> of the text data is redundant, and you want to simplify some operations
> such as changing some of the values to others I multiple ways, have you
> done any learning about an R feature very useful for dealing with
> categorical data called "factors"?
> >
> > If you have a vector or a column in a data.frame that contains text,
> then it can be replaced by a factor that often takes way less space as it
> stores a sort of dictionary of all the unique values and just records
> numbers like 1,2,3 to tell which one each item is.
>
> -- This is false. It used to be true a **long time ago**, but R has for
> quite a while used hashing/global string tables to avoid this problem. See
> here <
> https://stackoverflow.com/questions/50310092/why-does-r-use-factors-to-store-characters>
> for details/references.
> As a result, I think many would argue that working with strings *as
> strings,* not factors, if often a better default, though of course there
> are still situations where factors are useful (e.g. in ordering results by
> factor levels where the desired level order is not alphabetical).
>
> **I would appreciate correction/ clarification if my claims are wrong or
> misleading! **
>
> In any case, please do check such claims before making them on this list.
>
> Cheers,
> Bert
>
>
>
> [[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] Problem with filling dataframe's column

2023-06-13 Thread avi.e.gross
Bert,
 
I stand corrected. What I said may have once been true but apparently the 
implementation seems to have changed at some level.
 
I did not factor that in.
 
Nevertheless, whether you use an index as a key or as an offset into an 
attached vector of labels, it seems to work the same and I think my comment 
applies well enough that changing a few labels instead of scanning lots of 
entries can sometimes be a good think. As far as I can tell, external interface 
seem the same for now. 
 
One issue with R for a long time was how they did not do something more like a 
Python dictionary and it looks like …
 
ABOVE
 
From: Bert Gunter  
Sent: Tuesday, June 13, 2023 6:15 PM
To: avi.e.gr...@gmail.com
Cc: javad bayat ; R-help@r-project.org
Subject: Re: [R] Problem with filling dataframe's column
 
Below.


On Tue, Jun 13, 2023 at 2:18 PM mailto:avi.e.gr...@gmail.com> > wrote:
>
>  
> Javad,
>
> There may be nothing wrong with the methods people are showing you and if it 
> satisfied you, great.
>
> But I note you have lots of data in over a quarter million rows. If much of 
> the text data is redundant, and you want to simplify some operations such as 
> changing some of the values to others I multiple ways, have you done any 
> learning about an R feature very useful for dealing with categorical data 
> called "factors"?
>
> If you have a vector or a column in a data.frame that contains text, then it 
> can be replaced by a factor that often takes way less space as it stores a 
> sort of dictionary of all the unique values and just records numbers like 
> 1,2,3 to tell which one each item is.
 
-- This is false. It used to be true a **long time ago**, but R has for quite a 
while used hashing/global string tables to avoid this problem. See here 
<https://stackoverflow.com/questions/50310092/why-does-r-use-factors-to-store-characters>
  for details/references.
As a result, I think many would argue that working with strings *as strings,* 
not factors, if often a better default, though of course there are still 
situations where factors are useful (e.g. in ordering results by factor levels 
where the desired level order is not alphabetical).
 
**I would appreciate correction/ clarification if my claims are wrong or 
misleading! **
 
In any case, please do check such claims before making them on this list.
 
Cheers,
Bert
 
 

[[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 filling dataframe's column

2023-06-13 Thread Bert Gunter
Below.


On Tue, Jun 13, 2023 at 2:18 PM  wrote:
>
>
> Javad,
>
> There may be nothing wrong with the methods people are showing you and if
it satisfied you, great.
>
> But I note you have lots of data in over a quarter million rows. If much
of the text data is redundant, and you want to simplify some operations
such as changing some of the values to others I multiple ways, have you
done any learning about an R feature very useful for dealing with
categorical data called "factors"?
>
> If you have a vector or a column in a data.frame that contains text, then
it can be replaced by a factor that often takes way less space as it stores
a sort of dictionary of all the unique values and just records numbers like
1,2,3 to tell which one each item is.

-- This is false. It used to be true a **long time ago**, but R has for
quite a while used hashing/global string tables to avoid this problem. See
here
<https://stackoverflow.com/questions/50310092/why-does-r-use-factors-to-store-characters>
for details/references.
As a result, I think many would argue that working with strings *as
strings,* not factors, if often a better default, though of course there
are still situations where factors are useful (e.g. in ordering results by
factor levels where the desired level order is not alphabetical).

**I would appreciate correction/ clarification if my claims are wrong or
misleading! **

In any case, please do check such claims before making them on this list.

Cheers,
Bert


>
> You can access the values using levels(whatever) and also change them.
There are packages that make this straightforward such as forcats which is
one of the tidyverse packages that also includes many other tools some find
useful but are beyond the usual scope of this mailing list.
>
> As an example, if you have a vector in mydata$col1 then code like:
>
> mydata$col1 <- factor(mydata$col1)
>
> No matter which way you do it, you can now access the levels and make
whatever changes, and save the changes. One example could be to apply some
variant of grep to make the substitution. There is a family of functions
build in such as sub() that matches a Regular Expression and replaces it
with what you want.
>
> This has a similar result to changing all entries without doing all the
work. I mean if item 5 used to be "OLD" and is now "NEW" then any of you
quarter million entries that have a 5 will now be seen as having a value of
"NEW".
>
> I will stop here and suggest you may want to read some book that explains
R as a unified set of features with some emphasis on using it for the
features it is intended to have that can make life easier, rather than
using just features it shares with most languages. Some of your questions
indicate you have less grounding and are mainly following recipes you
stumble across.
>
> Otherwise, you will have a collection of what you call "codes" and others
like me call programming and that don't necessarily fit well together.
>
>
> -Original Message-
> From: R-help r-help-boun...@r-project.org   On Behalf Of javad bayat
> Sent: Tuesday, June 13, 2023 3:47 PM
> To: Eric Berger ericjber...@gmail.com <mailto:ericjber...@gmail.com>
> Cc: R-help@r-project.org <mailto:R-help@r-project.org>
> Subject: Re: [R] Problem with filling dataframe's column
>
> Dear all;
> I used these codes and I get what I wanted.
> Sincerely
>
> pat = c("Level 12","Level 22","0")
> data3 = data2[-which(data2$Layer == pat),]
> dim(data2)
> [1] 281549  9
> dim(data3)
> [1] 244075  9
>
> On Tue, Jun 13, 2023 at 11:36 AM Eric Berger <  ericjber...@gmail.com> wrote:
>
> > Hi Javed,
> > grep returns the positions of the matches. See an example below.
> >
> > > v <- c("abc", "bcd", "def")
> > > v
> > [1] "abc" "bcd" "def"
> > > grep("cd",v)
> > [1] 2
> > > w <- v[-grep("cd",v)]
> > > w
> > [1] "abc" "def"
> > >
> >
> >
> > On Tue, Jun 13, 2023 at 8:50 AM javad bayat <  j.bayat...@gmail.com> wrote:
> > >
> > > Dear Rui;
> > > Hi. I used your codes, but it seems it didn't work for me.
> > >
> > > > pat <- c("_esmdes|_Des Section|0")
> > > > dim(data2)
> > > [1]  281549  9
> > > > grep(pat, data2$Layer)
> > > > dim(data2)
> > > [1]  281549  9
> > >
> > > What does grep function do? I expected the function to remove 3 rows
of
> > the
> > > dataframe.
> > > I do not know the reason.
> > >
> > >
> > >

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread avi.e.gross
 
Javad,
 
There may be nothing wrong with the methods people are showing you and if it 
satisfied you, great.
 
But I note you have lots of data in over a quarter million rows. If much of the 
text data is redundant, and you want to simplify some operations such as 
changing some of the values to others I multiple ways, have you done any 
learning about an R feature very useful for dealing with categorical data 
called "factors"?
 
If you have a vector or a column in a data.frame that contains text, then it 
can be replaced by a factor that often takes way less space as it stores a sort 
of dictionary of all the unique values and just records numbers like 1,2,3 to 
tell which one each item is. 
 
You can access the values using levels(whatever) and also change them. There 
are packages that make this straightforward such as forcats which is one of the 
tidyverse packages that also includes many other tools some find useful but are 
beyond the usual scope of this mailing list.
 
As an example, if you have a vector in mydata$col1 then code like:
 
mydata$col1 <- factor(mydata$col1)
 
No matter which way you do it, you can now access the levels and make whatever 
changes, and save the changes. One example could be to apply some variant of 
grep to make the substitution. There is a family of functions build in such as 
sub() that matches a Regular Expression and replaces it with what you want.
 
This has a similar result to changing all entries without doing all the work. I 
mean if item 5 used to be "OLD" and is now "NEW" then any of you quarter 
million entries that have a 5 will now be seen as having a value of "NEW".
 
I will stop here and suggest you may want to read some book that explains R as 
a unified set of features with some emphasis on using it for the features it is 
intended to have that can make life easier, rather than using just features it 
shares with most languages. Some of your questions indicate you have less 
grounding and are mainly following recipes you stumble across. 
 
Otherwise, you will have a collection of what you call "codes" and others like 
me call programming and that don't necessarily fit well together.
 
 
-Original Message-
From: R-help r-help-boun...@r-project.org <mailto:r-help-boun...@r-project.org> 
 On Behalf Of javad bayat
Sent: Tuesday, June 13, 2023 3:47 PM
To: Eric Berger ericjber...@gmail.com <mailto:ericjber...@gmail.com> 
Cc: R-help@r-project.org <mailto:R-help@r-project.org> 
Subject: Re: [R] Problem with filling dataframe's column
 
Dear all;
I used these codes and I get what I wanted.
Sincerely
 
pat = c("Level 12","Level 22","0")
data3 = data2[-which(data2$Layer == pat),]
dim(data2)
[1] 281549  9
dim(data3)
[1] 244075  9
 
On Tue, Jun 13, 2023 at 11:36 AM Eric Berger < <mailto:ericjber...@gmail.com> 
ericjber...@gmail.com> wrote:
 
> Hi Javed,
> grep returns the positions of the matches. See an example below.
> 
> > v <- c("abc", "bcd", "def")
> > v
> [1] "abc" "bcd" "def"
> > grep("cd",v)
> [1] 2
> > w <- v[-grep("cd",v)]
> > w
> [1] "abc" "def"
> >
> 
> 
> On Tue, Jun 13, 2023 at 8:50 AM javad bayat < <mailto:j.bayat...@gmail.com> 
> j.bayat...@gmail.com> wrote:
> >
> > Dear Rui;
> > Hi. I used your codes, but it seems it didn't work for me.
> >
> > > pat <- c("_esmdes|_Des Section|0")
> > > dim(data2)
> > [1]  281549  9
> > > grep(pat, data2$Layer)
> > > dim(data2)
> > [1]  281549  9
> >
> > What does grep function do? I expected the function to remove 3 rows of
> the
> > dataframe.
> > I do not know the reason.
> >
> >
> >
> >
> >
> >
> > On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas < 
> > <mailto:ruipbarra...@sapo.pt> ruipbarra...@sapo.pt>
> wrote:
> >
> > > Às 23:13 de 12/06/2023, javad bayat escreveu:
> > > > Dear Rui;
> > > > Many thanks for the email. I tried your codes and found that the
> length
> > > of
> > > > the "Values" and "Names" vectors must be equal, otherwise the results
> > > will
> > > > not be useful.
> > > > For some of the characters in the Layer column that I do not need to
> be
> > > > filled in the LU column, I used "NA".
> > > > But I need to delete some of the rows from the table as they are
> useless
> > > > for me. I tried this code to delete entire rows of the dataframe
> which
> > > > contained these three value in the Layer co

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread Bill Dunlap
It is safer to use !grepl(...) instead of -grep(...) here.  If there are no
matches, the latter will give you a zero-row data.frame while the former
gives you the entire data.frame.

E.g.,

> d <- data.frame(a=c("one","two","three"), b=c(10,20,30))
> d[-grep("Q", d$a),]
[1] a b
<0 rows> (or 0-length row.names)
> d[!grepl("Q", d$a),]
  a  b
1   one 10
2   two 20
3 three 30

-Bill

On Tue, Jun 13, 2023 at 6:19 AM Rui Barradas  wrote:

> Às 17:18 de 13/06/2023, javad bayat escreveu:
> > Dear Rui;
> > Hi. I used your codes, but it seems it didn't work for me.
> >
> >> pat <- c("_esmdes|_Des Section|0")
> >> dim(data2)
> >  [1]  281549  9
> >> grep(pat, data2$Layer)
> >> dim(data2)
> >  [1]  281549  9
> >
> > What does grep function do? I expected the function to remove 3 rows of
> the
> > dataframe.
> > I do not know the reason.
> >
> >
> >
> >
> >
> >
> > On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas 
> wrote:
> >
> >> Às 23:13 de 12/06/2023, javad bayat escreveu:
> >>> Dear Rui;
> >>> Many thanks for the email. I tried your codes and found that the length
> >> of
> >>> the "Values" and "Names" vectors must be equal, otherwise the results
> >> will
> >>> not be useful.
> >>> For some of the characters in the Layer column that I do not need to be
> >>> filled in the LU column, I used "NA".
> >>> But I need to delete some of the rows from the table as they are
> useless
> >>> for me. I tried this code to delete entire rows of the dataframe which
> >>> contained these three value in the Layer column: It gave me the
> following
> >>> error.
> >>>
>  data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]
> >>>Warning message:
> >>> In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> >>> argument 'pattern' has length > 1 and only the first element
> will
> >> be
> >>> used
> >>>
>  data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]
> >>>   Warning message:
> >>>   In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> >>>   argument 'pattern' has length > 1 and only the first element
> will be
> >>> used
> >>>
> >>> How can I do this?
> >>> Sincerely
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas 
> >> wrote:
> >>>
>  Às 13:18 de 11/06/2023, Rui Barradas escreveu:
> > Às 22:54 de 11/06/2023, javad bayat escreveu:
> >> Dear Rui;
> >> Many thanks for your email. I used one of your codes,
> >> "data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
> >> correctly for me.
> >> Actually I need to expand the codes so as to consider all "Levels"
> in
>  the
> >> "Layer" column. There are more than hundred levels in the Layer
> >> column.
> >> If I use your provided code, I have to write it hundred of time as
>  below:
> >> data2$LU[which(data2$Layer == "Level 1")] <- "Park";
> >> data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
> >> ...
> >> ...
> >> ...
> >> .
> >> Is there any other way to expand the code in order to consider all
> of
>  the
> >> levels simultaneously? Like the below code:
> >> data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3",
> ...))]
>  <-
> >> c("Park", "Agri", "GS", ...)
> >>
> >>
> >> Sincerely
> >>
> >>
> >>
> >>
> >> On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas 
> >> wrote:
> >>
> >>> Às 21:05 de 11/06/2023, javad bayat escreveu:
>  Dear R users;
>  I am trying to fill a column based on a specific value in another
>  column
> >>> of
>  a dataframe, but it seems there is a problem with the codes!
>  The "Layer" and the "LU" are two different columns of the
> dataframe.
>  How can I fix this?
>  Sincerely
> 
> 
>  for (i in 1:nrow(data2$Layer)){
>    if (data2$Layer == "Level 12") {
>    data2$LU == "Park"
>    }
>    }
> 
> 
> 
> 
> >>> Hello,
> >>>
> >>> There are two bugs in your code,
> >>>
> >>> 1) the index i is not used in the loop
> >>> 2) the assignment operator is `<-`, not `==`
> >>>
> >>>
> >>> Here is the loop corrected.
> >>>
> >>> for (i in 1:nrow(data2$Layer)){
> >>>   if (data2$Layer[i] == "Level 12") {
> >>> data2$LU[i] <- "Park"
> >>>   }
> >>> }
> >>>
> >>>
> >>>
> >>> But R is a vectorized language, the following two ways are the
> >> idiomac
> >>> ways of doing what you want to do.
> >>>
> >>>
> >>>
> >>> i <- data2$Layer == "Level 12"
> >>> data2$LU[i] <- "Park"
> >>>
> >>> # equivalent one-liner
> >>> data2$LU[data2$Layer == "Level 12"] <- "Park"
> >>>
> >>>
> >>>
> >>> If there are NA's in 

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread Rui Barradas

Às 17:18 de 13/06/2023, javad bayat escreveu:

Dear Rui;
Hi. I used your codes, but it seems it didn't work for me.


pat <- c("_esmdes|_Des Section|0")
dim(data2)

 [1]  281549  9

grep(pat, data2$Layer)
dim(data2)

 [1]  281549  9

What does grep function do? I expected the function to remove 3 rows of the
dataframe.
I do not know the reason.






On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas  wrote:


Às 23:13 de 12/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for the email. I tried your codes and found that the length

of

the "Values" and "Names" vectors must be equal, otherwise the results

will

not be useful.
For some of the characters in the Layer column that I do not need to be
filled in the LU column, I used "NA".
But I need to delete some of the rows from the table as they are useless
for me. I tried this code to delete entire rows of the dataframe which
contained these three value in the Layer column: It gave me the following
error.


data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]

   Warning message:
In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
argument 'pattern' has length > 1 and only the first element will

be

used


data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]

  Warning message:
  In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
  argument 'pattern' has length > 1 and only the first element will be
used

How can I do this?
Sincerely










On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas 

wrote:



Às 13:18 de 11/06/2023, Rui Barradas escreveu:

Às 22:54 de 11/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for your email. I used one of your codes,
"data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
correctly for me.
Actually I need to expand the codes so as to consider all "Levels" in

the

"Layer" column. There are more than hundred levels in the Layer

column.

If I use your provided code, I have to write it hundred of time as

below:

data2$LU[which(data2$Layer == "Level 1")] <- "Park";
data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
...
...
...
.
Is there any other way to expand the code in order to consider all of

the

levels simultaneously? Like the below code:
data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))]

<-

c("Park", "Agri", "GS", ...)


Sincerely




On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas 
wrote:


Às 21:05 de 11/06/2023, javad bayat escreveu:

Dear R users;
I am trying to fill a column based on a specific value in another
column

of

a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
  if (data2$Layer == "Level 12") {
  data2$LU == "Park"
  }
  }





Hello,

There are two bugs in your code,

1) the index i is not used in the loop
2) the assignment operator is `<-`, not `==`


Here is the loop corrected.

for (i in 1:nrow(data2$Layer)){
  if (data2$Layer[i] == "Level 12") {
data2$LU[i] <- "Park"
  }
}



But R is a vectorized language, the following two ways are the

idiomac

ways of doing what you want to do.



i <- data2$Layer == "Level 12"
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[data2$Layer == "Level 12"] <- "Park"



If there are NA's in data2$Layer it's probably safer to use ?which()

in

the logical index, to have a numeric one.



i <- which(data2$Layer == "Level 12")
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[which(data2$Layer == "Level 12")] <- "Park"


Hope this helps,

Rui Barradas





Hello,

You don't need to repeat the same instruction 100+ times, there is a

way

of assigning all new LU values at the same time with match().
This assumes that you have the new values in a vector.


Sorry, this is not clear. I mean


This assumes that you have the new values in a vector, the vector Names
below. The vector of values to be matched is created from the data.


Rui Barradas




Values <- sort(unique(data2$Layer))
Names <- c("Park", "Agri", "GS")

i <- match(data2$Layer, Values)
data2$LU <- Names[i]


Hope this helps,

Rui Barradas

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






Hello,

Please cc the r-help list, R-Help is threaded and this can in the future
be helpful to others.

You can combine several patters like this:


pat <- c("_esmdes|_Des Section|0")
grep(pat, data2$Layer)

or, programatically,


pat <- paste(c("_esmdes","_Des Section","0"), collapse = "|")


Hope this helps,

Rui Barradas





Hello,

I only posted a corrected grep statement, the complete code should be


pat <- 

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread javad bayat
Dear all;
I used these codes and I get what I wanted.
Sincerely

pat = c("Level 12","Level 22","0")
data3 = data2[-which(data2$Layer == pat),]
dim(data2)
[1] 281549  9
dim(data3)
[1] 244075  9

On Tue, Jun 13, 2023 at 11:36 AM Eric Berger  wrote:

> Hi Javed,
> grep returns the positions of the matches. See an example below.
>
> > v <- c("abc", "bcd", "def")
> > v
> [1] "abc" "bcd" "def"
> > grep("cd",v)
> [1] 2
> > w <- v[-grep("cd",v)]
> > w
> [1] "abc" "def"
> >
>
>
> On Tue, Jun 13, 2023 at 8:50 AM javad bayat  wrote:
> >
> > Dear Rui;
> > Hi. I used your codes, but it seems it didn't work for me.
> >
> > > pat <- c("_esmdes|_Des Section|0")
> > > dim(data2)
> > [1]  281549  9
> > > grep(pat, data2$Layer)
> > > dim(data2)
> > [1]  281549  9
> >
> > What does grep function do? I expected the function to remove 3 rows of
> the
> > dataframe.
> > I do not know the reason.
> >
> >
> >
> >
> >
> >
> > On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas 
> wrote:
> >
> > > Às 23:13 de 12/06/2023, javad bayat escreveu:
> > > > Dear Rui;
> > > > Many thanks for the email. I tried your codes and found that the
> length
> > > of
> > > > the "Values" and "Names" vectors must be equal, otherwise the results
> > > will
> > > > not be useful.
> > > > For some of the characters in the Layer column that I do not need to
> be
> > > > filled in the LU column, I used "NA".
> > > > But I need to delete some of the rows from the table as they are
> useless
> > > > for me. I tried this code to delete entire rows of the dataframe
> which
> > > > contained these three value in the Layer column: It gave me the
> following
> > > > error.
> > > >
> > > >> data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]
> > > >   Warning message:
> > > >In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> > > >argument 'pattern' has length > 1 and only the first element
> will
> > > be
> > > > used
> > > >
> > > >> data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]
> > > >  Warning message:
> > > >  In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> > > >  argument 'pattern' has length > 1 and only the first element
> will be
> > > > used
> > > >
> > > > How can I do this?
> > > > Sincerely
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas 
> > > wrote:
> > > >
> > > >> Às 13:18 de 11/06/2023, Rui Barradas escreveu:
> > > >>> Às 22:54 de 11/06/2023, javad bayat escreveu:
> > >  Dear Rui;
> > >  Many thanks for your email. I used one of your codes,
> > >  "data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it
> works
> > >  correctly for me.
> > >  Actually I need to expand the codes so as to consider all
> "Levels" in
> > > >> the
> > >  "Layer" column. There are more than hundred levels in the Layer
> > > column.
> > >  If I use your provided code, I have to write it hundred of time as
> > > >> below:
> > >  data2$LU[which(data2$Layer == "Level 1")] <- "Park";
> > >  data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
> > >  ...
> > >  ...
> > >  ...
> > >  .
> > >  Is there any other way to expand the code in order to consider
> all of
> > > >> the
> > >  levels simultaneously? Like the below code:
> > >  data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3",
> ...))]
> > > >> <-
> > >  c("Park", "Agri", "GS", ...)
> > > 
> > > 
> > >  Sincerely
> > > 
> > > 
> > > 
> > > 
> > >  On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas <
> ruipbarra...@sapo.pt>
> > >  wrote:
> > > 
> > > > Às 21:05 de 11/06/2023, javad bayat escreveu:
> > > >> Dear R users;
> > > >> I am trying to fill a column based on a specific value in
> another
> > > >> column
> > > > of
> > > >> a dataframe, but it seems there is a problem with the codes!
> > > >> The "Layer" and the "LU" are two different columns of the
> dataframe.
> > > >> How can I fix this?
> > > >> Sincerely
> > > >>
> > > >>
> > > >> for (i in 1:nrow(data2$Layer)){
> > > >>  if (data2$Layer == "Level 12") {
> > > >>  data2$LU == "Park"
> > > >>  }
> > > >>  }
> > > >>
> > > >>
> > > >>
> > > >>
> > > > Hello,
> > > >
> > > > There are two bugs in your code,
> > > >
> > > > 1) the index i is not used in the loop
> > > > 2) the assignment operator is `<-`, not `==`
> > > >
> > > >
> > > > Here is the loop corrected.
> > > >
> > > > for (i in 1:nrow(data2$Layer)){
> > > >  if (data2$Layer[i] == "Level 12") {
> > > >data2$LU[i] <- "Park"
> > > >  }
> > > > }
> > > >
> > > >
> > > >
> > > > But R is a vectorized language, the following two ways are the
> > > idiomac
> > > > ways 

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread Eric Berger
Hi Javed,
grep returns the positions of the matches. See an example below.

> v <- c("abc", "bcd", "def")
> v
[1] "abc" "bcd" "def"
> grep("cd",v)
[1] 2
> w <- v[-grep("cd",v)]
> w
[1] "abc" "def"
>


On Tue, Jun 13, 2023 at 8:50 AM javad bayat  wrote:
>
> Dear Rui;
> Hi. I used your codes, but it seems it didn't work for me.
>
> > pat <- c("_esmdes|_Des Section|0")
> > dim(data2)
> [1]  281549  9
> > grep(pat, data2$Layer)
> > dim(data2)
> [1]  281549  9
>
> What does grep function do? I expected the function to remove 3 rows of the
> dataframe.
> I do not know the reason.
>
>
>
>
>
>
> On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas  wrote:
>
> > Às 23:13 de 12/06/2023, javad bayat escreveu:
> > > Dear Rui;
> > > Many thanks for the email. I tried your codes and found that the length
> > of
> > > the "Values" and "Names" vectors must be equal, otherwise the results
> > will
> > > not be useful.
> > > For some of the characters in the Layer column that I do not need to be
> > > filled in the LU column, I used "NA".
> > > But I need to delete some of the rows from the table as they are useless
> > > for me. I tried this code to delete entire rows of the dataframe which
> > > contained these three value in the Layer column: It gave me the following
> > > error.
> > >
> > >> data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]
> > >   Warning message:
> > >In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> > >argument 'pattern' has length > 1 and only the first element will
> > be
> > > used
> > >
> > >> data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]
> > >  Warning message:
> > >  In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> > >  argument 'pattern' has length > 1 and only the first element will be
> > > used
> > >
> > > How can I do this?
> > > Sincerely
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas 
> > wrote:
> > >
> > >> Às 13:18 de 11/06/2023, Rui Barradas escreveu:
> > >>> Às 22:54 de 11/06/2023, javad bayat escreveu:
> >  Dear Rui;
> >  Many thanks for your email. I used one of your codes,
> >  "data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
> >  correctly for me.
> >  Actually I need to expand the codes so as to consider all "Levels" in
> > >> the
> >  "Layer" column. There are more than hundred levels in the Layer
> > column.
> >  If I use your provided code, I have to write it hundred of time as
> > >> below:
> >  data2$LU[which(data2$Layer == "Level 1")] <- "Park";
> >  data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
> >  ...
> >  ...
> >  ...
> >  .
> >  Is there any other way to expand the code in order to consider all of
> > >> the
> >  levels simultaneously? Like the below code:
> >  data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))]
> > >> <-
> >  c("Park", "Agri", "GS", ...)
> > 
> > 
> >  Sincerely
> > 
> > 
> > 
> > 
> >  On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas 
> >  wrote:
> > 
> > > Às 21:05 de 11/06/2023, javad bayat escreveu:
> > >> Dear R users;
> > >> I am trying to fill a column based on a specific value in another
> > >> column
> > > of
> > >> a dataframe, but it seems there is a problem with the codes!
> > >> The "Layer" and the "LU" are two different columns of the dataframe.
> > >> How can I fix this?
> > >> Sincerely
> > >>
> > >>
> > >> for (i in 1:nrow(data2$Layer)){
> > >>  if (data2$Layer == "Level 12") {
> > >>  data2$LU == "Park"
> > >>  }
> > >>  }
> > >>
> > >>
> > >>
> > >>
> > > Hello,
> > >
> > > There are two bugs in your code,
> > >
> > > 1) the index i is not used in the loop
> > > 2) the assignment operator is `<-`, not `==`
> > >
> > >
> > > Here is the loop corrected.
> > >
> > > for (i in 1:nrow(data2$Layer)){
> > >  if (data2$Layer[i] == "Level 12") {
> > >data2$LU[i] <- "Park"
> > >  }
> > > }
> > >
> > >
> > >
> > > But R is a vectorized language, the following two ways are the
> > idiomac
> > > ways of doing what you want to do.
> > >
> > >
> > >
> > > i <- data2$Layer == "Level 12"
> > > data2$LU[i] <- "Park"
> > >
> > > # equivalent one-liner
> > > data2$LU[data2$Layer == "Level 12"] <- "Park"
> > >
> > >
> > >
> > > If there are NA's in data2$Layer it's probably safer to use ?which()
> > in
> > > the logical index, to have a numeric one.
> > >
> > >
> > >
> > > i <- which(data2$Layer == "Level 12")
> > > data2$LU[i] <- "Park"
> > >
> > > # equivalent one-liner
> > > data2$LU[which(data2$Layer == "Level 12")] <- "Park"

Re: [R] Problem with filling dataframe's column

2023-06-12 Thread javad bayat
Dear Rui;
Hi. I used your codes, but it seems it didn't work for me.

> pat <- c("_esmdes|_Des Section|0")
> dim(data2)
[1]  281549  9
> grep(pat, data2$Layer)
> dim(data2)
[1]  281549  9

What does grep function do? I expected the function to remove 3 rows of the
dataframe.
I do not know the reason.






On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas  wrote:

> Às 23:13 de 12/06/2023, javad bayat escreveu:
> > Dear Rui;
> > Many thanks for the email. I tried your codes and found that the length
> of
> > the "Values" and "Names" vectors must be equal, otherwise the results
> will
> > not be useful.
> > For some of the characters in the Layer column that I do not need to be
> > filled in the LU column, I used "NA".
> > But I need to delete some of the rows from the table as they are useless
> > for me. I tried this code to delete entire rows of the dataframe which
> > contained these three value in the Layer column: It gave me the following
> > error.
> >
> >> data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]
> >   Warning message:
> >In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> >argument 'pattern' has length > 1 and only the first element will
> be
> > used
> >
> >> data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]
> >  Warning message:
> >  In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
> >  argument 'pattern' has length > 1 and only the first element will be
> > used
> >
> > How can I do this?
> > Sincerely
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas 
> wrote:
> >
> >> Às 13:18 de 11/06/2023, Rui Barradas escreveu:
> >>> Às 22:54 de 11/06/2023, javad bayat escreveu:
>  Dear Rui;
>  Many thanks for your email. I used one of your codes,
>  "data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
>  correctly for me.
>  Actually I need to expand the codes so as to consider all "Levels" in
> >> the
>  "Layer" column. There are more than hundred levels in the Layer
> column.
>  If I use your provided code, I have to write it hundred of time as
> >> below:
>  data2$LU[which(data2$Layer == "Level 1")] <- "Park";
>  data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
>  ...
>  ...
>  ...
>  .
>  Is there any other way to expand the code in order to consider all of
> >> the
>  levels simultaneously? Like the below code:
>  data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))]
> >> <-
>  c("Park", "Agri", "GS", ...)
> 
> 
>  Sincerely
> 
> 
> 
> 
>  On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas 
>  wrote:
> 
> > Às 21:05 de 11/06/2023, javad bayat escreveu:
> >> Dear R users;
> >> I am trying to fill a column based on a specific value in another
> >> column
> > of
> >> a dataframe, but it seems there is a problem with the codes!
> >> The "Layer" and the "LU" are two different columns of the dataframe.
> >> How can I fix this?
> >> Sincerely
> >>
> >>
> >> for (i in 1:nrow(data2$Layer)){
> >>  if (data2$Layer == "Level 12") {
> >>  data2$LU == "Park"
> >>  }
> >>  }
> >>
> >>
> >>
> >>
> > Hello,
> >
> > There are two bugs in your code,
> >
> > 1) the index i is not used in the loop
> > 2) the assignment operator is `<-`, not `==`
> >
> >
> > Here is the loop corrected.
> >
> > for (i in 1:nrow(data2$Layer)){
> >  if (data2$Layer[i] == "Level 12") {
> >data2$LU[i] <- "Park"
> >  }
> > }
> >
> >
> >
> > But R is a vectorized language, the following two ways are the
> idiomac
> > ways of doing what you want to do.
> >
> >
> >
> > i <- data2$Layer == "Level 12"
> > data2$LU[i] <- "Park"
> >
> > # equivalent one-liner
> > data2$LU[data2$Layer == "Level 12"] <- "Park"
> >
> >
> >
> > If there are NA's in data2$Layer it's probably safer to use ?which()
> in
> > the logical index, to have a numeric one.
> >
> >
> >
> > i <- which(data2$Layer == "Level 12")
> > data2$LU[i] <- "Park"
> >
> > # equivalent one-liner
> > data2$LU[which(data2$Layer == "Level 12")] <- "Park"
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> 
> 
> >>> Hello,
> >>>
> >>> You don't need to repeat the same instruction 100+ times, there is a
> way
> >>> of assigning all new LU values at the same time with match().
> >>> This assumes that you have the new values in a vector.
> >>
> >> Sorry, this is not clear. I mean
> >>
> >>
> >> This assumes that you have the new values in a vector, the vector Names
> >> below. The vector of values to be matched is created from the data.
> >>
> >>
> >> Rui Barradas
> >>
> >>>
> 

Re: [R] Problem with filling dataframe's column

2023-06-12 Thread Rui Barradas

Às 23:13 de 12/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for the email. I tried your codes and found that the length of
the "Values" and "Names" vectors must be equal, otherwise the results will
not be useful.
For some of the characters in the Layer column that I do not need to be
filled in the LU column, I used "NA".
But I need to delete some of the rows from the table as they are useless
for me. I tried this code to delete entire rows of the dataframe which
contained these three value in the Layer column: It gave me the following
error.


data3 = data2[-grep(c("_esmdes","_Des Section","0"), data2$Layer),]

  Warning message:
   In grep(c("_esmdes", "_Des Section", "0"), data2$Layer) :
   argument 'pattern' has length > 1 and only the first element will be
used


data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),]

 Warning message:
 In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) :
 argument 'pattern' has length > 1 and only the first element will be
used

How can I do this?
Sincerely










On Sun, Jun 11, 2023 at 5:03 PM Rui Barradas  wrote:


Às 13:18 de 11/06/2023, Rui Barradas escreveu:

Às 22:54 de 11/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for your email. I used one of your codes,
"data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
correctly for me.
Actually I need to expand the codes so as to consider all "Levels" in

the

"Layer" column. There are more than hundred levels in the Layer column.
If I use your provided code, I have to write it hundred of time as

below:

data2$LU[which(data2$Layer == "Level 1")] <- "Park";
data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
...
...
...
.
Is there any other way to expand the code in order to consider all of

the

levels simultaneously? Like the below code:
data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))]

<-

c("Park", "Agri", "GS", ...)


Sincerely




On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas 
wrote:


Às 21:05 de 11/06/2023, javad bayat escreveu:

Dear R users;
I am trying to fill a column based on a specific value in another
column

of

a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
 if (data2$Layer == "Level 12") {
 data2$LU == "Park"
 }
 }





Hello,

There are two bugs in your code,

1) the index i is not used in the loop
2) the assignment operator is `<-`, not `==`


Here is the loop corrected.

for (i in 1:nrow(data2$Layer)){
 if (data2$Layer[i] == "Level 12") {
   data2$LU[i] <- "Park"
 }
}



But R is a vectorized language, the following two ways are the idiomac
ways of doing what you want to do.



i <- data2$Layer == "Level 12"
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[data2$Layer == "Level 12"] <- "Park"



If there are NA's in data2$Layer it's probably safer to use ?which() in
the logical index, to have a numeric one.



i <- which(data2$Layer == "Level 12")
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[which(data2$Layer == "Level 12")] <- "Park"


Hope this helps,

Rui Barradas





Hello,

You don't need to repeat the same instruction 100+ times, there is a way
of assigning all new LU values at the same time with match().
This assumes that you have the new values in a vector.


Sorry, this is not clear. I mean


This assumes that you have the new values in a vector, the vector Names
below. The vector of values to be matched is created from the data.


Rui Barradas




Values <- sort(unique(data2$Layer))
Names <- c("Park", "Agri", "GS")

i <- match(data2$Layer, Values)
data2$LU <- Names[i]


Hope this helps,

Rui Barradas

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






Hello,

Please cc the r-help list, R-Help is threaded and this can in the future 
be helpful to others.


You can combine several patters like this:


pat <- c("_esmdes|_Des Section|0")
grep(pat, data2$Layer)

or, programatically,


pat <- paste(c("_esmdes","_Des Section","0"), collapse = "|")


Hope this helps,

Rui Barradas

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


Re: [R] Problem with filling dataframe's column

2023-06-11 Thread avi.e.gross
The problem being discussed is really a common operation that R handles
quite easily in many ways.

The code shown has way too many things that do not fit to make much sense
and is not written the way many R programmers would write it.

Loops like the one used are legal but not needed. 

As has been noted, use of "==" for assignment is the wrong choice. Not using
some method to refer to a specific cell  would still result in odd behavior.


One accepted and common method s to do this vectorized as you are dealing
with two vectors of the same size.

Code like:

Matches <- Data2$Layer == "Level 12"

Will result in a Boolean vector containing TRUE where it found a match,
FALSE otherwise.

Now you can use the above as a sort of indexing as in:

data2$LU[Matches] <- "Park"

Only the indexes marked TRUE will be selected and set to the new value.

Of course, the two lines can be combined as:

data2$LU[Data2$Layer == "Level 12"] <- "Park"

There are also alternatives where people use functions like ifelse() also in
base R.

And, of course, some people like alternate packages such as in the Tidyverse
where you might have used a mutate() or other methods.

-Original Message-
From: R-help  On Behalf Of javad bayat
Sent: Sunday, June 11, 2023 4:05 PM
To: R-help@r-project.org
Subject: [R] Problem with filling dataframe's column

Dear R users;
I am trying to fill a column based on a specific value in another column of
a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
  if (data2$Layer == "Level 12") {
  data2$LU == "Park"
  }
  }




-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Alternative Mail: bayat...@yahoo.com

[[alternative HTML version deleted]]

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

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

2023-06-11 Thread Rui Barradas

Às 13:18 de 11/06/2023, Rui Barradas escreveu:

Às 22:54 de 11/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for your email. I used one of your codes,
"data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
correctly for me.
Actually I need to expand the codes so as to consider all "Levels" in the
"Layer" column. There are more than hundred levels in the Layer column.
If I use your provided code, I have to write it hundred of time as below:
data2$LU[which(data2$Layer == "Level 1")] <- "Park";
data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
...
...
...
.
Is there any other way to expand the code in order to consider all of the
levels simultaneously? Like the below code:
data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))] <-
c("Park", "Agri", "GS", ...)


Sincerely




On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas  
wrote:



Às 21:05 de 11/06/2023, javad bayat escreveu:

Dear R users;
I am trying to fill a column based on a specific value in another 
column

of

a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
    if (data2$Layer == "Level 12") {
    data2$LU == "Park"
    }
    }





Hello,

There are two bugs in your code,

1) the index i is not used in the loop
2) the assignment operator is `<-`, not `==`


Here is the loop corrected.

for (i in 1:nrow(data2$Layer)){
    if (data2$Layer[i] == "Level 12") {
  data2$LU[i] <- "Park"
    }
}



But R is a vectorized language, the following two ways are the idiomac
ways of doing what you want to do.



i <- data2$Layer == "Level 12"
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[data2$Layer == "Level 12"] <- "Park"



If there are NA's in data2$Layer it's probably safer to use ?which() in
the logical index, to have a numeric one.



i <- which(data2$Layer == "Level 12")
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[which(data2$Layer == "Level 12")] <- "Park"


Hope this helps,

Rui Barradas





Hello,

You don't need to repeat the same instruction 100+ times, there is a way 
of assigning all new LU values at the same time with match().

This assumes that you have the new values in a vector.


Sorry, this is not clear. I mean


This assumes that you have the new values in a vector, the vector Names 
below. The vector of values to be matched is created from the data.



Rui Barradas




Values <- sort(unique(data2$Layer))
Names <- c("Park", "Agri", "GS")

i <- match(data2$Layer, Values)
data2$LU <- Names[i]


Hope this helps,

Rui Barradas

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

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


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

2023-06-11 Thread Rui Barradas

Às 22:54 de 11/06/2023, javad bayat escreveu:

Dear Rui;
Many thanks for your email. I used one of your codes,
"data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
correctly for me.
Actually I need to expand the codes so as to consider all "Levels" in the
"Layer" column. There are more than hundred levels in the Layer column.
If I use your provided code, I have to write it hundred of time as below:
data2$LU[which(data2$Layer == "Level 1")] <- "Park";
data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
...
...
...
.
Is there any other way to expand the code in order to consider all of the
levels simultaneously? Like the below code:
data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))] <-
c("Park", "Agri", "GS", ...)


Sincerely




On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas  wrote:


Às 21:05 de 11/06/2023, javad bayat escreveu:

Dear R users;
I am trying to fill a column based on a specific value in another column

of

a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
if (data2$Layer == "Level 12") {
data2$LU == "Park"
}
}





Hello,

There are two bugs in your code,

1) the index i is not used in the loop
2) the assignment operator is `<-`, not `==`


Here is the loop corrected.

for (i in 1:nrow(data2$Layer)){
if (data2$Layer[i] == "Level 12") {
  data2$LU[i] <- "Park"
}
}



But R is a vectorized language, the following two ways are the idiomac
ways of doing what you want to do.



i <- data2$Layer == "Level 12"
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[data2$Layer == "Level 12"] <- "Park"



If there are NA's in data2$Layer it's probably safer to use ?which() in
the logical index, to have a numeric one.



i <- which(data2$Layer == "Level 12")
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[which(data2$Layer == "Level 12")] <- "Park"


Hope this helps,

Rui Barradas





Hello,

You don't need to repeat the same instruction 100+ times, there is a way 
of assigning all new LU values at the same time with match().

This assumes that you have the new values in a vector.


Values <- sort(unique(data2$Layer))
Names <- c("Park", "Agri", "GS")

i <- match(data2$Layer, Values)
data2$LU <- Names[i]


Hope this helps,

Rui Barradas

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


Re: [R] Problem with filling dataframe's column

2023-06-11 Thread javad bayat
Dear Rui;
Many thanks for your email. I used one of your codes,
"data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works
correctly for me.
Actually I need to expand the codes so as to consider all "Levels" in the
"Layer" column. There are more than hundred levels in the Layer column.
If I use your provided code, I have to write it hundred of time as below:
data2$LU[which(data2$Layer == "Level 1")] <- "Park";
data2$LU[which(data2$Layer == "Level 2")] <- "Agri";
...
...
...
.
Is there any other way to expand the code in order to consider all of the
levels simultaneously? Like the below code:
data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))] <-
c("Park", "Agri", "GS", ...)


Sincerely




On Sun, Jun 11, 2023 at 1:43 PM Rui Barradas  wrote:

> Às 21:05 de 11/06/2023, javad bayat escreveu:
> > Dear R users;
> > I am trying to fill a column based on a specific value in another column
> of
> > a dataframe, but it seems there is a problem with the codes!
> > The "Layer" and the "LU" are two different columns of the dataframe.
> > How can I fix this?
> > Sincerely
> >
> >
> > for (i in 1:nrow(data2$Layer)){
> >if (data2$Layer == "Level 12") {
> >data2$LU == "Park"
> >}
> >}
> >
> >
> >
> >
> Hello,
>
> There are two bugs in your code,
>
> 1) the index i is not used in the loop
> 2) the assignment operator is `<-`, not `==`
>
>
> Here is the loop corrected.
>
> for (i in 1:nrow(data2$Layer)){
>if (data2$Layer[i] == "Level 12") {
>  data2$LU[i] <- "Park"
>}
> }
>
>
>
> But R is a vectorized language, the following two ways are the idiomac
> ways of doing what you want to do.
>
>
>
> i <- data2$Layer == "Level 12"
> data2$LU[i] <- "Park"
>
> # equivalent one-liner
> data2$LU[data2$Layer == "Level 12"] <- "Park"
>
>
>
> If there are NA's in data2$Layer it's probably safer to use ?which() in
> the logical index, to have a numeric one.
>
>
>
> i <- which(data2$Layer == "Level 12")
> data2$LU[i] <- "Park"
>
> # equivalent one-liner
> data2$LU[which(data2$Layer == "Level 12")] <- "Park"
>
>
> Hope this helps,
>
> Rui Barradas
>


-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Alternative Mail: bayat...@yahoo.com

[[alternative HTML version deleted]]

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


Re: [R] Problem with filling dataframe's column

2023-06-11 Thread Rui Barradas

Às 21:05 de 11/06/2023, javad bayat escreveu:

Dear R users;
I am trying to fill a column based on a specific value in another column of
a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
   if (data2$Layer == "Level 12") {
   data2$LU == "Park"
   }
   }





Hello,

There are two bugs in your code,

1) the index i is not used in the loop
2) the assignment operator is `<-`, not `==`


Here is the loop corrected.

for (i in 1:nrow(data2$Layer)){
  if (data2$Layer[i] == "Level 12") {
data2$LU[i] <- "Park"
  }
}



But R is a vectorized language, the following two ways are the idiomac 
ways of doing what you want to do.




i <- data2$Layer == "Level 12"
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[data2$Layer == "Level 12"] <- "Park"



If there are NA's in data2$Layer it's probably safer to use ?which() in 
the logical index, to have a numeric one.




i <- which(data2$Layer == "Level 12")
data2$LU[i] <- "Park"

# equivalent one-liner
data2$LU[which(data2$Layer == "Level 12")] <- "Park"


Hope this helps,

Rui Barradas

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


[R] Problem with filling dataframe's column

2023-06-11 Thread javad bayat
Dear R users;
I am trying to fill a column based on a specific value in another column of
a dataframe, but it seems there is a problem with the codes!
The "Layer" and the "LU" are two different columns of the dataframe.
How can I fix this?
Sincerely


for (i in 1:nrow(data2$Layer)){
  if (data2$Layer == "Level 12") {
  data2$LU == "Park"
  }
  }




-- 
Best Regards
Javad Bayat
M.Sc. Environment Engineering
Alternative Mail: bayat...@yahoo.com

[[alternative HTML version deleted]]

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


[R] problem in arfima in forecast...

2023-04-25 Thread akshay kulkarni
Dear members,
 I am using the forecast package for arfima 
modelling. THe following is the code:

> arfima(ygrpch(OHLCDataEP[[1]]))

Call:
  arfima(y = ygrpch(OHLCDataEP[[1]]))

*** Warning during (fdcov) fit: unable to compute correlation matrix; maybe 
change 'h'

Coefficients:
dma.ma1
0.1745253 0.1600765
sigma[eps] = 34.4493
a list with components:
 [1] "log.likelihood"  "n"   "msg" "d"   
"ar"
 [6] "ma"  "covariance.dpq"  "fnormMin""sigma"   
"stderror.dpq"
[11] "correlation.dpq" "h"   "d.tol"   "M"   
"hessian.dpq"
[16] "length.w""residuals"   "fitted"  "call""x"
[21] "series"

What does the warning say? Is it Ok to proceed with it if the correlation 
matrix can't be caclulated? I just want the prediction, and forecast() is 
working fine:

> forecast(arfima(ygrpch(OHLCDataEP[[1]])), h = 1)
Point Forecast Lo 80Hi 80 Lo 95Hi 95
188   26.01569 -17.96402 69.99539 -41.24547 93.27684

I just want the point forecast. Is there any problem with arfima() as I am 
using it?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[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 installing RUcausal library

2023-04-23 Thread Jeff Newmiller
Perhaps read the Posting Guide, note that there is a special mailing list for 
MacOSX-specific questions, and post there instead?

You don't appear to have installed gfortran. I am aware that there are specific 
instructions for getting that installed in MacOS that you need to find and 
follow [1].

[1] https://cran.r-project.org/bin/macosx/tools/

On April 23, 2023 4:41:59 AM GMT+09:00, varin sacha via R-help 
 wrote:
>Me again ! How to solve this?
>
>At the end of this page there is the installation command :
>https://gitlab.science.ru.nl/gbucur/RUcausal/-/blob/master/README.Rmd
>
>Working with a MAC, I have tried to install the RUcausal library (copy and 
>paste the installation command).
>
>It is written that the package has been built on Linux using the GNU Compiler 
>Collection. To install the package, open an R instance and run:
>install.packages('devtools') # required package
>devtools::install_git('https://gitlab.science.ru.nl/gbucur/RUcausal')
>
>I get this error message :
>
>  ERROR: package installation failed
>Error: Failed to install 'RUcausal' from Git:
>  ! System command 'R' failed
>0d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’
>
>
>
>install.packages('devtools') # required package
>--- Please select a CRAN mirror for use in this session ---
>trying URL 
>'https://stat.ethz.ch/CRAN/bin/macosx/big-sur-arm64/contrib/4.2/devtools_2.4.5.tgz'
>Content type 'application/x-gzip' length 421790 bytes (411 KB)
>==
>downloaded 411 KB
>
>
>The downloaded binary packages are in
>
>/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T//Rtmp7SUtUd/downloaded_packages
>> devtools::install_git('https://gitlab.science.ru.nl/gbucur/RUcausal')
>Downloading git repo https://gitlab.science.ru.nl/gbucur/RUcausal
>'/usr/bin/git' clone --depth 1 --no-hardlinks 
>https://gitlab.science.ru.nl/gbucur/RUcausal 
>/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T//Rtmp7SUtUd/file61a2a8e336a
>── R CMD build 
>──
>─ installing the package to process help pages
>  ---ges
>─ installing *source* package ‘RUcausal’ ...
>  ** using staged installation
>  ** libs
>  clang++ -arch arm64 -std=gnu++14 
>-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
>-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include'
> 
>-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include'
> -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -Wall 
>-pedantic -c RcppExports.cpp -o RcppExports.o
>  clang++ -arch arm64 -std=gnu++14 
>-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
>-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include'
> 
>-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include'
> -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -Wall 
>-pedantic -c compute_DAG_probabilities_BGe_fast.cpp -o 
>compute_DAG_probabilities_BGe_fast.o
>  clang++ -arch arm64 -std=gnu++14 -dynamiclib 
>-Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module 
>-multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib 
>-L/opt/R/arm64/lib -o RUcausal.so RcppExports.o 
>compute_DAG_probabilities_BGe_fast.o 
>-L/Library/Frameworks/R.framework/Resources/lib -lRlapack 
>-L/Library/Frameworks/R.framework/Resources/lib -lRblas 
>-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 
>-L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath 
>-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
>-Wl,CoreFoundation
>  ld: warning: directory not found for option 
>'-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
>  ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
>  ld: library not found for -lgfortran
>  clang: error: linker command failed with exit code 1 (use -v to see 
>invocation)
>  make: *** [RUcausal.so] Error 1
>  ERROR: compilation failed for package ‘RUcausal’
>─ removing 
>‘/private/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’
>  ---
>  ERROR: package installation failed
>Error: Failed to install 'RUcausal' from Git:
>  ! System command 'R' failed
>0d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/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.

__

Re: [R] problem installing RUcausal library

2023-04-23 Thread Ivan Krylov
В Sat, 22 Apr 2023 19:41:59 + (UTC)
varin sacha via R-help  пишет:

> Working with a MAC, I have tried to install the RUcausal library
> (copy and paste the installation command).

For Mac-related problems, try r-sig-...@r-project.org.

> ld: warning: directory not found for option
> '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
> ld: warning: directory not found for option
> '-L/opt/R/arm64/gfortran/lib'
> ld: library not found for -lgfortran

It may be that you need a working Fortran compiler too (see
 on how to obtain it). I could be
mistaken about it, though.

-- 
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] problem installing RUcausal library

2023-04-22 Thread varin sacha via R-help
Me again ! How to solve this?

At the end of this page there is the installation command :
https://gitlab.science.ru.nl/gbucur/RUcausal/-/blob/master/README.Rmd

Working with a MAC, I have tried to install the RUcausal library (copy and 
paste the installation command).

It is written that the package has been built on Linux using the GNU Compiler 
Collection. To install the package, open an R instance and run:
install.packages('devtools') # required package
devtools::install_git('https://gitlab.science.ru.nl/gbucur/RUcausal')

I get this error message :

  ERROR: package installation failed
Error: Failed to install 'RUcausal' from Git:
  ! System command 'R' failed
0d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’



install.packages('devtools') # required package
--- Please select a CRAN mirror for use in this session ---
trying URL 
'https://stat.ethz.ch/CRAN/bin/macosx/big-sur-arm64/contrib/4.2/devtools_2.4.5.tgz'
Content type 'application/x-gzip' length 421790 bytes (411 KB)
==
downloaded 411 KB


The downloaded binary packages are in

/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T//Rtmp7SUtUd/downloaded_packages
> devtools::install_git('https://gitlab.science.ru.nl/gbucur/RUcausal')
Downloading git repo https://gitlab.science.ru.nl/gbucur/RUcausal
'/usr/bin/git' clone --depth 1 --no-hardlinks 
https://gitlab.science.ru.nl/gbucur/RUcausal 
/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T//Rtmp7SUtUd/file61a2a8e336a
── R CMD build 
──
─ installing the package to process help pages
  ---ges
─ installing *source* package ‘RUcausal’ ...
  ** using staged installation
  ** libs
  clang++ -arch arm64 -std=gnu++14 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include'
 
-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include'
 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -Wall -pedantic 
-c RcppExports.cpp -o RcppExports.o
  clang++ -arch arm64 -std=gnu++14 
-I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG 
-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include'
 
-I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include'
 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -Wall -pedantic 
-c compute_DAG_probabilities_BGe_fast.cpp -o 
compute_DAG_probabilities_BGe_fast.o
  clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names 
-undefined dynamic_lookup -single_module -multiply_defined suppress 
-L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o 
RUcausal.so RcppExports.o compute_DAG_probabilities_BGe_fast.o 
-L/Library/Frameworks/R.framework/Resources/lib -lRlapack 
-L/Library/Frameworks/R.framework/Resources/lib -lRblas 
-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 
-L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath 
-F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework 
-Wl,CoreFoundation
  ld: warning: directory not found for option 
'-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
  ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
  ld: library not found for -lgfortran
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
  make: *** [RUcausal.so] Error 1
  ERROR: compilation failed for package ‘RUcausal’
─ removing 
‘/private/var/folders/t_/myv0vvms11g40d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’
  ---
  ERROR: package installation failed
Error: Failed to install 'RUcausal' from Git:
  ! System command 'R' failed
0d0bz2p4xg64gn/T/RtmpMs1teQ/Rinst6453ee77bb8/RUcausal’

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

2023-04-22 Thread varin sacha via R-help
Bert,

Thanks ! It works !

Best,







Le samedi 22 avril 2023 à 19:42:18 UTC+2, Bert Gunter  
a écrit : 





Is lvida.R in your working directory?
Try using the full path name to the file instead in source()

-- Bert

On Sat, Apr 22, 2023 at 9:38 AM varin sacha via R-help
 wrote:
>
> The problem is that I am trying to run this R code :
> https://github.com/dmalinsk/lv-ida/blob/master/example.R
>
>
> So I run :
>
> library(pcalg)
> library(igraph)
> library(RBGL)
> source("lvida.R")
>
>
> Here is what I get :
>
> source("lvida.R")
> Error in file(filename, "r", encoding = encoding) :
>  cannot open the connection
> In addition: Warning message:
> In file(filename, "r", encoding = encoding) :
>  cannot open file 'lvida.R': No such file or directory
>
> So, I guess the problem is coming from the source not from the libraries? How 
> to solve that problem?
>
> Best,
>
>
>
>
>
>
> Le samedi 22 avril 2023 à 18:30:48 UTC+2, Eric Berger  
> a écrit :
>
>
>
>
>
> looks fine.
> what's the problem?
>
> On Sat, Apr 22, 2023 at 7:27 PM varin sacha  wrote:
> > Eric,
> >
> > Here it is :
> >
> >
> > library(RBGL)
> > Loading required package: graph
> > Loading required package: BiocGenerics
> >
> > Attaching package: ‘BiocGenerics’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >  normalize, path, union
> >
> > The following objects are masked from ‘package:stats’:
> >
> >  IQR, mad, sd, var, xtabs
> >
> > The following objects are masked from ‘package:base’:
> >
> >  anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, 
> >dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, 
> >intersect, is.unsorted, lapply, Map,
> >  mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, 
> >Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, 
> >tapply, union, unique, unsplit, which.max,
> >  which.min
> >
> >
> > Attaching package: ‘graph’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >  degree, edges, intersection
> >
> >
> > Attaching package: ‘RBGL’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >  bfs, dfs, transitivity
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Le samedi 22 avril 2023 à 18:12:56 UTC+2, Eric Berger 
> >  a écrit :
> >
> >
> >
> >
> >
> > What happens with the command
> >> library(RBGL)
> >
> >
> >
> > On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help 
> >  wrote:
> >> Dear R-experts,
> >>
> >> How to solve that problem?
> >>
> >> My R version is 4.2.1
> >>
> >> Here below trying to install RGBL library found here : 
> >> https://bioconductor.org/packages/release/bioc/html/RBGL.html
> >>
> >> So, I run this R code :
> >>
> >> if (!require("BiocManager", quietly = TRUE))
> >>    install.packages("BiocManager")
> >>
> >> BiocManager::install("RBGL")
> >>
> >>
> >> Here is what I get :
> >>
> >>> if (!require("BiocManager", quietly = TRUE))
> >> + install.packages("BiocManager")
> >> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >>>
> >>> BiocManager::install("RBGL")
> >> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >> Warning message:
> >> package(s) not installed when version(s) same as or greater than current; 
> >> use `force = TRUE` to re-install: 'RBGL'
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] problem installing RGBL library

2023-04-22 Thread Bert Gunter
Is lvida.R in your working directory?
Try using the full path name to the file instead in source()

-- Bert

On Sat, Apr 22, 2023 at 9:38 AM varin sacha via R-help
 wrote:
>
> The problem is that I am trying to run this R code :
> https://github.com/dmalinsk/lv-ida/blob/master/example.R
>
>
> So I run :
>
> library(pcalg)
> library(igraph)
> library(RBGL)
> source("lvida.R")
>
>
> Here is what I get :
>
> source("lvida.R")
> Error in file(filename, "r", encoding = encoding) :
>   cannot open the connection
> In addition: Warning message:
> In file(filename, "r", encoding = encoding) :
>   cannot open file 'lvida.R': No such file or directory
>
> So, I guess the problem is coming from the source not from the libraries? How 
> to solve that problem?
>
> Best,
>
>
>
>
>
>
> Le samedi 22 avril 2023 à 18:30:48 UTC+2, Eric Berger  
> a écrit :
>
>
>
>
>
> looks fine.
> what's the problem?
>
> On Sat, Apr 22, 2023 at 7:27 PM varin sacha  wrote:
> > Eric,
> >
> > Here it is :
> >
> >
> > library(RBGL)
> > Loading required package: graph
> > Loading required package: BiocGenerics
> >
> > Attaching package: ‘BiocGenerics’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >   normalize, path, union
> >
> > The following objects are masked from ‘package:stats’:
> >
> >   IQR, mad, sd, var, xtabs
> >
> > The following objects are masked from ‘package:base’:
> >
> >   anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, 
> > dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, 
> > intersect, is.unsorted, lapply, Map,
> >   mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, 
> > Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, 
> > tapply, union, unique, unsplit, which.max,
> >   which.min
> >
> >
> > Attaching package: ‘graph’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >   degree, edges, intersection
> >
> >
> > Attaching package: ‘RBGL’
> >
> > The following objects are masked from ‘package:igraph’:
> >
> >   bfs, dfs, transitivity
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Le samedi 22 avril 2023 à 18:12:56 UTC+2, Eric Berger 
> >  a écrit :
> >
> >
> >
> >
> >
> > What happens with the command
> >> library(RBGL)
> >
> >
> >
> > On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help 
> >  wrote:
> >> Dear R-experts,
> >>
> >> How to solve that problem?
> >>
> >> My R version is 4.2.1
> >>
> >> Here below trying to install RGBL library found here : 
> >> https://bioconductor.org/packages/release/bioc/html/RBGL.html
> >>
> >> So, I run this R code :
> >>
> >> if (!require("BiocManager", quietly = TRUE))
> >> install.packages("BiocManager")
> >>
> >> BiocManager::install("RBGL")
> >>
> >>
> >> Here is what I get :
> >>
> >>> if (!require("BiocManager", quietly = TRUE))
> >> + install.packages("BiocManager")
> >> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >>>
> >>> BiocManager::install("RBGL")
> >> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >> Warning message:
> >> package(s) not installed when version(s) same as or greater than current; 
> >> use `force = TRUE` to re-install: 'RBGL'
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] problem installing RGBL library

2023-04-22 Thread varin sacha via R-help
The problem is that I am trying to run this R code :
https://github.com/dmalinsk/lv-ida/blob/master/example.R

 
So I run :

library(pcalg)
library(igraph)
library(RBGL)
source("lvida.R")


Here is what I get :

source("lvida.R")
Error in file(filename, "r", encoding = encoding) :
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'lvida.R': No such file or directory

So, I guess the problem is coming from the source not from the libraries? How 
to solve that problem?

Best,






Le samedi 22 avril 2023 à 18:30:48 UTC+2, Eric Berger  a 
écrit : 





looks fine.
what's the problem?

On Sat, Apr 22, 2023 at 7:27 PM varin sacha  wrote:
> Eric,
> 
> Here it is :
> 
> 
> library(RBGL)
> Loading required package: graph
> Loading required package: BiocGenerics
> 
> Attaching package: ‘BiocGenerics’
> 
> The following objects are masked from ‘package:igraph’:
> 
>   normalize, path, union
> 
> The following objects are masked from ‘package:stats’:
> 
>   IQR, mad, sd, var, xtabs
> 
> The following objects are masked from ‘package:base’:
> 
>   anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, 
> dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, 
> intersect, is.unsorted, lapply, Map,
>   mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, 
> Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, 
> tapply, union, unique, unsplit, which.max,
>   which.min
> 
> 
> Attaching package: ‘graph’
> 
> The following objects are masked from ‘package:igraph’:
> 
>   degree, edges, intersection
> 
> 
> Attaching package: ‘RBGL’
> 
> The following objects are masked from ‘package:igraph’:
> 
>   bfs, dfs, transitivity
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Le samedi 22 avril 2023 à 18:12:56 UTC+2, Eric Berger  
> a écrit : 
> 
> 
> 
> 
> 
> What happens with the command
>> library(RBGL)
> 
> 
> 
> On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help  
> wrote:
>> Dear R-experts,
>> 
>> How to solve that problem?
>> 
>> My R version is 4.2.1
>> 
>> Here below trying to install RGBL library found here : 
>> https://bioconductor.org/packages/release/bioc/html/RBGL.html
>> 
>> So, I run this R code :
>> 
>> if (!require("BiocManager", quietly = TRUE))
>> install.packages("BiocManager")
>> 
>> BiocManager::install("RBGL")
>> 
>> 
>> Here is what I get :
>> 
>>> if (!require("BiocManager", quietly = TRUE))
>> + install.packages("BiocManager")
>> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
>>>
>>> BiocManager::install("RBGL")
>> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
>> Warning message:
>> package(s) not installed when version(s) same as or greater than current; 
>> use `force = TRUE` to re-install: 'RBGL'
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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] problem installing RGBL library

2023-04-22 Thread Eric Berger
looks fine.
what's the problem?

On Sat, Apr 22, 2023 at 7:27 PM varin sacha  wrote:

> Eric,
>
> Here it is :
>
>
> library(RBGL)
> Loading required package: graph
> Loading required package: BiocGenerics
>
> Attaching package: ‘BiocGenerics’
>
> The following objects are masked from ‘package:igraph’:
>
>   normalize, path, union
>
> The following objects are masked from ‘package:stats’:
>
>   IQR, mad, sd, var, xtabs
>
> The following objects are masked from ‘package:base’:
>
>   anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames,
> dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl,
> intersect, is.unsorted, lapply, Map,
>   mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
> Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table,
> tapply, union, unique, unsplit, which.max,
>   which.min
>
>
> Attaching package: ‘graph’
>
> The following objects are masked from ‘package:igraph’:
>
>   degree, edges, intersection
>
>
> Attaching package: ‘RBGL’
>
> The following objects are masked from ‘package:igraph’:
>
>   bfs, dfs, transitivity
>
>
>
>
>
>
>
>
>
>
> Le samedi 22 avril 2023 à 18:12:56 UTC+2, Eric Berger <
> ericjber...@gmail.com> a écrit :
>
>
>
>
>
> What happens with the command
> > library(RBGL)
>
>
>
> On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help <
> r-help@r-project.org> wrote:
> > Dear R-experts,
> >
> > How to solve that problem?
> >
> > My R version is 4.2.1
> >
> > Here below trying to install RGBL library found here :
> https://bioconductor.org/packages/release/bioc/html/RBGL.html
> >
> > So, I run this R code :
> >
> > if (!require("BiocManager", quietly = TRUE))
> > install.packages("BiocManager")
> >
> > BiocManager::install("RBGL")
> >
> >
> > Here is what I get :
> >
> >> if (!require("BiocManager", quietly = TRUE))
> > + install.packages("BiocManager")
> > Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >>
> >> BiocManager::install("RBGL")
> > Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> > Warning message:
> > package(s) not installed when version(s) same as or greater than
> current; use `force = TRUE` to re-install: 'RBGL'
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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 installing RGBL library

2023-04-22 Thread varin sacha via R-help
Eric,

Here it is :


library(RBGL)
Loading required package: graph
Loading required package: BiocGenerics

Attaching package: ‘BiocGenerics’

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

  normalize, path, union

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

  IQR, mad, sd, var, xtabs

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

  anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, 
dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, 
intersect, is.unsorted, lapply, Map,
  mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, 
rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, 
unique, unsplit, which.max,
  which.min


Attaching package: ‘graph’

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

  degree, edges, intersection


Attaching package: ‘RBGL’

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

  bfs, dfs, transitivity










Le samedi 22 avril 2023 à 18:12:56 UTC+2, Eric Berger  a 
écrit : 





What happens with the command
> library(RBGL)



On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help  
wrote:
> Dear R-experts,
> 
> How to solve that problem?
> 
> My R version is 4.2.1
> 
> Here below trying to install RGBL library found here : 
> https://bioconductor.org/packages/release/bioc/html/RBGL.html
> 
> So, I run this R code :
> 
> if (!require("BiocManager", quietly = TRUE))
> install.packages("BiocManager")
> 
> BiocManager::install("RBGL")
> 
> 
> Here is what I get :
> 
>> if (!require("BiocManager", quietly = TRUE))
> + install.packages("BiocManager")
> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
>>
>> BiocManager::install("RBGL")
> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> Warning message:
> package(s) not installed when version(s) same as or greater than current; use 
> `force = TRUE` to re-install: 'RBGL'
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] problem installing RGBL library

2023-04-22 Thread Eric Berger
What happens with the command
> library(RBGL)



On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help 
wrote:

> Dear R-experts,
>
> How to solve that problem?
>
> My R version is 4.2.1
>
> Here below trying to install RGBL library found here :
> https://bioconductor.org/packages/release/bioc/html/RBGL.html
>
> So, I run this R code :
>
> if (!require("BiocManager", quietly = TRUE))
> install.packages("BiocManager")
>
> BiocManager::install("RBGL")
>
>
> Here is what I get :
>
> > if (!require("BiocManager", quietly = TRUE))
> + install.packages("BiocManager")
> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> >
> > BiocManager::install("RBGL")
> Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
> Warning message:
> package(s) not installed when version(s) same as or greater than current;
> use `force = TRUE` to re-install: 'RBGL'
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] problem installing RGBL library

2023-04-22 Thread varin sacha via R-help
Dear R-experts,

How to solve that problem?

My R version is 4.2.1

Here below trying to install RGBL library found here : 
https://bioconductor.org/packages/release/bioc/html/RBGL.html

So, I run this R code :

if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")

BiocManager::install("RBGL")


Here is what I get :

> if (!require("BiocManager", quietly = TRUE))
+ install.packages("BiocManager")
Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
>
> BiocManager::install("RBGL")
Bioconductor version 3.16 (BiocManager 1.30.20), R 4.2.1 (2022-06-23)
Warning message:
package(s) not installed when version(s) same as or greater than current; use 
`force = TRUE` to re-install: 'RBGL'

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


Re: [R] Problem of intercept?

2023-02-22 Thread varin sacha via R-help
Dear Peter, Bert and Timothy,

Really appreciated your help. I guess Peter's comments were the nearest of what 
I was trying to do.
I have tried but it still does not work. I mean the graph is showing the 
coefficients I am not expecting !
I will try to explain. 
Starting from the equation : Y = b0 + b1*x1 where bo and b1 are the regression 
beta coefficients representing the intercept and the slope, respectively.
Suppose that, I wish to investigate the differences in Y between males and 
females. Based on the gender variable, I can create a new dichotomous/dummy 
variable that takes the value :

1 if a person is male
0 if a person is female

and use this variable as a predictor in the regression equation, leading to the 
following model :

b0 + b1 if person is male
b0 if person is female

the coefficients can be interpreted as follow:

1. b0 is the average Y among female
2. b0 + b1 is the average Y among male
3. and b1 is the average difference in Y between males and females

The graph with my R code is showing the coefficients I was expecting for 
multiple regression but not for simple regression. I mean I am expecting to see 
b0 + b1 for coefficients in the plot for simple regression and the plot is 
showing me b1 for simple regression ! Is there a solution to my problem?

Best,


Le mercredi 22 février 2023 à 10:59:38 UTC+1, peter dalgaard  
a écrit : 





Not sure what you are trying to do here.

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

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

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

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

-pd

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

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

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


Re: [R] Problem of intercept?

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

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

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

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

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

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

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

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


Re: [R] Problem of intercept?

2023-02-21 Thread Bert Gunter
Sigh...

In a linear model with qualitative predictor variables, models with and
without intercepts are just different parameterizations of the *same*
model. -- they produce exactly the same predicted responses.  So what do
you mean?

Search on "contrasts in linear models R" and similar for an explanation.

Cheers,
Bert

On Tue, Feb 21, 2023, 13:34 varin sacha via R-help 
wrote:

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

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

2023-02-21 Thread varin sacha via R-help
Dear R-experts,

Here below my R code working with quite a few warnings. 
x11 and x12 are dichotomous variable (0=no and 1=yes). I substract 1 to ignore 
intercept.
I would like not to ignore intercept. How to modify my R code because if I just 
remove -1 it does not work?


y= c(32,45,65,34,23,43,65,76,87,98,7,867,56,45,65,76,88,34,55,66)
x11=c(0,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,0,1)
x12=c(0,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,1,0,0)
 
Dataset=data.frame(y,x11,x12)
 
a=lm(y~x11+x12-1,Dataset)$coef
b=NULL
for(i in c(1:2)) {
  f=formula(paste('y~',names(Dataset)[i],-1))
  b=c(b,lm(f,Dataset)$coef)
}
coef=data.frame(rbind(a,b))
coef$Model=c('Multi','Single')
library(reshape2)
coef.long<-melt(coef,id.vars="Model")
 
library(ggplot2)
ggplot(coef.long,aes(x=variable,y=value,fill=Model))+
  geom_bar(stat="identity",position="dodge")+
  scale_fill_discrete(name="Model",
  labels=c("Multiple", "Simple"))+
  labs(title =paste('La différences des coefficients
  entre la régression multiple et simple'),
  x="Models",y="Coefficient")+
  coord_flip()
 
 
 

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


Re: [R] Problem to run python code in r markdown

2023-01-20 Thread avi.e.gross
Kai,

Just FYI, this is mainly an R mailing list and although there ware ways to 
combine python with R (or sort of alone) within environments like RSTUDIO, this 
may not be an optimal place to discuss this. You are discussing what is no 
longer really "R markdown" and more just plain "markdown" that supports many 
languages in many environments and you are using one called flexdashboard.

I had a similar problem for a while because I had an amazing number of copies 
of python installed on my machine in various ways including directly and within 
Anaconda and several other ways. Each may have kept copies of modules like 
numpy in a different place. Unfortunately, when running python from RSTUDIO, it 
was looking in a place that did not have it and when I used "pip" to get the 
latest copy, it insisted I already had it!

So I eventually uninstalled all versions I could find and reinstalled just one 
version and then got the numpy and pandas modules installed under that version. 
Oh, I also replaced/updated RSTUDIO. Things work fine for now.

Some people may advise you on how to determine which version of python you are 
calling, or change it, and how to download numpy to the place it is expected, 
or change some environmental variable to point to it or any number of other 
solutions. Some like virtual environments, for example.

The bottom line is your setup does not have numpy installed as far as the 
software is concerned even if it is installed somewhere on your machine. When 
you get things aligned, you will be fine. 

-Original Message-
From: R-help  On Behalf Of Kai Yang via R-help
Sent: Friday, January 20, 2023 11:20 AM
To: R-help Mailing List 
Subject: [R] Problem to run python code in r markdown

Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is 
below:

try Python=
```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
use_condaenv("base")
```
```{python}import numpy as np```

I got error message below:
Error in py_call_impl(callable, dots$args, dots$keywords) :   
ModuleNotFoundError: No module named 'numpy'Calls:  ... 
py_capture_output -> force ->  -> py_call_implIn addition: There 
were 26 warnings (use warnings() to see them)Execution halted


Based on message, the python can not find numpy package. But I'm sure I 
installed the package. I don't know how to fix the problem. please help Thank 
you,Kai















[[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] Problem to run python code in r markdown

2023-01-20 Thread Milan Glacier

Maybe it is the order. You called py_install() first and then called
use_condaenv(). Perhaps you need to switch to your conda env first and
then call py_install().

On 01/20/23 16:20, Kai Yang via R-help wrote:

Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is 
below:

try Python=
```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
use_condaenv("base")
```
```{python}import numpy as np```

I got error message below:
Error in py_call_impl(callable, dots$args, dots$keywords) :   ModuleNotFoundError: No module named 
'numpy'Calls:  ... py_capture_output -> force ->  -> 
py_call_implIn addition: There were 26 warnings (use warnings() to see them)Execution halted


Based on message, the python can not find numpy package. But I'm sure I 
installed the package. I don't know how to fix the problem. please help
Thank you,Kai


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

2023-01-20 Thread Eric Berger
You don't specify what platform you are on (linux / Windows / other),
and what tools you are using.
I am running a linux system and I have virtual environments set up.
I set the environment variable RETICULATE_PYTHON to point to python
(in my virtual environment).
I am using RStudio, and I use the File pulldown menu and select New
File --> 'R Markdown' or New File --> 'Quarto document'.
In the R Markdown (or Quarto) document, create a python code chunk:

```{python}
import numpy as np
print(np.arange(5))
```

works for me.
HTH,
Eric




On Fri, Jan 20, 2023 at 6:20 PM Kai Yang via R-help
 wrote:
>
> Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is 
> below:
>
> try Python=
> ```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
> use_condaenv("base")
> ```
> ```{python}import numpy as np```
>
> I got error message below:
> Error in py_call_impl(callable, dots$args, dots$keywords) :   
> ModuleNotFoundError: No module named 'numpy'Calls:  ... 
> py_capture_output -> force ->  -> py_call_implIn addition: There 
> were 26 warnings (use warnings() to see them)Execution halted
>
>
> Based on message, the python can not find numpy package. But I'm sure I 
> installed the package. I don't know how to fix the problem. please help
> Thank you,Kai
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> [[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] Problem to run python code in r markdown

2023-01-20 Thread Kai Yang via R-help
Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is 
below:

try Python=
```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
use_condaenv("base")
```
```{python}import numpy as np```

I got error message below:
Error in py_call_impl(callable, dots$args, dots$keywords) :   
ModuleNotFoundError: No module named 'numpy'Calls:  ... 
py_capture_output -> force ->  -> py_call_implIn addition: There 
were 26 warnings (use warnings() to see them)Execution halted


Based on message, the python can not find numpy package. But I'm sure I 
installed the package. I don't know how to fix the problem. please help
Thank you,Kai















[[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 integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Ivan Krylov
On Sun, 8 Jan 2023 05:24:05 +0200
Leonard Mada via R-help  wrote:

> pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
> # 3.385985

Note that at least one implementation used by pracma::integral has the
same problem:

pracma::integral(function(x) x^3/sin(x), -pi/2, pi/2, no_intervals=7)
# [1] NaN
# Warning:
# In .gkadpt(f, a, b, tol = tol) : Infinite or NA function value
# encountered.

You just have to be less lucky to have it evaluate the function at 0.
By default, the subdivision strategy used by pracma::integral combined
with the default number of intervals leaves the special point on the
edge of the interval, where the function happens not to be evaluated.

-- 
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 integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Andrew Simmons
`subdivisions` is the maximum number of subintervals. Looking here

https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/appl/integrate.c#L1275

I'm not surprised that changing `subdivisions` has no effect on the
outcome. The integration method from {pracma} might work, maybe it
never calculates the function at 0, maybe it's using some alternate
method. Or maybe it did calculate f(0) and got NaN and just assumed
that the limit converged. Maybe that's a fair assumption, and maybe
it's not.

However:

integrate(function(x) ifelse(x == 0, 0, x^3/sin(x), -pi/2, pi/2)

works perfectly fine and is a better function definition anyway.
`integrate` in the {stats} package is unlikely to change, so use the
alternate function definition or use {pracma}.

On Sat, Jan 7, 2023 at 10:41 PM Leonard Mada  wrote:
>
> Dear Andrew,
>
>
> The limit when x approaches 0 is 0. I think most integration algorithms 
> handle this situation.
>
>
> This actually works, and it "includes" formally the point x = 0:
>
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2 + 1E-10)
>
>
> Trying to "bypass" the 0 using subdivisions unfortunately did not work:
>
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097) # or 4096
>
>
> Sincerely,
>
>
> Leonard
>
>
> On 1/8/2023 5:32 AM, Andrew Simmons wrote:
>
> You're dividing 0 by 0, giving you NaN, perhaps you should try
>
> function(x) ifelse(x == 0, 0, x^3/sin(x))
>
> On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help  
> wrote:
>>
>> Dear List-Members,
>>
>> I encounter a problem while trying to integrate the following function:
>>
>> integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
>> # Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) :
>> #  non-finite function value
>>
>> # the value should be finite:
>> curve(x^3 / sin(x), -pi/2, pi/2)
>> integrate(function(x) x^3 / sin(x), -pi/2, 0)
>> integrate(function(x) x^3 / sin(x), 0, pi/2)
>> # but this does NOT work:
>> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4096)
>> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097)
>> # works:
>> integrate(function(x) x^3 / sin(x), -pi/2, pi/2 + 1E-10)
>>
>>
>> # Note: works directly with other packages
>>
>> pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
>> # 3.385985
>>
>>
>> I hope that integrate() gets improved in base R as well.
>>
>>
>> Sincerely,
>>
>>
>> Leonard
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Andrew Simmons
You're dividing 0 by 0, giving you NaN, perhaps you should try

function(x) ifelse(x == 0, 0, x^3/sin(x))

On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help 
wrote:

> Dear List-Members,
>
> I encounter a problem while trying to integrate the following function:
>
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
> # Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) :
> #  non-finite function value
>
> # the value should be finite:
> curve(x^3 / sin(x), -pi/2, pi/2)
> integrate(function(x) x^3 / sin(x), -pi/2, 0)
> integrate(function(x) x^3 / sin(x), 0, pi/2)
> # but this does NOT work:
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4096)
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097)
> # works:
> integrate(function(x) x^3 / sin(x), -pi/2, pi/2 + 1E-10)
>
>
> # Note: works directly with other packages
>
> pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
> # 3.385985
>
>
> I hope that integrate() gets improved in base R as well.
>
>
> Sincerely,
>
>
> Leonard
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Leonard Mada via R-help

Dear List-Members,

I encounter a problem while trying to integrate the following function:

integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
# Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) :
#  non-finite function value

# the value should be finite:
curve(x^3 / sin(x), -pi/2, pi/2)
integrate(function(x) x^3 / sin(x), -pi/2, 0)
integrate(function(x) x^3 / sin(x), 0, pi/2)
# but this does NOT work:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4096)
integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097)
# works:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2 + 1E-10)


# Note: works directly with other packages

pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
# 3.385985


I hope that integrate() gets improved in base R as well.


Sincerely,


Leonard

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

2022-10-13 Thread Tomas Kalibera

Hi Andrew,

On 9/30/22 15:05, Andrew Hart via R-help wrote:

Hi everyone,

Recently I upgraded to R 4.2.1 which now uses UTF-8 internally as its 
native encoding. Very nice. However, I've discovered that if I use 
writeClipboard to try and move a string containing accented characters 
to the Windows clipboard and then try and paste that into another 
application (e.g. notepad, Eclipse, etc.), the accents turn out all 
garbled. Here's an example:


writeClipboard("categoría")
Pasting the result into this e-mail message yields
Categoría

As near as I can tell, the problem seems to have something to do with 
the format parameter of writeClipboard. By default, format has a value 
of 1, which tells the clipboard to receive Text in the machine's 
locale. If I set format=13 in the call, the accents transfer to the 
clipboard correctly:


writeClipboard("categoría", format=13)
and the result is
Categoría


Ivan Krylov has kindly turned this into a bug report, please see

https://bugs.r-project.org/show_bug.cgi?id=18412

for more details. In short, yes, using format=13 is recommended, but 
please note it has already been documented in ?writeClipboard.


It seems that format=13 may be a better default now that R is using 
UTF-8. It would be nice not to have to specify the format every time I 
want to copy text to the clipboard with writeClipboard.


Yes, I agree, I've changed the default to format=13.

Is writeClipboard supposed to perform any kind of encoding conversion 
or is the format parameter merely informing the clipboard of the kind 
of payload it's being handed?


Btw, with pre-4.2.0 versions of R, this wasn't a problem. I am very 
much in favour of R using some kind of Unicode encoding natively, but 
this wrinkle seems to be something the user shouldn't have to deal 
with since the Windows clipboard is capable of holding Unicode text. 
Any advice would be gratefully received.


This is a bit complicated and more can be found in the bug report 
response. In short, the clipboard is capable of holding either "text" 
(then with locale information) or "Unicode text". One can ask Windows 
for either content and Windows will do the conversion, it would convert 
from "text" to "Unicode text" using that locale. If that locale is not 
filled in explicitly, it is the current input language (so the 
"keyboard" the user has selected at the time of the copying to 
clipboard, e.g. of writeClipboard). If that locale encoding doesn't 
match the R current native encoding, and you are using "text", 
characters may be mis-represented. This could have happened even before 
R 4.2.0, but is more likely from R 4.2.0 when it uses UTF-8. Going via 
"Unicode text" resolves the issue as the conversion to/from UTF-16LE is 
done by readClipboard/writeClipboard using the R current native encoding.


Users who don't want to deal with these complexities can use the 
higher-level connections interface (?connections, "clipboard").


Best
Tomas



Thanks,
Andrew.

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

2022-09-30 Thread Rui Barradas

Hello,

I can reproduce this.


C:\Users\ruipb>R -q -e  "writeClipboard('categoría'); sessionInfo()"
> writeClipboard('categoría'); sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8  LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.utf8

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

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

# quoting Andrew: Pasting the result into this e-mail message yields
categoría



And with the same sessionInfo() output


R -q -e  "writeClipboard('categoría', format = 13)"
#  paste clipboard here
categoría


Hope this helps,

Rui Barradas

Às 14:05 de 30/09/2022, Andrew Hart via R-help escreveu:

Hi everyone,

Recently I upgraded to R 4.2.1 which now uses UTF-8 internally as its 
native encoding. Very nice. However, I've discovered that if I use 
writeClipboard to try and move a string containing accented characters 
to the Windows clipboard and then try and paste that into another 
application (e.g. notepad, Eclipse, etc.), the accents turn out all 
garbled. Here's an example:


writeClipboard("categoría")
Pasting the result into this e-mail message yields
Categoría

As near as I can tell, the problem seems to have something to do with 
the format parameter of writeClipboard. By default, format has a value 
of 1, which tells the clipboard to receive Text in the machine's locale. 
If I set format=13 in the call, the accents transfer to the clipboard 
correctly:


writeClipboard("categoría", format=13)
and the result is
Categoría

It seems that format=13 may be a better default now that R is using 
UTF-8. It would be nice not to have to specify the format every time I 
want to copy text to the clipboard with writeClipboard.


Is writeClipboard supposed to perform any kind of encoding conversion or 
is the format parameter merely informing the clipboard of the kind of 
payload it's being handed?


Btw, with pre-4.2.0 versions of R, this wasn't a problem. I am very much 
in favour of R using some kind of Unicode encoding natively, but this 
wrinkle seems to be something the user shouldn't have to deal with since 
the Windows clipboard is capable of holding Unicode text. Any advice 
would be gratefully received.


Thanks,
 Andrew.

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

2022-09-30 Thread Andrew Hart via R-help

Hi everyone,

Recently I upgraded to R 4.2.1 which now uses UTF-8 internally as its 
native encoding. Very nice. However, I've discovered that if I use 
writeClipboard to try and move a string containing accented characters 
to the Windows clipboard and then try and paste that into another 
application (e.g. notepad, Eclipse, etc.), the accents turn out all 
garbled. Here's an example:


writeClipboard("categoría")
Pasting the result into this e-mail message yields
Categoría

As near as I can tell, the problem seems to have something to do with 
the format parameter of writeClipboard. By default, format has a value 
of 1, which tells the clipboard to receive Text in the machine's locale. 
If I set format=13 in the call, the accents transfer to the clipboard 
correctly:


writeClipboard("categoría", format=13)
and the result is
Categoría

It seems that format=13 may be a better default now that R is using 
UTF-8. It would be nice not to have to specify the format every time I 
want to copy text to the clipboard with writeClipboard.


Is writeClipboard supposed to perform any kind of encoding conversion or 
is the format parameter merely informing the clipboard of the kind of 
payload it's being handed?


Btw, with pre-4.2.0 versions of R, this wasn't a problem. I am very much 
in favour of R using some kind of Unicode encoding natively, but this 
wrinkle seems to be something the user shouldn't have to deal with since 
the Windows clipboard is capable of holding Unicode text. Any advice 
would be gratefully received.


Thanks,
Andrew.

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

2022-09-15 Thread Eric Berger
Can you bring up R in a shell? Do you get the same message?
(Also, set your email to send plain text. HTML versions are deleted.)



On Thu, Sep 15, 2022 at 11:27 AM Farah Al Saifi  wrote:
>
> Dear Sir/Madam
>
> After the update of the new version of R 4.2.1, an error message ( Error in 
> nchar(homeDir): invalid multibyte string, element 1)  appears every time i 
> open RStudio. Also the following warning message appears in the console: In 
> normalizePath (path.expand(path),  winslash, mustwork): 
> path[1]="C:/Users/41784/oneDrive - Universität zürich UZH/Dokumente": the 
> system cannot find the given path.
>
> I would be glad, if you can tell me the solution for this problem. Thank you 
> for your consideration.
>
> Best,
>
>
> [[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] Problem with installing packages in R

2022-09-15 Thread Farah Al Saifi
Dear Sir/Madam

After the update of the new version of R 4.2.1, an error message ( Error in 
nchar(homeDir): invalid multibyte string, element 1)  appears every time i open 
RStudio. Also the following warning message appears in the console: In 
normalizePath (path.expand(path),  winslash, mustwork): 
path[1]="C:/Users/41784/oneDrive - Universit�t z�rich UZH/Dokumente": the 
system cannot find the given path.

I would be glad, if you can tell me the solution for this problem. Thank you 
for your consideration.

Best,


[[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 installing R 4.2 on Ubuntu 20-04

2022-07-25 Thread Micha Silver

Just a guess:


On 25/07/2022 17:43, Witold E Wolski wrote:

I am failing to get R 4 installed on Ubuntu. I am following the
instructions given here:
https://cran.r-project.org/bin/linux/ubuntu/

These are the errors I am getting:

parallels@ubuntu-linux-20-04-desktop:~/Downloads/fragpipe/bin$ sudo
apt install --no-install-recommends r-base


--no-install-recommends might be your problem

Try running without that.


(And also do sudo apt update first)



The following packages have unmet dependencies:
And this is why that --no-install-recommends is causing the install to 
fail:

  r-base : Depends: r-base-core (>= 4.2.1-1.2004.0) but it is not going
to be installed
   Depends: r-recommended (= 4.2.1-1.2004.0) but it is not
going to be installed
E: Unable to correct problems, you have held broken packages.



Best regards
Witek


--
Witold Eryk Wolski

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


--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

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

2022-07-25 Thread Bert Gunter
Better posted on R-sig-debian, I think.

Cheers,
Bert

On Mon, Jul 25, 2022 at 7:44 AM Witold E Wolski  wrote:

> I am failing to get R 4 installed on Ubuntu. I am following the
> instructions given here:
> https://cran.r-project.org/bin/linux/ubuntu/
>
> These are the errors I am getting:
> 
> parallels@ubuntu-linux-20-04-desktop:~/Downloads/fragpipe/bin$ sudo
> apt install --no-install-recommends r-base
> [sudo] password for parallels:
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Some packages could not be installed. This may mean that you have
> requested an impossible situation or if you are using the unstable
> distribution that some required packages have not yet been created
> or been moved out of Incoming.
> The following information may help to resolve the situation:
>
> The following packages have unmet dependencies:
>  r-base : Depends: r-base-core (>= 4.2.1-1.2004.0) but it is not going
> to be installed
>   Depends: r-recommended (= 4.2.1-1.2004.0) but it is not
> going to be installed
> E: Unable to correct problems, you have held broken packages.
> 
>
>
> This is the tail of the source.lists file:
>
> 
> deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
> # deb-src https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
> 
>
> This is the head of executing: apt-cache policy r-base
> 
> arallels@ubuntu-linux-20-04-desktop:~/Downloads/fragpipe/bin$
> apt-cache policy r-base
> r-base:
>   Installed: (none)
>   Candidate: 4.2.1-1.2004.0
>   Version table:
>  4.2.1-1.2004.0 500
> 500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
> Packages
>  4.2.0-1.2004.0 500
> 500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
> Packages
>  4.1.3-1.2004.0 500
> 500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
> Packages
>  4.1.2-1.2004.0 500
>
> 
>
> End this is for executing apt-cache policy r-base-core
>
> 
> parallels@ubuntu-linux-20-04-desktop:~/Downloads/fragpipe/bin$
> apt-cache policy r-base-core
> r-base-core:
>   Installed: (none)
>   Candidate: 3.6.3-2
>   Version table:
>  3.6.3-2 500
> 500 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64
> Packages
> 100 /var/lib/dpkg/status
>
> 
>
> Someone else described the same/similar problem here:
>
>
> https://askubuntu.com/questions/1373827/problems-installing-latest-version-of-r-in-ubuntu-20-04-lts
>
> What step did I miss executing?
>
> Best regards
> Witek
>
>
> --
> Witold Eryk Wolski
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 installing/updating nloptr...

2022-05-19 Thread Ivan Krylov
On Thu, 19 May 2022 19:50:56 -0400
Brian Lunergan  wrote:

> CMake Error: The source directory
> "/tmp/RtmpCNCU3l/R.INSTALL21c510095118/nloptr/src/CMAKE_RANLIB=/usr/bin
> /ranlib" does not exist.
> Specify --help for usage, or press the help button on the CMake GUI.
> Unknown argument -j
> Unknown argument 2
> Usage: cmake --build  [options] [-- [native-options]]

The package's ./configure script got confused in a pretty spectacular
way. Unfortunately, Linux Mint 19.3 is based on Ubuntu 18.04, which
only has NLopt 2.4.2, insufficient for the latest version of nloptr (it
wants 2.7.0 or newer), so in order to install the latest version of the
package, you do need this step to succeed.

> Uninstalled the package and tried reinstalling. Same stumble so I now
> no longer have it at all, and it's needed to load Rcmdr.

Do you need the new version? Installing one of the older versions from
https://cran.r-project.org/src/contrib/Archive/nloptr/ should be a safe
bet. You can also use `sudo apt install libnlopt-dev` to skip the NLopt
build step once you find an old enough version of nloptr that's okay
with NLopt 2.4.2.

I'm not sure how this error could have happened, but if you send the
full installation log to , they
may be able to figure it out.

-- 
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] Problem installing/updating nloptr...

2022-05-19 Thread Brian Lunergan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Evening folks:

Running R 4.2.0 on Linux Mint 19.3. When I tried to update package
nloptr the operation failed with this error text seeming to be key to
the problem.

CMake Error: The source directory
"/tmp/RtmpCNCU3l/R.INSTALL21c510095118/nloptr/src/CMAKE_RANLIB=/usr/bin
/ranlib" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Unknown argument -j
Unknown argument 2
Usage: cmake --build  [options] [-- [native-options]]
Options:
= Project binary directory to be built.
  --target  = Build  instead of default targets.
   May only be specified once.
  --config  = For multi-configuration tools, choose .
  --clean-first  = Build target 'clean' first, then build.
   (To clean only, use --target 'clean'.)
  --use-stderr   = Ignored.  Behavior is default in CMake >= 3.0.
  -- = Pass remaining options to the native tool.
CMake Error: The source directory
"/tmp/RtmpCNCU3l/R.INSTALL21c510095118/nloptr/src/nlopt" does not
exist.
Specify --help for usage, or press the help button on the CMake GUI.
cp: cannot stat 'nlopt/include/*': No such file or directory

Uninstalled the package and tried reinstalling. Same stumble so I now
no longer have it at all, and it's needed to load Rcmdr.

Any help sorting this out would be appreciated. Please... :-(
- -- 
Brian Lunergan
Russell, Ontario
Canada

-BEGIN PGP SIGNATURE-

iQEzBAEBCgAdFiEEQnNPvUcw8TGKI+uNUQG1sc4S+04FAmKG1+AACgkQUQG1sc4S
+06RxQgAo4Hq7rB99Gpvhv9RvzgvhoxVUXsFYuEmFMzysCIwFzfBVS+ZVgydSoRW
FfAxZYLruYOU2+i+9PGD/J3cW9sMaXw7NJQRUhYINTc1Q4vrSQZBmvRxwil8tPBq
z+KB5yxuEVMsyfhSRFjWdRGaBEnxVeRBlPnvWHRYgUYKFqrsosvwY1hdnlIwRMh9
/J9qfsi98mbSZB2HZd1OaCACxP+fAM0+jQuMJhTSNvvt4l3O583J6ewbvJE53YFT
2+gU9JJI7yn6rIamX2iHGKaueF9N+HPHMMnLfuO6lsmeE6OfzqyiFzy13Rr3H6yF
ptDrR2NTURpt5LyipIlK7vamJnt6pA==
=QWJP
-END PGP SIGNATURE-

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


Re: [R] Problem downloading pcalg library/package

2022-03-24 Thread varin sacha via R-help
Ivan,

Here is what I get : 

download.file('https://stat.ethz.ch/CRAN/src/contrib/PACKAGES','PACKAGES')

essai de l'URL 'https://stat.ethz.ch/CRAN/src/contrib/PACKAGES'
Erreur dans download.file("https://stat.ethz.ch/CRAN/src/contrib/PACKAGES",  :
  impossible d'ouvrir l'URL 'https://stat.ethz.ch/CRAN/src/contrib/PACKAGES'
De plus : Message d'avis :
Dans download.file("https://stat.ethz.ch/CRAN/src/contrib/PACKAGES",  :
  URL 'https://stat.ethz.ch/CRAN/src/contrib/PACKAGES': statut 'Peer 
certificate cannot be authenticated with given CA certificates'









Le jeudi 24 mars 2022, 14:39:03 UTC+1, Ivan Krylov  a 
écrit : 





On Thu, 24 Mar 2022 13:29:45 + (UTC)
varin sacha  wrote:

> I have changed my CRANmirror to the Switzerland (ETHZ) one using the
> function you sent to me chooseCRANmirror( ). It still does not work !
> I still cannot install the pcalg package !

That's odd.

Do you see any error messages if you run the following command?

download.file('https://stat.ethz.ch/CRAN/src/contrib/PACKAGES',
'PACKAGES')

Maybe it would work if you set a different
options(download.file.method)? Available options are: "internal",
"libcurl", "wget", "curl".


-- 
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 downloading pcalg library/package

2022-03-24 Thread Ivan Krylov
On Thu, 24 Mar 2022 13:29:45 + (UTC)
varin sacha  wrote:

> I have changed my CRANmirror to the Switzerland (ETHZ) one using the
> function you sent to me chooseCRANmirror( ). It still does not work !
> I still cannot install the pcalg package !

That's odd.

Do you see any error messages if you run the following command?

download.file('https://stat.ethz.ch/CRAN/src/contrib/PACKAGES',
'PACKAGES')

Maybe it would work if you set a different
options(download.file.method)? Available options are: "internal",
"libcurl", "wget", "curl".

-- 
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] Problem downloading pcalg library/package

2022-03-24 Thread varin sacha via R-help
Dear R-experts,

Here below my sessionInfo( ). I cannot download the pcalg package/library. Is 
my R version too old ?


sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   
/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: 
/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

Random number generation:
 RNG: Mersenne-Twister
 Normal:  Inversion
 Sample:  Rounding
 
locale:
[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8

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

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


install.packages("pcalg")
Installation du package dans ‘/Users/Caro/Library/R/4.1/library’
(car ‘lib’ n'est pas spécifié)
Avis : unable to access index for repository http://cran.cict.fr/src/contrib:
  impossible d'ouvrir l'URL 'http://cran.cict.fr/src/contrib/PACKAGES'
Avis : unable to access index for repository 
http://cran.cict.fr/bin/macosx/contrib/4.1:
  impossible d'ouvrir l'URL 
'http://cran.cict.fr/bin/macosx/contrib/4.1/PACKAGES'
Message d'avis :
le package ‘pcalg’ n'est pas disponible for this version of R

Une version de ce package pour votre version de R est peut-être disponible 
ailleurs,
Voyez des idées à
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-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] Problem installing Rcmdr on version 4.1.2...

2022-03-04 Thread Ivan Krylov
On Fri, 4 Mar 2022 08:23:43 -0500
Brian Lunergan  wrote:

> Running R 4.1.2 on Linux Mint 19.3.

> g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include
> -I'/home/brian/R/x86_64-pc-linux-gnu-library/4.1/testthat/include'
> -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-J7pprH/r-base-4.1.2=.
> -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
> -D_FORTIFY_SOURCE=2 -g  -c test-runner.cpp -o test-runner.o
> g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
> -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o
> test-runner.o -llapack -lblas -lgfortran -lm -lquadmath -Lnlopt/lib
> -lnlopt -L/usr/lib/R/lib -lR
> /usr/bin/ld: cannot find -lnlopt
> collect2: error: ld returned 1 exit status

Typically, when an R package wraps a third-party library, you need a
development version of it installed in order to install that package
from source.

If you're running R from the Linux Mint repos, try to install
r-cran-nloptr from Linux Mint repositories. If you don't, or have some
trouble installing the package, install the libnlopt-dev Linux Mint
package before trying to install the nloptr R package.

-- 
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 data distribution

2022-02-17 Thread Ebert,Timothy Aaron
Maybe what you want is to recode your data differently.
One data set has bug versus no bug. What is the probability of having one or 
more bugs?
The other data set has bugs only. Given that I have bugs how many will I get?

Tim

-Original Message-
From: R-help  On Behalf Of Neha gupta
Sent: Thursday, February 17, 2022 4:54 PM
To: Bert Gunter 
Cc: r-help mailing list 
Subject: Re: [R] Problem with data distribution

[External Email]

:) :)

On Thu, Feb 17, 2022 at 10:37 PM Bert Gunter  wrote:

> imo, with such simple data, a plot is mere chartjunk. A simple table(= 
> the distribution) would suffice and be more informative:
>
> > table(bug) ## bug is a vector. No data frame is needed
>
>   0   1 23   4   5   7   ## bug count
> 162  40   9   7   2   1   1   ## nmbr of cases with the given count
>
> You or others may disagree, of course.
>
> Bert Gunter
>
>
>
> On Thu, Feb 17, 2022 at 11:56 AM Neha gupta 
> wrote:
> >
> > Ebert and Rui, thank you for providing the tips (in fact, for 
> > providing
> the
> > answer I needed).
> >
> > Yes, you are right that boxplot of all zero values will not make sense.
> > Maybe histogram will work.
> >
> > I am providing a few details of my data here and the context of the 
> > question I asked.
> >
> > My data is about bugs/defects in different classes of a large 
> > software system. I have to predict which class will contain bugs and 
> > which will be free of bugs (bug=0). I trained ML models and predict 
> > but my advisor
> asked
> > me to provide first the data distribution about bugs e.g details of 
> > how many classes with bugs (bug > 0) and how many are free of bugs (bug=0).
> >
> > That is why I need to provide the data distribution of both types of
> values
> > (i.e. bug=0 and bug >0)
> >
> > Thank you again.
> >
> > On Thu, Feb 17, 2022 at 8:28 PM Rui Barradas 
> wrote:
> >
> > > Hello,
> > >
> > > In your original post you read the same file "synapse.arff" twice, 
> > > apparently to filter each of them by its own criterion. You don't 
> > > need to do that, read once and filter that one by different criteria.
> > >
> > > As for the data as posted, I have read it in with the following code:
> > >
> > >
> > > x <- "
> > > 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 
> > > 0 0 0
> > > 4 1 0
> > > 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 
> > > 0 0 0
> > > 0 0 0
> > > 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 
> > > 0 0 7
> > > 0 0 1
> > > 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 
> > > 0 0 0
> > > 1 0 0
> > > 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 
> > > 1 0 0
> > > 0 0 1
> > > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0 "
> > > bug <- scan(text = x)
> > > data <- data.frame(bug)
> > >
> > >
> > > This is not the right way to post data, the posting guide asks to 
> > > post the output of
> > >
> > >
> > > dput(data)
> > > structure(list(bug = c(0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
> > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
> > > 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 0, 0, 0, 0, 3, 0, 0, 
> > > 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 
> > > 2, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 
> > > 0, 1, 0, 0, 5, 0, 0, 0, 0, 0, 0, 7, 0, 0, 1, 0, 1, 1, 0, 2, 0, 3, 
> > > 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 3, 2, 1, 1, 
> > > 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 
> > > 0, 0, 3, 0, 0, 1, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 1, 1, 
> > > 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
> > > 0, 0, 3, 0, 1, 0, 0, 0, 0, 0)), class = "data.frame", row.names = 
> > > c(NA, -222L))
> > >
> > >
> > >
> > > This can be copied into an R session and the data set recreated 
> > > with
> > >
> > > data <- structure(etc)
> > >
> > >
> > > Now the boxplots.
> > >
> > > (Why would you want to plot a vector of all zeros, btw?)
> > >
> > >
> > >
> > > library(dplyr)
> > >
> > > boxplot(filter(data, bug == 0))# nonsense
> > > boxplot(filt

Re: [R] Problem with data distribution

2022-02-17 Thread Neha gupta
:) :)

On Thu, Feb 17, 2022 at 10:37 PM Bert Gunter  wrote:

> imo, with such simple data, a plot is mere chartjunk. A simple table(=
> the distribution) would suffice and be more informative:
>
> > table(bug) ## bug is a vector. No data frame is needed
>
>   0   1 23   4   5   7   ## bug count
> 162  40   9   7   2   1   1   ## nmbr of cases with the given count
>
> You or others may disagree, of course.
>
> Bert Gunter
>
>
>
> On Thu, Feb 17, 2022 at 11:56 AM Neha gupta 
> wrote:
> >
> > Ebert and Rui, thank you for providing the tips (in fact, for providing
> the
> > answer I needed).
> >
> > Yes, you are right that boxplot of all zero values will not make sense.
> > Maybe histogram will work.
> >
> > I am providing a few details of my data here and the context of the
> > question I asked.
> >
> > My data is about bugs/defects in different classes of a large software
> > system. I have to predict which class will contain bugs and which will be
> > free of bugs (bug=0). I trained ML models and predict but my advisor
> asked
> > me to provide first the data distribution about bugs e.g details of how
> > many classes with bugs (bug > 0) and how many are free of bugs (bug=0).
> >
> > That is why I need to provide the data distribution of both types of
> values
> > (i.e. bug=0 and bug >0)
> >
> > Thank you again.
> >
> > On Thu, Feb 17, 2022 at 8:28 PM Rui Barradas 
> wrote:
> >
> > > Hello,
> > >
> > > In your original post you read the same file "synapse.arff" twice,
> > > apparently to filter each of them by its own criterion. You don't need
> > > to do that, read once and filter that one by different criteria.
> > >
> > > As for the data as posted, I have read it in with the following code:
> > >
> > >
> > > x <- "
> > > 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0 0
> > > 4 1 0
> > > 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0 0
> > > 0 0 0
> > > 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0 7
> > > 0 0 1
> > > 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0 0
> > > 1 0 0
> > > 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0 0
> > > 0 0 1
> > > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
> > > "
> > > bug <- scan(text = x)
> > > data <- data.frame(bug)
> > >
> > >
> > > This is not the right way to post data, the posting guide asks to post
> > > the output of
> > >
> > >
> > > dput(data)
> > > structure(list(bug = c(0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0,
> > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0,
> > > 0, 0, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 0, 0, 0, 0,
> > > 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
> > > 0, 0, 1, 1, 2, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
> > > 1, 0, 0, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 0, 0, 7, 0, 0, 1, 0,
> > > 1, 1, 0, 2, 0, 3, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
> > > 0, 1, 0, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
> > > 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 3, 0, 0, 1, 0, 1, 3, 0, 0, 0, 0,
> > > 0, 0, 0, 0, 1, 0, 4, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
> > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0)),
> > > class = "data.frame", row.names = c(NA, -222L))
> > >
> > >
> > >
> > > This can be copied into an R session and the data set recreated with
> > >
> > > data <- structure(etc)
> > >
> > >
> > > Now the boxplots.
> > >
> > > (Why would you want to plot a vector of all zeros, btw?)
> > >
> > >
> > >
> > > library(dplyr)
> > >
> > > boxplot(filter(data, bug == 0))# nonsense
> > > boxplot(filter(data, bug > 0), range = 0)
> > >
> > > # Another way
> > > data %>%
> > >filter(bug > 0) %>%
> > >boxplot(range = 0)
> > >
> > >
> > > Hope this helps,
> > >
> > > Rui Barradas
> > >
> > >
> > > Às 19:03 de 17/02/2022, Neha gupta escreveu:
> > > > That is all the code I have. How can I provide a  reproducible code ?
> > > >
> > > > How can I save this result?
> > > >

Re: [R] Problem with data distribution

2022-02-17 Thread Neha gupta
Ebert and Rui, thank you for providing the tips (in fact, for providing the
answer I needed).

Yes, you are right that boxplot of all zero values will not make sense.
Maybe histogram will work.

I am providing a few details of my data here and the context of the
question I asked.

My data is about bugs/defects in different classes of a large software
system. I have to predict which class will contain bugs and which will be
free of bugs (bug=0). I trained ML models and predict but my advisor asked
me to provide first the data distribution about bugs e.g details of how
many classes with bugs (bug > 0) and how many are free of bugs (bug=0).

That is why I need to provide the data distribution of both types of values
(i.e. bug=0 and bug >0)

Thank you again.

On Thu, Feb 17, 2022 at 8:28 PM Rui Barradas  wrote:

> Hello,
>
> In your original post you read the same file "synapse.arff" twice,
> apparently to filter each of them by its own criterion. You don't need
> to do that, read once and filter that one by different criteria.
>
> As for the data as posted, I have read it in with the following code:
>
>
> x <- "
> 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0 0
> 4 1 0
> 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0 0
> 0 0 0
> 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0 7
> 0 0 1
> 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0 0
> 1 0 0
> 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0 0
> 0 0 1
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
> "
> bug <- scan(text = x)
> data <- data.frame(bug)
>
>
> This is not the right way to post data, the posting guide asks to post
> the output of
>
>
> dput(data)
> structure(list(bug = c(0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0,
> 0, 0, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 0, 0, 0, 0,
> 3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
> 0, 0, 1, 1, 2, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
> 1, 0, 0, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 0, 0, 7, 0, 0, 1, 0,
> 1, 1, 0, 2, 0, 3, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
> 0, 1, 0, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 3, 0, 0, 1, 0, 1, 3, 0, 0, 0, 0,
> 0, 0, 0, 0, 1, 0, 4, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0)),
> class = "data.frame", row.names = c(NA, -222L))
>
>
>
> This can be copied into an R session and the data set recreated with
>
> data <- structure(etc)
>
>
> Now the boxplots.
>
> (Why would you want to plot a vector of all zeros, btw?)
>
>
>
> library(dplyr)
>
> boxplot(filter(data, bug == 0))# nonsense
> boxplot(filter(data, bug > 0), range = 0)
>
> # Another way
> data %>%
>filter(bug > 0) %>%
>boxplot(range = 0)
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 19:03 de 17/02/2022, Neha gupta escreveu:
> > That is all the code I have. How can I provide a  reproducible code ?
> >
> > How can I save this result?
> >
> > On Thu, Feb 17, 2022 at 8:00 PM Ebert,Timothy Aaron 
> wrote:
> >
> >> You pipe the filter but do not save the result. A reproducible example
> >> might help.
> >> Tim
> >>
> >> -Original Message-
> >> From: R-help  On Behalf Of Neha gupta
> >> Sent: Thursday, February 17, 2022 1:55 PM
> >> To: r-help mailing list 
> >> Subject: [R] Problem with data distribution
> >>
> >> [External Email]
> >>
> >> Hello everyone
> >>
> >> I have a dataset with output variable "bug" having the following values
> >> (at the bottom of this email). My advisor asked me to provide data
> >> distribution of bugs with 0 values and bugs with more than 0 values.
> >>
> >> data = readARFF("synapse.arff")
> >> data2 = readARFF("synapse.arff")
> >> data$bug
> >> library(tidyverse)
> >> data %>%
> >>filter(bug == 0)
> >> data2 %>%
> >>filter(bug >= 1)
> >> boxplot(data2$bug, data$bug, range=0)
> >>
> >> But both the graphs are exactly the same, how is it possible? Where I am
> >> doing wrong?
> >>
> >>
> >> data$bug
> >>[1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0
> 0 0 0
> >> 0 4 1 0
> >>   [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1

Re: [R] Problem with data distribution

2022-02-17 Thread Neha gupta
Dear John, thanks a lot for the detailed answer.

Yes, I am not an expert in R language and when a problem comes in, I google
it or post it on these forums. (I have just a little bit experience of ML
in R).



On Thu, Feb 17, 2022 at 8:21 PM John Fox  wrote:

> Dear Nega gupta,
>
> On 2022-02-17 1:54 p.m., Neha gupta wrote:
> > Hello everyone
> >
> > I have a dataset with output variable "bug" having the following values
> (at
> > the bottom of this email). My advisor asked me to provide data
> distribution
> > of bugs with 0 values and bugs with more than 0 values.
> >
> > data = readARFF("synapse.arff")
> > data2 = readARFF("synapse.arff")
> > data$bug
> > library(tidyverse)
> > data %>%
> >filter(bug == 0)
> > data2 %>%
> >filter(bug >= 1)
> > boxplot(data2$bug, data$bug, range=0)
> >
> > But both the graphs are exactly the same, how is it possible? Where I am
> > doing wrong?
>
> As it turns out, you're doing several things wrong.
>
> First, you're not using pipes and filter() correctly. That is, you don't
> do anything with the filtered versions of the data sets. You're
> apparently under the incorrect impression that filtering modifies the
> original data set.
>
> Second, you're greatly complicating a simple problem. You don't need to
> read the data twice and keep two versions of the data set. As well,
> processing the data with pipes and filter() is entirely unnecessary. The
> following code works:
>
> with(data, boxplot(bug[bug == 0], bug[bug >= 1], range=0))
>
> Third, and most fundamentally, the parallel boxplots you're apparently
> trying to construct don't really make sense. The first "boxplot" is just
> a horizontal line at 0 and so conveys no information. Why not just plot
> the nonzero values if that's what you're interested in?
>
> Fourth, you didn't share your data in a convenient form. I was able to
> reconstruct them via
>
>bug <- scan()
>0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
>0 4 1 0
>0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0
>0 0 0 0
>1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0
>7 0 0 1
>0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0
>0 1 0 0
>0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0
>0 0 0 1
>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
>
>data <- data.frame(bug)
>
> Finally, it's better not to post to the list in plain-text email, rather
> than html (as the posting guide suggests).
>
> I hope this helps,
>   John
>
> >
> >
> > data$bug
> >[1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0
> 0 0
> > 0 4 1 0
> >   [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1
> 0 0
> > 0 0 0 0
> >   [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0
> 0 0
> > 7 0 0 1
> > [118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0
> 0 0
> > 0 1 0 0
> > [157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1
> 1 0
> > 0 0 0 1
> > [196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
> >
> >   [[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.
> --
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://socialsciences.mcmaster.ca/jfox/
>
>

[[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 data distribution

2022-02-17 Thread John Fox

Dear Nega gupta,

In the last point, I meant to say, "Finally, it's better to post to the 
list in plain-text email, rather than html (as the posting guide 
suggests)." (I accidentally inserted a "not" in this sentence.)


Sorry,
 John

On 2022-02-17 2:21 p.m., John Fox wrote:

Dear Nega gupta,

On 2022-02-17 1:54 p.m., Neha gupta wrote:

Hello everyone

I have a dataset with output variable "bug" having the following 
values (at
the bottom of this email). My advisor asked me to provide data 
distribution

of bugs with 0 values and bugs with more than 0 values.

data = readARFF("synapse.arff")
data2 = readARFF("synapse.arff")
data$bug
library(tidyverse)
data %>%
   filter(bug == 0)
data2 %>%
   filter(bug >= 1)
boxplot(data2$bug, data$bug, range=0)

But both the graphs are exactly the same, how is it possible? Where I am
doing wrong?


As it turns out, you're doing several things wrong.

First, you're not using pipes and filter() correctly. That is, you don't 
do anything with the filtered versions of the data sets. You're 
apparently under the incorrect impression that filtering modifies the 
original data set.


Second, you're greatly complicating a simple problem. You don't need to 
read the data twice and keep two versions of the data set. As well, 
processing the data with pipes and filter() is entirely unnecessary. The 
following code works:


    with(data, boxplot(bug[bug == 0], bug[bug >= 1], range=0))

Third, and most fundamentally, the parallel boxplots you're apparently 
trying to construct don't really make sense. The first "boxplot" is just 
a horizontal line at 0 and so conveys no information. Why not just plot 
the nonzero values if that's what you're interested in?


Fourth, you didn't share your data in a convenient form. I was able to 
reconstruct them via


   bug <- scan()
   0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
   0 4 1 0
   0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0
   0 0 0 0
   1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0
   7 0 0 1
   0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0
   0 1 0 0
   0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0
   0 0 0 1
   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0

   data <- data.frame(bug)

Finally, it's better not to post to the list in plain-text email, rather 
than html (as the posting guide suggests).


I hope this helps,
  John




data$bug
   [1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 
0 0 0

0 4 1 0
  [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 
1 0 0

0 0 0 0
  [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 
0 0 0

7 0 0 1
[118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 
0 0 0

0 1 0 0
[157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 
1 1 0

0 0 0 1
[196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0

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

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

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

2022-02-17 Thread John Fox

Dear Neha gupta,

I hope that I'm not overstepping my role when I say that googling 
solutions to specific problems isn't an inefficient way to learn a 
programming language, and will probably waste your time in the long run. 
There are many good introductions to R.


Best,
 John

On 2022-02-17 2:27 p.m., Neha gupta wrote:

Dear John, thanks a lot for the detailed answer.

Yes, I am not an expert in R language and when a problem comes in, I 
google it or post it on these forums. (I have just a little bit 
experience of ML in R).




On Thu, Feb 17, 2022 at 8:21 PM John Fox > wrote:


Dear Nega gupta,

On 2022-02-17 1:54 p.m., Neha gupta wrote:
 > Hello everyone
 >
 > I have a dataset with output variable "bug" having the following
values (at
 > the bottom of this email). My advisor asked me to provide data
distribution
 > of bugs with 0 values and bugs with more than 0 values.
 >
 > data = readARFF("synapse.arff")
 > data2 = readARFF("synapse.arff")
 > data$bug
 > library(tidyverse)
 > data %>%
 >    filter(bug == 0)
 > data2 %>%
 >    filter(bug >= 1)
 > boxplot(data2$bug, data$bug, range=0)
 >
 > But both the graphs are exactly the same, how is it possible?
Where I am
 > doing wrong?

As it turns out, you're doing several things wrong.

First, you're not using pipes and filter() correctly. That is, you
don't
do anything with the filtered versions of the data sets. You're
apparently under the incorrect impression that filtering modifies the
original data set.

Second, you're greatly complicating a simple problem. You don't need to
read the data twice and keep two versions of the data set. As well,
processing the data with pipes and filter() is entirely unnecessary.
The
following code works:

     with(data, boxplot(bug[bug == 0], bug[bug >= 1], range=0))

Third, and most fundamentally, the parallel boxplots you're apparently
trying to construct don't really make sense. The first "boxplot" is
just
a horizontal line at 0 and so conveys no information. Why not just plot
the nonzero values if that's what you're interested in?

Fourth, you didn't share your data in a convenient form. I was able to
reconstruct them via

    bug <- scan()
    0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0
0 0 0
    0 4 1 0
    0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1
1 0 0
    0 0 0 0
    1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0
0 0 0
    7 0 0 1
    0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0
0 0 0
    0 1 0 0
    0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4
1 1 0
    0 0 0 1
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0

    data <- data.frame(bug)

Finally, it's better not to post to the list in plain-text email,
rather
than html (as the posting guide suggests).

I hope this helps,
   John

 >
 >
 > data$bug
 >    [1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0
1 0 0 0 0 0
 > 0 4 1 0
 >   [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0
0 1 1 1 0 0
 > 0 0 0 0
 >   [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5
0 0 0 0 0 0
 > 7 0 0 1
 > [118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0
0 0 0 0 0
 > 0 1 0 0
 > [157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1
0 4 1 1 0
 > 0 0 0 1
 > [196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
 >
 >       [[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.
-- 
John Fox, Professor Emeritus

McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/



--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

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

2022-02-17 Thread Rui Barradas

Hello,

In your original post you read the same file "synapse.arff" twice, 
apparently to filter each of them by its own criterion. You don't need 
to do that, read once and filter that one by different criteria.


As for the data as posted, I have read it in with the following code:


x <- "
0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0 0 
4 1 0
0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0 0 
0 0 0
1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0 7 
0 0 1
0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0 0 
1 0 0
0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0 0 
0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
"
bug <- scan(text = x)
data <- data.frame(bug)


This is not the right way to post data, the posting guide asks to post 
the output of



dput(data)
structure(list(bug = c(0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 0, 0, 0, 0,
3, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
0, 0, 1, 1, 2, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 0, 0, 7, 0, 0, 1, 0,
1, 1, 0, 2, 0, 3, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
0, 1, 0, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 3, 0, 0, 1, 0, 1, 3, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 4, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0)),
class = "data.frame", row.names = c(NA, -222L))



This can be copied into an R session and the data set recreated with

data <- structure(etc)


Now the boxplots.

(Why would you want to plot a vector of all zeros, btw?)



library(dplyr)

boxplot(filter(data, bug == 0))# nonsense
boxplot(filter(data, bug > 0), range = 0)

# Another way
data %>%
  filter(bug > 0) %>%
  boxplot(range = 0)


Hope this helps,

Rui Barradas


Às 19:03 de 17/02/2022, Neha gupta escreveu:

That is all the code I have. How can I provide a  reproducible code ?

How can I save this result?

On Thu, Feb 17, 2022 at 8:00 PM Ebert,Timothy Aaron  wrote:


You pipe the filter but do not save the result. A reproducible example
might help.
Tim

-Original Message-
From: R-help  On Behalf Of Neha gupta
Sent: Thursday, February 17, 2022 1:55 PM
To: r-help mailing list 
Subject: [R] Problem with data distribution

[External Email]

Hello everyone

I have a dataset with output variable "bug" having the following values
(at the bottom of this email). My advisor asked me to provide data
distribution of bugs with 0 values and bugs with more than 0 values.

data = readARFF("synapse.arff")
data2 = readARFF("synapse.arff")
data$bug
library(tidyverse)
data %>%
   filter(bug == 0)
data2 %>%
   filter(bug >= 1)
boxplot(data2$bug, data$bug, range=0)

But both the graphs are exactly the same, how is it possible? Where I am
doing wrong?


data$bug
   [1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
0 4 1 0
  [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0
0 0 0 0
  [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0
7 0 0 1
[118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0
0 1 0 0
[157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0
0 0 0 1
[196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=NxfkBJHBnd8naYPQTd9Z8dZ2m-RCwh_lpGvHVQ8MwYQ=
PLEASE do read the posting guide
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=exznSElUW1tc6ajt0C8uw5cR8ZqwHRD6tUPAarFYdYo=
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] Problem with data distribution

2022-02-17 Thread Neha gupta
That is all the code I have. How can I provide a  reproducible code ?

How can I save this result?

On Thu, Feb 17, 2022 at 8:00 PM Ebert,Timothy Aaron  wrote:

> You pipe the filter but do not save the result. A reproducible example
> might help.
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Neha gupta
> Sent: Thursday, February 17, 2022 1:55 PM
> To: r-help mailing list 
> Subject: [R] Problem with data distribution
>
> [External Email]
>
> Hello everyone
>
> I have a dataset with output variable "bug" having the following values
> (at the bottom of this email). My advisor asked me to provide data
> distribution of bugs with 0 values and bugs with more than 0 values.
>
> data = readARFF("synapse.arff")
> data2 = readARFF("synapse.arff")
> data$bug
> library(tidyverse)
> data %>%
>   filter(bug == 0)
> data2 %>%
>   filter(bug >= 1)
> boxplot(data2$bug, data$bug, range=0)
>
> But both the graphs are exactly the same, how is it possible? Where I am
> doing wrong?
>
>
> data$bug
>   [1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
> 0 4 1 0
>  [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0
> 0 0 0 0
>  [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0
> 7 0 0 1
> [118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0
> 0 1 0 0
> [157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0
> 0 0 0 1
> [196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=NxfkBJHBnd8naYPQTd9Z8dZ2m-RCwh_lpGvHVQ8MwYQ=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=exznSElUW1tc6ajt0C8uw5cR8ZqwHRD6tUPAarFYdYo=
> 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 data distribution

2022-02-17 Thread Ebert,Timothy Aaron
You pipe the filter but do not save the result. A reproducible example might 
help.
Tim

-Original Message-
From: R-help  On Behalf Of Neha gupta
Sent: Thursday, February 17, 2022 1:55 PM
To: r-help mailing list 
Subject: [R] Problem with data distribution

[External Email]

Hello everyone

I have a dataset with output variable "bug" having the following values (at the 
bottom of this email). My advisor asked me to provide data distribution of bugs 
with 0 values and bugs with more than 0 values.

data = readARFF("synapse.arff")
data2 = readARFF("synapse.arff")
data$bug
library(tidyverse)
data %>%
  filter(bug == 0)
data2 %>%
  filter(bug >= 1)
boxplot(data2$bug, data$bug, range=0)

But both the graphs are exactly the same, how is it possible? Where I am doing 
wrong?


data$bug
  [1] 0 1 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
0 4 1 0
 [40] 0 1 0 0 0 0 0 0 1 0 3 2 0 0 0 0 3 0 0 0 0 2 0 0 0 1 0 0 0 0 1 1 1 0 0
0 0 0 0
 [79] 1 1 2 1 0 1 0 0 0 2 2 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 5 0 0 0 0 0 0
7 0 0 1
[118] 0 1 1 0 2 0 3 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 3 2 1 1 0 0 0 0 0 0
0 1 0 0
[157] 0 0 0 0 0 0 0 0 0 1 0 1 0 0 3 0 0 1 0 1 3 0 0 0 0 0 0 0 0 1 0 4 1 1 0
0 0 0 1
[196] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=NxfkBJHBnd8naYPQTd9Z8dZ2m-RCwh_lpGvHVQ8MwYQ=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=TZx8pDTF9x1Tu4QZW3x_99uu9RowVjAna39KcjCXSElI1AOk1C_6L2pR8YIVfiod=exznSElUW1tc6ajt0C8uw5cR8ZqwHRD6tUPAarFYdYo=
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] problem with switching windows in RSelenium..

2021-12-22 Thread akshay kulkarni
dear Kim,
Hope you are doing well.

I am Akshay, from bengaluru, INDIA. I am stock trader and am using R for my 
research. More specifically, I am using RSelenium to scrape news articles. I am 
stuck in the problem related to RSelenium.

I am not able to switch windows in Rselenium 1.7.7 ( I am using chrome) . My 
situation is exactly as described in this link: 
https://github.com/ropensci/RSelenium/issues/143
I also referred to this link:   https://github.com/ropensci/RSelenium/issues/205
I have three questions:


  1.  Please refer to the second link. I ran the following command as suggested 
in that link:
  2.  > binman::list_versions("chromedriver")
$win32
[1] "96.0.4664.45" "97.0.4692.20" "97.0.4692.36"

  I am currently using the first option. Will i be lucky if I switch to 
either the second or the third option? Or to any other version? Also, I suppose 
the versions are for 32 bit($win32 above). Again, will I be lucky if I switch 
to 64bit versions? If yes, how do you switch to 64 bit versions? (I am using 
AWS EC2 windows instance which is 64 bit system)

2. Please refer to the first link. I have read in the comments that the 
myswitch function works in these cases. The solution was presented in 2017. 
Will myswitch still be valid in December 2021? If not, can you please give me a 
modified version?

3. My Rselenium session gets terminated after some period of 
inactivity. How can I change that?

Your help will be highly appreciated.

Thanking You,
Yours sincerely,
AKSHAY M KULKARNI


[[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: try to passing macro value into submit block

2021-12-21 Thread David Winsemius



On 12/21/21 6:00 PM, Kai Yang via R-help wrote:

Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to do change 
variable in color= and export the result with different file name.If I don't use macro, 
the code work well. But when I try to use macro below, I got error message: "Submit 
block cannot be directly placed in a macro. Instead, place the submit block into a file 
first and then use %include to include the file within a macro definition.". After 
reading the message, I still not sure how to fix the problem in the code. Anyone can help 
me?
Thank you,Kai
%macro pplot(a);proc iml;
submit / R;
library(ggplot2)library(tidyverse)
mpg %>%  filter(hwy <35) %>%   ggplot(aes(x = displ, y = hwy, color = )) +   
geom_point()ggsave("c:/temp/")
endsubmit;
quit;%mend;%pplot(drv);%pplot(cyl);

[[alternative HTML version deleted]]



Two problems I see. 1) you posted to R-help using html whereas the 
mailing list is a plain text venue, and 2) I reasonably sure that's a 
SAS error message and we don't consult on SAS problems.


If you strip out the stuff involving "" and add back in the elided 
line-breaks the R code runs without error.


--

David.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] problem: try to passing macro value into submit block

2021-12-21 Thread Kai Yang via R-help
Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to 
do change variable in color= and export the result with different file name.If 
I don't use macro, the code work well. But when I try to use macro below, I got 
error message: "Submit block cannot be directly placed in a macro. Instead, 
place the submit block into a file first and then use %include to include the 
file within a macro definition.". After reading the message, I still not sure 
how to fix the problem in the code. Anyone can help me?
Thank you,Kai
%macro pplot(a);proc iml;
submit / R;
library(ggplot2)library(tidyverse)
mpg %>%  filter(hwy <35) %>%   ggplot(aes(x = displ, y = hwy, color = )) +   
geom_point()ggsave("c:/temp/")
endsubmit;
quit;%mend;%pplot(drv);%pplot(cyl);

[[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] problem with RSelenium....

2021-12-18 Thread akshay kulkarni
dear members,
 I am using RSelenium. I have downloaded the java 
binary standalone server. I am running it in my windows powershell with the 
following command:  java -jar selenium-server-standalone-4.0.0-alpha-2.jar
(note that the command doesn't get finished in the powershell ( the prompt 
doesn't return to C"\Users\Administrator\Downloads after running the command)).

Then I run the following in R console:
 > remDr <- remoteDriver(remoteServerAddr = "localhost", port = L, 
 > browserName = "chrome")

and then the following:
> remDr$open

It gives me the following error:

[1] "Connecting to remote server"

Selenium message:Unable to create new service: ChromeDriverService
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: 
'2019-07-01T21:30:10'
System info: host: 'EC2AMAZ-1JRGETJ', ip: '172.31.9.48', os.name: 'Windows 
Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: driver.version: unknown

Error:   Summary: SessionNotCreatedException
 Detail: A new session could not be created.
 Further Details: run errorDetails method

Please note that I'm fine with using rsDriver. What's going on? (I'm using 
remoteDriver instaed of rsDriver because it should not give the "port already 
in use" error.

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[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 lm Giving Wrong Results

2021-12-03 Thread Labone, Thomas
Two of the machines having the problem are AVX-512 capable (e.g., i7-7820X) but 
another one is an old Samsung Series 5 with an i5-3317U. I guess I will start 
with the folks at Linux Mint.

Tom


Thomas R. LaBone
PhD student
Department of Epidemiology and Biostatistics
Arnold School of Public Health
University of South Carolina
Columbia, South Carolina USA




From: Sarah Goslee 
Sent: Friday, December 3, 2021 11:00 AM
To: Labone, Thomas 
Cc: Bill Dunlap ; r-help@r-project.org 

Subject: Re: [R] Problem with lm Giving Wrong Results

It might also be a BLAS+processor problem - I got bit pretty hard by
that, with an example here:

https://stat.ethz.ch/pipermail/r-help/2019-July/463477.html

With a key excerpt here:

On Thu, Jul 18, 2019 at 1:59 PM Ivan Krylov  wrote:
> Yes, this might be bad. I have heard about OpenBLAS (specifically, the
> matrix product routine) misbehaving on certain AVX-512 capable
> processors, so much that they had to disable some optimizations in
> 0.3.6 [*], which you already have installed. Still, would `env
> OPENBLAS_CORETYPE=Haswell R --vanilla` give a better result?
>

On Fri, Dec 3, 2021 at 10:29 AM Labone, Thomas  wrote:
>
> Thanks for the feedback everyone. If you go to 
> https://protect2.fireeye.com/v1/url?k=f8bdd2b7-a726ea7c-f8bd9c76-86ce7c8b8969-1acf41b3a3825b65=1=05c346dc-4f60-4e2e-ada8-1abaa8792515=https%3A%2F%2Fgithub.com%2Fcsantill%2FRPerformanceWBLAS%2Fblob%2Fmaster%2FRPerformanceBLAS.md
>  you will find the Linux commands to change the default math library. When I 
> switch the BLAS library from MKL to the system default (see sessionInfo 
> below), everything works as expected. I installed version 2020.0-166-1 of 
> "Intel-MKL" from the Linux Mint Software Manager. I may be coming to a hasty 
> conclusion, but there appears to be something wrong with that package or how 
> it interacts with other system software. Any suggestions on who I should 
> notify about the problem (e.g., Intel, Mint, Ubuntu)?
>
> R version 4.1.2 (2021-11-01)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Linux Mint 20.2
>
> Matrix products: default
> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
> LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C   LC_TIME=en_US.UTF-8
>  [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
> LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C  LC_ADDRESS=C
> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_4.1.2 tools_4.1.2
>
>
>
> Thomas R. LaBone
> PhD student
> Department of Epidemiology and Biostatistics
> Arnold School of Public Health
> University of South Carolina
> Columbia, South Carolina USA
>
>
>
> ________
> From: Labone, Thomas 
> Sent: Thursday, December 2, 2021 11:53 AM
> To: Bill Dunlap 
> Cc: r-help@r-project.org 
> Subject: Re: [R] Problem with lm Giving Wrong Results
>
> > summary(fit)
>
> Call:
> lm(formula = log(k) ~ Z)
>
> Residuals:
> Min  1Q  Median  3Q Max
> -21.241   1.327   1.776   2.245   4.418
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) -0.034650.01916  -1.809   0.0705 .
> Z   -0.242070.01916 -12.634   <2e-16 ***
> ---
> Signif. codes:  0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
>
> Residual standard error: 1.914 on 9998 degrees of freedom
> Multiple R-squared:  0.01467, Adjusted R-squared:  0.01457
> F-statistic: 148.8 on 1 and 9998 DF,  p-value: < 2.2e-16
>
> > summary(k)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
>  0.2735  3.7658  5.9052  7.5113  9.4399 82.9531
> > summary(Z)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
> -3.8906 -0.6744  0.  0.  0.6744  3.8906
> > summary(gm*gsd^Z)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
>  0.3767  0.8204  0.9659  0.9947  1.1372  2.4772
> >
>
>
> Thomas R. LaBone
> PhD student
> Department of Epidemiology and Biostatistics
> Arnold School of Public Health
> University of South Carolina
> Columbia, South Carolina USA
>
>
> 
> From: Bill Dunlap 
> Sent: Thursday, December 2, 2021 10:31 AM
> To: Labone, Thomas 
> Cc: r-help@r-project.org 
> Subject: Re: [R] Problem with lm Giving Wrong Results
>
> On the 'bad' machines, what did you get for
>summary(fit)
>summary(k)
>summary(Z)
>summary(gm*gsd^Z)
> ?
>
> -Bill
>

Re: [R] Problem with lm Giving Wrong Results

2021-12-03 Thread Sarah Goslee
It might also be a BLAS+processor problem - I got bit pretty hard by
that, with an example here:

https://stat.ethz.ch/pipermail/r-help/2019-July/463477.html

With a key excerpt here:

On Thu, Jul 18, 2019 at 1:59 PM Ivan Krylov  wrote:
> Yes, this might be bad. I have heard about OpenBLAS (specifically, the
> matrix product routine) misbehaving on certain AVX-512 capable
> processors, so much that they had to disable some optimizations in
> 0.3.6 [*], which you already have installed. Still, would `env
> OPENBLAS_CORETYPE=Haswell R --vanilla` give a better result?
>

On Fri, Dec 3, 2021 at 10:29 AM Labone, Thomas  wrote:
>
> Thanks for the feedback everyone. If you go to 
> https://github.com/csantill/RPerformanceWBLAS/blob/master/RPerformanceBLAS.md 
> you will find the Linux commands to change the default math library. When I 
> switch the BLAS library from MKL to the system default (see sessionInfo 
> below), everything works as expected. I installed version 2020.0-166-1 of 
> "Intel-MKL" from the Linux Mint Software Manager. I may be coming to a hasty 
> conclusion, but there appears to be something wrong with that package or how 
> it interacts with other system software. Any suggestions on who I should 
> notify about the problem (e.g., Intel, Mint, Ubuntu)?
>
> R version 4.1.2 (2021-11-01)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Linux Mint 20.2
>
> Matrix products: default
> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
> LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C   LC_TIME=en_US.UTF-8
>  [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
> LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C  LC_ADDRESS=C
> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_4.1.2 tools_4.1.2
>
>
>
> Thomas R. LaBone
> PhD student
> Department of Epidemiology and Biostatistics
> Arnold School of Public Health
> University of South Carolina
> Columbia, South Carolina USA
>
>
>
> ________
> From: Labone, Thomas 
> Sent: Thursday, December 2, 2021 11:53 AM
> To: Bill Dunlap 
> Cc: r-help@r-project.org 
> Subject: Re: [R] Problem with lm Giving Wrong Results
>
> > summary(fit)
>
> Call:
> lm(formula = log(k) ~ Z)
>
> Residuals:
> Min  1Q  Median  3Q Max
> -21.241   1.327   1.776   2.245   4.418
>
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) -0.034650.01916  -1.809   0.0705 .
> Z   -0.242070.01916 -12.634   <2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 1.914 on 9998 degrees of freedom
> Multiple R-squared:  0.01467, Adjusted R-squared:  0.01457
> F-statistic: 148.8 on 1 and 9998 DF,  p-value: < 2.2e-16
>
> > summary(k)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
>  0.2735  3.7658  5.9052  7.5113  9.4399 82.9531
> > summary(Z)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
> -3.8906 -0.6744  0.  0.  0.6744  3.8906
> > summary(gm*gsd^Z)
>Min. 1st Qu.  MedianMean 3rd Qu.Max.
>  0.3767  0.8204  0.9659  0.9947  1.1372  2.4772
> >
>
>
> Thomas R. LaBone
> PhD student
> Department of Epidemiology and Biostatistics
> Arnold School of Public Health
> University of South Carolina
> Columbia, South Carolina USA
>
>
> 
> From: Bill Dunlap 
> Sent: Thursday, December 2, 2021 10:31 AM
> To: Labone, Thomas 
> Cc: r-help@r-project.org 
> Subject: Re: [R] Problem with lm Giving Wrong Results
>
> On the 'bad' machines, what did you get for
>summary(fit)
>summary(k)
>summary(Z)
>summary(gm*gsd^Z)
> ?
>
> -Bill
>
> On Thu, Dec 2, 2021 at 6:18 AM Labone, Thomas 
> mailto:lab...@email.sc.edu>> wrote:
> In the code below the first and second plots should look pretty much the 
> same, the only difference being that the first has n=1000 points and the 
> second n=1 points. On two of my Linux machines (info below) the second 
> plot is a horizontal line (incorrect answer from lm), but on my Windows 10 
> machine and a third Linux machine it works as expected. The interesting thing 
> is that the code works as expected for n <= 4095 but fails for n>=4096 (which 
> equals 2^12). Can anyone else reproduce this problem? Any ideas on how to fix 
> it?
>
> set.seed(132)
>
>

Re: [R] Problem with lm Giving Wrong Results

2021-12-03 Thread Labone, Thomas
Thanks for the feedback everyone. If you go to 
https://github.com/csantill/RPerformanceWBLAS/blob/master/RPerformanceBLAS.md 
you will find the Linux commands to change the default math library. When I 
switch the BLAS library from MKL to the system default (see sessionInfo below), 
everything works as expected. I installed version 2020.0-166-1 of "Intel-MKL" 
from the Linux Mint Software Manager. I may be coming to a hasty conclusion, 
but there appears to be something wrong with that package or how it interacts 
with other system software. Any suggestions on who I should notify about the 
problem (e.g., Intel, Mint, Ubuntu)?

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.2

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so

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

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

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



Thomas R. LaBone
PhD student
Department of Epidemiology and Biostatistics
Arnold School of Public Health
University of South Carolina
Columbia, South Carolina USA




From: Labone, Thomas 
Sent: Thursday, December 2, 2021 11:53 AM
To: Bill Dunlap 
Cc: r-help@r-project.org 
Subject: Re: [R] Problem with lm Giving Wrong Results

> summary(fit)

Call:
lm(formula = log(k) ~ Z)

Residuals:
Min  1Q  Median  3Q Max
-21.241   1.327   1.776   2.245   4.418

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.034650.01916  -1.809   0.0705 .
Z   -0.242070.01916 -12.634   <2e-16 ***
---
Signif. codes:  0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1

Residual standard error: 1.914 on 9998 degrees of freedom
Multiple R-squared:  0.01467, Adjusted R-squared:  0.01457
F-statistic: 148.8 on 1 and 9998 DF,  p-value: < 2.2e-16

> summary(k)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 0.2735  3.7658  5.9052  7.5113  9.4399 82.9531
> summary(Z)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
-3.8906 -0.6744  0.  0.  0.6744  3.8906
> summary(gm*gsd^Z)
   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 0.3767  0.8204  0.9659  0.9947  1.1372  2.4772
>


Thomas R. LaBone
PhD student
Department of Epidemiology and Biostatistics
Arnold School of Public Health
University of South Carolina
Columbia, South Carolina USA



From: Bill Dunlap 
Sent: Thursday, December 2, 2021 10:31 AM
To: Labone, Thomas 
Cc: r-help@r-project.org 
Subject: Re: [R] Problem with lm Giving Wrong Results

On the 'bad' machines, what did you get for
   summary(fit)
   summary(k)
   summary(Z)
   summary(gm*gsd^Z)
?

-Bill

On Thu, Dec 2, 2021 at 6:18 AM Labone, Thomas 
mailto:lab...@email.sc.edu>> wrote:
In the code below the first and second plots should look pretty much the same, 
the only difference being that the first has n=1000 points and the second 
n=1 points. On two of my Linux machines (info below) the second plot is a 
horizontal line (incorrect answer from lm), but on my Windows 10 machine and a 
third Linux machine it works as expected. The interesting thing is that the 
code works as expected for n <= 4095 but fails for n>=4096 (which equals 2^12). 
Can anyone else reproduce this problem? Any ideas on how to fix it?

set.seed(132)

#~~~
# This works
n <- 1000# OK <= 4095
Z <- qnorm(ppoints(n))

k <- sort(rlnorm(n,log(2131),log(1.61)) / rlnorm(n,log(355),log(1.61)))

quantile(k,probs=c(0.025,0.5,0.975))
summary(k)

fit <- lm(log(k) ~ Z)
summary(fit)

gm <- exp(coef(fit)[1])
gsd <- exp(coef(fit)[2])
gm
gsd

plot(Z,k,log="y",xlim=c(-4,4),ylim=c(0.1,100))
lines(Z,gm*gsd^Z,col="red")

#~~~
#this does not
n <- 1# fails >= 4096 = 2^12
Z <- qnorm(ppoints(n))

k <- sort(rlnorm(n,log(2131),log(1.61)) / rlnorm(n,log(355),log(1.61)))

quantile(k,probs=c(0.025,0.5,0.975))
summary(k)

fit <- lm(log(k) ~ Z)
summary(fit)

gm <- exp(coef(fit)[1])
gsd <- exp(coef(fit)[2])
gm
gsd

plot(Z,k,log="y",xlim=c(-4,4),ylim=c(0.1,100))
lines(Z,gm*gsd^Z,col="red")


#~~~
> sessionInfo() #for two Linux machines having problem
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.2

  1   2   3   4   5   6   7   8   9   10   >