Re: [R] Weird R Studio behaviour...

2024-07-09 Thread Stephen H. Dawson, DSL via R-help

I disagree.

UTF-8 is far from new. The IDE cannot fail at the point of not handling 
a known technology without advancing the argument with further messaging.


What happens when you run the same code within R apart from the IDE?

What trace work have you accomplished with this special character in a 
separate test script?


It may be how Windows 10 is handling UTF-8 after the latest update of 
optional packages that Microsoft released last week. Run a test in CMD 
on UTF-8 and see what you discover.



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


On 7/9/24 11:24, Bert Gunter wrote:

I think you should also update R to the latest version, as that *might* be
the source of the problem.

Other may be able to give you a specific diagnosis, but updating R is to a
(reasonably, at least) current version is good practice anyway.

Cheers,
Bert

On Tue, Jul 9, 2024 at 8:11 AM Levent TERLEMEZ via R-help <
r-help@r-project.org> wrote:


Hi,

Have a nice week. First of all, I know this is not R Studio forum but I
want to ask here first, if you all do not mind. Well, I am away from my
computer right now but, I have a strange problem (at least to me). My
script worked perfectly for a year, and today, suddenly stop working
because R Studio begins to warn me about illegal characters in the script.

System is on W 10, and R 3.4.1 is working with R Studio. R Studio is
updated today to the latest one because of this problem with the hope of
resolving the problem (but no luck) and they are used as their default
installation settings. Anyway, the problem example may not be repoducable
right now but if it is, I can give detailed one later.

While the original working code is this (there is no synax error, too in
the code because it was working perfectly until today before updating R
Studio, error also came out before this update as I mensioned before);

