Re: [R] readxl/lifecycle/rlang

2021-12-01 Thread Jeff Newmiller
This

>package ‘rlang’ successfully unpacked and MD5 sums checked
>Warning in install.packages :
>  cannot remove prior installation of package ‘rlang’

indicates that rlang didn't get re-installed. It is a warning because R seems 
to think it could still be working, but it isn't verifying that status.

Below that,

>ERROR: dependency 'rlang' is not available for package 'lifecycle'

indicates that there is still a problem with rlang.

The "cannot remove prior installation" often means that the installed package 
is open, or you have some other program (File Manager?) holding one of the 
directories open. Be sure to shut down all but one instance of R before 
modifying your package library.

It is also possible that anti-virus software is being overly protective.

And DONT keep bashing on the package that depends on rlang... install the one 
that was at the root of the problem: rlang. Only after that succeeds should you 
go back and try lifecycle. Once that one works, try installing/updating readxl 
again.


On December 1, 2021 1:38:37 PM PST, Dennis Weygand  wrote:
>I have been using read_excel for years... suddenly today I have this
>problem:
>
>> T1 <- read_excel(fname,sheet="T1")
>Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
>:
>  there is no package called ‘lifecycle’
>
>So I install lifecycle:
>
>install.packages("lifecycle")
>WARNING: Rtools is required to build R packages but is not currently
>installed. Please download and install the appropriate version of Rtools
>before proceeding:
>
>https://cran.rstudio.com/bin/windows/Rtools/
>Installing package into ‘C:/Users/dennisweygand/Documents/R/win-library/3.5’
>(as ‘lib’ is unspecified)
>also installing the dependency ‘rlang’
>
>
>  There are binary versions available but the source versions are later:
>  binary source needs_compilation
>rlang  0.4.5 0.4.12  TRUE
>lifecycle  0.2.0  1.0.1 FALSE
>
>  Binaries will be installed
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.4.5.zip
>'
>Content type 'application/zip' length 1115838 bytes (1.1 MB)
>downloaded 1.1 MB
>
>package ‘rlang’ successfully unpacked and MD5 sums checked
>Warning in install.packages :
>  cannot remove prior installation of package ‘rlang’
>
>The downloaded binary packages are in
>C:\Users\dennisweygand\AppData\Local\Temp\RtmpKSler3\downloaded_packages
>installing the source package ‘lifecycle’
>
>trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.1.tar.gz'
>Content type 'application/x-gzip' length 99716 bytes (97 KB)
>downloaded 97 KB
>
>ERROR: dependency 'rlang' is not available for package 'lifecycle'
>* removing 'C:/Users/dennisweygand/Documents/R/win-library/3.5/lifecycle'
>In R CMD INSTALL
>Warning in install.packages :
>  installation of package ‘lifecycle’ had non-zero exit status
>
>The downloaded source packages are in
>‘C:\Users\dennisweygand\AppData\Local\Temp\RtmpKSler3\downloaded_packages’
>
>
>Did it work?
>Try it again:
>
>> T1 <- read_excel(fname,sheet="T1")
>Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
>:
>  there is no package called ‘lifecycle’
>
>I am clueless: what am I doing wrong?
>Can anyone help?
>D.P. Weygand
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


[R] readxl/lifecycle/rlang

2021-12-01 Thread Dennis Weygand
I have been using read_excel for years... suddenly today I have this
problem:

> T1 <- read_excel(fname,sheet="T1")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
:
  there is no package called ‘lifecycle’

So I install lifecycle:

install.packages("lifecycle")
WARNING: Rtools is required to build R packages but is not currently
installed. Please download and install the appropriate version of Rtools
before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/dennisweygand/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependency ‘rlang’


  There are binary versions available but the source versions are later:
  binary source needs_compilation
rlang  0.4.5 0.4.12  TRUE
lifecycle  0.2.0  1.0.1 FALSE

  Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.4.5.zip
'
Content type 'application/zip' length 1115838 bytes (1.1 MB)
downloaded 1.1 MB

package ‘rlang’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  cannot remove prior installation of package ‘rlang’

The downloaded binary packages are in
C:\Users\dennisweygand\AppData\Local\Temp\RtmpKSler3\downloaded_packages
installing the source package ‘lifecycle’

trying URL 'https://cran.rstudio.com/src/contrib/lifecycle_1.0.1.tar.gz'
Content type 'application/x-gzip' length 99716 bytes (97 KB)
downloaded 97 KB

ERROR: dependency 'rlang' is not available for package 'lifecycle'
* removing 'C:/Users/dennisweygand/Documents/R/win-library/3.5/lifecycle'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘lifecycle’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\dennisweygand\AppData\Local\Temp\RtmpKSler3\downloaded_packages’