legend(c("Kapanış",""20 Günlük,"50 Günlük"),col=c("black"...

The warning is this;

Error: unexpected symbol inside:
" Encoding(kill3) <- "latin1" legend(c(kill1,kill2,"50
G�nl�k"),col=c("black"… and can be solved when converted “ü” to “u”.
Addition to this another solution (at least for me) is this;

kill1<-"Kapanış"
Encoding(kill1) <- "UTF-8" (these two statements are not needed but fort
he sake of code integrity, is applied to it, too. If kill1 is converted to
latin1, this time it is broken)
kill2<-"22 Günlük MA"
Encoding(kill2) <- "latin1"
kill3<-"50 Günlük MA"
Encoding(kill3) <- "latin1"

And also it is set to “ASK” and always “UTF-8” is selected.

But, I also wonder why today and what changed so R Studio stops suddenly
running the script? I can not following up the changes anymore as used to
be and if this is a character set problem, it is coming back again and
again. What is the permenant solution of this? This is like an endless
problem…

With my best regards and thanks for your patience….

Levent Terlemez.




YASAL UYARI: Bu e-postanın içerdiği bilgiler (ekleri de dahil olmak üzere)
gizlidir. Sahibinin onayı olmaksızın içeriği kopyalanamaz, üçüncü kişilere
açıklanamaz veya iletilemez . Bu mesajın gönderilmek istendiği kişi
değilseniz (ya da bu e-postayı yanlışlıkla aldıysanız), lütfen yollayan
kişiyi haberdar ediniz ve mesajı sisteminizden derhal siliniz. Eskişehir
Teknik Üniversitesi, bu mesajın içerdiği bilgilerin doğruluğu veya eksiksiz
olduğu konusunda bir garanti vermemektedir. Bu nedenle, bilgilerin ne
şekilde olursa olsun içeriğinden, iletilmesinden, alınmasından,
saklanmasından Eskişehir Teknik Üniversitesi sorumlu değildir. Bu mesajın
içeriği yazarına ait olup, Eskişehir Teknik Üniversitesi'nin görüşlerini
içermeyebilir. Bu e-posta bizce bilinen tüm bilgisayar virüslerine karşı
taranmıştır.

DISCLAIMER: This e-mail (including any attachments) may contain
confidential and/or privileged information. Copying, disclosure or
distribution of the material in this e-mail without owner authority is
strictly forbidden. If you are not the intended recipient (or have received
this e-mail in error), please notify the sender and delete it from your
system immediately. Eskisehir Technical University makes no warranty as to
the accuracy or completeness of any information contained in this message
and hereby excludes any liability of any kind for the information contained
therein or for the information transmission, reception, storage or use of
such in any way whatsoever. Any opinions expressed in this message are
those of the author and may not necessarily reflect the opinions of
Eskisehir Technical University. This e-mail has been scanned for all
computer viruses known to us.

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

Re: [R] Positron as a tool

2024-06-28 Thread Stephen H. Dawson, DSL via R-help

The gap I see is in the database engine monitoring.

MySQL has discontinued development of Workbench. Percona Monitoring and 
Management seems nice, but not as integrated in IDE as I would prefer.


A Positron tool proposed by the vendor is positioned as a data science 
tool. The ability to know if any R work is killing the DB by overloading 
it is still a missing piece of the IDE picture without running multiple 
code monitoring sections in watch windows.



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


On 6/28/24 11:41, avi.e.gr...@gmail.com wrote:

Just to be clear, Denis, I am not in any way associated with anybody or 
anything and just read about it on a news feed not from POSIT directly.

I am aware it is based on existing functionality and have used possibly similar 
editors for other languages. I did try possibly one touted by Microsoft years 
ago (perhaps what you are referring to) but felt no need to keep using it at 
the time. What I am interested in is hearing from others who have opinions, 
perhaps after having tried it.

And there is a trend I have noted where some development environments have been 
moving towards multiple language support including at times integration between 
languages. RSTUDI, itself, has been supporting a number of languages besides R 
and that is one reason it changed names for the company. What they are offering 
now, and I am not clear what they are adding or changing, looks like an attempt 
to evolve along such lines.

Python versions typically have shipped with a fairly rudimentary IDLE program 
you can use as a sort of editor. Plenty of other add-ons are available 
independently. As noted, RSTUDIO now is such an add-on for python too.

R, as far as I know, has not taken that route and you get just the language 
alone and the community is free to use anything else they want. RSTUDIO is one 
of many but arguably, quite a few here have used it. Many versions are 
currently FREE and some paid versions may have more functionality. I am 
wondering if this new product is going to change things such as fee structures 
or even eventually replace ...


-Original Message-
From: Dénes Tóth 
Sent: Friday, June 28, 2024 7:03 AM
To: avi.e.gr...@gmail.com; r-help@r-project.org
Subject: Re: [R] Positron as a tool

Hi Avi,

I am not sure that the R-help mailing list is a suitable channel for
advertising R-related tools... But given you mentioned Positron
(https://github.com/posit-dev/positron), which is based on VSCode, it is
worth calling out that a free, open-source, community-maintained, very
feature rich R extension
(https://code.visualstudio.com/docs/languages/r) already exists in VS
Code for years.

Regards,
Denes


On 6/28/24 07:10, avi.e.gr...@gmail.com wrote:

This is just an FYI based on a news item I saw tonight.
   
There have been discussions on what editors or environments people can use

when working with R and I personally have mostly been using versions of
RSTUDIO and lately for both R and python. As often noted, RSTUDIO is a
product of a company, currently still largely free and they have some tweaks
that can cause issues.
   
The news article mentions a future project as described below, if anyone is

interested, that may be a nice alternative similar (and based on) what some
use for programming in multiple languages. Again, I am noty suggesting
anyone use it, albeit I plan on trying it out when it is a bit further
along.
   
The current name seems to be Positron, to sort of go with the new name of

the company behind RSTUDIO, which is now Posit. Nothing to do with Asimov's
Positronic Brains, LOL!
   
Here is a reference if anyone is interested.
   
https://www.infoworld.com/article/3715702/maker-of-rstudio-launches-new-r-an

d-python-ide.html
   
   


[[alternative HTML version deleted]]

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


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


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

2023-10-07 Thread Stephen H. Dawson, DSL via R-help

Thanks, Jeff.

So, how do you know in your work if the box you are hitting for data is 
alive in the moment?



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


On 10/7/23 11:26, Jeff Newmiller wrote:

Not really an R question, but some processes are connected to interactive 
terminals (where someone can type) and some are not (because they were created 
and managed by another process). The system call creates a process and controls 
all interactions with that process. You really should not be messing with sudo 
in the background like that.

On October 7, 2023 8:09:25 AM PDT, "Stephen H. Dawson, DSL via R-help" 
 wrote:

Hi,


Getting some data from an older MySQL box. I had an event recently where the 
MySQL box went off-line for maintenance without a prior announcement of service 
disruption.

I decided to add a line on my local version of MySQL as I considered how to 
handle this condition going forward.

system("sudo systemctl status mysql", input = rstudioapi::askForPassword("sudo 
password"))

system("sudo systemctl status mysql",input=readline("Enter Password: "))


Both fail for the same reason, saying I need a terminal.



system("sudo systemctl status mysql", input = rstudioapi::askForPassword("sudo 
password"))

sudo: a terminal is required to read the password; either use the -S option to 
read from standard input or configure an askpass helper
sudo: a password is required



system("sudo systemctl status mysql",input=readline("Enter Password: "))

Enter Password: ***REDACTED***
sudo: a terminal is required to read the password; either use the -S option to 
read from standard input or configure an askpass helper
sudo: a password is required


I can run the code segments for things like ls and pwd. So, there is something 
unique about systemctl and R that is beyond my understanding today.

QUESTIONS
What is so special about systemctl and R in a system syntax statement?

What are some of the best practices to confirm a box I am hitting for data with 
R , either local or across the network, has MySQL up and running?


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] Confirming MySQL Alive

2023-10-07 Thread Stephen H. Dawson, DSL via R-help

Hi,


Getting some data from an older MySQL box. I had an event recently where 
the MySQL box went off-line for maintenance without a prior announcement 
of service disruption.


I decided to add a line on my local version of MySQL as I considered how 
to handle this condition going forward.


system("sudo systemctl status mysql", input = 
rstudioapi::askForPassword("sudo password"))


system("sudo systemctl status mysql",input=readline("Enter Password: "))


Both fail for the same reason, saying I need a terminal.


> system("sudo systemctl status mysql", input = 
rstudioapi::askForPassword("sudo password"))
sudo: a terminal is required to read the password; either use the -S 
option to read from standard input or configure an askpass helper

sudo: a password is required
>



> system("sudo systemctl status mysql",input=readline("Enter Password: "))
Enter Password: ***REDACTED***
sudo: a terminal is required to read the password; either use the -S 
option to read from standard input or configure an askpass helper

sudo: a password is required
>



I can run the code segments for things like ls and pwd. So, there is 
something unique about systemctl and R that is beyond my understanding 
today.


QUESTIONS
What is so special about systemctl and R in a system syntax statement?

What are some of the best practices to confirm a box I am hitting for 
data with R , either local or across the network, has MySQL up and running?



Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] Book Recommendation

2023-08-31 Thread Stephen H. Dawson, DSL via R-help

Thanks, Greg. I appreciate your helpful assistance.


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


On 8/30/23 16:52, Greg Snow wrote:

Stephen,  I see lots of answers with packages and resources, but not
book recommendations.  I have used Introduction to Data Technologies
by Paul Murrell (https://www.stat.auckland.ac.nz/~paul/ItDT/) to teach
SQL and database design and would recommend looking at it as a
possibility.

On Mon, Aug 28, 2023 at 9:47 AM Stephen H. Dawson, DSL via R-help
 wrote:

Good Morning,


I am doing some research to develop a new course where I teach. I am
looking for a book to use in the course content to teach accomplishing
SQL in R.

Does anyone know of a book on this topic to recommend for consideration?


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

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





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


Re: [R] Book Recommendation

2023-08-30 Thread Stephen H. Dawson, DSL via R-help

Thanks, Hadley. I appreciate your helpful assistance.


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


On 8/28/23 18:00, Hadley Wickham wrote:

These days I'd recommend duckdb
(https://cran.r-project.org/web/packages/duckdb/index.html) instead.
It's a similar design to RSQLite (i.e. you don't need a separate
server) but it's designed for the needs of data science.

Hadley

On Tue, Aug 29, 2023 at 9:22 AM Martin Møller Skarbiniks Pedersen
 wrote:

The SQLite is a good database to use.

https://cran.r-project.org/web/packages/RSQLite/vignettes/RSQLite.html

On Mon, Aug 28, 2023, 22:12 Stephen H. Dawson, DSL via R-help <
r-help@r-project.org> wrote:


This is an academic course. The effort now is to nail down the former. I
am pushing against a local db for the students. I prefer they focus on
the get-and-analyze efforts and not db administration efforts.



 [[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] Book Recommendation

2023-08-30 Thread Stephen H. Dawson, DSL via R-help

Thanks, Martin. I appreciate your helpful assistance.


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


On 8/28/23 17:14, Martin Møller Skarbiniks Pedersen wrote:

The SQLite is a good database to use.

https://cran.r-project.org/web/packages/RSQLite/vignettes/RSQLite.html

On Mon, Aug 28, 2023, 22:12 Stephen H. Dawson, DSL via R-help 
 wrote:



This is an academic course. The effort now is to nail down the
former. I
am pushing against a local db for the students. I prefer they
focus on
the get-and-analyze efforts and not db administration efforts.



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

2023-08-30 Thread Stephen H. Dawson, DSL via R-help

Thanks, Bill. I appreciate your helpful assistance.


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


On 8/29/23 00:07, William Michels wrote:

I'm a big fan of the sqldf package by Gabor Grothendieck:

"sqldf: Manipulate R Data Frames Using SQL"
https://CRAN.R-project.org/package=sqldf

The sqldf "README.html" converts to a 42 page PDF:
https://cran.r-project.org/web/packages/sqldf/readme/README.html

You can also find favorable blog posts for the sqldf package on the
web, notably a post (circa 2013) from Patrick Burns:
https://www.burns-stat.com/translating-r-sql-basics/

HTH,

Bill.

W. Michels, Ph.D.



On Mon, Aug 28, 2023 at 8:47 AM Stephen H. Dawson, DSL via R-help
 wrote:

Good Morning,


I am doing some research to develop a new course where I teach. I am
looking for a book to use in the course content to teach accomplishing
SQL in R.

Does anyone know of a book on this topic to recommend for consideration?


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

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


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


Re: [R] Book Recommendation

2023-08-28 Thread Stephen H. Dawson, DSL via R-help

Thanks, Bert. I appreciate your helpful assistance.

This is an academic course. The effort now is to nail down the former. I 
am pushing against a local db for the students. I prefer they focus on 
the get-and-analyze efforts and not db administration efforts.



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


On 8/28/23 13:47, Bert Gunter wrote:
I presume you are familiar with the RSQL and RSQLite packages and 
their vignettes.


Can't offer any help, but a point of clarification:
When you say, "teach accomplishing SQL in R," do you explicitly mean 
using SQL syntax in R to manipulate data or do you mean just doing 
SQL-like types of data manipulation in R? For the former, I assume you 
would be using the above-mentioned packages -- or perhaps others that 
I don't know about like them. For the latter, which I think would be 
subsumed under "data wrangling in R" there are tons of packages, 
tutorials, and books out there that one could search for under that 
rubric. If neither of the above, further clarification might help you 
get a better answer.


Cheers,
Bert

On Mon, Aug 28, 2023 at 8:47 AM Stephen H. Dawson, DSL via R-help 
 wrote:


Good Morning,


I am doing some research to develop a new course where I teach. I am
looking for a book to use in the course content to teach
accomplishing
SQL in R.

Does anyone know of a book on this topic to recommend for
consideration?


Thank You,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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
<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] Book Recommendation

2023-08-28 Thread Stephen H. Dawson, DSL via R-help

Thanks, Hadley. I appreciate your helpful assistance.


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


On 8/28/23 14:48, Hadley Wickham wrote:

You might find this chapter of R for Data Science helpful:
https://r4ds.hadley.nz/databases

Hadley

On Tue, Aug 29, 2023 at 3:47 AM Stephen H. Dawson, DSL via R-help
 wrote:

Good Morning,


I am doing some research to develop a new course where I teach. I am
looking for a book to use in the course content to teach accomplishing
SQL in R.

Does anyone know of a book on this topic to recommend for consideration?


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

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





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


Re: [R] Book Recommendation

2023-08-28 Thread Stephen H. Dawson, DSL via R-help

Thanks, Spencer. I appreciate your helpful assistance.


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


On 8/28/23 15:42, Spencer Graves wrote:

library(sos)
(sql <- findFn('SQL'))


# This opened two tabs in the default browser on my computer just now. 
The second tab lists 298 different packages with help pages containing 
"SQL", sorted to put the package with the most matches first.  The 
first tab lists 1900 different help pages, sorted to put the highest 
ranking package first.



installPackages(sql)


# This installs the highest ranking packages, because the 'sos' code 
knows how to get more information about installed packages than about 
ones that are not installed. To get that information, I followed this 
"installPackages(sql)" with:



sqo


# Hadley Wickham is listed as an author on 14 of those packages. The 
RSQL and RSQLite are numbers 22 and 50 on that list.  RMySQL and 
RPostgreSQL are numbers 48 and 31, respectively.



  If you are looking for course content, I suggest you consider 
using findFn with SQL and applications of greatest interest to your 
target audience.



  Spencer Graves


p.s.  DISCLAIMER:  I'm the lead author and maintainer of the sos package.


On 8/28/23 1:48 PM, Hadley Wickham wrote:

You might find this chapter of R for Data Science helpful:
https://r4ds.hadley.nz/databases

Hadley

On Tue, Aug 29, 2023 at 3:47 AM Stephen H. Dawson, DSL via R-help
 wrote:


Good Morning,


I am doing some research to develop a new course where I teach. I am
looking for a book to use in the course content to teach accomplishing
SQL in R.

Does anyone know of a book on this topic to recommend for 
consideration?



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

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

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






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


[R] Book Recommendation

2023-08-28 Thread Stephen H. Dawson, DSL via R-help

Good Morning,


I am doing some research to develop a new course where I teach. I am 
looking for a book to use in the course content to teach accomplishing 
SQL in R.


Does anyone know of a book on this topic to recommend for consideration?


Thank You,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] OFF TOPIC: chatGPT glibly produces a lot of wrong answers?

2023-08-13 Thread Stephen H. Dawson, DSL via R-help

Thanks.

https://www.wsj.com/articles/with-ai-hackers-can-simply-talk-computers-into-misbehaving-ad488686?mod=hp_lead_pos10

Ever heard of AI prompt injection?


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


On 8/13/23 13:49, Bert Gunter wrote:

**OFF TOPIC** but perhaps of interest to some on this list. I apologize in
advance to those who may be offended.

The byline:

"ChatGPT's odds of getting code questions correct are worse than a coin flip

But its suggestions are so annoyingly plausible"
*
from here:
https://www.theregister.com/2023/08/07/chatgpt_stack_overflow_ai/

Hmm... Perhaps not surprising. Sounds like some expert consultants I've
met. 

Just for amusement. I am ignorant about this and have no strongly held
views,

Cheers to all,
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Could not read time series data using read.zoo()

2023-08-03 Thread Stephen H. Dawson, DSL via R-help

Agreed. Tab character is not comma character.

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


On 8/3/23 11:04, Jeff Newmiller wrote:

no commas?

On August 3, 2023 7:53:07 AM PDT, Christofer Bogaso 
 wrote:

Hi,

I have a CSV which contains data like below (only first few rows),

Date Adj Close lret
02-01-1997 737.01
03-01-1997 748.03 1.48416235
06-01-1997 747.65 -0.050813009
07-01-1997 753.23 0.743567202
08-01-1997 748.41 -0.64196699
09-01-1997 754.85 0.856809786
10-01-1997 759.5 0.614126802

However when I try to read this data using below code I get error,

read.zoo("1.csv", sep = ',', format = '%d-%m-%Y')

Error reads as,

index has 4500 bad entries at data rows: 1 2 3 4 5 6 7 8 9.

Could you please help to understand why I am getting this error?


sessionInfo()

R version 4.2.2 (2022-10-31)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Big Sur ... 10.16


Matrix products: default

BLAS:   
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib

LAPACK: 
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib


locale:

[1] C/UTF-8/C/C/C/C


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


other attached packages:

[1] zoo_1.8-12


loaded via a namespace (and not attached):

[1] compiler_4.2.2  tools_4.2.2 grid_4.2.2  lattice_0.20-45

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] Retirement/archiving of rgdal, rgeos and maptools October 2023

2023-04-10 Thread Stephen H. Dawson, DSL via R-help

Thank you, Roger.


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


On 4/10/23 11:31, Roger Bivand wrote:

The third report on the R-spatial evolution project has been published.

https://r-spatial.org/r/2023/04/10/evolution3.html

It links back to earlier blogs and presentations, and focuses on work 
that maintainers of R packages and workflows using rgdal, rgeos and 
maptools need to put in train now before the packages are archived on 
CRAN.


The first changes will occur in June 2023, and the retiring packages 
will be archived during October 2023. If you are giving a workshop or 
tutorial during the Northern hemisphere summer, aim for June.


If you still need more assistance after reading the project materials, 
raise an issue on https://github.com/r-spatial/evolution/issues or 
email me (issue better, less likely to be overlooked).




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

2022-09-29 Thread Stephen H. Dawson, DSL via R-help

Awesome idea, Jorgen. Thanks for the input.

As expected, it was smart to ask about matter this before I undertook my 
build effort.



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


On 9/28/22 12:06, Jorgen Harmse via R-help wrote:

eol seems to be the parameter to use, but the answers so far appear to assume 
that the file is created on a Mac. For example, I think that �\r\n� on Windows 
would produce CR CR LF. I don�t have both systems handy (so I can�t test), but 
I think you should use raw to specify the bytes you want.

# I think the following are independent of the OS on which you are writing the 
file.
CR <- rawToChar(as.raw(13))
LF <- rawToChar(as.raw(10))
if missing(target)
   # Hope that it matches the machine on which you are writing the file.
   eol <- �\n�
else if (target==�Windows�)
   eol <- c(CR,LF)
else if (target %in% c(�Unix�,�Mac�))
   eol <- LF
else if �.
else
   stop(�Unexpected target.�)

write.table(eol=eol, �.)

Regards,
Jorgen Harmse.



Message: 7
Date: Tue, 27 Sep 2022 11:35:54 -0400
From: "Stephen H. Dawson, DSL" 
To: Bert Gunter 
Cc: r-help 
Subject: Re: [R] Question about Line Ending Choice
Message-ID: <04e458aa-e5f5-c932-da3c-1aa35db7d...@shdawson.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi Bert,


Thanks for the reply.

I did see the parameter, but was not sure if this is the correct
parameter to reference. I also see it in write.csv.

I take it you are saying the eol parameter is the best practice for
exporting from R using these functions. Am I correct or is there another
option other than write.csv and write.table I should be considering?


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


On 9/27/22 11:29, Bert Gunter wrote:

Did you not see the "eol" parameter in write.table ?

Bert

On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help
 wrote:

 Hi All,


 I am writing with a question about choosing the line ending aspect
 of a
 file, please.

 I use write.csv and write.table to export work to CSV files and TXT
 files. I am planning now on how to share my work with the Windows
 crowd
 beyond only sharing with the Linux crowd. I use my text editor to
 flip
 the line ending option from Linux to Windows after exporting. This is
 inefficient for me to accomplish if I ramp up production as I expect
 will occur.

 Staying with the character encoding of UTF-8 seems fine for now from
 what I understand I need to deliver to my customers.

 What seems more efficient to me is to learn how to use R to define
 the
 line ending aspect of the exported file. I have not found if this
 is an
 option within R.

 QUESTION
 Is it possible within R to define the line ending aspect of file
 output?


 Kindest Regards,
 --
 *Stephen Dawson, DSL*
 /Executive Strategy Consultant/
 Business & Technology
 +1 (865) 804-3454
 http://www.shdawson.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
 <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] Question about Line Ending Choice

2022-09-29 Thread Stephen H. Dawson, DSL via R-help

Hi Enrico,


You bring me the missing piece of my understanding to my conceptual 
planning and cost counting to avoid delivery costs being greater than 
acceptable.


Much appreciated.


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


On 9/29/22 05:24, Enrico Schumann wrote:

On Tue, 27 Sep 2022, Stephen H. Dawson, DSL via R-help writes:


Hi All,


I am writing with a question about choosing the line
ending aspect of a file, please.

I use write.csv and write.table to export work to CSV
files and TXT files. I am planning now on how to share
my work with the Windows crowd beyond only sharing with
the Linux crowd. I use my text editor to flip the line
ending option from Linux to Windows after
exporting. This is inefficient for me to accomplish if
I ramp up production as I expect will occur.

Staying with the character encoding of UTF-8 seems fine
for now from what I understand I need to deliver to my
customers.

What seems more efficient to me is to learn how to use
R to define the line ending aspect of the exported
file. I have not found if this is an option within R.

QUESTION
Is it possible within R to define the line ending aspect of file output?


Kindest Regards,

Just a remark: there is a "standard" for CSV,
https://datatracker.ietf.org/doc/html/rfc4180.
It always requires CRLF as the line ending.



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

2022-09-27 Thread Stephen H. Dawson, DSL via R-help

Hi Bert,


Thanks for the reply.

I did see the parameter, but was not sure if this is the correct 
parameter to reference. I also see it in write.csv.


I take it you are saying the eol parameter is the best practice for 
exporting from R using these functions. Am I correct or is there another 
option other than write.csv and write.table I should be considering?



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


On 9/27/22 11:29, Bert Gunter wrote:

Did you not see the "eol" parameter in write.table ?

Bert

On Tue, Sep 27, 2022 at 8:23 AM Stephen H. Dawson, DSL via R-help 
 wrote:


Hi All,


I am writing with a question about choosing the line ending aspect
of a
file, please.

I use write.csv and write.table to export work to CSV files and TXT
files. I am planning now on how to share my work with the Windows
crowd
beyond only sharing with the Linux crowd. I use my text editor to
flip
the line ending option from Linux to Windows after exporting. This is
inefficient for me to accomplish if I ramp up production as I expect
will occur.

Staying with the character encoding of UTF-8 seems fine for now from
what I understand I need to deliver to my customers.

What seems more efficient to me is to learn how to use R to define
the
line ending aspect of the exported file. I have not found if this
is an
option within R.

QUESTION
Is it possible within R to define the line ending aspect of file
output?


Kindest Regards,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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
<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] Question about Line Ending Choice

2022-09-27 Thread Stephen H. Dawson, DSL via R-help

Hi All,


I am writing with a question about choosing the line ending aspect of a 
file, please.


I use write.csv and write.table to export work to CSV files and TXT 
files. I am planning now on how to share my work with the Windows crowd 
beyond only sharing with the Linux crowd. I use my text editor to flip 
the line ending option from Linux to Windows after exporting. This is 
inefficient for me to accomplish if I ramp up production as I expect 
will occur.


Staying with the character encoding of UTF-8 seems fine for now from 
what I understand I need to deliver to my customers.


What seems more efficient to me is to learn how to use R to define the 
line ending aspect of the exported file. I have not found if this is an 
option within R.


QUESTION
Is it possible within R to define the line ending aspect of file output?


Kindest Regards,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] Error Running arules

2022-09-04 Thread Stephen H. Dawson, DSL via R-help

I contacted the arules package maintainer.

He concluded the syntax I submitted to this original post is correct. 
The problem he estimates is a version mismatch within my R packages, 
although all packages I am using come from R repositories. Specifically, 
something is off on the r-base version I am running.


I will remove all of R from my box and look to other repositories.


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


On 9/2/22 12:50, Stephen H. Dawson, DSL via R-help wrote:

Go it, thanks.

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


On 9/2/22 12:46, Bert Gunter wrote:

1. I told you essentially everything there is to know.
2. Chapter 13.3 of "An Introduction to R" on 'namespaces'.
3. Search on "masking in R"

Bert

On Fri, Sep 2, 2022 at 9:01 AM Stephen H. Dawson, DSL
 wrote:

Bert,
Thanks for the guidance. Do you have a documentation URL I can 
review to

research your suggestion?

Ivan,
Thanks for the guidance. The traceback() revealed the same results that
I shared originally.

This is a bigger problem than coding a command set to run against data.
It does seem like a version problem with arules or how it leverages
r-base. I will go to arules maintainer for further guidance.


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


On 9/2/22 03:09, Ivan Krylov wrote:

В Thu, 1 Sep 2022 11:45:15 -0400
"Stephen H. Dawson, DSL via R-help"  пишет:


Error in eval(ei, envir) : object 'Insert' not found

traceback() is invaluable when debugging errors like this.

It might be a bug in one of the packages you're running. You might end
up having to contact the maintainer (see the maintainer() function) of
one of them to have it fixed.



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

2022-09-02 Thread Stephen H. Dawson, DSL via R-help

Go it, thanks.

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


On 9/2/22 12:46, Bert Gunter wrote:

1. I told you essentially everything there is to know.
2. Chapter 13.3 of "An Introduction to R" on 'namespaces'.
3. Search on "masking in R"

Bert

On Fri, Sep 2, 2022 at 9:01 AM Stephen H. Dawson, DSL
 wrote:

Bert,
Thanks for the guidance. Do you have a documentation URL I can review to
research your suggestion?

Ivan,
Thanks for the guidance. The traceback() revealed the same results that
I shared originally.

This is a bigger problem than coding a command set to run against data.
It does seem like a version problem with arules or how it leverages
r-base. I will go to arules maintainer for further guidance.


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


On 9/2/22 03:09, Ivan Krylov wrote:

В Thu, 1 Sep 2022 11:45:15 -0400
"Stephen H. Dawson, DSL via R-help"  пишет:


Error in eval(ei, envir) : object 'Insert' not found

traceback() is invaluable when debugging errors like this.

It might be a bug in one of the packages you're running. You might end
up having to contact the maintainer (see the maintainer() function) of
one of them to have it fixed.



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

2022-09-01 Thread Stephen H. Dawson, DSL via R-help

Hi Everyone,


I upgraded my box recently. I am now running R at version 4.2. I 
attempted to do association rules today using arules. I am getting two 
errors.


My first guess is there is something in the build of the arules that is 
not found in r-base. My second guess is the script syntax needs further 
work.


Anyone have an idea how to interpret these two errors, pls?

***
stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-base | grep Version
Version: 4.2.1-2.2204.0
stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-arules | grep Version
Version: 1.7-4-1cran1.2204.0
stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-Matrix | grep Version
Version: 1.4-1-1.2204.0
stephen@LENOVO-SSD ~/Desktop $ dpkg -s r-cran-psych | grep Version
Version: 2.2.5-1cran1.2204.0
stephen@LENOVO-SSD ~/Desktop $
***
setwd("/home/stephen/SHD-R")

library(Matrix)
library(arules)
library(psych)

Data <- read.csv("./input/DataSet.csv", header=T, colClasses='factor')

Groups <- Data[6:12]
Groups[Groups=="0"] <- NA
View(Groups)

rules <- apriori(Groups, parameter = list(ext = FALSE, minlen=2, 
supp=0.2, conf=0.5))

inspect(rules)
***
ERROR ONE
Attaching package: ‘arules’

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

    abbreviate, write
***
ERROR TWO
Error in eval(ei, envir) : object 'Insert' not found
***


Kindest Regards,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] Circular Graph Recommendation Request

2022-05-30 Thread Stephen H. Dawson, DSL via R-help

Hi Christopher,


Thanks for the reply. Your comments are helpful.

I agree with you about relative position in relation to geography.

The thing with this particular circular graph is it speaks to the 
executive ranks a bit more than a bar or line graph.



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


On 5/29/22 22:10, Christopher W. Ryan via R-help wrote:

If the units of analysis are real spatial regions (e.g. states), how
about a cartogram?

https://gisgeography.com/cartogram-maps/

An R package (I have no experience with it)

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

The advantage of a cartogram is that it is a single graphic, rather than
2 like the original post referenced. No need to move eye back and forth
to decode the colors. And it maintains---as much as possible given the
distortion, which is the whole point of a cartogram--- the relative
spatial positions of the areal units (in this case, states.)  The round
figure in the original post has the northern midwestern region in the
7:00 to 8:00-ish position, what might be considered notionally the
"southwest."  A little counterintuitive.

--Chris Ryan

Bert Gunter wrote:

Very nice plot. Thanks for sharing.
Can't help directly, but as the plot is sort of a map with polygonal
areas encoding the value of a variable, you might try posting on
r-sig-geo instead where there might be more relevant expertise in such
  things -- or perhaps suggestions for alternative visualizations that
work similarly.

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 Sat, May 28, 2022 at 8:39 AM Stephen H. Dawson, DSL via R-help
 wrote:

https://www.visualcapitalist.com/us-goods-exports-by-state/
Visualizing U.S. Exports by State

Good Morning,


https://www.visualcapitalist.com/wp-content/uploads/2022/05/us-exports-by-state-infographic.jpg

Saw an impressive graph today. Sharing with the list.

The size proportionality of the state segments in a circle graph is catchy.

QUESTION
Is there a package one could use with R to accomplish this particular
circular-style graph?


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

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

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


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

2022-05-28 Thread Stephen H. Dawson, DSL via R-help

Thanks for your help.

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


On 5/28/22 14:38, Lucas Heber Mariano Dos Santos wrote:

Here another one https://rpubs.com/StevenDuttRoss/voronoiTreemap

-Original Message-
From: Stephen H. Dawson, DSL 
Sent: Saturday, May 28, 2022 3:37 PM
To: Lucas Heber Mariano Dos Santos ; Bert Gunter 

Cc: r-help 
Subject: Re: [R] Circular Graph Recommendation Request

Thank you, Lucas!


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


On 5/28/22 14:33, Lucas Heber Mariano Dos Santos wrote:

That`s voronoi tremap
Here a tutorial to get you started
https://www.stat.auckland.ac.nz/~paul/Reports/VoronoiTreemap/voronoiTr
eeMap.html



-Original Message-
From: R-help  On Behalf Of Stephen H.
Dawson, DSL via R-help
Sent: Saturday, May 28, 2022 1:10 PM
To: Bert Gunter 
Cc: r-help 
Subject: Re: [R] Circular Graph Recommendation Request

Thanks, Bert. Will do.


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


On 5/28/22 11:55, Bert Gunter wrote:

Very nice plot. Thanks for sharing.
Can't help directly, but as the plot is sort of a map with polygonal
areas encoding the value of a variable, you might try posting on
r-sig-geo instead where there might be more relevant expertise in such
things -- or perhaps suggestions for alternative visualizations
that work similarly.

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 Sat, May 28, 2022 at 8:39 AM Stephen H. Dawson, DSL via R-help
 wrote:

https://www.visualcapitalist.com/us-goods-exports-by-state/
Visualizing U.S. Exports by State

Good Morning,


https://www.visualcapitalist.com/wp-content/uploads/2022/05/us-expor
t
s-by-state-infographic.jpg

Saw an impressive graph today. Sharing with the list.

The size proportionality of the state segments in a circle graph is catchy.

QUESTION
Is there a package one could use with R to accomplish this
particular circular-style graph?


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

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

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


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

2022-04-01 Thread Stephen H. Dawson, DSL via R-help

Good Morning,


I have been doing some further reading on the topic of statistics 
lately. I enjoyed reading the following material. I am writing to share 
the material with the list as recommended reading on the respective topics.



Estimating the number of clusters in a data set via the gap statistic
https://hastie.su.domains/Papers/gap.pdf



Package ‘FNN’
https://cran.r-project.org/web/packages/FNN/FNN.pdf



The Relationship Between Precision-Recall and ROC Curves
https://www.biostat.wisc.edu/~page/rocpr.pdf


Enjoy!


Kindest Regards
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] tidying up

2022-02-28 Thread Stephen H. Dawson, DSL via R-help

Hi Avi,


I thought about your question over the past few days. A new email list 
may help, but I doubt the help will suffice to solve the problem of 
forming emails as the existing list prefers.


Here is where I see the source of the problem with using R by way of 
getting questions answers.


https://cran.r-project.org/doc/manuals/r-release/R-intro.html

This writing is not an introductory learning piece. This work needs to 
be restructured and expanded. It is evident another author would need to 
be found who has the writing skills to accomplish the necessary 
improvements.



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


On 2/27/22 16:59, Avi Gross via R-help wrote:

Indeed, Jim, the hopeful purpose of interactions here is to help people without 
doing the job for them. As you note, sometimes it is help in getting them to 
formulate what they are trying to do and maybe see the resolution on their own, 
or give enough info that others can troubleshoot.

I have dealt with people on and off forums like this who know very little and 
have done some rudimentary search and found something they hope is helpful and 
then get stuck. Some have no actual interest in learning R or Python or 
anything and see it as a one-time thing. For them, any sustained interaction is 
just frustrating. Others may want a tutor, albeit mahy of us here are not 
willing or able to provide endless hours to volunteer. And some, may be better 
off spending the money to hire someone and I assume there are places they can 
be directed.




-Original Message-
From: Jim Lemon 
To: Avi Gross 
Cc: r-help@r-project.org 
Sent: Sun, Feb 27, 2022 4:52 pm
Subject: Re: [R] tidying up


Hi Avi,
I just sent in an answer to a very simple question. In many cases it
seems to me that the real problem isn't apparent from the request.
ektaraK appears to have almost no experience with R (sorry if I'm
wrong). A person in this position may sort of know what they want to
do but do not know how to ask the question. What's a reproducible
example? So I often submit really dumb looking answers that show the
person how to ask the question. If I'm successful, the OP learns how
to do some basic operation, but also learns how to ask the next
question. Until they get there, most responses just give them a typing
exercise.

Jim


On Mon, Feb 28, 2022 at 6:35 AM Avi Gross via R-help
 wrote:

This mailing list seems to steadily get messages that some see as not relevant 
to this forum. In particular, some see it as wrong to bring up some things here 
and keep reminding people of some ground rules.

So I want to know, briefly, if it is reasonable to ask a person with a question 
or problem to reproduce their problem another way. If using RSTUDIO or one of 
many IDE, can they run the code on a naked R interpreter by sourcing the file 
or copying it in or typing it anew, or perhaps using IDLE which comes by 
default with many installations of R? If using a library (which I like so I am 
not really in agreement about the unsuitability) like the tidyverse which is 
free and available to all even if loosely associated with the RSTUDIO folks and 
that can be run on any version of R that I am aware of, then some questions may 
still be fair if they are really about more general R issues as much of the 
rest of the code may be base R and may be the cause of whatever issue is being 
reported. And, some simple requests like pointing out a missing comma, ...

I have stated my thought before and it boils down to the reality that there are 
some things about earlier versions of R that were far from perfect or complete 
and a little healthy competition is not a bad thing and may help base R evolve. 
Not everything in the tidyverse is better and it keeps evolving and deprecating 
older features, but it cannot really be ignored any longer. If you apply for a 
job at some company as something of an R expert, you may well be asked by all 
kinds of people about their programs that use the tidyverse for help or to help 
them solve a problem. You don't have to like it, but if you cannot read it, you 
no longer are really qualified in many places.

Ask yourself if a language like R was created from scratch, what graphics might 
be built into the base distribution? Would you rather have lattice or ggplot or 
perhaps both as well as base R graphics? Would you make many of the built-in 
functions more consistent, so for instance, the data being worked on would be 
the first argument whenever possible?

One reason there are so many packages is not so much due to the superiority of 
R but because people find it lacks quite a bit. Much of that should not be 
included, of course, if R is meant to be somewhat on the lean side, and yes, 
packages are a deliberate way to extend it when needed. But when people use it 
and think they are programming in R, ...

__

Re: [R] (Off-Topic) Time for a companion mailing list for R packages?

2022-01-13 Thread Stephen H. Dawson, DSL via R-help

Good comments, Ivan.

I also have found StackOverflow to not be too helpful in a structured 
conversation. I have had it and miss success with GitHub interactions.



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


On 1/13/22 9:01 AM, Ivan Calandra wrote:

This is indeed a very valid question.


IMHO, I still think that these kind of package-specific questions should have a 
space on the main R mailing list, as long as these questions are about how to 
do something (coding), and not bug or feature requests. Regarding tidyverse and 
ggplot2 (and the likes), many answers actually provide ways using different 
packages (how many times have I seen the same question answered with base R, 
data.table and dplyr?). This is a great way to learn.

And honestly, how many only use base R? Of course, everything can be done in 
base R, but packages also belong to R, that's the way it works and why it works 
so well. Reinventing the wheel is rarely a good solution.


Regarding other help platforms, GitHub is great for the package maintainers that spend 
time on solving issues, but I myself feel bad to ask there "how to do that" 
(help is not always good).

I gave up on StackOverflow. Everytime I tried, I either got treated as an idiot by persons who 
didn't even read my questions (with answers like "do it" to questions like "I don't 
know how to do it"), or I couldn't comment on my question to make it clearer because I was new 
(which is ridiculous, it is when you are new that you need to be able to clarify the most!).

If people think it's tough to ask a question on the R mailing list because 
beginners are not well-handled, they should try SO, it's much worse!

This is to say we should keep the R mailing list!


My $0.02

Ivan

--
Dr. Ivan Calandra
Imaging lab
RGZM - MONREPOS Archaeological Research Centre
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra



From: R-help  on behalf of Duncan Murdoch 

Sent: Thursday, January 13, 2022 2:25 PM
To: Kevin Thorpe; Jeff Newmiller
Cc: R Help Mailing List
Subject: Re: [R] (Off-Topic) Time for a companion mailing list for R packages?

Currently help for contributed packages is available on StackOverflow,
package-specific web sites and Github.

I rarely read package-specific (e.g. RStudio) web pages, and have only
posted questions there a few times, with generally unsatisfactory results.

Most package developers (including tidyverse ones) respond very
helpfully on Github, but to post there you need to already have a very
good idea of where the problem lies.  It's not an appropriate place for
beginners to ask for help.

That leaves StackOverflow.  It gets way too much traffic from people who
don't pose their questions well, but it has the advantage over a mailing
list that questions can be edited and improved (or deleted) after the
fact.  We should be sending beginners there.  And if you want to read
questions and help people, apply N95 filters to the questions:  e.g. I
mainly read questions that have been unanswered and undeleted for an
hour or more.

Duncan Murdoch

On 13/01/2022 7:44 a.m., Kevin Thorpe wrote:

This is an interesting issue and something I have been thinking about raising 
with my fellow volunteer moderators.

I honestly don�t know what the best solution is. Personally, I would loathe 
having to check multiple web-forums/mailing lists to find an answer. New users 
often do not appreciate the subtleties (i.e. RStudio is not R) and will 
continue to post here. The frequent reply to questions outside base R that 
inform them they are off-topic could come across as unfriendly. That could have 
the side effect of making the community appear elitist. Folks are also often 
referred to package maintainers but not all maintainers are equally responsive 
to queries about their packages. In summary, it can be very hard for novice 
users to get the help they need.

I appreciate the desire of many to keep the focus of this list narrow, yet 
despite the narrow mandate there are many readers who can answer non-base R 
questions, which is probably one of the reasons we see the questions. I wonder 
if there would be an appetite to create a new list, R-package-help, that has a 
broad mandate (as suggested by Avi). Naturally there is no guarantee that 
specific questions about some esoteric package will be answered, but that�s a 
different problem. On the other hand, why not expand the mandate of R-help 
rather than going to the trouble of creating a new list? Like I said, I don�t 
know.

Thanks for raising the issue.

Kevin



On Jan 12, 2022, at 11:24 PM, Jeff Newmiller  wrote:

TL;DR The people responsible for tidyverse don't think much of mailing lists.

IANAMLA (I am not mailing list admin) and I know some people get kind of heated 
about these things, but my take is that this list 

Re: [R] (Off-Topic) Time for a companion mailing list for R packages?

2022-01-13 Thread Stephen H. Dawson, DSL via R-help

Great discussion thread.

The problem is not a mailing list. The problem is the inability to 
segment questions. Segment, by keyword or sub-directory (loose word) or 
any other compartmentalization.


QUESTION
What other technology options are available here beyond a mailing list?


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


On 1/13/22 8:25 AM, Duncan Murdoch wrote:
Currently help for contributed packages is available on StackOverflow, 
package-specific web sites and Github.


I rarely read package-specific (e.g. RStudio) web pages, and have only 
posted questions there a few times, with generally unsatisfactory 
results.


Most package developers (including tidyverse ones) respond very 
helpfully on Github, but to post there you need to already have a very 
good idea of where the problem lies.  It's not an appropriate place 
for beginners to ask for help.


That leaves StackOverflow.  It gets way too much traffic from people 
who don't pose their questions well, but it has the advantage over a 
mailing list that questions can be edited and improved (or deleted) 
after the fact.  We should be sending beginners there.  And if you 
want to read questions and help people, apply N95 filters to the 
questions:  e.g. I mainly read questions that have been unanswered and 
undeleted for an hour or more.


Duncan Murdoch

On 13/01/2022 7:44 a.m., Kevin Thorpe wrote:
This is an interesting issue and something I have been thinking about 
raising with my fellow volunteer moderators.


I honestly don’t know what the best solution is. Personally, I would 
loathe having to check multiple web-forums/mailing lists to find an 
answer. New users often do not appreciate the subtleties (i.e. 
RStudio is not R) and will continue to post here. The frequent reply 
to questions outside base R that inform them they are off-topic could 
come across as unfriendly. That could have the side effect of making 
the community appear elitist. Folks are also often referred to 
package maintainers but not all maintainers are equally responsive to 
queries about their packages. In summary, it can be very hard for 
novice users to get the help they need.


I appreciate the desire of many to keep the focus of this list 
narrow, yet despite the narrow mandate there are many readers who can 
answer non-base R questions, which is probably one of the reasons we 
see the questions. I wonder if there would be an appetite to create a 
new list, R-package-help, that has a broad mandate (as suggested by 
Avi). Naturally there is no guarantee that specific questions about 
some esoteric package will be answered, but that’s a different 
problem. On the other hand, why not expand the mandate of R-help 
rather than going to the trouble of creating a new list? Like I said, 
I don’t know.


Thanks for raising the issue.

Kevin


On Jan 12, 2022, at 11:24 PM, Jeff Newmiller 
 wrote:


TL;DR The people responsible for tidyverse don't think much of 
mailing lists.


IANAMLA (I am not mailing list admin) and I know some people get 
kind of heated about these things, but my take is that this list 
_is_ about R so to be on topic the question needs to be about R and 
how to get things done in R. Since contributed packages are almost 
by definition creating capabilities linked with specific problem 
domains or domain-specific-languages (DSLs), and there are thousands 
of these, it isn't practical to support questions framed within 
those DSLs here. It seems perfectly legitimate IMHO to mention such 
packages here, as long as the question does not hinge on that 
package, and even to offer small solutions to posed R problems using 
such packages. Others may disagree with my perspective on this. 
Unfortunately all of this this subtlety is usually lost upon 
newbies, much to the detriment of this list's reputation.


The responsibility to setup and manage support for contributed 
packages belongs to the package maintainer. In the case of 
tidyverse, the general opinion of those people seems to be that web 
forums avoid the "only unformatted info can be shared" nature of 
traditional mailing lists, so mailing lists have AFAIK not been 
built or tended.


Unfortunately, they also try to "allow all topics" as much as 
possible in those forums to minimize the appearance of 
unfriendliness to beginners, but my impression is that this leads to 
such a wide range of topics that many posts don't get answered. I 
have certainly found it to be just too much quantity to sift 
through, and I really am selective about which portions of the 
tidyverse I work with anyway, so I don't hang out there much at all.


On January 12, 2022 7:27:20 PM PST, Avi Gross via R-help 
 wrote:
Respectfully, this forum gets lots of questions that include 
non-base R components and especially packages in the tidyverse. 
Like it or not, the extended R language is far more useful and 
interesting for 

Re: [R] splitting data matrix into submatrices

2022-01-05 Thread Stephen H. Dawson, DSL via R-help

Hi,


Please post the data structure so it is more clear what data is being 
massaged.



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


On 1/4/22 10:52 PM, Faheem Jan via R-help wrote:

I have data in a matrix form of order 1826*24 where 1826 represents the days 
and 24 hourly observations on each data. My objective is to split the matrix 
into working (Monday to Friday) and non-working (Saturday and Sunday) 
submatrices. Can anyone help me that how I will do that splitting using R?


[[alternative HTML version deleted]]

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



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


Re: [R] Error Awareness

2021-12-24 Thread Stephen H. Dawson, DSL via R-help
Thank you, Avi. I appreciate your reply. I agree maturing code is the 
best move to answer this interrogatory. I express deep thanks for 
contextualizing your response.


I also agree with you responses are becoming a pattern here. A post of 
an open-ended question regarding either a conceptual or stylistic topic 
is answered pervasively with linear thinking. This combination is a 
mismatch of context.


https://www.r-project.org/posting-guide.html

I summarize reading in the R Posting Guide, which is written in English, 
the recommendation to state a specific question involving specific R 
functionality. I read nothing in the R Posting Guide where open-ended 
questions are disallowed or even discouraged. Furthermore, I cannot 
imagine not posting either conceptual or stylistic questions to any 
practice group. If learning is not accomplished by open-ended questions, 
then there is nothing left other than closed-ended (direct) questions.


All the same, the benefit of gaining either tacit understanding or 
wisdom to use the R language by way of open-ended questioning is not 
found in the R Posting Guide as it is either written or practiced. This 
reality impairs the ability to learn about a dialogue member's thought 
process. It also impairs the ability to ever be able to one day offer 
either contract or employment work to anyone demonstrating both intimate 
knowledge of the R language and having the wisdom to implement it 
effectively.


It is inappropriate to recommend modifications to the R Posting Guide in 
this discussion, as it would be out of scope. So, I will not do it.


I close this dialogue as resolved. It is best to post any further 
discussion of this interrogatory in a new dialogue to avoid violating 
the R Posting Guide requirement of the stated Latin term ad hominem.


 https://www.dictionary.com/browse/ad-hominem

 https://en.wikipedia.org/wiki/Ad_hominem#Terminology


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


On 12/23/21 10:28 PM, Avi Gross via R-help wrote:

Stephen,

It is becoming a pattern here.

You have been told R allows ways to check for errors as the code is
interpreted and this DOES NOT distinguish between development aspects and in
the field. It does not matter if a problem is external like a required file
not being in place or having a new name or whatever.

Anything that may go wrong can be handled in quite a few ways. Some are
fairly obvious, such as checking if an expected  list or vector or whatever
is returned that is empty or not set or is the wrong data type or contains
some NA or negative numbers and on and on. All kinds of IF statements and
checks are a way to deal with these and you decide whether to make some kind
of fix or abort.

But obviously if the error happens outside your code (and sometimes also
within) you can use various ways R provides to intercept the error and do
something. Heck, people often use this in advance as a programming tactic
such as using try() or tryCatch() to something like try to open file1 in the
current directory and if that fails, in a specified directory and maybe if
that fails, get it from file2 or maybe standard input ...

Well-written code that wants to be bullet-proof will often be a bit bloated
as it regularly stops and checks not only for all kinds of error conditions
but also checks if the variables being used are in the proper format and
range before being passed to functions that might break, is say you told it
to use a correlation above 1. It also decides to intelligently deal with the
errors, when possible.

I have written code that called a statistical analysis (lavaan)  function
hundreds of thousands of times on randomly generated data and it worked
fine, except occasionally it broke. As I tended to run it overnight, it was
a pain to wake up and find it had crashed. No, I am not aware why it
crashed, but it could have been something as simple as a matrix that could
not be inverted. But for my purposes, it did not matter as what I would be
happy to get is knowing it failed, marking associated rows of a data.frame
accordingly, and filtering out the results in later analyses. So, I wrapped
not only this call but some others as described above and intercepted the
rare problem and dealt with it and let my program continue overnight.

Clearly if you expect anomalies to be rare, this is extra overhead. But if
things do happen, then your code is not robust enough.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Thursday, December 23, 2021 11:17 AM
To: Bert Gunter 
Cc: R-help 
Subject: Re: [R] Error Awareness

Hi Bert,


Thanks for the reply.

The use case I presented involves working code, not diagnosing a script in
development.

The concern is running a script where something changes outside of the
script, as I stated. An example of a change is a d

Re: [R] Script Run Output Capturing

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

Thank you, Rasmus. I appreciate the reply.


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


On 12/23/21 10:00 AM, Rasmus Liland wrote:

sink and capture.output seem
useful, but I have not used them.
I looked into pipe() a long time ago ...

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

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

Hi Duncan,


Thanks for the reply. You bring much insight to the equation of the R 
journey. I look forward to dialoging with you.



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


On 12/22/21 12:12 PM, Duncan Murdoch wrote:

On 22/12/2021 12:01 p.m., Stephen H. Dawson, DSL wrote:

Data <- read.csv("./input/Source.csv", header=T)
v1 <- sort(unique(Data[, 1]))
cat(format(v1, justify = "right"), sep = "\n")

OK, working with the options you presented. This is the combination
where I gain the most benefit.

However, there is no listing of a column header with the output of this
syntax.

  > cat(format(v1, justify = "right"), sep = "\n")
   2
   3
   4
   5
   6
   7
   8
   9
10
  >

NOTE
The output here is correct (unique) based on the entries from the 
column.


QUESTION
How does one add a text label of something as simple as v1 to the
vertical output of this syntax, please?


In this case, you'd just put in cat("v1\n") before the given command.

In the general case where you want to get the name of the column from 
the dataframe, I think you'll need to write your own function.  The 
one Rui just posted looks pretty good.  To get it to print without the 
row numbers as in the example above, just change it a little in the 
header and one other line:


print.sortUnique <- function(x, row.names = FALSE, ...){
   n <- max(lengths(x))
   y <- lapply(x, \(.x) c(.x, rep("", n - length(.x
   y <- do.call(cbind.data.frame, y)
   names(y) <- names(x)
   print(y, row.names = row.names, ...)
   invisible(x)
}

This will give

> Data2
 V1 V2 V3 V4
  3  2  2  1
  5  4  3  2
  6  5  4  4
  7  6  5  5
  8  9  6  6
  9 11  8  9
 12 15  9 10
 14 16 11 11
 15 17 14 12
 18 18 15 13
 19 19 17 14
 20    19 16
   20 18
  19

with his example data.

Duncan Murdoch




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


On 12/22/21 11:13 AM, Stephen H. Dawson, DSL via R-help wrote:

OK, now I get what you are suggesting.

Much appreciated.


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


On 12/22/21 11:08 AM, Duncan Murdoch wrote:

On 22/12/2021 10:55 a.m., Stephen H. Dawson, DSL wrote:

I see.

So, we are talking taking the output into a new dataframe. I was 
hoping
to have the output rendered on screen without another dataframe, 
but I

can live with this option it if must occur.

Am I correct the desired vertical output must first go to a 
dataframe?


No, that's just one option.  The other 3 don't use dataframes.

Duncan Murdoch



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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output.
However,
the output is rendered as horizontal. What needs to happen to 
get the

output to render vertical, please?


The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to 
print

one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer). For
example,


 v <- c("red", "green", "blue")
 data.frame(v)

    v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "right"), sep = "\n")

    red
green
   blue

If you want this to happen when you auto-print the object, you can
give it a class attribute and write a function to print that class,
e.g.


    class(v) <- "oneperline"

 print.oneperline <- function(x, ...) cat(format(x, justify =

"right"), sep = "\n")


 v

    red
green
   blue

Duncan Murdoch




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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last,
decreasing =
decreasing)) :
    undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". 
Use

Data[[1]] for that, so

   sort(unique(Data[[1]]))


Actually, I'd probably recommend

 sort(unique(D

Re: [R] Adding SORT to UNIQUE

2021-12-23 Thread Stephen H. Dawson, DSL via R-help
ges that implemented something like print.vertical().

Your earlier statement suggests you may be interested in what is the canonical 
or best way and by now, you may note there are very often MANY ways and some 
programmers prefer one or another. And, I note, after enough questions of a 
fairly basic or even naïve nature, some responders in these groups stop 
responding for some reason.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson, DSL 
via R-help
Sent: Wednesday, December 22, 2021 10:55 AM
To: Duncan Murdoch ; Rui Barradas ; 
Stephen H. Dawson, DSL via R-help 
Subject: Re: [R] Adding SORT to UNIQUE

I see.

So, we are talking taking the output into a new dataframe. I was hoping to have 
the output rendered on screen without another dataframe, but I can live with 
this option it if must occur.

Am I correct the desired vertical output must first go to a dataframe?


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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output.
However, the output is rendered as horizontal. What needs to happen
to get the output to render vertical, please?

The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to print
one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer).  For
example,


   v <- c("red", "green", "blue")
   data.frame(v)

   v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "right"), sep = "\n")

   red
green
  blue

If you want this to happen when you auto-print the object, you can
give it a class attribute and write a function to print that class, e.g.


  class(v) <- "oneperline"

   print.oneperline <- function(x, ...) cat(format(x, justify =

"right"), sep = "\n")

   v

   red
green
  blue

Duncan Murdoch



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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing
=
decreasing)) :
   undefined columns selected

That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

  sort(unique(Data[[1]]))

Actually, I'd probably recommend

sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list.
Dataframes are lists that look like matrices, but to me the matrix
aspect is usually more intuitive.

Duncan Murdoch


I think Rui already pointed out the typo in the quoted text below...

Duncan Murdoch


The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the
column may be text or numbers. This is a huge analysis effort with
data coming at me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the
unique entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with
ease.
Python and SQL can do it with ease.

I've seen several responses that looked pretty simple. It's hard
to beat sort(unique(x)), though there's a fair bit of confusion
about what you actually want.  Maybe you should post an example
of the code you'd use in Python?

Duncan Murdoch


QUESTION
Is there a simpler means than other than the unique function to
capture distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.

This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax
Data[[1]] extracts the column vector.

As for my previous answer, it was not addressing the question,
I misinterpreted it as being a question on how to sort by
numeric order when the data is not

Re: [R] Script Run Output Capturing

2021-12-23 Thread Stephen H. Dawson, DSL via R-help
I have not tired sink yet. I was asking for best processes by soliciting 
input from others who have succeeded in this effort before. My question 
is more conceptual in nature, a research point, to learn more about the 
strengths and weaknesses of options.



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


On 12/23/21 10:54 AM, Bert Gunter wrote:

?sink explicitly says:

"sink diverts R output to a connection (and stops such diversions)"

Is this not exactly what you requested? If not, why not? Have you
tried it to see?

Bert Gunter

On Thu, Dec 23, 2021 at 5:28 AM Stephen H. Dawson, DSL via R-help
 wrote:

Nice! Thanks for the reply.

I will research over the next few days.

https://www.ssc.wisc.edu/~hemken/Rworkshops/interface/savingoutput.html

How about the sink() and capture.output() functions? Have you ever used
them?


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


On 12/23/21 6:44 AM, Rasmus Liland wrote:

Dear Stephen,

Maybe running R in batch mode is what
you're after?  E.g. running

   R CMD BATCH ./process/script-name.r

creates ./process/script-name.Rout (or
./process/script-name.rout ?) with
output of R commands and inline output,
I think stderr (maybe others?  Not only
stdout like tee ...
https://en.wikipedia.org/wiki/Standard_streams )

Note, the batch output is overwritten,
as opposed to being appended to (the tee
-a flag) the next time you run that line
again ...

Best,
Rasmus

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


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

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

Hi Bert,


Thanks for the reply.

The use case I presented involves working code, not diagnosing a script 
in development.


The concern is running a script where something changes outside of the 
script, as I stated. An example of a change is a data source changing 
perhaps the columns in the data source, or even changing the spelling of 
a column. The point is something changes.


The question then becomes how to be aware of the change when the reset 
of the script runs fine, as I presented.


Think of having a script running daily where you are not running it 
manually. How do you know there are errors in the script processing at 
this point?


Does this question now make more sense?


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


On 12/23/21 10:49 AM, Bert Gunter wrote:

?tryCatch

This list is not meant for tutorials. A web search on "find errors in
R code" brought up what appeared to be many resources to address your
question. Please make use of such resources before posting here. Also,
please read and follow the posting gui)de linked below to find out
what sort of help you can expect (and have already received here.

Cheers,
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 Thu, Dec 23, 2021 at 3:14 AM Stephen H. Dawson, DSL via R-help
 wrote:

Hi,


I am thinking about awareness of errors when an R script runs.

My concern is I have an error-free script. I run it for months on end
without problems. Then, something changes somewhere causing an error. My
wonderment is how R will tell me I had an error in the script, but the
rest of the script ran without impairment.

QUESTIONS
What are some of the more helpful options available to an R developer to
capture errors in a script run?

What are some of the best processes to implement these more helpful options?


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

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


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


Re: [R] Script Run Output Capturing

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

Nice! Thanks for the reply.

I will research over the next few days.

https://www.ssc.wisc.edu/~hemken/Rworkshops/interface/savingoutput.html

How about the sink() and capture.output() functions? Have you ever used 
them?



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


On 12/23/21 6:44 AM, Rasmus Liland wrote:

Dear Stephen,

Maybe running R in batch mode is what
you're after?  E.g. running

R CMD BATCH ./process/script-name.r

creates ./process/script-name.Rout (or
./process/script-name.rout ?) with
output of R commands and inline output,
I think stderr (maybe others?  Not only
stdout like tee ...
https://en.wikipedia.org/wiki/Standard_streams )

Note, the batch output is overwritten,
as opposed to being appended to (the tee
-a flag) the next time you run that line
again ...

Best,
Rasmus

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



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

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

Hi,


I am thinking about awareness of errors when an R script runs.

My concern is I have an error-free script. I run it for months on end 
without problems. Then, something changes somewhere causing an error. My 
wonderment is how R will tell me I had an error in the script, but the 
rest of the script ran without impairment.


QUESTIONS
What are some of the more helpful options available to an R developer to 
capture errors in a script run?


What are some of the best processes to implement these more helpful options?


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

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


[R] Script Run Output Capturing

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

Hi,


I need to capture the output in a physical file when I run an R script. 
I would like to capture the output as a TXT file. I am thinking 
something along the line of the tee command is what I am after, but I am 
not certain what I am after here.


https://en.wikipedia.org/wiki/Tee_(command)

https://www.gnu.org/software/coreutils/manual/html_node/tee-invocation.html


Here is a syntax example of how I use the tee command on other efforts 
of life:

/bin/bash ./BackUp_script-v3.sh | tee -a ~/Desktop/script-run-Sunday-1.txt


Here is a syntax example of how I am running my R scripts now:
#R Studio Console
#source("./process/script-name.r")

#Bash Terminal
#Rscript ./process/script-name.r


QUESTIONS
What command or function am I after to capture console and terminal output?

It would be best to also define the character encoding and line ending 
parameters of the TXT file. How do I amend my existing script run syntax 
to capture the said outputs?



Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] Adding SORT to UNIQUE

2021-12-23 Thread Stephen H. Dawson, DSL via R-help
Yes, I saw the period character is where the problem occurred. However, 
I decided to loop back with the poster to close the discussion loop.



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


On 12/22/21 5:37 PM, Rui Barradas wrote:

Hello,

The error is a simple typo, instead of the period after 
names(Data[,1]), it should be a comma.


cat(format(names(Data[,1]), "\n", v1, justify = "right"), sep = "\n")

(And the error message accurately points out where the error is, in 
these cases try to read the instruction more carefully, typos can be 
hard to find.)



Hope this helps,

Rui Barradas

Às 17:59 de 22/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

I am pondering label names, not set on one as of yet. I like your 
recommendation.



 > cat(format(names(Data[,1]). "\n", v1, justify = "right"), sep = "\n")
Error: unexpected symbol in "cat(format(names(Data[,1])."
 >

Your proposed syntax has an error.

QUESTION
Can you identify the error and reply with another recommendation, 
please?



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


On 12/22/21 12:33 PM, Avi Gross via R-help wrote:

Stephen,

Why should there be a column header when you take your data and 
reformat it?


cat(format(v1, justify = "right"), sep = "\n")

The above is no longer your original data structure and has 
specified what you want printed. Your column header and other names 
associated with your original data.frame are stored as attributes 
that you sort of discarded.


The name you want is associated not with v1 but with what you call 
Data[,1] and you can get that name using names(Data[,1]) and put it 
where you want. In your case, if you want the single line above your 
values to have that name, this would do it:


cat(format(names(Data[,1]). "\n", v1, justify = "right"), sep = "\n")

-Original Message-
From: R-help  On Behalf Of Stephen H. 
Dawson, DSL via R-help

Sent: Wednesday, December 22, 2021 12:02 PM
To: Duncan Murdoch ; Rui Barradas 
; Stephen H. Dawson, DSL via R-help 


Subject: Re: [R] Adding SORT to UNIQUE

Data <- read.csv("./input/Source.csv", header=T)
v1 <- sort(unique(Data[, 1]))
cat(format(v1, justify = "right"), sep = "\n")

OK, working with the options you presented. This is the combination 
where I gain the most benefit.


However, there is no listing of a column header with the output of 
this syntax.


  > cat(format(v1, justify = "right"), sep = "\n")
   2
   3
   4
   5
   6
   7
   8
   9
10
  >

NOTE
The output here is correct (unique) based on the entries from the 
column.


QUESTION
How does one add a text label of something as simple as v1 to the 
vertical output of this syntax, please?


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


On 12/22/21 11:13 AM, Stephen H. Dawson, DSL via R-help wrote:

OK, now I get what you are suggesting.

Much appreciated.


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


On 12/22/21 11:08 AM, Duncan Murdoch wrote:

On 22/12/2021 10:55 a.m., Stephen H. Dawson, DSL wrote:

I see.

So, we are talking taking the output into a new dataframe. I was
hoping to have the output rendered on screen without another
dataframe, but I can live with this option it if must occur.

Am I correct the desired vertical output must first go to a 
dataframe?

No, that's just one option.  The other 3 don't use dataframes.

Duncan Murdoch


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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output.
However,
the output is rendered as horizontal. What needs to happen to get
the output to render vertical, please?

The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to
print one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer). For
example,


 v <- c("red", "green", "blue")
 data.frame(v)

    v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "righ

Re: [R] Adding SORT to UNIQUE

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

Thanks.

I am pondering label names, not set on one as of yet. I like your 
recommendation.



> cat(format(names(Data[,1]). "\n", v1, justify = "right"), sep = "\n")
Error: unexpected symbol in "cat(format(names(Data[,1])."
>

Your proposed syntax has an error.

QUESTION
Can you identify the error and reply with another recommendation, please?


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


On 12/22/21 12:33 PM, Avi Gross via R-help wrote:

Stephen,

Why should there be a column header when you take your data and reformat it?

cat(format(v1, justify = "right"), sep = "\n")

The above is no longer your original data structure and has specified what you 
want printed. Your column header and other names associated with your original 
data.frame are stored as attributes that you sort of discarded.

The name you want is associated not with v1 but with what you call Data[,1] and 
you can get that name using names(Data[,1]) and put it where you want. In your 
case, if you want the single line above your values to have that name, this 
would do it:

cat(format(names(Data[,1]). "\n", v1, justify = "right"), sep = "\n")

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson, DSL 
via R-help
Sent: Wednesday, December 22, 2021 12:02 PM
To: Duncan Murdoch ; Rui Barradas ; 
Stephen H. Dawson, DSL via R-help 
Subject: Re: [R] Adding SORT to UNIQUE

Data <- read.csv("./input/Source.csv", header=T)
v1 <- sort(unique(Data[, 1]))
cat(format(v1, justify = "right"), sep = "\n")

OK, working with the options you presented. This is the combination where I 
gain the most benefit.

However, there is no listing of a column header with the output of this syntax.

  > cat(format(v1, justify = "right"), sep = "\n")
   2
   3
   4
   5
   6
   7
   8
   9
10
  >

NOTE
The output here is correct (unique) based on the entries from the column.

QUESTION
How does one add a text label of something as simple as v1 to the vertical 
output of this syntax, please?

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


On 12/22/21 11:13 AM, Stephen H. Dawson, DSL via R-help wrote:

OK, now I get what you are suggesting.

Much appreciated.


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


On 12/22/21 11:08 AM, Duncan Murdoch wrote:

On 22/12/2021 10:55 a.m., Stephen H. Dawson, DSL wrote:

I see.

So, we are talking taking the output into a new dataframe. I was
hoping to have the output rendered on screen without another
dataframe, but I can live with this option it if must occur.

Am I correct the desired vertical output must first go to a dataframe?

No, that's just one option.  The other 3 don't use dataframes.

Duncan Murdoch


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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output.
However,
the output is rendered as horizontal. What needs to happen to get
the output to render vertical, please?

The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to
print one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer). For
example,


 v <- c("red", "green", "blue")
 data.frame(v)

v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "right"), sep = "\n")

red
green
   blue

If you want this to happen when you auto-print the object, you can
give it a class attribute and write a function to print that class,
e.g.


class(v) <- "oneperline"

 print.oneperline <- function(x, ...) cat(format(x, justify =

"right"), sep = "\n")

 v

red
green
   blue

Duncan Murdoch



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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last,
decreasing =
dec

Re: [R] Adding SORT to UNIQUE

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

Wow! Thanks.

I need to process the logic you have presented next week when I have the 
time to focus. I now need to accomplish some productive work output 
based on what I have now for understandings.



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


On 12/22/21 11:57 AM, Rui Barradas wrote:

Hello,

The problem is that the vectors of unique values in each column of the 
original data.frame Data need not be same length. And the output of 
sort(unique(.)) is a list of vectors of different lengths. And lists 
print "horizontally", each vector on its own.


Like Duncan said, one of the ways of getting a vertical display is to 
have the list of sorted, unique values be of a custom class and write 
a print method for that class. Here is an example of this. The 
function to sort outputs an object of a class that sub-classes class 
"list". And a print method takes care of the printing. This method 
creates a temp data.frame, prints that df and invisibly returns its 
input.


# Create a test data set
set.seed(2021)
Data <- replicate(4, as.character(sample(20, 20, TRUE)))
Data <- as.data.frame(Data)


# Now the functions
sort_unique <- function(x){
  y <- lapply(x, \(.x) stringr::str_sort(unique(.x), numeric = TRUE))
  old_class <- class(y)
  class(y) <- c("sortUnique", old_class)
  y
}
print.sortUnique <- function(x, ...){
  n <- max(lengths(x))
  y <- lapply(x, \(.x) c(.x, rep("", n - length(.x
  y <- do.call(cbind.data.frame, y)
  names(y) <- names(x)
  print(y)
  invisible(x)
}

# Test the functions above
Data2 <- sort_unique(Data)

class(Data2)
Data2
print(Data2)


Hope this helps,

Rui Barradas

Às 15:55 de 22/12/21, Stephen H. Dawson, DSL escreveu:

I see.

So, we are talking taking the output into a new dataframe. I was 
hoping to have the output rendered on screen without another 
dataframe, but I can live with this option it if must occur.


Am I correct the desired vertical output must first go to a dataframe?


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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output. 
However,

the output is rendered as horizontal. What needs to happen to get the
output to render vertical, please?


The result of those expressions is a vector of the same type as the 
column, so your question is really about how to get a vector to 
print one element per line.


Probably the simplest way is to put the vector in a dataframe (or 
matrix, or tibble, depending on which formatting you prefer).  For 
example,


>   v <- c("red", "green", "blue")
>   data.frame(v)
  v
1   red
2 green
3  blue

If you want a more minimal display, try

> cat(v, sep = "\n")
red
green
blue

or

> cat(format(v, justify = "right"), sep = "\n")
  red
green
 blue

If you want this to happen when you auto-print the object, you can 
give it a class attribute and write a function to print that class, 
e.g.


>  class(v) <- "oneperline"
>
>   print.oneperline <- function(x, ...) cat(format(x, justify = 
"right"), sep = "\n")

>
>   v
  red
green
 blue

Duncan Murdoch




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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
      undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

 sort(unique(Data[[1]]))


Actually, I'd probably recommend

   sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list.
Dataframes are lists that look like matrices, but to me the matrix
aspect is usually more intuitive.

Duncan Murdoch



I think Rui already pointed out the typo in the quoted text below...

Duncan Murdoch



The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the 
column

may
be text or numbers. This is a huge analysis effort with data 
coming at

me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a

Re: [R] Adding SORT to UNIQUE

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

Data <- read.csv("./input/Source.csv", header=T)
v1 <- sort(unique(Data[, 1]))
cat(format(v1, justify = "right"), sep = "\n")

OK, working with the options you presented. This is the combination 
where I gain the most benefit.


However, there is no listing of a column header with the output of this 
syntax.


> cat(format(v1, justify = "right"), sep = "\n")
 2
 3
 4
 5
 6
 7
 8
 9
10
>

NOTE
The output here is correct (unique) based on the entries from the column.

QUESTION
How does one add a text label of something as simple as v1 to the 
vertical output of this syntax, please?


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


On 12/22/21 11:13 AM, Stephen H. Dawson, DSL via R-help wrote:

OK, now I get what you are suggesting.

Much appreciated.


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


On 12/22/21 11:08 AM, Duncan Murdoch wrote:

On 22/12/2021 10:55 a.m., Stephen H. Dawson, DSL wrote:

I see.

So, we are talking taking the output into a new dataframe. I was hoping
to have the output rendered on screen without another dataframe, but I
can live with this option it if must occur.

Am I correct the desired vertical output must first go to a dataframe?


No, that's just one option.  The other 3 don't use dataframes.

Duncan Murdoch



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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output. 
However,

the output is rendered as horizontal. What needs to happen to get the
output to render vertical, please?


The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to print
one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer). For
example,


    v <- c("red", "green", "blue")
    data.frame(v)

   v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "right"), sep = "\n")

   red
green
  blue

If you want this to happen when you auto-print the object, you can
give it a class attribute and write a function to print that class, 
e.g.



   class(v) <- "oneperline"

    print.oneperline <- function(x, ...) cat(format(x, justify =

"right"), sep = "\n")


    v

   red
green
  blue

Duncan Murdoch




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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, 
decreasing =

decreasing)) :
   undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

  sort(unique(Data[[1]]))


Actually, I'd probably recommend

    sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list.
Dataframes are lists that look like matrices, but to me the matrix
aspect is usually more intuitive.

Duncan Murdoch



I think Rui already pointed out the typo in the quoted text 
below...


Duncan Murdoch



The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the 
column

may
be text or numbers. This is a huge analysis effort with data
coming at
me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:
On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help 
wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the 
unique

entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with
ease.
Python and SQL can do it with ease.


I've seen several responses that looked pretty simple. It's 
hard to
beat sort(unique(x)), though there's a fair bit of confusion 
about

what you actually want.  Maybe you should post an example of the
code
you'd use in Python?

Duncan Murdoch



QUESTION
Is there a simpler means than other than the unique function to
capture
distin

Re: [R] Adding SORT to UNIQUE

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

OK, now I get what you are suggesting.

Much appreciated.


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


On 12/22/21 11:08 AM, Duncan Murdoch wrote:

On 22/12/2021 10:55 a.m., Stephen H. Dawson, DSL wrote:

I see.

So, we are talking taking the output into a new dataframe. I was hoping
to have the output rendered on screen without another dataframe, but I
can live with this option it if must occur.

Am I correct the desired vertical output must first go to a dataframe?


No, that's just one option.  The other 3 don't use dataframes.

Duncan Murdoch



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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output. 
However,

the output is rendered as horizontal. What needs to happen to get the
output to render vertical, please?


The result of those expressions is a vector of the same type as the
column, so your question is really about how to get a vector to print
one element per line.

Probably the simplest way is to put the vector in a dataframe (or
matrix, or tibble, depending on which formatting you prefer). For
example,


    v <- c("red", "green", "blue")
    data.frame(v)

   v
1   red
2 green
3  blue

If you want a more minimal display, try


cat(v, sep = "\n")

red
green
blue

or


cat(format(v, justify = "right"), sep = "\n")

   red
green
  blue

If you want this to happen when you auto-print the object, you can
give it a class attribute and write a function to print that class, 
e.g.



   class(v) <- "oneperline"

    print.oneperline <- function(x, ...) cat(format(x, justify =

"right"), sep = "\n")


    v

   red
green
  blue

Duncan Murdoch




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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
   undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

  sort(unique(Data[[1]]))


Actually, I'd probably recommend

    sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list.
Dataframes are lists that look like matrices, but to me the matrix
aspect is usually more intuitive.

Duncan Murdoch



I think Rui already pointed out the typo in the quoted text below...

Duncan Murdoch



The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the 
column

may
be text or numbers. This is a huge analysis effort with data
coming at
me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the 
unique

entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with
ease.
Python and SQL can do it with ease.


I've seen several responses that looked pretty simple. It's 
hard to

beat sort(unique(x)), though there's a fair bit of confusion about
what you actually want.  Maybe you should post an example of the
code
you'd use in Python?

Duncan Murdoch



QUESTION
Is there a simpler means than other than the unique function to
capture
distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help 
escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.


This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax 
Data[[1]]

extracts the column vector.

As for my previous answer, it was not addressing the question, I
misinterpreted it as being a question on how to sort by numeric
order
when the data is not numeric. Here is a, hopefully, complete
answer.
Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
       stringr::str_sort(unique(x),

Re: [R] Adding SORT to UNIQUE

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

I see.

So, we are talking taking the output into a new dataframe. I was hoping 
to have the output rendered on screen without another dataframe, but I 
can live with this option it if must occur.


Am I correct the desired vertical output must first go to a dataframe?


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


On 12/22/21 10:47 AM, Duncan Murdoch wrote:

On 22/12/2021 10:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

Both syntax options work to render the correct (unique) output. However,
the output is rendered as horizontal. What needs to happen to get the
output to render vertical, please?


The result of those expressions is a vector of the same type as the 
column, so your question is really about how to get a vector to print 
one element per line.


Probably the simplest way is to put the vector in a dataframe (or 
matrix, or tibble, depending on which formatting you prefer).  For 
example,


>   v <- c("red", "green", "blue")
>   data.frame(v)
  v
1   red
2 green
3  blue

If you want a more minimal display, try

> cat(v, sep = "\n")
red
green
blue

or

> cat(format(v, justify = "right"), sep = "\n")
  red
green
 blue

If you want this to happen when you auto-print the object, you can 
give it a class attribute and write a function to print that class, e.g.


>  class(v) <- "oneperline"
>
>   print.oneperline <- function(x, ...) cat(format(x, justify = 
"right"), sep = "\n")

>
>   v
  red
green
 blue

Duncan Murdoch




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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
      undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

 sort(unique(Data[[1]]))


Actually, I'd probably recommend

   sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list.
Dataframes are lists that look like matrices, but to me the matrix
aspect is usually more intuitive.

Duncan Murdoch



I think Rui already pointed out the typo in the quoted text below...

Duncan Murdoch



The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the column
may
be text or numbers. This is a huge analysis effort with data 
coming at

me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique
entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with 
ease.

Python and SQL can do it with ease.


I've seen several responses that looked pretty simple. It's hard to
beat sort(unique(x)), though there's a fair bit of confusion about
what you actually want.  Maybe you should post an example of the 
code

you'd use in Python?

Duncan Murdoch



QUESTION
Is there a simpler means than other than the unique function to
capture
distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.


This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]]
extracts the column vector.

As for my previous answer, it was not addressing the question, I
misinterpreted it as being a question on how to sort by numeric
order
when the data is not numeric. Here is a, hopefully, complete 
answer.

Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
      stringr::str_sort(unique(x), numeric = TRUE)
})


Or using Avi's suggestion of writing a function to do all the
work and
simplify the lapply loop later,


unisort2 <- function(vec, ...) stringr::str_sort(unique(vec), ...)
Data2 <- lapply(Data[cols_to_sort], unisort, numeric = TRUE)


Hope this helps,

Rui Barradas




*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
ht

Re: [R] Adding SORT to UNIQUE

2021-12-22 Thread Stephen H. Dawson, DSL via R-help
ing with how things 
are added into the right place or tightening up the data structure if something 
is removed all the time. Others simply supply a sorted() method to use only 
when you actually need that. R can be done in similar ways and you can create 
objects of quite a few kinds to implement some things but it does not often 
seem necessary, at least to me.

I can imagine writing a function that makes a data.frame even from vectors of 
unequal length by calculating the length of the longest vector and then setting 
each shorter vector to be longer with code like:

length(a) <- longest

You can then patch together all the results into a data.frame with trailing NA 
values on some columns.

I quickly cobbled together a few lines that can do that and can be placed 
inside a function to return this:

   lapply(lapply(lapply(mydf, unique), sort), toupper) -> uneven
   longest <- max(unlist(lapply(uneven, length)))
   answer <- data.frame(lapply(uneven, `length<-`, longest))
   print(answer)

   ints chars
13 I
24 S
35 T
4  Z

Now this has a single NA but I suggest generalizes well to a more complex 
example:

ints lower upper
110 k Z
2 9 j A
3 8 i Z
4 7 h A
5 6 g Z
6 5 f A
7 4 h Z
8 3 i A
9 2 j Z
101 k A
112 l Z
123 m A

These are uneven and three columns so I tried a function version:

   mydf2 <- data.frame(ints = c(10:1, 2:3),
   lower = c(letters[11:6], letters[8:13]),
   upper = rep(c("Z", "A"), 6))
   
   unisortuneven <- function(anydf) {

 uneven <- lapply(lapply(lapply(anydf, unique), sort), toupper)
 longest <- max(unlist(lapply(uneven, length)))
 data.frame(lapply(uneven, `length<-`, longest))
   }
   
   unisortuneven(mydf2)

   ints lower upper
   1 1 F A
   2 2 G Z
   3 3 H  
 4 4 I  
 5 5 J  
 6 6 K  
 7 7 L  
 8 8 M  
 9 9
 10   10
 
 The above does not format great for text, sadly, so is better shown as the transpose for display purposes:


   > t(unisortuneven(mydf2))
   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
   ints  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"
   lower "F"  "G"  "H"  "I"  "J"  "K"  "L"  "M"  NA   NA
   upper "A"  "Z"  NA   NA   NA   NA   NA   NA   NA   NA

But hopefully it makes my point that a little thinking and KNOWING about features 
of R like how to use a functionalized version of length() that sets a changed 
value using the odd notation of `length<-` can let you solve all kinds of 
problems in a somewhat abstract manner. Of course the above function is not 
refined and will not handle some useful transformations or deal with errors. That 
can make it quite a bit harder and in some cases, make it a good idea to find 
someone sharing a package where they did the hard work and documented exactly what 
their function does.

I am eclectic and happy to switch tools at a moment's notice if they offer an 
interesting way to do something. But, within a language, I learn the darn rules 
and also the idioms often used and then choose from among many ways I can see 
to solve something and use what is available.  You had a trivial solution 
available to you to simply do one step at a time and save intermediate values, 
transforming at times. Some of us have sent you more general solutions. Do you 
still think what you want is so much harder to do in R, or that perhaps you are 
not thinking in R and thus want it to do it some other way other languages do?





-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson, DSL 
via R-help
Sent: Tuesday, December 21, 2021 10:16 AM
To: Rui Barradas ; Stephen H. Dawson, DSL via R-help 

Subject: Re: [R] Adding SORT to UNIQUE

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique entries into 
another dataframe.

It seems odd R cannot sort a list of unique column entries with ease.
Python and SQL can do it with ease.

QUESTION
Is there a simpler means than other than the unique function to capture 
distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.

This is not right.
The syntax Data[1] extracts a sub-data

Re: [R] Adding SORT to UNIQUE

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

Bert,


Thanks for the reply.

I did not think to put values back into the same column. This action 
would not make sense to me, as it would destroy data integrity. I guess 
adding to a new column in the same container, in this case a dataframe, 
is possible but again not probable with me.


Either way, thanks for confirming all that comes out count-wise in a 
dataframe is what must go back into a dataframe count-wise.


It is nice to have folks on a mailing list that help to flush out what 
one thinks is and will happen with syntax versus what is happening and 
will happen with syntax.



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


On 12/21/21 3:38 PM, Bert Gunter wrote:

Stephen:
You seem confused about data frames. sort(unique(...)) has no problem
sorting individual columns in a data frame (mod the issues about
mixing numerics and non-numerics that have already been discussed).
But the problem is that the results can *not* be put back in a data
frame because, **by definition** all columns in a data frame **must**
have the same number of values. unique() will change the number of
values in a column if done column by column, e.g. via lapply() or
looping over columns. Consequently, if you do this by lapply(), you'll
get a list back, not a data frame. e.g.


dat <- data.frame(a = rep(3:1,2), b = c(5:1,5))
dat

   a b
1 3 5
2 2 4
3 1 3
4 3 2
5 2 1
6 1 5

## via lapply
dat <- lapply(dat, \(x)sort(unique(x)))
dat  ## a list.

$a
[1] 1 2 3

$b
[1] 1 2 3 4 5


## Trying to do this with an explicit loop results in an error
dat <- data.frame(a = rep(1:3,2), b = c(1:5,5))
for(nm in names(dat))dat[[nm]] <- sort(unique(dat[[nm]])) ## error

Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(1, 2, 3, 4, 5)) :
   replacement has 5 rows, data has 6

OTOH, unique() has a data.frame method which will give unique *rows*
(thinking of a data frame as a matrix-like object with a "dim"
attribute):


dat <- data.frame(a = c(1,2,1), b = c('a','b','a'))
dat

   a b
1 1 a
2 2 b
3 1 a

unique(dat)

   a b
1 1 a
2 2 b

There is no sort() method for data frames as this has no obvious
single interpretation of sorting by whole rows. However, see ?sort for
an example using ?order to carry out one possible interpretation of
sorting by rows.

Bert


On Tue, Dec 21, 2021 at 7:16 AM Stephen H. Dawson, DSL via R-help
 wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique
entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with ease.
Python and SQL can do it with ease.

QUESTION
Is there a simpler means than other than the unique function to capture
distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.

This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]]
extracts the column vector.

As for my previous answer, it was not addressing the question, I
misinterpreted it as being a question on how to sort by numeric order
when the data is not numeric. Here is a, hopefully, complete answer.
Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
   stringr::str_sort(unique(x), numeric = TRUE)
})


Or using Avi's suggestion of writing a function to do all the work and
simplify the lapply loop later,


unisort2 <- function(vec, ...) stringr::str_sort(unique(vec), ...)
Data2 <- lapply(Data[cols_to_sort], unisort, numeric = TRUE)


Hope this helps,

Rui Barradas



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


On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


Running a simple syntax set to review entries in dataframe columns.
Here is the working code.

Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various
columns are not defined as numbers, but also text. I realize 1 and
10 will not sort properly, as the column is not defined as a number,
but want to see what I have in the columns viewed as sorted.

QUESTION
What is the best process to sort unique output, 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/p

Re: [R] Adding SORT to UNIQUE

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

Thanks for the reply.

Both syntax options work to render the correct (unique) output. However, 
the output is rendered as horizontal. What needs to happen to get the 
output to render vertical, please?



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


On 12/21/21 11:38 AM, Duncan Murdoch wrote:

On 21/12/2021 11:31 a.m., Duncan Murdoch wrote:

On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote:

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
     undefined columns selected


That's the wrong syntax:  Data[1] is not "column one of Data". Use
Data[[1]] for that, so

    sort(unique(Data[[1]]))


Actually, I'd probably recommend

  sort(unique(Data[, 1]))

instead.  This treats Data as a matrix rather than as a list. 
Dataframes are lists that look like matrices, but to me the matrix 
aspect is usually more intuitive.


Duncan Murdoch



I think Rui already pointed out the typo in the quoted text below...

Duncan Murdoch



The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the column 
may

be text or numbers. This is a huge analysis effort with data coming at
me from many different sources.


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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique
entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with ease.
Python and SQL can do it with ease.


I've seen several responses that looked pretty simple.  It's hard to
beat sort(unique(x)), though there's a fair bit of confusion about
what you actually want.  Maybe you should post an example of the code
you'd use in Python?

Duncan Murdoch



QUESTION
Is there a simpler means than other than the unique function to 
capture

distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.


This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]]
extracts the column vector.

As for my previous answer, it was not addressing the question, I
misinterpreted it as being a question on how to sort by numeric 
order

when the data is not numeric. Here is a, hopefully, complete answer.
Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
     stringr::str_sort(unique(x), numeric = TRUE)
})


Or using Avi's suggestion of writing a function to do all the 
work and

simplify the lapply loop later,


unisort2 <- function(vec, ...) stringr::str_sort(unique(vec), ...)
Data2 <- lapply(Data[cols_to_sort], unisort, numeric = TRUE)


Hope this helps,

Rui Barradas




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


On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


Running a simple syntax set to review entries in dataframe 
columns.

Here is the working code.

Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the 
various

columns are not defined as numbers, but also text. I realize 1 and
10 will not sort properly, as the column is not defined as a 
number,

but want to see what I have in the columns viewed as sorted.

QUESTION
What is the best process to sort unique output, 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
P

Re: [R] Adding SORT to UNIQUE

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

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = 
decreasing)) :

  undefined columns selected

The recommended syntax did not work, as listed above.

What I want is the sort of distinct column output. Again, the column may 
be text or numbers. This is a huge analysis effort with data coming at 
me from many different sources.



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


On 12/21/21 11:07 AM, Duncan Murdoch wrote:

On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote:

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique
entries into another dataframe.

It seems odd R cannot sort a list of unique column entries with ease.
Python and SQL can do it with ease.


I've seen several responses that looked pretty simple.  It's hard to 
beat sort(unique(x)), though there's a fair bit of confusion about 
what you actually want.  Maybe you should post an example of the code 
you'd use in Python?


Duncan Murdoch



QUESTION
Is there a simpler means than other than the unique function to capture
distinct column entries, then sort that list?


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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.


This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]]
extracts the column vector.

As for my previous answer, it was not addressing the question, I
misinterpreted it as being a question on how to sort by numeric order
when the data is not numeric. Here is a, hopefully, complete answer.
Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
   stringr::str_sort(unique(x), numeric = TRUE)
})


Or using Avi's suggestion of writing a function to do all the work and
simplify the lapply loop later,


unisort2 <- function(vec, ...) stringr::str_sort(unique(vec), ...)
Data2 <- lapply(Data[cols_to_sort], unisort, numeric = TRUE)


Hope this helps,

Rui Barradas




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


On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


Running a simple syntax set to review entries in dataframe columns.
Here is the working code.

Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various
columns are not defined as numbers, but also text. I realize 1 and
10 will not sort properly, as the column is not defined as a number,
but want to see what I have in the columns viewed as sorted.

QUESTION
What is the best process to sort unique output, 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] Adding SORT to UNIQUE

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

Thanks everyone for the replies.

It is clear one either needs to write a function or put the unique 
entries into another dataframe.


It seems odd R cannot sort a list of unique column entries with ease. 
Python and SQL can do it with ease.


QUESTION
Is there a simpler means than other than the unique function to capture 
distinct column entries, then sort that list?



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


On 12/20/21 5:53 PM, Rui Barradas wrote:

Hello,

Inline.

Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu:

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.


This is not right.
The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]] 
extracts the column vector.


As for my previous answer, it was not addressing the question, I 
misinterpreted it as being a question on how to sort by numeric order 
when the data is not numeric. Here is a, hopefully, complete answer.

Still with package stringr.


cols_to_sort <- 1:4

Data2 <- lapply(Data[cols_to_sort], \(x){
  stringr::str_sort(unique(x), numeric = TRUE)
})


Or using Avi's suggestion of writing a function to do all the work and 
simplify the lapply loop later,



unisort2 <- function(vec, ...) stringr::str_sort(unique(vec), ...)
Data2 <- lapply(Data[cols_to_sort], unisort, numeric = TRUE)


Hope this helps,

Rui Barradas




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


On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


Running a simple syntax set to review entries in dataframe columns. 
Here is the working code.


Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various 
columns are not defined as numbers, but also text. I realize 1 and 
10 will not sort properly, as the column is not defined as a number, 
but want to see what I have in the columns viewed as sorted.


QUESTION
What is the best process to sort unique output, 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.


Re: [R] Adding SORT to UNIQUE

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

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = 
decreasing)) :

  undefined columns selected

The recommended syntax did not work, as listed above.


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


On 12/20/21 12:15 PM, Avi Gross via R-help wrote:

Stephen,

You can sort using sort() either before or after doing a unique. Unique
removes all duplicates in any order so sorting before may be wasteful. in
your data shown below, do this:

sort(unique(Data[1]))
sort(unique(Data[2]))
sort(unique(Data[3]))
sort(unique(Data[4]))

Even simpler is to define a function like this:

unisort <- function(vec) sort(unique(vec))

and use it like this:

unisort(Data[1])


And since you seem to want all of the first four columns of Data you may
want to do them all at once using something like:

lapply(Data[1:4], unisort)

As you note, the sort ordering depends on the data and perhaps on options
you specify.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Monday, December 20, 2021 11:59 AM
To: Stephen H. Dawson, DSL via R-help 
Subject: [R] Adding SORT to UNIQUE

Hi,


Running a simple syntax set to review entries in dataframe columns. Here is
the working code.

Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various columns
are not defined as numbers, but also text. I realize 1 and 10 will not sort
properly, as the column is not defined as a number, but want to see what I
have in the columns viewed as sorted.

QUESTION
What is the best process to sort unique output, please?


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

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

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



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

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

Thanks.

sort(unique(Data[[1]]))

This syntax provides row numbers, not column values.

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


On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


Running a simple syntax set to review entries in dataframe columns. 
Here is the working code.


Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various 
columns are not defined as numbers, but also text. I realize 1 and 10 
will not sort properly, as the column is not defined as a number, but 
want to see what I have in the columns viewed as sorted.


QUESTION
What is the best process to sort unique output, 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.


Re: [R] Adding SORT to UNIQUE

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

Thanks for the reply.

sort(unique(Data[1]))
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = 
decreasing)) :

  undefined columns selected

The recommended syntax did not work, as listed above.

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


On 12/20/21 12:15 PM, Avi Gross via R-help wrote:

Stephen,

You can sort using sort() either before or after doing a unique. Unique
removes all duplicates in any order so sorting before may be wasteful. in
your data shown below, do this:

sort(unique(Data[1]))
sort(unique(Data[2]))
sort(unique(Data[3]))
sort(unique(Data[4]))

Even simpler is to define a function like this:

unisort <- function(vec) sort(unique(vec))

and use it like this:

unisort(Data[1])


And since you seem to want all of the first four columns of Data you may
want to do them all at once using something like:

lapply(Data[1:4], unisort)

As you note, the sort ordering depends on the data and perhaps on options
you specify.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Monday, December 20, 2021 11:59 AM
To: Stephen H. Dawson, DSL via R-help 
Subject: [R] Adding SORT to UNIQUE

Hi,


Running a simple syntax set to review entries in dataframe columns. Here is
the working code.

Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various columns
are not defined as numbers, but also text. I realize 1 and 10 will not sort
properly, as the column is not defined as a number, but want to see what I
have in the columns viewed as sorted.

QUESTION
What is the best process to sort unique output, please?


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

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

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



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

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

Hi,


Running a simple syntax set to review entries in dataframe columns. Here 
is the working code.


Data <- read.csv("./input/Source.csv", header=T)
describe(Data)
summary(Data)
unique(Data[1])
unique(Data[2])
unique(Data[3])
unique(Data[4])

I would like to add sort the unique entries. The data in the various 
columns are not defined as numbers, but also text. I realize 1 and 10 
will not sort properly, as the column is not defined as a number, but 
want to see what I have in the columns viewed as sorted.


QUESTION
What is the best process to sort unique output, please?


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

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


Re: [R] Question about Rfast colMins and colMaxs

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

Thanks, Richard.

I am researching other library options for data inspection. I have many 
csv files I am reviewing with different column names and data types. 
Flexibility of a quick review of max and min is quite valuable at this 
juncture.


I will implement your code recommendation next week and see how it performs.


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


On 12/2/21 11:06 PM, Richard O'Keefe wrote:

What puzzles me is why you are not just using
lapply(some.data.frame, min)
lapply(some.data.frame, max)
or as.vector(lapply(...))
Why go to another package for this?
Is it the indices you want?

col.min.indices <- function (some.data.frame) {
    v <- sapply(some.data.frame, function (column)
which(column == min(column))[1])
    names(v) <- colnames(some.data.frame)
    v
}


On Wed, 1 Dec 2021 at 07:55, Stephen H. Dawson, DSL via R-help 
mailto:r-help@r-project.org>> 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/index.html>

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
<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,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>
<http://www.shdawson.com <http://www.shdawson.com>>

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



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


Re: [R] Question about Rfast colMins and colMaxs

2021-12-02 Thread Stephen H. Dawson, DSL via R-help
he 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 <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 the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

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

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

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


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse
consists of all *non*-standard contributed packages, about which the PG

says:

"For questions about functions in standard packages distributed with
R (see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of cu

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

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 <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 <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 <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 <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
 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 <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 the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

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

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

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


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse
consists of all *non*-standard contributed packages, about which the PG

says:

"For questions about functions in standard packages distributed with
R (see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first.
You can also use find("functionname") and
packageDescription("packagename") to find this information. Only
send such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to
bug reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be

posted.



Bert Gunter

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

On Tue, Nov 30, 2021 at 10:55 AM 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=dou

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 <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 <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 <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] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

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 <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 the best practice should be for their package. As has been
pointed out already, it appears to differ from the usual "read it in
as a data frame" procedure.

Bert

On Tue, Nov 30, 2021 at 2:11 PM Stephen H. Dawson, DSL
 wrote:

Right, R Studio is not R.

However, the Rfast package is part of R.

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

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be
accessed by colMaxs and colMins, please?

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


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the PG says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.



Bert Gunter

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

On Tue, Nov 30, 2021 at 10:55 AM 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,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>

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




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


Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

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


Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Thanks, Bill.

How do you go about getting maximum and minimum values from your 
columns? Do you simply do them one column at a time? The functions I am 
identifying from Rfast do this work in bulk.



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


On 11/30/21 3:24 PM, Bill Dunlap wrote:
You can use as.matrix() to convert your data.frame to a matrix, but 
that loses the speed/space advantages of colMins (as well as causing 
issues if some columns are not numeric).  You could write to the 
maintainer of the package to ask that data.frames be directly 
supported.  In the meantime you could use

   vapply(yourDataFrame, which.min, FUN.VALUE=NA_real_)
or
    vapply(yourDataFrame, min, FUN.VALUE=NA_real_)
instead of colMins.

-Bill

On Tue, Nov 30, 2021 at 10:55 AM Stephen H. Dawson, DSL via R-help 
mailto:r-help@r-project.org>> 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/index.html>

https://cran.r-project.org/web/packages/Rfast/Rfast.pdf
<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,
-- 
*Stephen Dawson, DSL*

/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>
<http://www.shdawson.com <http://www.shdawson.com>>

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



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


Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

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


Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

Right, R Studio is not R.

However, the Rfast package is part of R.

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

So, rephrasing my question...
What is the best practice to bring a csv file into R so it can be 
accessed by colMaxs and colMins, please?


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


On 11/30/21 3:19 PM, Bert Gunter wrote:

RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the PG says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Add-on-packages-in-R
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

Note that RStudio maintains its own help resources at:
https://community.rstudio.com/
This is where questions about the TidyVerse, ggplot, etc. should be posted.



Bert Gunter

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

On Tue, Nov 30, 2021 at 10:55 AM 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,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>

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


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


[R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Stephen H. Dawson, DSL via R-help

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,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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] Defining Parameters in arules

2021-11-24 Thread Stephen H. Dawson, DSL via R-help

https://rattle.togaware.com/

https://journal.r-project.org/archive/2009/RJ-2009-016/index.html

Thank you, Tom.

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


On 11/23/21 5:55 AM, Tom Woolman wrote:
Greg Williams has a book titled "Data Mining with Rattle and R", which 
has a chapter on association rules and the arules package. Williams' 
Rattle GUI package for R also lets you define an association rules 
model using a graphical interface (which creates the R code for you in 
the log file for Rattle). I use this textbook in one of the MS-level R 
courses that I teach and found it to be a good way to convey these 
concepts especially for those new to R and AI/ML generally.



On 2021-11-23 05:17, Ivan Krylov wrote:

Hello,

If you don't get an answer here, consider asking the package
maintainer: Michael Hahsler


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

2021-11-24 Thread Stephen H. Dawson, DSL via R-help

Thank, Ivan.

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


On 11/23/21 5:17 AM, Ivan Krylov wrote:

Hello,

If you don't get an answer here, consider asking the package
maintainer: Michael Hahsler



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

2021-11-23 Thread Stephen H. Dawson, DSL via R-help

Hi,


New to the list, first post.

I have reviewed the file:
https://cran.r-project.org/web/packages/arules/arules.pdf

I am unable to find what I am after, so I am asking the mailing list for 
assistance, please.


I am using arules to accomplish apriori for reviewing some association 
rules work output from a colleague. I have validated I have the exact 
same output as my colleague in the syntax I am running. However, I read 
my colleague has ext listed as FALSE in their parameter specification. I 
would like to set my ext to FALSE on my end, as it is set to TRUE now.


QUESTION
What is the syntax to set my apriori parameter specification for ext to 
FALSE?


Thank you in advance for your assistance.


Kindest Regards,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.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 with plotmat package

2021-09-16 Thread H
On 09/16/2021 09:26 PM, H wrote:
> On 09/16/2021 09:00 PM, Jim Lemon wrote:
>> Okay, that was just my reading of the help page. I hope that I haven't
>> added to the confusion.
>>
>> Jim
>>
>> On Fri, Sep 17, 2021 at 10:50 AM H  wrote:
>>> On 09/15/2021 09:40 PM, Jim Lemon wrote:
>>>> Oops, your plot
>>>>
>>>> On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon  wrote:
>>>>> Hi H,
>>>>> Looking at your example and the help page, it looks to me as though
>>>>> the plot is consistent with the "A" matrix:
>>>>>
>>>>>  Oz
>>>>> Rain Nice
>>>>> Rain 0.25 0.75
>>>>> Nice 0.60 0.40
>>>>>
>>>>> # help page
>>>>> A  - square coefficient matrix, specifying the links (rows=to, cols=from).
>>>>>
>>>>> In your plot (attached):
>>>>> Rain (col) goes to Rain (row) 0.25
>>>>> Rain (col) goes to Nice (row) 0.6
>>>>> Nice (col) goes to Nice (row) 0.4
>>>>> Nice (col) goes to Rain (row) 0.75
>>>>>
>>>>> This is a bit confusing, but it seems to do what it says it does.
>>>>>
>>>>> Jim
>>>>>
>>>>> On Thu, Sep 16, 2021 at 10:40 AM H  wrote:
>>>>>> I am using plotmat 1.6.5 (part of the diagram package) in R 3.6 to plot 
>>>>>> Markov transition charts but have run into an issue that I was hoping 
>>>>>> someone could shed light on here. I did e-mail the maintainer over a 
>>>>>> month ago but have not received a reply.
>>>>>>
>>>>>> The issue is that the directional arrows point in the wrong direction. A 
>>>>>> brief example:
>>>>>>
>>>>>> stateNames <- c("Rain", "Nice")
>>>>>> Oz <- matrix(c(0.25, 0.75, 0.6, 0.4), nrow = 2, byrow = TRUE)
>>>>>> rownames(Oz) <- stateNames; colnames(Oz) <- stateNames
>>>>>> plotmat(Oz, pos = c(1, 1), lwd = 1, box.lwd = 2, cex.txt = 0.8, box.size 
>>>>>> = 0.1, box.type = "circle", box.prop = 0.5, box.col = "light yellow", 
>>>>>> arr.length = 0.2, arr.width = 0.2, self.cex = 0.4, self.shifty = 0.01, 
>>>>>> self.shiftx = 0.13, main = "")
>>>>>>
>>>>>> In the above example both arrows seem to point in the direction opposite 
>>>>>> to what I expect. Has anyone encountered this and know how to fix it?
>>>>>>
>>>>>> 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.
>>> I am sorry but I think you have it wrong. A transition probability matrix 
>>> for the rain/nice scenario would be written:
>>>
>>> Rain, Nice
>>>
>>> Rain |0.25, 0.75|
>>>
>>> Nice |0.60, 0.40|
>>>
>>> If you sum the transition probabilities for rain or nice, they should each 
>>> add to 1. Logic dictates if the only two states are rain and nice, and rain 
>>> continues the next day with a probability of 0.25, nice must have a 
>>> probability of 0.75. Likewise, the sum of probabilities for nice weather to 
>>> change to rain, 0.6, and remain the same, 0.4 must add up to 1.
>>>
>>> I find that the arrow directions are the opposite of what I expect.
>>>
> I just realized you did identify what the problem was, it was not the arrow 
> direction but that the matrix needed to be transposed before used in plotmat. 
> I am used to transition probability matrices read row-wise where each row 
> adds up to 1. Plotmat expects the transition matrix to be read column-wise 
> where each column adds up to 1.
>
> Transposing the original matrix using t() before using it in plotmat() also 
> resolved my own example which is considerably more complex.
>
> Thank you for your help!
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Perhaps someone knows if it is possible to position the state boxes more 
flexibly in plotmat()?

I have eight states I plot in four rows of 1-3-3-1 because it makes logical 
sense to group them this way row-wise. There are transitions between some of 
the states and the default positioning of the states, the transition arrows and 
associated transition probabilities makes for not-so-clear figure...

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

2021-09-16 Thread H
On 09/16/2021 09:00 PM, Jim Lemon wrote:
> Okay, that was just my reading of the help page. I hope that I haven't
> added to the confusion.
>
> Jim
>
> On Fri, Sep 17, 2021 at 10:50 AM H  wrote:
>> On 09/15/2021 09:40 PM, Jim Lemon wrote:
>>> Oops, your plot
>>>
>>> On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon  wrote:
>>>> Hi H,
>>>> Looking at your example and the help page, it looks to me as though
>>>> the plot is consistent with the "A" matrix:
>>>>
>>>>  Oz
>>>> Rain Nice
>>>> Rain 0.25 0.75
>>>> Nice 0.60 0.40
>>>>
>>>> # help page
>>>> A  - square coefficient matrix, specifying the links (rows=to, cols=from).
>>>>
>>>> In your plot (attached):
>>>> Rain (col) goes to Rain (row) 0.25
>>>> Rain (col) goes to Nice (row) 0.6
>>>> Nice (col) goes to Nice (row) 0.4
>>>> Nice (col) goes to Rain (row) 0.75
>>>>
>>>> This is a bit confusing, but it seems to do what it says it does.
>>>>
>>>> Jim
>>>>
>>>> On Thu, Sep 16, 2021 at 10:40 AM H  wrote:
>>>>> I am using plotmat 1.6.5 (part of the diagram package) in R 3.6 to plot 
>>>>> Markov transition charts but have run into an issue that I was hoping 
>>>>> someone could shed light on here. I did e-mail the maintainer over a 
>>>>> month ago but have not received a reply.
>>>>>
>>>>> The issue is that the directional arrows point in the wrong direction. A 
>>>>> brief example:
>>>>>
>>>>> stateNames <- c("Rain", "Nice")
>>>>> Oz <- matrix(c(0.25, 0.75, 0.6, 0.4), nrow = 2, byrow = TRUE)
>>>>> rownames(Oz) <- stateNames; colnames(Oz) <- stateNames
>>>>> plotmat(Oz, pos = c(1, 1), lwd = 1, box.lwd = 2, cex.txt = 0.8, box.size 
>>>>> = 0.1, box.type = "circle", box.prop = 0.5, box.col = "light yellow", 
>>>>> arr.length = 0.2, arr.width = 0.2, self.cex = 0.4, self.shifty = 0.01, 
>>>>> self.shiftx = 0.13, main = "")
>>>>>
>>>>> In the above example both arrows seem to point in the direction opposite 
>>>>> to what I expect. Has anyone encountered this and know how to fix it?
>>>>>
>>>>> 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.
>> I am sorry but I think you have it wrong. A transition probability matrix 
>> for the rain/nice scenario would be written:
>>
>> Rain, Nice
>>
>> Rain |0.25, 0.75|
>>
>> Nice |0.60, 0.40|
>>
>> If you sum the transition probabilities for rain or nice, they should each 
>> add to 1. Logic dictates if the only two states are rain and nice, and rain 
>> continues the next day with a probability of 0.25, nice must have a 
>> probability of 0.75. Likewise, the sum of probabilities for nice weather to 
>> change to rain, 0.6, and remain the same, 0.4 must add up to 1.
>>
>> I find that the arrow directions are the opposite of what I expect.
>>
I just realized you did identify what the problem was, it was not the arrow 
direction but that the matrix needed to be transposed before used in plotmat. I 
am used to transition probability matrices read row-wise where each row adds up 
to 1. Plotmat expects the transition matrix to be read column-wise where each 
column adds up to 1.

Transposing the original matrix using t() before using it in plotmat() also 
resolved my own example which is considerably more complex.

Thank you for your help!

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

2021-09-16 Thread H
On 09/15/2021 09:40 PM, Jim Lemon wrote:
> Oops, your plot
>
> On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon  wrote:
>> Hi H,
>> Looking at your example and the help page, it looks to me as though
>> the plot is consistent with the "A" matrix:
>>
>>  Oz
>> Rain Nice
>> Rain 0.25 0.75
>> Nice 0.60 0.40
>>
>> # help page
>> A  - square coefficient matrix, specifying the links (rows=to, cols=from).
>>
>> In your plot (attached):
>> Rain (col) goes to Rain (row) 0.25
>> Rain (col) goes to Nice (row) 0.6
>> Nice (col) goes to Nice (row) 0.4
>> Nice (col) goes to Rain (row) 0.75
>>
>> This is a bit confusing, but it seems to do what it says it does.
>>
>> Jim
>>
>> On Thu, Sep 16, 2021 at 10:40 AM H  wrote:
>>> I am using plotmat 1.6.5 (part of the diagram package) in R 3.6 to plot 
>>> Markov transition charts but have run into an issue that I was hoping 
>>> someone could shed light on here. I did e-mail the maintainer over a month 
>>> ago but have not received a reply.
>>>
>>> The issue is that the directional arrows point in the wrong direction. A 
>>> brief example:
>>>
>>> stateNames <- c("Rain", "Nice")
>>> Oz <- matrix(c(0.25, 0.75, 0.6, 0.4), nrow = 2, byrow = TRUE)
>>> rownames(Oz) <- stateNames; colnames(Oz) <- stateNames
>>> plotmat(Oz, pos = c(1, 1), lwd = 1, box.lwd = 2, cex.txt = 0.8, box.size = 
>>> 0.1, box.type = "circle", box.prop = 0.5, box.col = "light yellow", 
>>> arr.length = 0.2, arr.width = 0.2, self.cex = 0.4, self.shifty = 0.01, 
>>> self.shiftx = 0.13, main = "")
>>>
>>> In the above example both arrows seem to point in the direction opposite to 
>>> what I expect. Has anyone encountered this and know how to fix it?
>>>
>>> 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.

I am sorry but I think you have it wrong. A transition probability matrix for 
the rain/nice scenario would be written:

Rain, Nice

Rain |0.25, 0.75|

Nice |0.60, 0.40|

If you sum the transition probabilities for rain or nice, they should each add 
to 1. Logic dictates if the only two states are rain and nice, and rain 
continues the next day with a probability of 0.25, nice must have a probability 
of 0.75. Likewise, the sum of probabilities for nice weather to change to rain, 
0.6, and remain the same, 0.4 must add up to 1.

I find that the arrow directions are the opposite of what I expect.

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

2021-09-15 Thread H
I am using plotmat 1.6.5 (part of the diagram package) in R 3.6 to plot Markov 
transition charts but have run into an issue that I was hoping someone could 
shed light on here. I did e-mail the maintainer over a month ago but have not 
received a reply.

The issue is that the directional arrows point in the wrong direction. A brief 
example:

stateNames <- c("Rain", "Nice")
Oz <- matrix(c(0.25, 0.75, 0.6, 0.4), nrow = 2, byrow = TRUE)
rownames(Oz) <- stateNames; colnames(Oz) <- stateNames
plotmat(Oz, pos = c(1, 1), lwd = 1, box.lwd = 2, cex.txt = 0.8, box.size = 0.1, 
box.type = "circle", box.prop = 0.5, box.col = "light yellow", arr.length = 
0.2, arr.width = 0.2, self.cex = 0.4, self.shifty = 0.01, self.shiftx = 0.13, 
main = "")

In the above example both arrows seem to point in the direction opposite to 
what I expect. Has anyone encountered this and know how to fix it?

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] Markov modeling using msm

2021-08-08 Thread H
On 08/08/2021 03:43 AM, Rui Barradas wrote:
> Hello,
>
> There are CRAN packages, for instance, packages DTMCPack and markovchain, 
> that require transition probabilities as input. See this R-bloggers post [1].
>
>
> [1] https://www.r-bloggers.com/2016/01/getting-started-with-markov-chains/
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 02:21 de 08/08/21, H escreveu:
>> I would like to use R and msm to replicate the results from a published 
>> study where the authors used Tree Age Pro 2011 for their Markov modeling. I 
>> am new to Markov modeling and while I have tried to read up, my 
>> understanding is still quite limited...
>>
>> The papers contains the the state transition probabilities but it seems to 
>> me that msm requires transition intensities rather than transition 
>> probabilities. Is this correct?
>>
>> If so, the msm documentation suggests that msm can output transition 
>> probabilities but is there any way I can do the reverse, ie input transition 
>> probabilities into my msm model?
>>
>> Appreciate any pointers.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
Thank you, will check those out!

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

2021-08-07 Thread H
I would like to use R and msm to replicate the results from a published study 
where the authors used Tree Age Pro 2011 for their Markov modeling. I am new to 
Markov modeling and while I have tried to read up, my understanding is still 
quite limited...

The papers contains the the state transition probabilities but it seems to me 
that msm requires transition intensities rather than transition probabilities. 
Is this correct?

If so, the msm documentation suggests that msm can output transition 
probabilities but is there any way I can do the reverse, ie input transition 
probabilities into my msm model?

Appreciate any pointers.

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

2020-10-30 Thread H
On 10/30/2020 03:52 AM, Enrico Schumann wrote:
> On Thu, 29 Oct 2020, H writes:
>
>> I tried to install the fredr package yesterday to
>> access the data series hosted by the St. Louis Fed but
>> my installation of R, version 3.6, tells me it is not
>> available from a cran repository.
>>
>> I could not find any information on this on the fredr information package 
>> and was wondering if anyone here might know?
>>
> Just for completeness: there is also the 'alfred' package
> (https://cran.r-project.org/package=alfred), with which
> you can also access data of the St. Louis Fed.
>
Thank you, will look at alfred.

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

2020-10-29 Thread H
On 10/29/2020 07:20 PM, Marc Schwartz wrote:
>> On Oct 29, 2020, at 6:35 PM, H  wrote:
>>
>> On 10/29/2020 01:49 PM, Marc Schwartz wrote:
>>>> On Oct 29, 2020, at 1:29 PM, H  wrote:
>>>>
>>>> I tried to install the fredr package yesterday to access the data series 
>>>> hosted by the St. Louis Fed but my installation of R, version 3.6, tells 
>>>> me it is not available from a cran repository.
>>>>
>>>> I could not find any information on this on the fredr information package 
>>>> and was wondering if anyone here might know?
>>> Hi,
>>>
>>> When that happens, check the CRAN page for the package:
>>>
>>>  https://cran.r-project.org/web/packages/fredr/index.html
>>>
>>> where you will see that the package has been archived as a result of a lack 
>>> of response by the maintainer to problems with the package.
>>>
>>> The archive link on the above page allows you to download the last version 
>>> of the source package tarball, however, the check results for the package 
>>> show numerous issues.
>>>
>>> You may want to contact the package maintainer (sboy...@gmail.com) to see 
>>> what the current status of the package is, and if they plan to resolve the 
>>> issues. If not, consider alternative approaches.
>>>
>>> You should also consider updating your R installation, as 3.6.0 is well 
>>> over a year old at this point. 4.0.3 is the current stable release.
>>>
>>> Regards,
>>>
>>> Marc Schwartz
>> Thank you. That is very surprising! I would have thought there would be 
>> sufficient number of users and interest enough for this important package 
>> that it would be maintained!
>>
>> As for R 3.6, it is the latest version in the repository for my operating 
>> system, CentOS/RHEL...
>
> Hi,
>
> On your first point, the number of users is largely irrelevant, if the 
> package maintainer no longer has the interest or the time to continue to 
> support it. It is possible, in that scenario, that an interested user, who 
> has the time and interest, might engage in a process to take over such 
> maintenance.
>
> Keep in mind that package maintainers are, in the vast majority of cases, 
> volunteers. Their motivations for creating and maintaining CRAN packages will 
> vary.
>
> I did a quick check and found that there are discussions in the Issues 
> section of the package's Github repo:
>
>   https://github.com/sboysel/fredr
>
> that suggest that such discussions are indeed taking place. So perhaps the 
> situation with CRAN will be resolved in time. Again, you should contact the 
> maintainer to get a better sense of their plans and possible timeline.
>
> With respect to CentOS/RHEL, you might post to r-sig-fedora, which focuses on 
> R issues on RH derived Linux distros, to see if there are any plans to update 
> R for your version of the distribution:
>
>   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora
>
> The R RPM maintainers, like Tom Callaway, follow that list.
>
> Regards,
>
> Marc
>
Thank you, I will check out the GitHub pages tomorrow. As for R, amazingly 
enough, shortly after your post I received another post that R 4.0 was 
available for CentOS 8... I run CentOS 7 though but hopefully R 4.0 will be 
available there shortly as well. Turns out I was already a member of that 
mailing list and will post a question.

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

2020-10-29 Thread H
On 10/29/2020 01:49 PM, Marc Schwartz wrote:
>> On Oct 29, 2020, at 1:29 PM, H  wrote:
>>
>> I tried to install the fredr package yesterday to access the data series 
>> hosted by the St. Louis Fed but my installation of R, version 3.6, tells me 
>> it is not available from a cran repository.
>>
>> I could not find any information on this on the fredr information package 
>> and was wondering if anyone here might know?
>
> Hi,
>
> When that happens, check the CRAN page for the package:
>
>   https://cran.r-project.org/web/packages/fredr/index.html
>
> where you will see that the package has been archived as a result of a lack 
> of response by the maintainer to problems with the package.
>
> The archive link on the above page allows you to download the last version of 
> the source package tarball, however, the check results for the package show 
> numerous issues.
>
> You may want to contact the package maintainer (sboy...@gmail.com) to see 
> what the current status of the package is, and if they plan to resolve the 
> issues. If not, consider alternative approaches.
>
> You should also consider updating your R installation, as 3.6.0 is well over 
> a year old at this point. 4.0.3 is the current stable release.
>
> Regards,
>
> Marc Schwartz

Thank you. That is very surprising! I would have thought there would be 
sufficient number of users and interest enough for this important package that 
it would be maintained!

As for R 3.6, it is the latest version in the repository for my operating 
system, CentOS/RHEL...

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

2020-10-29 Thread H
I tried to install the fredr package yesterday to access the data series hosted 
by the St. Louis Fed but my installation of R, version 3.6, tells me it is not 
available from a cran repository.

I could not find any information on this on the fredr information package and 
was wondering if anyone here might know?

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

2020-09-20 Thread H
On 09/19/2020 04:33 PM, Abby Spurdle wrote:
>> Understood
> I'd recommend you try to be more precise.
>
>> I just began looking at the volcano dataset which uses geom_contour.
> The volcano dataset does *not* use geom_contour.
> However, the help file for the volcano dataset, does use the
> filled.contour function, in its example.
>
>> I now realize that the function stat_density_2d really maps a heatmap
> If I hadn't read the rest of this thread, I wouldn't know what you
> meant by "maps" a heatmap.
>
> The kde2d function returns a list, containing a density matrix.
> (As per my previous post).
>
> The plotting functions, compute the density via the above density
> estimation function, and then plot that density, in some form.
>
> I suppose you could say the plotting functions map observations to
> density estimates, then map the density estimates to contours and/or
> other graphic data, and then map the graphic data to a plot, which is
> seen by a user...
> ...but it's probably easier to just say plot the density.
>
>> of a computed variable.
> It's rare in probability theory to refer to density as a "variable".
> (Which is relevant because density estimates are estimates of
> probability distributions).
>
> However, it is common in computer graphics and geometry, to use "z"
> for a "third variable".
> And in applied statistics and data science, "variable" could mean anything...
> So, be careful there...
>
> Based on your posts, I take it you want to plot a function of two
> variables (or plot a matrix of values), using a 2d plot.
>
> There are a number of options here.
>
> Contour plots.
> Filled contour plots.
> Heatmaps.
> Plots using hex/other binning.
> Maybe others...?
>
> Additionally, there are 3d plots, such as surface plots.
>
> And I note that it's possible to plot contour lines on top of
> color-filled contours or heatmaps.

I was looking at this example which uses geom_contour():

ggvolcano = volcano %>%
 reshape2::melt() %>%
 ggplot() +
 geom_tile(aes(x=Var1,y=Var2,fill=value)) +
 geom_contour(aes(x=Var1,y=Var2,z=value),color="black") +
 scale_x_continuous("X",expand = c(0,0)) +
 scale_y_continuous("Y",expand = c(0,0)) +
 scale_fill_gradientn("Z",colours = terrain.colors(10)) +
 coord_fixed()
print(ggvolcano)

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

2020-09-19 Thread H
On 09/19/2020 12:42 AM, Jeff Newmiller wrote:
> When dealing with a 2-d density plot, the z variable is a predefined function 
> of your x and y data, it is not something you can specify. If you want to 
> specify z, then you need to use geom_contour. You appear to need to study the 
> theory of kernel density estimates, which is off topic here. (Technically 
> contributed packages like ggplot2 are off topic here also, though sometimes 
> people will answer questions about them anyway.)
>
> On September 18, 2020 6:34:43 PM PDT, H  wrote:
>> On 09/18/2020 02:26 AM, Jeff Newmiller wrote:
>>> No, but fortunately you are off in the weeds. Density has an
>> internally-computed "z" coordinate... you should be looking at
>> ?geom_contour.
>>> On September 17, 2020 7:17:33 PM PDT, H 
>> wrote:
>>>> I am trying to understand how to map 2D to 3D using ggplot() and
>>>> eventually plot_gg(). I am, however, stuck on understanding how to
>>>> express the third variable to be mapped. This example:
>>>>
>>>> ggdiamonds = ggplot(diamonds, aes(x, depth)) +
>>>> stat_density_2d(aes(fill = stat(nlevel)),
>>>> geom = "polygon", n = 100, bins = 10,contour = TRUE) +
>>>> facet_wrap(clarity~.) +
>>>> scale_fill_viridis_c(option = "A")
>>>>
>>>> uses a variable nlevel that I now understand is calculated during
>> the
>>>> building of the ggplot but I have not figured out from where it is
>>>> calculated or how to specify a variable of my choosing.
>>>>
>>>> Does anyone have a good reference for understanding how to specify
>> this
>>>> variable? Most examples on the 'net seem to use the same dataset but
>> do
>>>> not specify this particular aspect...
>>>>
>>>> __
>>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>> But looking at the code in my message above, how does one know what
>> stat(nlevel) refers to? What if I wanted to map another variable in
>> this particular dataset??
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

Understood, I just began looking at the volcano dataset which uses 
geom_contour. I now realize that the function stat_density_2d really maps a 
heatmap of a computed variable.

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

2020-09-18 Thread H
On 09/18/2020 03:08 AM, Carlos Ortega wrote:
> Hi,
>
> There are some further references in the own "RStudio Community" and in 
> StackOverflow:
>
>   * https://community.rstudio.com/t/options-to-stat-density-2d/792/4
>   * 
> https://stackoverflow.com/questions/32206623/what-does-level-mean-in-ggplotstat-density2d
>
> Kind Regards,
> Carlos.
>
>
> On Fri, Sep 18, 2020 at 4:17 AM H  <mailto:age...@meddatainc.com>> wrote:
>
> I am trying to understand how to map 2D to 3D using ggplot() and 
> eventually plot_gg(). I am, however, stuck on understanding how to express 
> the third variable to be mapped. This example:
>
> ggdiamonds = ggplot(diamonds, aes(x, depth)) +
> stat_density_2d(aes(fill = stat(nlevel)),
> geom = "polygon", n = 100, bins = 10,contour = TRUE) +
> facet_wrap(clarity~.) +
> scale_fill_viridis_c(option = "A")
>
> uses a variable nlevel that I now understand is calculated during the 
> building of the ggplot but I have not figured out from where it is calculated 
> or how to specify a variable of my choosing.
>
> Does anyone have a good reference for understanding how to specify this 
> variable? Most examples on the 'net seem to use the same dataset but do not 
> specify this particular aspect...
>
> __
> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Yes, these are two of the links I found but unfortunately they do not explain 
enough. In the second link there is the reference to an internal dataframe etc. 
but I can still not figure out how to specify a z-variable of my choosing when 
I am creating this type of plot...


[[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] Mapping 2D to 3D

2020-09-18 Thread H
On 09/18/2020 02:26 AM, Jeff Newmiller wrote:
> No, but fortunately you are off in the weeds. Density has an 
> internally-computed "z" coordinate... you should be looking at ?geom_contour.
>
> On September 17, 2020 7:17:33 PM PDT, H  wrote:
>> I am trying to understand how to map 2D to 3D using ggplot() and
>> eventually plot_gg(). I am, however, stuck on understanding how to
>> express the third variable to be mapped. This example:
>>
>> ggdiamonds = ggplot(diamonds, aes(x, depth)) +
>> stat_density_2d(aes(fill = stat(nlevel)),
>> geom = "polygon", n = 100, bins = 10,contour = TRUE) +
>> facet_wrap(clarity~.) +
>> scale_fill_viridis_c(option = "A")
>>
>> uses a variable nlevel that I now understand is calculated during the
>> building of the ggplot but I have not figured out from where it is
>> calculated or how to specify a variable of my choosing.
>>
>> Does anyone have a good reference for understanding how to specify this
>> variable? Most examples on the 'net seem to use the same dataset but do
>> not specify this particular aspect...
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

But looking at the code in my message above, how does one know what 
stat(nlevel) refers to? What if I wanted to map another variable in this 
particular dataset??

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

2020-09-17 Thread H
I am trying to understand how to map 2D to 3D using ggplot() and eventually 
plot_gg(). I am, however, stuck on understanding how to express the third 
variable to be mapped. This example:

ggdiamonds = ggplot(diamonds, aes(x, depth)) +
stat_density_2d(aes(fill = stat(nlevel)),
geom = "polygon", n = 100, bins = 10,contour = TRUE) +
facet_wrap(clarity~.) +
scale_fill_viridis_c(option = "A")

uses a variable nlevel that I now understand is calculated during the building 
of the ggplot but I have not figured out from where it is calculated or how to 
specify a variable of my choosing.

Does anyone have a good reference for understanding how to specify this 
variable? Most examples on the 'net seem to use the same dataset but do not 
specify this particular aspect...

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-pkgs] salesforcer v0.2.2: An Implementation of Salesforce APIs Using Tidy Principles

2020-09-15 Thread H
On September 13, 2020 6:42:18 AM EDT, "Steven M. Mortimer" 
 wrote:
>The {salesforcer} package allows users to query and analyze Salesforce
>data
>and administer their Org's records and object metadata (fields,
>triggers,
>layouts). It has been three years in the making to map multiple
>Salesforce Platform
>APIs for use in R. The package implements the REST, SOAP, Bulk 1.0,
>Bulk
>2.0, Metadata, and Reports and Dashboards APIs. If you or your
>colleagues
>maintain or analyze Salesforce data, then I would greatly appreciate
>your
>use and feedback of this package. Thank you.
>
>Sincerely,
>Steven M. Mortimer
>
>CRAN: https://cran.r-project.org/package=salesforcer
>GitHub: https://github.com/StevenMMortimer/salesforcer
>
>   [[alternative HTML version deleted]]
>
>___
>R-packages mailing list
>r-packa...@r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-packages
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

That sounds great. Is there any similar package that works with SuiteCRM or 
SugarCRM?

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

2020-07-30 Thread H
On 07/30/2020 06:09 PM, Gabor Grothendieck wrote:
> Probably simplest to assign the names afterwards as others have
> suggested but it could be done like this:
>
>   library(sqldf)
>   write.csv(BOD, "BOD.csv", quote = FALSE, row.names = FALSE)  # test data
>
>   read.csv.sql("BOD.csv", "select Time as Time2, demand as demand2 from file")
>
> giving the column names Time2 and demand2 rather than the original column 
> names.
>
> Time2 demand2
>   1 1 8.3
>   2 210.3
>   3 319.0
>   4 416.0
>   5 515.6
>   6 719.8
>
> On Fri, Jul 17, 2020 at 9:28 PM H  wrote:
>> I have created a dataframe with columns that are characters, integers and 
>> numeric and with column names assigned by me. I am using read.csv.sql() to 
>> read portions of a number of large csv files into this dataframe, each csv 
>> file having a header row with columb names.
>>
>> The problem I am having is that the csv files have header rows with column 
>> names that are slightly different from the column names I have assigned in 
>> the dataframe and it seems that when I read the csv data into the dataframe, 
>> the column names from the csv file replace the column names I chose when 
>> creating the dataframe.
>>
>> I have been unable to figure out if it is possible to assign column names of 
>> my choosing in the read.csv.sql() function? I have tried various variations 
>> but none seem to work. I tried colClasses = c() but that did not work, I 
>> tried field.types = c(...) but could not get that to work either.
>>
>> It seems that the above should be feasible but I am missing something? Does 
>> anyone know?
>>
>> A secondary issue is that the csv files have a column with a date in 
>> mm/dd/ format that I would like to make into a Date type column in my 
>> dataframe. Again, I have been unable to find a way - if at all possible - to 
>> force a conversion into a Date format when importing into the dataframe. The 
>> best I have so far is to import is a character column and then use as.Date() 
>> to later force the conversion of the dataframe column.
>>
>> Is it possible to do this when importing using read.csv.sql()?
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
Apologies, I had tuned out from this discussion since I solved the problem by 
renaming the columns after reading the file. Your suggestion to do it in the 
SQL statement itself, however, seems to be neatest one though!

Thank you.

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


Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-28 Thread H
On 07/28/2020 12:35 PM, Ulrik Stervbo wrote:
> Would this work:
>
> ```
> library(ggplot2)
> library(cowplot)
>
> p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
> p2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width * 1000)) + 
> geom_point()
>
> plot_grid(p1, p2, ncol = 1, align = "hv", rel_heights = c(2, 1))
> ```
>
> Best,
> Ulrik
>
> On 2020-07-24 21:58, Bert Gunter wrote:
>> ?grid.frame, etc. should be straightforward for this I would think.
>> But of course you have to resort to the underlying grid framework rather
>> than the ggplot2 interface.
>>
>> 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 Fri, Jul 24, 2020 at 12:11 PM H  wrote:
>>
>>> On 07/24/2020 02:50 PM, H wrote:
>>> > On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>>> >> The set of people interested in helping when you supply a minimal
>>> reproducible example is rather larger than the set of people willing to
>>> read the documentation for you (hint) and guess what aspect of alignment
>>> you are having trouble with.
>>> >>
>>> >> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>> >>> On 07/24/2020 01:14 PM, John Kane wrote:
>>> >>>> Well, I am not looking for help debugging my code but for
>>> >>> information to better understand arranging plots vertically. The code
>>> >>> above aligns them horizontally as expected.
>>> >>>> Sigh, we know the code works but we do not know what the plots are
>>> >>> and we cannot play around with them to see if we can help you if we
>>> >>> have nothing to work with.
>>> >>>> On Fri, 24 Jul 2020 at 12:12, H >> >>> <mailto:age...@meddatainc.com>> wrote:
>>> >>>> On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>> >>>> > Hav a look at the packages cowplot and patchwork
>>> >>>> >
>>> >>>> >> On 24.07.2020, at 02:36, H >> >>> <mailto:age...@meddatainc.com>> wrote:
>>> >>>> >>
>>> >>>> >> I am trying to arrange two plots vertically, ie plot 2 below
>>> >>> plot 1, where I want the plots to align columnwise but have a height
>>> >>> ratio of eg 3:1.
>>> >>>> >>
>>> >>>> >> My attempts so far after consulting various webpages is that
>>> >>> the following code aligns them columnwise correctly but I have, so far,
>>> >>> failed in setting the relative heights...
>>> >>>> >>
>>> >>>> >> g2<-ggplotGrob(s)
>>> >>>> >> g3<-ggplotGrob(v)
>>> >>>> >> g<-rbind(g2, g3, size = "first")
>>> >>>> >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>> >>>> >>
>>> >>>> >> what would the appropriate statement for the relative heights
>>> >>> to add here be?
>>> >>>> >>
>>> >>>> >> grid.newpage()
>>> >>>> >> grid.draw(g)
>>> >>>> >>
>>> >>>> >> Thank you!
>>> >>>> >>
>>> >>>> >> __
>>> >>>> >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
>>> >>> list -- To UNSUBSCRIBE and more, see
>>> >>>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>>> >>>> >> PLEASE do read the posting guide
>>> >>> http://www.R-project.org/posting-guide.html
>>> >>>> >> and provide commented, minimal, self-contained, reproducible
>>> >>> code.
>>> >>>> So this is not possible without using one of those two packages?
>>> >>> I got the impression I should be able to use grid.arrange to do so but
>>> >>> was not able to get it to work without disturbing the width alignment
>>> >>> above...
>>> >>>> __

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-26 Thread H
On 07/25/2020 03:05 PM, H wrote:
> On 07/25/2020 03:01 PM, Rui Barradas wrote:
>> Hello,
>>
>> OK, now it's reproducible, thanks.
>> align = "hv" works like I had suggested.
>>
>> The full code is now
>>
>> library(ggplot2)
>> library(cowplot)
>>
>> s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, 
>> Sepal.Width)) + geom_point()
>> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
>> Sepal.Width * 1000)) + geom_point()
>>
>> cowplot::plot_grid(s, v, align = "hv", nrow = 2, rel_heights = 2:1)
>>
>>
>> Also, I have been failing to comply to the posting guide and never posted 
>> the output of
>>
>> sessionInfo()
>> R version 4.0.2 (2020-06-22)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 10 x64 (build 18362)
>>
>> Matrix products: default
>>
>> locale:
>> [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
>> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
>> [5] LC_TIME=Portuguese_Portugal.1252
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods base
>>
>> other attached packages:
>> [1] cowplot_1.0.0 ggplot2_3.3.2 tidyr_1.1.0   dplyr_1.0.0 sos_2.0-0
>> [6] brew_1.0-6
>>
>> loaded via a namespace (and not attached):
>>  [1] Rcpp_1.0.4.6 magrittr_1.5 tidyselect_1.1.0 munsell_0.5.0
>>  [5] colorspace_1.4-1 R6_2.4.1 rlang_0.4.6 fansi_0.4.1
>>  [9] tools_4.0.2  grid_4.0.2   gtable_0.3.0 utf8_1.1.4
>> [13] cli_2.0.2    withr_2.2.0  ellipsis_0.3.1 digest_0.6.25
>> [17] assertthat_0.2.1 tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4
>> [21] farver_2.0.3 purrr_0.3.4  vctrs_0.3.1 glue_1.4.1
>> [25] labeling_0.3 compiler_4.0.2   pillar_1.4.4 generics_0.0.2
>> [29] scales_1.1.1 pkgconfig_2.0.3
>>
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>> Às 19:13 de 25/07/2020, H escreveu:
>>> On 07/25/2020 12:36 PM, Rui Barradas wrote:
>>>> Hello,
>>>>
>>>> Inline.
>>>>
>>>> Às 16:54 de 25/07/2020, H escreveu:
>>>>> On 07/24/2020 05:56 PM, Rui Barradas wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I've just tried it.
>>>>>>
>>>>>> library(ggplot2)
>>>>>> #library(grid)
>>>>>> library(cowplot)
>>>>>>
>>>>>> s <- ggplot(data = subset(iris, Species == 'virginica'), 
>>>>>> aes(Sepal.Length, Sepal.Width)) + geom_point()
>>>>>> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
>>>>>> Sepal.Width)) + geom_point()
>>>>>>
>>>>>> #g2 <- ggplotGrob(s)
>>>>>> #g3 <- ggplotGrob(v)
>>>>>> #g <- rbind(g2, g3, size = "first")
>>>>>>
>>>>>> cowplot::plot_grid(s, v, align = "h", nrow = 2, rel_heights = 2:1)
>>>>>>
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> Rui Barradas
>>>>>>
>>>>>> Às 19:57 de 24/07/2020, Felipe Carrillo via R-help escreveu:
>>>>>>> What about cowplot?
>>>>>>> https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html
>>>>>>>
>>>>>>>    On Friday, July 24, 2020, 11:51:17 AM PDT, H 
>>>>>>>  wrote:
>>>>>>>       On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>>>>>>>> The set of people interested in helping when you supply a minimal 
>>>>>>>> reproducible example is rather larger than the set of people willing 
>>>>>>>> to read the documentation for you (hint) and guess what aspect of 
>>>>>>>> alignment you are having trouble with.
>>>>>>>>
>>>>>>>> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>>>>>>>> On 07/24/2020 01:14 PM, John Kane wrote:
>>>>>>>>>> Well, I am not looking for help debugging my code but for
>>>>>>>>> information to better understand arranging plots vertically. The code
>>>>>>>>> above aligns them horizontally as expected.
>>>>>>>>>> Sigh, we know th

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread H
On 07/25/2020 04:17 PM, Jeff Newmiller wrote:
> False. Mutate is similar in structure to the base function `within`. Which is 
> why you have to assign the altered data frame back onto itself.
>
> On July 25, 2020 12:59:06 PM PDT, "Patrick (Malone Quantitative)" 
>  wrote:
>> Jeff,
>>
>> mutate(), which is I think part of dplyr, also violates this, for what
>> it's
>> worth. I suspect the breaking point is that mutate() is intended to
>> create
>> new columns in the dataframe, not alter existing ones.
>>
>> On Sat, Jul 25, 2020 at 3:52 PM Jeff Newmiller
>> 
>> wrote:
>>
>>> R is largely a functional language. You do something to an input and
>> end
>>> up with an output that has no effect on the input. This is actually a
>>> highly desirable feature.
>>>
>>> If you want your df variable to reflect changes made then you  need
>> to
>>> assign your result back into it.
>>>
>>> df <- df %>% mutate(v1 = as.double(v1))
>>>
>>> (Note that the data.table package violates this principle and is
>>> controversial as a result.)
>>>
>>> On July 25, 2020 12:11:24 PM PDT, H  wrote:
>>>> In a statement like:
>>>>
>>>> df %>% mutate(v1 = as.double(v1))
>>>>
>>>> I expect the variable v1 in dataframe df to have been converted into
>> a
>>>> double. However, when I do:
>>>>
>>>> str(df)
>>>>
>>>> v1 still shows as int. Do I need to save the modified dataframe
>> after
>>>> mutating a variable?
>>>>
>>>> __
>>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/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.
>>>
Thank you, code corrected and problem solved. I was thrown off by the fact that 
after mutating it looked like the column data type had been changed. I also 
tried mutate_at() which similarly failed...

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

2020-07-25 Thread H
In a statement like:

df %>% mutate(v1 = as.double(v1))

I expect the variable v1 in dataframe df to have been converted into a double. 
However, when I do:

str(df)

v1 still shows as int. Do I need to save the modified dataframe after mutating 
a variable?

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

2020-07-25 Thread H
On 07/25/2020 03:01 PM, Rui Barradas wrote:
> Hello,
>
> OK, now it's reproducible, thanks.
> align = "hv" works like I had suggested.
>
> The full code is now
>
> library(ggplot2)
> library(cowplot)
>
> s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, 
> Sepal.Width)) + geom_point()
> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
> Sepal.Width * 1000)) + geom_point()
>
> cowplot::plot_grid(s, v, align = "hv", nrow = 2, rel_heights = 2:1)
>
>
> Also, I have been failing to comply to the posting guide and never posted the 
> output of
>
> sessionInfo()
> R version 4.0.2 (2020-06-22)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 18362)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
> [5] LC_TIME=Portuguese_Portugal.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods base
>
> other attached packages:
> [1] cowplot_1.0.0 ggplot2_3.3.2 tidyr_1.1.0   dplyr_1.0.0 sos_2.0-0
> [6] brew_1.0-6
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_1.0.4.6 magrittr_1.5 tidyselect_1.1.0 munsell_0.5.0
>  [5] colorspace_1.4-1 R6_2.4.1 rlang_0.4.6 fansi_0.4.1
>  [9] tools_4.0.2  grid_4.0.2   gtable_0.3.0 utf8_1.1.4
> [13] cli_2.0.2    withr_2.2.0  ellipsis_0.3.1 digest_0.6.25
> [17] assertthat_0.2.1 tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4
> [21] farver_2.0.3 purrr_0.3.4  vctrs_0.3.1 glue_1.4.1
> [25] labeling_0.3 compiler_4.0.2   pillar_1.4.4 generics_0.0.2
> [29] scales_1.1.1 pkgconfig_2.0.3
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 19:13 de 25/07/2020, H escreveu:
>> On 07/25/2020 12:36 PM, Rui Barradas wrote:
>>> Hello,
>>>
>>> Inline.
>>>
>>> Às 16:54 de 25/07/2020, H escreveu:
>>>> On 07/24/2020 05:56 PM, Rui Barradas wrote:
>>>>> Hello,
>>>>>
>>>>> I've just tried it.
>>>>>
>>>>> library(ggplot2)
>>>>> #library(grid)
>>>>> library(cowplot)
>>>>>
>>>>> s <- ggplot(data = subset(iris, Species == 'virginica'), 
>>>>> aes(Sepal.Length, Sepal.Width)) + geom_point()
>>>>> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
>>>>> Sepal.Width)) + geom_point()
>>>>>
>>>>> #g2 <- ggplotGrob(s)
>>>>> #g3 <- ggplotGrob(v)
>>>>> #g <- rbind(g2, g3, size = "first")
>>>>>
>>>>> cowplot::plot_grid(s, v, align = "h", nrow = 2, rel_heights = 2:1)
>>>>>
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> Rui Barradas
>>>>>
>>>>> Às 19:57 de 24/07/2020, Felipe Carrillo via R-help escreveu:
>>>>>> What about cowplot?
>>>>>> https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html
>>>>>>
>>>>>>    On Friday, July 24, 2020, 11:51:17 AM PDT, H 
>>>>>>  wrote:
>>>>>>       On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>>>>>>> The set of people interested in helping when you supply a minimal 
>>>>>>> reproducible example is rather larger than the set of people willing to 
>>>>>>> read the documentation for you (hint) and guess what aspect of 
>>>>>>> alignment you are having trouble with.
>>>>>>>
>>>>>>> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>>>>>>> On 07/24/2020 01:14 PM, John Kane wrote:
>>>>>>>>> Well, I am not looking for help debugging my code but for
>>>>>>>> information to better understand arranging plots vertically. The code
>>>>>>>> above aligns them horizontally as expected.
>>>>>>>>> Sigh, we know the code works but we do not know what the plots are
>>>>>>>> and we cannot play around with them to see if we can help you if we
>>>>>>>> have nothing to work with.
>>>>>>>>> On Fri, 24 Jul 2020 at 12:12, H >>>>>>> <mailto:age...@meddatainc.com>> wrote:
>>>>>>>>> 

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/25/2020 12:36 PM, Rui Barradas wrote:
> Hello,
>
> Inline.
>
> Às 16:54 de 25/07/2020, H escreveu:
>> On 07/24/2020 05:56 PM, Rui Barradas wrote:
>>> Hello,
>>>
>>> I've just tried it.
>>>
>>> library(ggplot2)
>>> #library(grid)
>>> library(cowplot)
>>>
>>> s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, 
>>> Sepal.Width)) + geom_point()
>>> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
>>> Sepal.Width)) + geom_point()
>>>
>>> #g2 <- ggplotGrob(s)
>>> #g3 <- ggplotGrob(v)
>>> #g <- rbind(g2, g3, size = "first")
>>>
>>> cowplot::plot_grid(s, v, align = "h", nrow = 2, rel_heights = 2:1)
>>>
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Às 19:57 de 24/07/2020, Felipe Carrillo via R-help escreveu:
>>>> What about cowplot?
>>>> https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html
>>>>
>>>>   On Friday, July 24, 2020, 11:51:17 AM PDT, H  
>>>> wrote:
>>>>      On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>>>>> The set of people interested in helping when you supply a minimal 
>>>>> reproducible example is rather larger than the set of people willing to 
>>>>> read the documentation for you (hint) and guess what aspect of alignment 
>>>>> you are having trouble with.
>>>>>
>>>>> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>>>>> On 07/24/2020 01:14 PM, John Kane wrote:
>>>>>>> Well, I am not looking for help debugging my code but for
>>>>>> information to better understand arranging plots vertically. The code
>>>>>> above aligns them horizontally as expected.
>>>>>>> Sigh, we know the code works but we do not know what the plots are
>>>>>> and we cannot play around with them to see if we can help you if we
>>>>>> have nothing to work with.
>>>>>>> On Fri, 24 Jul 2020 at 12:12, H >>>>> <mailto:age...@meddatainc.com>> wrote:
>>>>>>>       On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>>>>>>       > Hav a look at the packages cowplot and patchwork
>>>>>>>       >
>>>>>>>       >> On 24.07.2020, at 02:36, H >>>>> <mailto:age...@meddatainc.com>> wrote:
>>>>>>>       >>
>>>>>>>       >> I am trying to arrange two plots vertically, ie plot 2 below
>>>>>> plot 1, where I want the plots to align columnwise but have a height
>>>>>> ratio of eg 3:1.
>>>>>>>       >>
>>>>>>>       >> My attempts so far after consulting various webpages is that
>>>>>> the following code aligns them columnwise correctly but I have, so far,
>>>>>> failed in setting the relative heights...
>>>>>>>       >>
>>>>>>>       >> g2<-ggplotGrob(s)
>>>>>>>       >> g3<-ggplotGrob(v)
>>>>>>>       >> g<-rbind(g2, g3, size = "first")
>>>>>>>       >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>>>>>>       >>
>>>>>>>       >> what would the appropriate statement for the relative heights
>>>>>> to add here be?
>>>>>>>       >>
>>>>>>>       >> grid.newpage()
>>>>>>>       >> grid.draw(g)
>>>>>>>       >>
>>>>>>>       >> Thank you!
>>>>>>>       >>
>>>>>>>       >> __
>>>>>>>       >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
>>>>>> list -- To UNSUBSCRIBE and more, see
>>>>>>>       >> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>>>       >> PLEASE do read the posting guide
>>>>>> http://www.R-project.org/posting-guide.html
>>>>>>>       >> and provide commented, minimal, self-contained, reproducible
>>>>>> code.
>>>>>>>       So this is not possible without using one of those two packages?

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/24/2020 05:56 PM, Rui Barradas wrote:
> Hello,
>
> I've just tried it.
>
> library(ggplot2)
> #library(grid)
> library(cowplot)
>
> s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, 
> Sepal.Width)) + geom_point()
> v <- ggplot(data = subset(iris, Species == 'setosa'), aes(Sepal.Length, 
> Sepal.Width)) + geom_point()
>
> #g2 <- ggplotGrob(s)
> #g3 <- ggplotGrob(v)
> #g <- rbind(g2, g3, size = "first")
>
> cowplot::plot_grid(s, v, align = "h", nrow = 2, rel_heights = 2:1)
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 19:57 de 24/07/2020, Felipe Carrillo via R-help escreveu:
>> What about cowplot?
>> https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html
>>
>>  On Friday, July 24, 2020, 11:51:17 AM PDT, H  
>> wrote:
>>     On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>>> The set of people interested in helping when you supply a minimal 
>>> reproducible example is rather larger than the set of people willing to 
>>> read the documentation for you (hint) and guess what aspect of alignment 
>>> you are having trouble with.
>>>
>>> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>>> On 07/24/2020 01:14 PM, John Kane wrote:
>>>>> Well, I am not looking for help debugging my code but for
>>>> information to better understand arranging plots vertically. The code
>>>> above aligns them horizontally as expected.
>>>>> Sigh, we know the code works but we do not know what the plots are
>>>> and we cannot play around with them to see if we can help you if we
>>>> have nothing to work with.
>>>>> On Fri, 24 Jul 2020 at 12:12, H >>> <mailto:age...@meddatainc.com>> wrote:
>>>>>      On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>>>>      > Hav a look at the packages cowplot and patchwork
>>>>>      >
>>>>>      >> On 24.07.2020, at 02:36, H >>> <mailto:age...@meddatainc.com>> wrote:
>>>>>      >>
>>>>>      >> I am trying to arrange two plots vertically, ie plot 2 below
>>>> plot 1, where I want the plots to align columnwise but have a height
>>>> ratio of eg 3:1.
>>>>>      >>
>>>>>      >> My attempts so far after consulting various webpages is that
>>>> the following code aligns them columnwise correctly but I have, so far,
>>>> failed in setting the relative heights...
>>>>>      >>
>>>>>      >> g2<-ggplotGrob(s)
>>>>>      >> g3<-ggplotGrob(v)
>>>>>      >> g<-rbind(g2, g3, size = "first")
>>>>>      >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>>>>      >>
>>>>>      >> what would the appropriate statement for the relative heights
>>>> to add here be?
>>>>>      >>
>>>>>      >> grid.newpage()
>>>>>      >> grid.draw(g)
>>>>>      >>
>>>>>      >> Thank you!
>>>>>      >>
>>>>>      >> __
>>>>>      >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
>>>> list -- To UNSUBSCRIBE and more, see
>>>>>      >> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>      >> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>>>      >> and provide commented, minimal, self-contained, reproducible
>>>> code.
>>>>>      So this is not possible without using one of those two packages?
>>>> I got the impression I should be able to use grid.arrange to do so but
>>>> was not able to get it to work without disturbing the width alignment
>>>> above...
>>>>>      __
>>>>>      R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>>>> -- To UNSUBSCRIBE and more, see
>>>>>      https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>      PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>>>      and provide commented, minimal, self-contained, reproducible
>>>> code.
>>>>>
>>>>> -- 
>>>>> John Kane
>>>>&g

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 02:50 PM, H wrote:
> On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
>> The set of people interested in helping when you supply a minimal 
>> reproducible example is rather larger than the set of people willing to read 
>> the documentation for you (hint) and guess what aspect of alignment you are 
>> having trouble with.
>>
>> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>>> On 07/24/2020 01:14 PM, John Kane wrote:
>>>> Well, I am not looking for help debugging my code but for
>>> information to better understand arranging plots vertically. The code
>>> above aligns them horizontally as expected.
>>>> Sigh, we know the code works but we do not know what the plots are  
>>> and we cannot play around with them to see if we can help you if we
>>> have nothing to work with.
>>>> On Fri, 24 Jul 2020 at 12:12, H >> <mailto:age...@meddatainc.com>> wrote:
>>>> On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>>> > Hav a look at the packages cowplot and patchwork
>>>> >
>>>> >> On 24.07.2020, at 02:36, H >> <mailto:age...@meddatainc.com>> wrote:
>>>> >>
>>>> >> I am trying to arrange two plots vertically, ie plot 2 below
>>> plot 1, where I want the plots to align columnwise but have a height
>>> ratio of eg 3:1.
>>>> >>
>>>> >> My attempts so far after consulting various webpages is that
>>> the following code aligns them columnwise correctly but I have, so far,
>>> failed in setting the relative heights...
>>>> >>
>>>> >> g2<-ggplotGrob(s)
>>>> >> g3<-ggplotGrob(v)
>>>> >> g<-rbind(g2, g3, size = "first")
>>>> >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>>> >>
>>>> >> what would the appropriate statement for the relative heights
>>> to add here be?
>>>> >>
>>>> >> grid.newpage()
>>>> >> grid.draw(g)
>>>> >>
>>>> >> Thank you!
>>>> >>
>>>> >> __
>>>> >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
>>> list -- To UNSUBSCRIBE and more, see
>>>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> >> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>>> >> and provide commented, minimal, self-contained, reproducible
>>> code.
>>>> So this is not possible without using one of those two packages?
>>> I got the impression I should be able to use grid.arrange to do so but
>>> was not able to get it to work without disturbing the width alignment
>>> above...
>>>> __
>>>> R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>>> -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible
>>> code.
>>>> -- 
>>>> John Kane
>>>> Kingston ON Canada
>>> No need to play around with anything. I am simply looking for
>>> assistance on how to use eg arrangeGrob to not only align two plots
>>> columnwise but also adjust their heights relative to each other rather
>>> than 1:1.
>>>
>>> Can arrangeGrob() be used for that?
>>>
>>>
>>> [[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.
>
> Look at https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html 
> where there are two mpg charts, one above the other. What would I need to add 
> to:
>
> |library(gtable) g2 <-ggplotGrob(p2) g3 <-ggplotGrob(p3) g <-rbind(g2, g3, 
> size = "first") g$widths <-unit.pmax(g2$widths, g3$widths) grid.newpage() 
> grid.draw(g) |
>
> |to make the second chart 1/2 the size of the top one?|
>
> ||
>
The following code aligns the two plot areas of the two charts perfectly but 
they are the same height whereas I want to make the bottom one 1/2 as tall as 
the top one:

g2<-ggplotGrob(s)
g3<-ggplotGrob(v)
g<-rbind(g2, g3, size = "first")
g$widths<-unit.pmax(g2$widths, g3$widths)
grid.newpage()
grid.draw(g)


[[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] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
> The set of people interested in helping when you supply a minimal 
> reproducible example is rather larger than the set of people willing to read 
> the documentation for you (hint) and guess what aspect of alignment you are 
> having trouble with.
>
> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>> On 07/24/2020 01:14 PM, John Kane wrote:
>>> Well, I am not looking for help debugging my code but for
>> information to better understand arranging plots vertically. The code
>> above aligns them horizontally as expected.
>>> Sigh, we know the code works but we do not know what the plots are  
>> and we cannot play around with them to see if we can help you if we
>> have nothing to work with.
>>> On Fri, 24 Jul 2020 at 12:12, H > <mailto:age...@meddatainc.com>> wrote:
>>> On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>> > Hav a look at the packages cowplot and patchwork
>>> >
>>> >> On 24.07.2020, at 02:36, H > <mailto:age...@meddatainc.com>> wrote:
>>> >>
>>> >> I am trying to arrange two plots vertically, ie plot 2 below
>> plot 1, where I want the plots to align columnwise but have a height
>> ratio of eg 3:1.
>>> >>
>>> >> My attempts so far after consulting various webpages is that
>> the following code aligns them columnwise correctly but I have, so far,
>> failed in setting the relative heights...
>>> >>
>>> >> g2<-ggplotGrob(s)
>>> >> g3<-ggplotGrob(v)
>>> >> g<-rbind(g2, g3, size = "first")
>>> >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>> >>
>>> >> what would the appropriate statement for the relative heights
>> to add here be?
>>> >>
>>> >> grid.newpage()
>>> >> grid.draw(g)
>>> >>
>>> >> Thank you!
>>> >>
>>> >> __
>>> >> R-help@r-project.org <mailto:R-help@r-project.org> mailing
>> list -- To UNSUBSCRIBE and more, see
>>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>>> >> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>>> >> and provide commented, minimal, self-contained, reproducible
>> code.
>>> So this is not possible without using one of those two packages?
>> I got the impression I should be able to use grid.arrange to do so but
>> was not able to get it to work without disturbing the width alignment
>> above...
>>> __
>>> R-help@r-project.org <mailto:R-help@r-project.org> mailing list
>> -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible
>> code.
>>>
>>>
>>> -- 
>>> John Kane
>>> Kingston ON Canada
>> No need to play around with anything. I am simply looking for
>> assistance on how to use eg arrangeGrob to not only align two plots
>> columnwise but also adjust their heights relative to each other rather
>> than 1:1.
>>
>> Can arrangeGrob() be used for that?
>>
>>
>>  [[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.

Look at https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html 
where there are two mpg charts, one above the other. What would I need to add 
to:

|library(gtable) g2 <-ggplotGrob(p2) g3 <-ggplotGrob(p3) g <-rbind(g2, g3, size 
= "first") g$widths <-unit.pmax(g2$widths, g3$widths) grid.newpage() 
grid.draw(g) |

|to make the second chart 1/2 the size of the top one?|

||


[[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] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 01:14 PM, John Kane wrote:
> Well, I am not looking for help debugging my code but for information to 
> better understand arranging plots vertically. The code above aligns them 
> horizontally as expected.
>
> Sigh, we know the code works but we do not know what the plots are   and we 
> cannot play around with them to see if we can help you if we have nothing to 
> work with.
>
> On Fri, 24 Jul 2020 at 12:12, H  <mailto:age...@meddatainc.com>> wrote:
>
> On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
> > Hav a look at the packages cowplot and patchwork
> >
> >> On 24.07.2020, at 02:36, H  <mailto:age...@meddatainc.com>> wrote:
> >>
> >> I am trying to arrange two plots vertically, ie plot 2 below plot 1, 
> where I want the plots to align columnwise but have a height ratio of eg 3:1.
> >>
> >> My attempts so far after consulting various webpages is that the 
> following code aligns them columnwise correctly but I have, so far, failed in 
> setting the relative heights...
> >>
> >> g2<-ggplotGrob(s)
> >> g3<-ggplotGrob(v)
> >> g<-rbind(g2, g3, size = "first")
> >> g$widths<-unit.pmax(g2$widths, g3$widths)
> >>
> >> what would the appropriate statement for the relative heights to add 
> here be?
> >>
> >> grid.newpage()
> >> grid.draw(g)
> >>
> >> Thank you!
> >>
> >> __
> >> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
> So this is not possible without using one of those two packages? I got 
> the impression I should be able to use grid.arrange to do so but was not able 
> to get it to work without disturbing the width alignment above...
>
> __
> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> -- 
> John Kane
> Kingston ON Canada

No need to play around with anything. I am simply looking for assistance on how 
to use eg arrangeGrob to not only align two plots columnwise but also adjust 
their heights relative to each other rather than 1:1.

Can arrangeGrob() be used for that?


[[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] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread H
On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
> Hav a look at the packages cowplot and patchwork
>
>> On 24.07.2020, at 02:36, H  wrote:
>>
>> I am trying to arrange two plots vertically, ie plot 2 below plot 1, where I 
>> want the plots to align columnwise but have a height ratio of eg 3:1.
>>
>> My attempts so far after consulting various webpages is that the following 
>> code aligns them columnwise correctly but I have, so far, failed in setting 
>> the relative heights...
>>
>> g2<-ggplotGrob(s)
>> g3<-ggplotGrob(v)
>> g<-rbind(g2, g3, size = "first")
>> g$widths<-unit.pmax(g2$widths, g3$widths)
>>
>> what would the appropriate statement for the relative heights to add here be?
>>
>> grid.newpage()
>> grid.draw(g)
>>
>> Thank you!
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

So this is not possible without using one of those two packages? I got the 
impression I should be able to use grid.arrange to do so but was not able to 
get it to work without disturbing the width alignment above...

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

2020-07-24 Thread H
On 07/24/2020 10:16 AM, John Kane wrote:
> We reallly need to see more code (a minimum working example and some data.
>
> For some suggestions on how to do this see
>
>  http://adv-r.had.co.nz/Reproducibility.html
>
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>
> On Fri, 24 Jul 2020 at 01:16, H  <mailto:age...@meddatainc.com>> wrote:
>
> I am trying to arrange two plots vertically, ie plot 2 below plot 1, 
> where I want the plots to align columnwise but have a height ratio of eg 3:1.
>
> My attempts so far after consulting various webpages is that the 
> following code aligns them columnwise correctly but I have, so far, failed in 
> setting the relative heights...
>
> g2<-ggplotGrob(s)
> g3<-ggplotGrob(v)
> g<-rbind(g2, g3, size = "first")
> g$widths<-unit.pmax(g2$widths, g3$widths)
>
> what would the appropriate statement for the relative heights to add here 
> be?
>
> grid.newpage()
> grid.draw(g)
>
> Thank you!
>
> __
> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> -- 
> John Kane
> Kingston ON Canada

Well, I am not looking for help debugging my code but for information to better 
understand arranging plots vertically. The code above aligns them horizontally 
as expected.


[[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] Arranging ggplot2 objects with ggplotGrob()

2020-07-23 Thread H
I am trying to arrange two plots vertically, ie plot 2 below plot 1, where I 
want the plots to align columnwise but have a height ratio of eg 3:1.

My attempts so far after consulting various webpages is that the following code 
aligns them columnwise correctly but I have, so far, failed in setting the 
relative heights...

g2<-ggplotGrob(s)
g3<-ggplotGrob(v)
g<-rbind(g2, g3, size = "first")
g$widths<-unit.pmax(g2$widths, g3$widths)

what would the appropriate statement for the relative heights to add here be?

grid.newpage()
grid.draw(g)

Thank you!

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


Re: [R] Help with read.csv.sql()

2020-07-20 Thread H
On 07/18/2020 11:42 PM, Rasmus Liland wrote:
> On 2020-07-18 18:09 +0100, Rui Barradas wrote:
> | �s 17:59 de 18/07/2020, H escreveu:
> | | On Fri, Jul 17, 2020 at 6:28 PM H  wrote:
> | | | 
> | | | The problem I am having is that 
> | | | the csv files have header rows 
> | | | with column names that are 
> | | | slightly different from the column 
> | | | names I have assigned in the 
> | | | dataframe and it seems that when I 
> | | | read the csv data into the 
> | | | dataframe, the column names from 
> | | | the csv file replace the column 
> | | | names I chose when creating the 
> | | | dataframe.
> | | | 
> | | | A secondary issue is that the csv 
> | | | files have a column with a date in 
> | | | mm/dd/ format that I would 
> | | | like to make into a Date type 
> | | | column in my dataframe. Again, I 
> | | | have been unable to find a way - 
> | | | if at all possible - to force a 
> | | | conversion into a Date format when 
> | | | importing into the dataframe. The 
> | | | best I have so far is to import is 
> | | | a character column and then use 
> | | | as.Date() to later force the 
> | | | conversion of the dataframe 
> | | | column.
> | | 
> | | The documentation for read.csv.sql() 
> | | suggests that colClasses() and/or 
> | | field.types() should work but I may 
> | | well have misunderstood the 
> | | documentation, hence my question in 
> | | this group.
> | 
> | As for colClasses, those are R class 
> | names.
>
> Ok Mister H, I might have hit the nail 
> on the head this time with this badass 
> example for your usecase:
>
>   # Make a csv with %d/%m/%Y dates in it ...
>   Lines <- "STM05-1 2005/02/28 17:35 Good -35.562 177.158
>   STM05-1 2005/02/28 19:44 Good -35.487 177.129
>   STM05-1 2005/02/28 23:01 Unknown -35.399 177.064
>   STM05-1 2005/03/01 07:28 Unknown -34.978 177.268
>   STM05-1 2005/03/01 18:06 Poor -34.799 177.027
>   STM05-1 2005/03/01 18:47 Poor -34.85 177.059
>   STM05-2 2005/02/28 12:49 Good -35.928 177.328
>   STM05-2 2005/02/28 21:23 Poor -35.926 177.314
>   "
>   DF <- read.table(textConnection(Lines), as.is = TRUE,
> col.names = c("Id", "Date", "Time", "Quality", "Lat", "Long"))
>   DF$Date <- format(as.Date(DF$Date, "%Y/%m/%d"), "%d/%m/%Y")
>   write.csv(DF, file="df.csv", row.names=FALSE)
>   
>   colClasses <-
> c("character",
>   "Date",
>   "character",
>   "character",
>   "numeric",
>   "numeric")
>   sql <- paste0(
> "select ",
>   "date(",  # [2]
> "substr(Date, 8, 4) || '-' || ",  # [1]
> "substr(Date, 5, 2) || '-' || ",
> "substr(Date, 2, 2)), Long, Lat, Quality ",
> "from ff where Quality like '%oo%' and Long>177.129")
>   ff <- file(description="df.csv", open="r")
>   dat <- sqldf::read.csv.sql(
> sql=sql, colClasses=colClasses)
>   close(ff)
>   
>   str(dat)
>   
>   as.Date(dat[,1])
>   dat[,3]
>
> Both sqlite and Postgres has a function 
> substr you can call on strings like 
> this.[5]  I have a hunch this has always 
> been possible in sql from way back ... 
>
> The warning from sqldf about unused 
> connections, might suggest file 
> descriptor handling to be a bit crusty 
> ... [3] 
>
> The thing is, defining the second column 
> as of type Date in colClasses happens to 
> work, but it's still character when you 
> check with str(dat) ... perhaps it has 
> something to do with this info from [4]: 
>
>   as_tibble_row() converts a vector to 
>   a tibble with one row. The input 
>   must be a bare vector, e.g. vectors 
>   of dates are not supported yet. If 
>   the input is a list, all elements 
>   must have length one.
>
> [1] 
> https://stackoverflow.com/questions/15563656/convert-string-to-date-in-sqlite
> [2] https://www.sqlite.org/lang_datefunc.html
> [3] https://groups.google.com/forum/#!topic/sqldf/mcQ_K_E--q8
> [4] https://tibble.tidyverse.org/reference/as_tibble.html
> [5] https://www.sqlite.org/lang_corefunc.html#substr, 
> https://www.postgresql.org/docs/9.1/functions-string.html,
> http://www.h2database.com/html/functions.html#substring 
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https

Re: [R] Help with read.csv.sql()

2020-07-19 Thread H
On 07/18/2020 01:38 PM, William Michels wrote:
> Do either of the postings/threads below help?
>
> https://r.789695.n4.nabble.com/read-csv-sql-to-select-from-a-large-csv-file-td4650565.html#a4651534
> https://r.789695.n4.nabble.com/using-sqldf-s-read-csv-sql-to-read-a-file-with-quot-NA-quot-for-missing-td4642327.html
>
> Otherwise you can try reading through the FAQ on Github:
>
> https://github.com/ggrothendieck/sqldf
>
> HTH, Bill.
>
> W. Michels, Ph.D.
>
>
>
> On Sat, Jul 18, 2020 at 9:59 AM H  wrote:
>> On 07/18/2020 11:54 AM, Rui Barradas wrote:
>>> Hello,
>>>
>>> I don't believe that what you are asking for is possible but like Bert 
>>> suggested, you can do it after reading in the data.
>>> You could write a convenience function to read the data, then change what 
>>> you need to change.
>>> Then the function would return this final object.
>>>
>>> Rui Barradas
>>>
>>> Às 16:43 de 18/07/2020, H escreveu:
>>>
>>>> On 07/17/2020 09:49 PM, Bert Gunter wrote:
>>>>> Is there some reason that you can't make the changes to the data frame 
>>>>> (column names, as.date(), ...) *after* you have read all your data in?
>>>>>
>>>>> Do all your csv files use the same names and date formats?
>>>>>
>>>>>
>>>>> 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 Fri, Jul 17, 2020 at 6:28 PM H >>>> <mailto:age...@meddatainc.com>> wrote:
>>>>>
>>>>>  I have created a dataframe with columns that are characters, 
>>>>> integers and numeric and with column names assigned by me. I am using 
>>>>> read.csv.sql() to read portions of a number of large csv files into this 
>>>>> dataframe, each csv file having a header row with columb names.
>>>>>
>>>>>  The problem I am having is that the csv files have header rows with 
>>>>> column names that are slightly different from the column names I have 
>>>>> assigned in the dataframe and it seems that when I read the csv data into 
>>>>> the dataframe, the column names from the csv file replace the column 
>>>>> names I chose when creating the dataframe.
>>>>>
>>>>>  I have been unable to figure out if it is possible to assign column 
>>>>> names of my choosing in the read.csv.sql() function? I have tried various 
>>>>> variations but none seem to work. I tried colClasses = c() but that 
>>>>> did not work, I tried field.types = c(...) but could not get that to work 
>>>>> either.
>>>>>
>>>>>  It seems that the above should be feasible but I am missing 
>>>>> something? Does anyone know?
>>>>>
>>>>>  A secondary issue is that the csv files have a column with a date in 
>>>>> mm/dd/ format that I would like to make into a Date type column in my 
>>>>> dataframe. Again, I have been unable to find a way - if at all possible - 
>>>>> to force a conversion into a Date format when importing into the 
>>>>> dataframe. The best I have so far is to import is a character column and 
>>>>> then use as.Date() to later force the conversion of the dataframe column.
>>>>>
>>>>>  Is it possible to do this when importing using read.csv.sql()?
>>>>>
>>>>>  __
>>>>>  R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- 
>>>>> To UNSUBSCRIBE and more, see
>>>>>  https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>  PLEASE do read the posting guide 
>>>>> http://www.R-project.org/posting-guide.html
>>>>>  and provide commented, minimal, self-contained, reproducible code.
>>>>>
>>>> Yes, the files use the same column names and date format (at least as far 
>>>> as I know now.) I agree I could do it as you suggest above but from a 
>>>> purist perspective I would rather do it when importing the data using 
>>>> read.csv.sql(), particularly if column names and/or date format might 
>>>&

  1   2   3   >