Did it work?
Try it again:

> T1 <- read_excel(fname,sheet="T1")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
:
  there is no package called ‘lifecycle’

I am clueless: what am I doing wrong?
Can anyone help?
D.P. Weygand

[[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] help

2021-12-01 Thread Jim Lemon
Hi mehdi,
Try this (first example in the help page):

ref<-rnorm(30,sd=2)
 # add a little noise
 model1<-ref+rnorm(30)/2
 # add more noise
 model2<-ref+rnorm(30)
 # display the diagram with the better model
 oldpar<-taylor.diagram(ref,model1)
 # now add the worse model
 taylor.diagram(ref,model2,add=TRUE,col="blue")
 # get approximate legend position
 lpos<-1.5*sd(ref)
 # add a legend
 legend(lpos,lpos,legend=c("Better","Worse"),pch=19,col=c("red","blue"))
 # now restore par values
 par(oldpar)

What you have done is to leave out the "reference" model (ref), so
that the second argument is missing.

Jim

On Wed, Dec 1, 2021 at 7:29 PM mehdi ghasemi  wrote:
>
> Hi Dr
>
> If we want to draw two plots only in a Taylor diagram ,What  the  attached  
> code should be modified ?
> thanks

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


Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Bert Gunter
"As to obtaining min or max of columns, such a question is nonsensical
when the column contains character data,"

That is false.

First, if it's plain (unclassed) character data, character data is
sorted lexicographically, which depends on the locale, as Petr already
pointed out.

Perhaps more useful, however, is that of the character data has been
classed as an *ordered* factor, then max, min, and range are all
meaningfully interpreted for it according to the ordering:

> z <- ordered(sample(letters[1:3], 10,rep = TRUE), levels = c('c','a','b'))
> z
 [1] a a c b b c a a b c
Levels: c < a < b
> max(z)
[1] b
Levels: c < a < b
> min(z)
[1] c
Levels: c < a < b
> range(z)
[1] c b
Levels: c < a < b
> sort(z)
 [1] c c c a a a a b b b
Levels: c < a < b
### etc.

See ?ordered for details, and particularly note:
"There are "factor" and "ordered" methods for the group generic Ops
which provide methods for the Comparison operators, and for the min,
max, and range generics in Summary of "ordered". (The rest of the
groups and the Math group generate an error as they are not meaningful
for factors.)"

(You would have to go down a rabbit hole to learn about group generics
for S3 classes, but I think you can ignore those details for the
purposes here).

Bert Gunter

Bert Gunter

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


On Wed, Dec 1, 2021 at 8:41 AM Jeff Newmiller  wrote:
>
> Avi: As I understand it, the definition regarding what is on-topic is not 
> targeted at tidyverse... it addresses the futility of trying to support the 
> thousands of problem domains represented by contributed packages in one 
> mailing list without drowning the subscribers in discussions about problem 
> domains they are not interested in. This mailing list happens to be about the 
> R language, and extends as far as the packages included with the R language. 
> Tidyverse just happens to be outside this scope (though some here are more 
> opposed to using it than others and express that sentiment in their 
> responses).
>
> Stephen: As to obtaining min or max of columns, such a question is 
> nonsensical when the column contains character data, and mostly nonsensical 
> when the data are binary regardless of what package you are using. From this 
> perspective, it only makes sense to look at extremes on numeric columns 
> selected from the data after they are loaded into a data frame.
>
> dta <- read.csv( "yourdata.csv" )
> dta_num <- dta[ , c("Elapsed_Time", "Age" ) ]
>
> I don't know this package Rfast or its functions, but I would imagine that 
> you could then use
>
> dta_maxs <- colMaxs( as.matrix( dta_num ) )
>
> which might be a few microseconds faster than a typical base R solution:
>
> dta_maxs <- apply( dta_num, 2, max )
>
> which works fine without loading a special package for this rather basic 
> functionality.
>
> Sometimes packages get developed to meet unusual needs (thousands of columns) 
> or while chasing an optimization that turns out to be marginal (the real time 
> sink may be in converting a data frame into a matrix so the compiled C code 
> can then process it a smidge quicker), and none of this should be interfering 
> in your learning of R but you end up following biased blogs or package 
> vignettes that may or may not deliver on their promise to simplify your tasks.
>
> Some aspects of tidyverse are quite effective and I use them regularly... but 
> there are a lot of these less valuable contributions also that are 
> distractions or are best for corner cases. You can only figure out the 
> difference by learning the basics first and comparing approaches (sometimes a 
> package that requires you to manually convert to matrix is a good idea, but 
> sometimes it is just a pain) for usefulness and/or speed (e.g. using the 
> microbenchmark contributed package).
>
> On November 30, 2021 7:42:35 PM PST, Avi Gross via R-help 
>  wrote:
> >Stephen,
> >
> >Although what is in the STANDARD R distribution can vary several ways, in
> >general, if you need to add a line like:
> >
> >library(something)
> >or
> >require(something)
> >
> >and your code does not work unless you have done that, then you can imagine
> >it is not sort of built in to R as it starts.
> >
> >Having said that, tons of exceptions may exist that cause R to load in
> >things on your machine for everyone or just for you without you having to
> >notice.
> >
> >I think this forum lately has been deluged with questions about all kinds of
> >add-on packages and in particular, lots of the ones in the tidyverse.
> >Clearly the purpose here is not that broad.
> >
> >But since I use some packages like the tidyverse extensively, and I am far
> >from alone, I wonder if someday the powers that be realize it is a losing
> >battle to exclude at least some of it. It would be so nice not having to
> >include a long list of packages 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Thanks, Avi.

Yes, loading packages by library command is necessary to access a 
function not resident in the standard R code.


The data set I am reviewing has column names changing. The thought is to 
do a review of max and min for whatever the column names happen to be 
for the data input I am reviewing.



*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 10:42 PM, Avi Gross via R-help wrote:

Stephen,

Although what is in the STANDARD R distribution can vary several ways, in
general, if you need to add a line like:

library(something)
or
require(something)

and your code does not work unless you have done that, then you can imagine
it is not sort of built in to R as it starts.

Having said that, tons of exceptions may exist that cause R to load in
things on your machine for everyone or just for you without you having to
notice.

I think this forum lately has been deluged with questions about all kinds of
add-on packages and in particular, lots of the ones in the tidyverse.
Clearly the purpose here is not that broad.

But since I use some packages like the tidyverse extensively, and I am far
from alone, I wonder if someday the powers that be realize it is a losing
battle to exclude at least some of it. It would be so nice not having to
include a long list of packages for some programs or somehow arrange that
people using something you shared had installed and loaded them. But there
are too many packages out there of varying quality and usefulness and
popularity with more every day being added. Worse, many are somewhat
incompatible such as having functions with the same names that hide earlier
ones loaded.

Base R doe come with functions like colSums and colMeans and similar row
functions. But as mentioned, a data.frame is a list of vectors and R
supports certain functional programming constructs over lists using things
like:

lapply(df, min)
sapply(df, min)

And actually quite a few ways depending on what info you want back and
whether you insist it be returned as a list or vector or other things . You
can even supply additional arguments that might be needed such as if you
want to ignore any NA values,

lapply(df, min, na.rm=TRUE

The package you looked at it is trying to be fast and uses what looks like
compiled external code but so does lapply.

If this is too bothersome for you, consider making a one-liner function like
this:

mycolMins <- function(df, ...) lapply(df, min, ...)

Once defined, you can use that just fine and not think about it again and I
note this answer (like others) is offering you something in base R that
works fine on data.frames and the like.

You can extend to many similar ideas like this one that calulates the min
unless you over-ride it with max or mean or sd or a bizarre function like
`[` so a call to:

mycolCalc(df, `[`, 3)

Will return exactly the third items in each row!

I find it to be very common for someone these days to do a quick search for
a way to do something in a language like R and not really look to see if it
is a standard way or something special/ Matrices in R are not quite the same
as some other objects like a data.frame or tibble and a package written to
be used on one may (or may not) happen to work with another. Some packages
are carefully written to try to detect what kind of object it gets and when
possible convert it to another. The "apply" function is meant for matrices
but if it sees something else it looks ta the dimensionality and tries to
coerce it with as.matrix or as.array first. As others have noted, this mean
a data.frame containing non-numeric parts may fail or should have any other
columns hidden/removed as in this df that has some non-numeric fields:


df

i   s   f b i2
1 1   hello 1.2  TRUE  5
2 2   there 2.3 FALSE  4
3 3 goodbye 3.4  TRUE  3

So a bit more complex one-liner removes any non-numeric columns like this:


mycolMins(df[, sapply(df, is.numeric)])

$i
[1] 1

$f
[1] 1.2

$i2
[1] 3

Clearly converting that to a matrix while whole would result in everything
being converted to character and a minimum may be elusive.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Tuesday, November 30, 2021 5:37 PM
To: Bert Gunter 
Cc: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Oh, you are segmenting standard R from the rest of R.

Well, that part did not come across to me in your original reply. I am not
clear on a standard versus non-standard list. I will look into this aspect
and see what I can learn going forward.


Thanks,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:26 PM, Bert Gunter wrote:

... but Rfast is *not* a "standard" package, as the rest of the PG
excerpt says. So contact the maintainer and ask him/her what they
think 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Thank you, Petr, for the kind explanation.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 12/1/21 11:19 AM, PIKAL Petr wrote:

Hi.

It is always worth to consult excellent R help.

max and min return the maximum or minimum of all the values present in their 
arguments, as integer if all are logical or integer, as double if all are 
numeric, and character otherwise.

Character versions are sorted lexicographically, and this depends on the collating sequence of the 
locale in use: the help for ‘Comparison’ gives details. The max/min of an empty character vector is 
defined to be character NA. (One could argue that as "" is the smallest character 
element, the maximum should be "", but there is no obvious candidate for the minimum.)

Cheers
Petr


-Original Message-
From: R-help  On Behalf Of Stephen H.
Dawson, DSL via R-help
Sent: Wednesday, December 1, 2021 5:11 PM
To: r-help@r-project.org
Subject: Re: [R] Question about Rfast colMins and colMaxs

Jeff,

Can you use max and min evaluations on any other data type then numeric?
If so, how do you evaluate max or min of text content? String length?
Ascii values of text characters?


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:

Well, no it is not. The email list stripped off the attachment.

The data is numeric, happens to be all whole numbers.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:29 PM, Jeff Newmiller wrote:

I don't know anything about this package, but read.csv returns a
data frame. How you go about forming a matrix using that data frame
depends what is in it. If it is all numeric then as.matrix may be
all you need.

Half of any R data analysis is data... and the details are almost
always crucial. Since you have told us nothing useful about the
data, it is up to you to inspect your data and figure out what to do
with it.

On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via
R-help"  wrote:

Hi,


I am working to understand the Rfast functions of colMins and
colMaxs. I worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF
saying I need to bring data into R using a matrix. I think read.csv
brings the data in as a dataframe. I think colMins is failing
because it is looking for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it
can be accessed by colMaxs and colMins, please?


Thanks,

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


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


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


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


Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Hi Jeff,


Thanks for the reply.

Your attitude in your writing is terse.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 12/1/21 11:31 AM, Jeff Newmiller wrote:

Avi: As I understand it, the definition regarding what is on-topic is not 
targeted at tidyverse... it addresses the futility of trying to support the 
thousands of problem domains represented by contributed packages in one mailing 
list without drowning the subscribers in discussions about problem domains they 
are not interested in. This mailing list happens to be about the R language, 
and extends as far as the packages included with the R language. Tidyverse just 
happens to be outside this scope (though some here are more opposed to using it 
than others and express that sentiment in their responses).

Stephen: As to obtaining min or max of columns, such a question is nonsensical 
when the column contains character data, and mostly nonsensical when the data 
are binary regardless of what package you are using. From this perspective, it 
only makes sense to look at extremes on numeric columns selected from the data 
after they are loaded into a data frame.

 dta <- read.csv( "yourdata.csv" )
 dta_num <- dta[ , c("Elapsed_Time", "Age" ) ]

I don't know this package Rfast or its functions, but I would imagine that you 
could then use

 dta_maxs <- colMaxs( as.matrix( dta_num ) )

which might be a few microseconds faster than a typical base R solution:

 dta_maxs <- apply( dta_num, 2, max )

which works fine without loading a special package for this rather basic 
functionality.

Sometimes packages get developed to meet unusual needs (thousands of columns) 
or while chasing an optimization that turns out to be marginal (the real time 
sink may be in converting a data frame into a matrix so the compiled C code can 
then process it a smidge quicker), and none of this should be interfering in 
your learning of R but you end up following biased blogs or package vignettes 
that may or may not deliver on their promise to simplify your tasks.

Some aspects of tidyverse are quite effective and I use them regularly... but 
there are a lot of these less valuable contributions also that are distractions 
or are best for corner cases. You can only figure out the difference by 
learning the basics first and comparing approaches (sometimes a package that 
requires you to manually convert to matrix is a good idea, but sometimes it is 
just a pain) for usefulness and/or speed (e.g. using the microbenchmark 
contributed package).

On November 30, 2021 7:42:35 PM PST, Avi Gross via R-help 
 wrote:

Stephen,

Although what is in the STANDARD R distribution can vary several ways, in
general, if you need to add a line like:

library(something)
or
require(something)

and your code does not work unless you have done that, then you can imagine
it is not sort of built in to R as it starts.

Having said that, tons of exceptions may exist that cause R to load in
things on your machine for everyone or just for you without you having to
notice.

I think this forum lately has been deluged with questions about all kinds of
add-on packages and in particular, lots of the ones in the tidyverse.
Clearly the purpose here is not that broad.

But since I use some packages like the tidyverse extensively, and I am far

>from alone, I wonder if someday the powers that be realize it is a losing

battle to exclude at least some of it. It would be so nice not having to
include a long list of packages for some programs or somehow arrange that
people using something you shared had installed and loaded them. But there
are too many packages out there of varying quality and usefulness and
popularity with more every day being added. Worse, many are somewhat
incompatible such as having functions with the same names that hide earlier
ones loaded.

Base R doe come with functions like colSums and colMeans and similar row
functions. But as mentioned, a data.frame is a list of vectors and R
supports certain functional programming constructs over lists using things
like:

lapply(df, min)
sapply(df, min)

And actually quite a few ways depending on what info you want back and
whether you insist it be returned as a list or vector or other things . You
can even supply additional arguments that might be needed such as if you
want to ignore any NA values,

lapply(df, min, na.rm=TRUE

The package you looked at it is trying to be fast and uses what looks like
compiled external code but so does lapply.

If this is too bothersome for you, consider making a one-liner function like
this:

mycolMins <- function(df, ...) lapply(df, min, ...)

Once defined, you can use that just fine and not think about it again and I
note this answer (like others) is offering you something in base R that
works fine on data.frames and the like.

You can extend to many similar ideas like this one that calulates the 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Jeff Newmiller
Avi: As I understand it, the definition regarding what is on-topic is not 
targeted at tidyverse... it addresses the futility of trying to support the 
thousands of problem domains represented by contributed packages in one mailing 
list without drowning the subscribers in discussions about problem domains they 
are not interested in. This mailing list happens to be about the R language, 
and extends as far as the packages included with the R language. Tidyverse just 
happens to be outside this scope (though some here are more opposed to using it 
than others and express that sentiment in their responses).

Stephen: As to obtaining min or max of columns, such a question is nonsensical 
when the column contains character data, and mostly nonsensical when the data 
are binary regardless of what package you are using. From this perspective, it 
only makes sense to look at extremes on numeric columns selected from the data 
after they are loaded into a data frame.

dta <- read.csv( "yourdata.csv" )
dta_num <- dta[ , c("Elapsed_Time", "Age" ) ]

I don't know this package Rfast or its functions, but I would imagine that you 
could then use

dta_maxs <- colMaxs( as.matrix( dta_num ) )

which might be a few microseconds faster than a typical base R solution:

dta_maxs <- apply( dta_num, 2, max )

which works fine without loading a special package for this rather basic 
functionality.

Sometimes packages get developed to meet unusual needs (thousands of columns) 
or while chasing an optimization that turns out to be marginal (the real time 
sink may be in converting a data frame into a matrix so the compiled C code can 
then process it a smidge quicker), and none of this should be interfering in 
your learning of R but you end up following biased blogs or package vignettes 
that may or may not deliver on their promise to simplify your tasks.

Some aspects of tidyverse are quite effective and I use them regularly... but 
there are a lot of these less valuable contributions also that are distractions 
or are best for corner cases. You can only figure out the difference by 
learning the basics first and comparing approaches (sometimes a package that 
requires you to manually convert to matrix is a good idea, but sometimes it is 
just a pain) for usefulness and/or speed (e.g. using the microbenchmark 
contributed package).

On November 30, 2021 7:42:35 PM PST, Avi Gross via R-help 
 wrote:
>Stephen,
>
>Although what is in the STANDARD R distribution can vary several ways, in
>general, if you need to add a line like:
>
>library(something)
>or
>require(something)
>
>and your code does not work unless you have done that, then you can imagine
>it is not sort of built in to R as it starts.
>
>Having said that, tons of exceptions may exist that cause R to load in
>things on your machine for everyone or just for you without you having to
>notice.
>
>I think this forum lately has been deluged with questions about all kinds of
>add-on packages and in particular, lots of the ones in the tidyverse.
>Clearly the purpose here is not that broad.
>
>But since I use some packages like the tidyverse extensively, and I am far
>from alone, I wonder if someday the powers that be realize it is a losing
>battle to exclude at least some of it. It would be so nice not having to
>include a long list of packages for some programs or somehow arrange that
>people using something you shared had installed and loaded them. But there
>are too many packages out there of varying quality and usefulness and
>popularity with more every day being added. Worse, many are somewhat
>incompatible such as having functions with the same names that hide earlier
>ones loaded.
>
>Base R doe come with functions like colSums and colMeans and similar row
>functions. But as mentioned, a data.frame is a list of vectors and R
>supports certain functional programming constructs over lists using things
>like:
>
>lapply(df, min)
>sapply(df, min)
>
>And actually quite a few ways depending on what info you want back and
>whether you insist it be returned as a list or vector or other things . You
>can even supply additional arguments that might be needed such as if you
>want to ignore any NA values,
>
>lapply(df, min, na.rm=TRUE
>
>The package you looked at it is trying to be fast and uses what looks like
>compiled external code but so does lapply.
>
>If this is too bothersome for you, consider making a one-liner function like
>this:
>
>mycolMins <- function(df, ...) lapply(df, min, ...)
>
>Once defined, you can use that just fine and not think about it again and I
>note this answer (like others) is offering you something in base R that
>works fine on data.frames and the like.
>
>You can extend to many similar ideas like this one that calulates the min
>unless you over-ride it with max or mean or sd or a bizarre function like
>`[` so a call to:
>
>mycolCalc(df, `[`, 3)
>
>Will return exactly the third items in each row!
>
>I find it to be very common for 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread PIKAL Petr
Hi.

It is always worth to consult excellent R help.

max and min return the maximum or minimum of all the values present in their 
arguments, as integer if all are logical or integer, as double if all are 
numeric, and character otherwise.

Character versions are sorted lexicographically, and this depends on the 
collating sequence of the locale in use: the help for ‘Comparison’ gives 
details. The max/min of an empty character vector is defined to be character 
NA. (One could argue that as "" is the smallest character element, the maximum 
should be "", but there is no obvious candidate for the minimum.)

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Stephen H.
> Dawson, DSL via R-help
> Sent: Wednesday, December 1, 2021 5:11 PM
> To: r-help@r-project.org
> Subject: Re: [R] Question about Rfast colMins and colMaxs
> 
> Jeff,
> 
> Can you use max and min evaluations on any other data type then numeric?
> If so, how do you evaluate max or min of text content? String length?
> Ascii values of text characters?
> 
> 
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com 
> 
> 
> On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:
> > Well, no it is not. The email list stripped off the attachment.
> >
> > The data is numeric, happens to be all whole numbers.
> >
> >
> > Kindest Regards,
> > *Stephen Dawson, DSL*
> > /Executive Strategy Consultant/
> > Business & Technology
> > +1 (865) 804-3454
> > http://www.shdawson.com 
> >
> >
> > On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:
> >> Hi Jeff,
> >>
> >>
> >> Thanks for the data review offer. Attached is the CSV.
> >>
> >>
> >> *Stephen Dawson, DSL*
> >> /Executive Strategy Consultant/
> >> Business & Technology
> >> +1 (865) 804-3454
> >> http://www.shdawson.com 
> >>
> >>
> >> On 11/30/21 3:29 PM, Jeff Newmiller wrote:
> >>> I don't know anything about this package, but read.csv returns a
> >>> data frame. How you go about forming a matrix using that data frame
> >>> depends what is in it. If it is all numeric then as.matrix may be
> >>> all you need.
> >>>
> >>> Half of any R data analysis is data... and the details are almost
> >>> always crucial. Since you have told us nothing useful about the
> >>> data, it is up to you to inspect your data and figure out what to do
> >>> with it.
> >>>
> >>> On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via
> >>> R-help"  wrote:
>  Hi,
> 
> 
>  I am working to understand the Rfast functions of colMins and
>  colMaxs. I worked through the example listed on page 54 of the PDF.
> 
>  https://cran.r-project.org/web/packages/Rfast/index.html
> 
>  https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
> 
>  My data is in a CSV file. So, I bring it into R Studio using:
>  Data <- read.csv("./input/DataSet05.csv", header=T)
> 
>  However, I read the instructions listed on page 54 of the PDF
>  saying I need to bring data into R using a matrix. I think read.csv
>  brings the data in as a dataframe. I think colMins is failing
>  because it is looking for a matrix but finds a dataframe.
> 
> > colMaxs(Data)
>  Error in colMaxs(Data) :
> Not compatible with requested type: [type=list; target=double].
> > colMins(Data, na.rm = TRUE)
>  Error in colMins(Data, na.rm = TRUE) :
> unused argument (na.rm = TRUE)
> > colMins(Data, value = FALSE, parallel = FALSE)
>  Error in colMins(Data, value = FALSE, parallel = FALSE) :
> Not compatible with requested type: [type=list; target=double].
> 
>  QUESTION
>  What is the best practice to bring a csv file into R Studio so it
>  can be accessed by colMaxs and colMins, please?
> 
> 
>  Thanks,
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org 

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Stephen H. Dawson, DSL via R-help

Jeff,

Can you use max and min evaluations on any other data type then numeric? 
If so, how do you evaluate max or min of text content? String length? 
Ascii values of text characters?



*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:23 PM, Stephen H. Dawson, DSL via R-help wrote:

Well, no it is not. The email list stripped off the attachment.

The data is numeric, happens to be all whole numbers.


Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 5:14 PM, Stephen H. Dawson, DSL via R-help wrote:

Hi Jeff,


Thanks for the data review offer. Attached is the CSV.


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 11/30/21 3:29 PM, Jeff Newmiller wrote:
I don't know anything about this package, but read.csv returns a 
data frame. How you go about forming a matrix using that data frame 
depends what is in it. If it is all numeric then as.matrix may be 
all you need.


Half of any R data analysis is data... and the details are almost 
always crucial. Since you have told us nothing useful about the 
data, it is up to you to inspect your data and figure out what to do 
with it.


On November 30, 2021 10:55:13 AM PST, "Stephen H. Dawson, DSL via 
R-help"  wrote:

Hi,


I am working to understand the Rfast functions of colMins and 
colMaxs. I

worked through the example listed on page 54 of the PDF.

https://cran.r-project.org/web/packages/Rfast/index.html

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf

My data is in a CSV file. So, I bring it into R Studio using:
Data <- read.csv("./input/DataSet05.csv", header=T)

However, I read the instructions listed on page 54 of the PDF saying I
need to bring data into R using a matrix. I think read.csv brings the
data in as a dataframe. I think colMins is failing because it is 
looking

for a matrix but finds a dataframe.


colMaxs(Data)

Error in colMaxs(Data) :
   Not compatible with requested type: [type=list; target=double].

colMins(Data, na.rm = TRUE)

Error in colMins(Data, na.rm = TRUE) :
   unused argument (na.rm = TRUE)

colMins(Data, value = FALSE, parallel = FALSE)

Error in colMins(Data, value = FALSE, parallel = FALSE) :
   Not compatible with requested type: [type=list; target=double].

QUESTION
What is the best practice to bring a csv file into R Studio so it 
can be

accessed by colMaxs and colMins, please?


Thanks,


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

2021-12-01 Thread Jeff Newmiller
Probably some kind of failure occurred during package updating and one or more 
of the packages readxl depends on was removed but not successfully re-installed.

Run

  install.packages( "lifecycle" )

and then

  update.packages()

and try using your function again. If a similar error occurs, repeat for the 
next missing package.

On December 1, 2021 7:30:39 AM PST, Dennis Weygand  wrote:
>I have been using readxl function for years...
>Suddenly, today, I get an error message:
>
>> T1 <- read_excel(fname,sheet="T1")
>Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
>:
>  there is no package called ‘lifecycle’
>
>Does anyone know what has happened?
>D.P. Weygand
>Old Dominion University
>Norfolk, VA
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


[R] readxl

2021-12-01 Thread Dennis Weygand
I have been using readxl function for years...
Suddenly, today, I get an error message:

> T1 <- read_excel(fname,sheet="T1")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])
:
  there is no package called ‘lifecycle’

Does anyone know what has happened?
D.P. Weygand
Old Dominion University
Norfolk, VA

[[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] Syntax help for 'Pivot_longer'

2021-12-01 Thread John Kane
Hi Phillip,

Let's say your original data is in a data.frame called "mydata".

What you want to do is issue de command
dput(mydata)

then just copy the output and paste it into the message.

Here is a very simple example


dat1 <-   data.frame(xx = LETTERS[1:10], yy = 10:1)

dput(dat1)

output to copy and paste===

structure(list(xx = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J"), yy = 10:1), class = "data.frame", row.names = c(NA,
-10L))

=

 If you have a very large data set then something like
head(dput(myfile), 100) will likely supply enough data for us to work
with.


On Mon, 29 Nov 2021 at 05:20, Philip Monk  wrote:
>
> Apologies, all.  No offence was intended.
>
> I'll go away and do a lot more reading and thinking then come back
> with a clearly articulated query if and when that is appropriate.
> I'm out of time this week, so it won't be for some time.
>
> Thank you all for the helpful replies.
>
> Best wishes,
>
> Philip
>
> On Mon, 29 Nov 2021 at 00:31, Jeff Newmiller  wrote:
> >
> > This "data_long" appears to be a mess you are not satisfied with, rather 
> > than the "data" you started with or a model of what you want.
> >
> > On November 28, 2021 9:06:54 AM PST, Philip Monk  wrote:
> > >Thanks for your suggestions, Chris.
> > >
> > >I'm writing from Gmail's web client, and have checked the message is
> > >being sent as plain text (though I also did this previously so it may
> > >be that I need to change to Outlook).  Let me know if it doesn't work.
> > >
> > >Hopefully I've used dput properly (see example below with apologies to
> > >Burt and the PG).   In my defence, I have very limited time due to
> > >caring responsibilities so am time-poor out of necessity rather than
> > >laziness.
> > >
> > >Reading the 'pivot_longer' documentation I think I need to use
> > >'names_pattern' to split the weather data into different columns, but
> > >I don't understand the required syntax.
> > >
> > >Thanks for your help,
> > >
> > >Philip
> > >
> > >rm(list=ls())
> > >library(ggplot2)
> > >library(ggpubr)
> > >library(tidyverse)
> > >library(rstatix)
> > >library(ez)
> > >library(dplyr)
> > >
> > >data_long <-
> > >  structure(
> > >list(
> > >  Buffer = c(
> > >"100",
> > >"200",
> > >"300",
> > >"400",
> > >"500",
> > >"600",
> > >"700",
> > >"800",
> > >"900",
> > >"1000",
> > >"1100",
> > >"1200",
> > >"1300",
> > >"1400",
> > >"1500",
> > >"1600",
> > >"1700",
> > >"1800",
> > >"1900",
> > >"Temperature",
> > >"Wind speed",
> > >"Wind trend",
> > >"Wind direction",
> > >"Humidity",
> > >"Pressure",
> > >"Pressure trend"
> > >  ),
> > >  `15/01/2010` = c(
> > >6.091741043,
> > >5.271975614,
> > >4.451891901,
> > >3.385694303,
> > >2.900508112,
> > >3.110238149,
> > >3.150580922,
> > >3.079728958,
> > >2.327902499,
> > >1.641887823,
> > >1.63370882,
> > >0.986559368,
> > >0.920601397,
> > >0.571882394,
> > >0.340505009,
> > >0.813480877,
> > >0.47192,
> > >0.269067515,
> > >0.303179244,
> > >12,
> > >10,
> > >1,
> > >22.5,
> > >40,
> > >1024,
> > >1
> > >  ),
> > >  `16/02/2010` = c(
> > >6.405879111,
> > >5.994054977,
> > >5.61142085,
> > >4.77953426,
> > >4.305900444,
> > >3.616699448,
> > >2.848148846,
> > >2.016807672,
> > >1.452876728,
> > >2.120099832,
> > >1.661317381,
> > >1.133219897,
> > >1.237239562,
> > >0.93675648,
> > >0.7379146,
> > >1.026085605,
> > >0.566766122,
> > >0.13349775,
> > >0.082892149,
> > >15,
> > >9,
> > >1,
> > >45,
> > >44.5,
> > >1018.5,
> > >1
> > >  ),
> > >  `20/03/2010` = c(
> > >8.925945159,
> > >7.375445078,
> > >6.120095292,
> > >5.608927408,
> > >5.61367474,
> > >4.83992,
> > >4.216782177,
> > >4.05288041,
> > >3.779922823,
> > >4.267840277,
> > >3.747342619,
> > >2.414025636,
> > >2.647100163,
> > >2.272566024,
> > >2.526476424,
> > >2.643863876,
> > >1.290173713,
> > >0.612263766,
> > >0.465457136,
> > >16,
> > >10.5,
> > >1,
> > >67.5,
> > >22,
> > >1025,
> > >1
> > >  ),
> > >  `24/04/2011` = c(
> > >6.278147269,
> > >5.805619599,
> > >5.149985946,
> > >4.542354226,
> > >

Re: [R] Degree symbol as axis label superscript

2021-12-01 Thread Rich Shepard

On Wed, 1 Dec 2021, ani jaya wrote:


one of my solution :
text(x,y,"\u00B0C", cex=1.1, font=2)
it will produce "°C"


Ani,

That's what I did.

Thank you,

Rich

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Degree symbol as axis label superscript [RESOLVED]

2021-12-01 Thread Rich Shepard

On Tue, 30 Nov 2021, David Winsemius wrote:


There's nothing special about following a digit. You can have it follow
anything. Since you were going to need to quote the parentheses anywa,
then have it superscripted above the level of the paren:
plot(1,1, ylab = expression(Temperature~"("^degree*C*")")   )


Thank you, David. I tried something like that missed the correct quoting.

Regards,

Rich

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