Re: [R] Basic astronomy package recommendation wanted.

2024-01-30 Thread Kevin Thorpe
There is also the package solrad that might do some of this. It is more 
intended for calculating solar radiation, which is probably not what you want, 
but may do other things you may find helpful.


> On Jan 30, 2024, at 5:44 AM, Enrico Schumann  wrote:
> 
> On Tue, 30 Jan 2024, Richard O'Keefe writes:
> 
>> Given
>> - UTC timestamp
>> - a location (latitude,longitude,elevation)
>> I want to know
>> - the sun angles
>> - the moon angles
>> - the phase of the moon.
>> I looked on CRAN for astronomy, but didn't notice anything that seems
>> to offer what I want.  I could try coding these functions myself, but
>> "if you didn't write it you didn't wrong it".
>> 
> 
> A quick search showed several candidate packages:
> 
>  https://cran.r-project.org/package=suntools
>  https://cran.r-project.org/package=suncalc
> 
> (but I don't use any of those packages)
> 
> Perhaps also worth asking at:
>  https://stat.ethz.ch/mailman/listinfo/R-SIG-Geo/
> 
> 
> -- 
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.946-8083



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

2023-11-20 Thread Kevin Thorpe
I think that you may be correct about OneDrive being related.

I have seen OneDrive associated with problems before.

What happens if you manually set the working directory to that location? Does 
it work if your default home directory is local to your machine?


> On Nov 20, 2023, at 6:18 AM, Ana de las Heras Molina  wrote:
> 
> [You don't often get email from andel...@ucm.es. Learn why this is important 
> at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Hello,
> I am Ana de las Heras, and I write to you because every time I open RStudio
> or R directly I have the following message, before I can do anything at
> all:
> 
> Error in setwd(dir) : no es posible cambiar el directorio de trabajo
> 
> 
> At first I didn't pay much attention to it, but I am having lots of
> troubles with different programs, including LinDa, ANCOMBC or Genome
> InfoDbdata (and thus, phyloseq). After asking in the different forus of
> each program, they have told me that the issue is more related to my R
> installation and that first message I obtain when I start the program.
> 
> I would be very grateful if someone could help me. This issue started when
> I installed the latest version of R (4.3.1. and now 4.3.2.). I have already
> uninstalled and reinstalled both programs, as well as Rtools. I am not sure
> if the issue could be related to ONe Drive, since the HOME folder is in
> OneDrive. I am currently working on Windows 10, 64 bits.
> 
> Yours faithfully,
> Ana
> --
> *Ana de las Heras Molina*
> 
> 
> Nutrición Animal
> Departamento de  Producción Animal
> Facultad de Veterinaria
> Universidad Complutense de Madrid
> 
> *Contacto*: 913943855/anaher...@ucm.es
> 
>[[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] R installation

2023-01-26 Thread Kevin Thorpe
If you used this link for R-4.2.2-arm64.pkg then I have no other ideas.

The r-sig-mac list can probably help you more, but there is the possibility you 
will get help here.


> On Jan 26, 2023, at 12:19 PM, Vivian Jungels  wrote:
> 
> I have an M1 Mac with OS 13.2 so I did the most recent version that said for 
> M1 Macs and higher. 
> 
> Vivian Jungels 
> 
>> On Jan 26, 2023, at 11:16 AM, Kevin Thorpe  wrote:
>> 
>> The most obvious question is did you download the correct package? There is 
>> a version for Intel-based MACs and for M1-based MACs.
>> 
>> 
>>> On Jan 25, 2023, at 11:22 AM, Vivian Jungels via R-help 
>>>  wrote:
>>> 
>>> Hello! 
>>> 
>>> I am trying to install R and its says there is an error with the software. 
>>> I am using the link for Mac OS the most recent version on the website 
>>> because my Mac OS is M1 and 13.2 version. I am able to download it but then 
>>> when I install it it says they’re an error with the software that caused 
>>> the installation to fail. I was wondering what I need to do to install R? 
>>> 
>>> Vivian Jungels 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 


-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016


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

2023-01-26 Thread Kevin Thorpe
The most obvious question is did you download the correct package? There is a 
version for Intel-based MACs and for M1-based MACs.


> On Jan 25, 2023, at 11:22 AM, Vivian Jungels via R-help 
>  wrote:
> 
> Hello! 
> 
> I am trying to install R and its says there is an error with the software. I 
> am using the link for Mac OS the most recent version on the website because 
> my Mac OS is M1 and 13.2 version. I am able to download it but then when I 
> install it it says they’re an error with the software that caused the 
> installation to fail. I was wondering what I need to do to install R? 
> 
> Vivian Jungels 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] foreign package: unable to read S-Plus objects

2023-01-17 Thread Kevin Thorpe
I think you may be right about the cause. From the, “R Data Import/Export” 
document I find,

Function read.S which can read binary objects produced by S-PLUS 3.x, 4.x or 
2000 on (32-bit) Unix or Windows (and can read them on a different OS). This is 
able to read many but not all S objects: in particular it can read vectors, 
matrices and data frames and lists containing those.

This suggests that the binary objects you have cannot be read by this function. 
The next two paragraphs read,

Function data.restore reads S-PLUS data dumps (created by data.dump) with the 
same restrictions (except that dumps from the Alpha platform can also be read). 
It should be possible to read data dumps from S-PLUS 5.x and later written with 
data.dump(oldStyle=T).

If you have access to S-PLUS, it is usually more reliable to dump the object(s) 
in S-PLUS and source the dump file in R. For S-PLUS 5.x and later you may need 
to use dump(..., oldStyle=T), and to read in very large objects it may be 
preferable to use the dump file as a batch script rather than use the source 
function.

I think this means that if you had dumped versions of the files you could read 
them back with data.restore() or source().


> On Jan 16, 2023, at 5:22 PM, Joseph Voelkel  wrote:
> 
> [You don't often get email from jgv...@rit.edu. Learn why this is important 
> at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Dear foreign maintainers and others,
> 
> I am trying to import a number of S-Plus objects into R. The only way I see 
> how to do this is by using the foreign package.
> 
> However, when I try to do this I receive an error message. A snippet of code 
> and the error message follows:
> 
> read.S(file.path(Spath, "nrand"))
> Error in read.S(file.path(Spath, "nrand")) : not an S object
> 
> I no longer know the version of S-Plus in which these objects were created. I 
> do know that I have printed documentation, dated July 2001, from S-Plus 6; 
> and that all S-Plus objects were created in the 9/2004 -- 5/2005 range.
> 
> I am afraid that I simply have S-Plus objects that are not the S version 3 
> files that the foreign package can read, yes? But I am still hoping that it 
> may be possible to read these in.
> 
> I am not attaching some sample S-Plus objects to this email, because I  
> believe they will be stripped away as binary files. However, a sample of 
> these files may be found at
> 
> https://drive.google.com/drive/folders/1wFVa972ciP44Ob2YVWfqk8SGIodzAXPv?usp=sharing
>   (simdat is the largest file, at 469 KB)
> 
> Thank you for any assistance you may provide.
> 
> R 4.2.2
> Microsoft Windows [Version 10.0.22000.1455]
> foreign_0.8-83
> 
> 
> Joe Voelkel
> Professor Emeritus
> RIT
> 
>[[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.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2022-02-01 Thread Kevin Thorpe
This looks like a version of FAQ 7.31.

> On Feb 1, 2022, at 8:45 AM, Nathan Boeger  wrote:
> 
> [You don't often get email from nboe...@gmail.com. Learn why this is 
> important at http://aka.ms/LearnAboutSenderIdentification.]
> 
> Hello,
> 
> I found something strange and maybe I am going nuts but this does not make
> sense:
> 
>> (0.4 + 0.2 + 0 + 0.3 + 0 + 0.1) > 1
> [1] TRUE
> 
> I tried it on my mac M1 (R v4.1.2) and my Linux box (R v4.0.4). If I use
> other values, it does not work (see below). It seems only that combination,
> granted I did not try them all.
> 
>> (0.4 + 0.2 + 0 + 0.2 + 0 + 0.2) > 1
> [1] FALSE
> 
> Am I missing something?
> 
> Cheers
> 
> -nb
> 
>[[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.


-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2022-01-13 Thread Kevin Thorpe
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 many people and 
>> especially those who do not wish to constantly reinvent the wheel.
>> And repeatedly, we get people reminding (and sometimes chiding) others for 
>> daring to post questions or supply answers on what they see as a pure R 
>> list. They have a point.
>> Yes, there are other places (many not being mailing lists like this one) 
>> where we can direct the questions but why can't there be an official mailing 
>> list alongside this one specifically focused on helping or just discussing R 
>> issues related partially to the use of packages. I don't mean for people 
>> making a package to share, just users who may be searching for an 
>> appropriate package or using a common package, especially the ones in the 
>> tidyverse that are NOT GOING AWAY just because some purists ...
>> I prefer a diverse set of ways to do things and base R is NOT enough for me, 
>> nor frankly is R with all packages included as I find other languages suit 
>> my needs at times for doing various things. If this group is for purists, 
>> fine. Can we have another for the rest of us? Live and let live.
>> 
>> 
>> -Original Message-
>> From: Duncan Murdoch 
>> To: Kai Yang ; R-help Mailing List 
>> 
>> Sent: Wed, Jan 12, 2022 3:22 pm
>> Subject: Re: [R] how to find the table in R studio
>> 
>> On 12/01/2022 3:07 p.m., Kai Yang via R-help wrote:
>>> Hi all,
>>> I created a function in R. It will be generate a 

Re: [R] vectorization of loops in R

2021-11-17 Thread Kevin Thorpe
If I follow what you are trying to do, you want the mean of z for each value of 
y.

tapply(df$z, df$y, mean)


> On Nov 17, 2021, at 8:20 AM, Luigi Marongiu  wrote:
> 
> Hello,
> I have a dataframe with 3 variables. I want to loop through it to get
> the mean value of the variable `z`, as follows:
> ```
> df = data.frame(x = c(rep(1,5), rep(2,5), rep(3,5)),
> y = rep(letters[1:5],3),
> z = rnorm(15),
> stringsAsFactors = FALSE)
> m = vector()
> for (i in unique(df$y)) {
> s = df[df$y == i,]
> m = append(m, mean(s$z))
> }
> names(m) = unique(df$y)
>> (m)
> a  b  c  d  e
> -0.6355382 -0.4218053 -0.7256680 -0.8320783 -0.2587004
> ```
> The problem is that I have one million `y` values, so the work takes
> almost a day. I understand that vectorization will speed up the
> procedure. But how shall I write the procedure in vectorial terms?
> 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.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-11-01 Thread Kevin Thorpe
Is there a leading space on those variables for that row?

Kevin


> On Nov 1, 2021, at 2:01 PM, Rich Shepard  wrote:
> 
> On Mon, 1 Nov 2021, Jeff Newmiller wrote:
> 
>> Sorry... untested code... use which... not where.
> 
> Jeff,
> 
> That problem's resolved; problems() found the lines.
> 
> Question:
> 
>> cor_disc
> # A tibble: 415,263 × 8
>   site_nbr  year mon   day   hrmin   tz disc
> 
> 1 14171600  2009 10230000PDT8750
> 
> While not seen in this message, the 2 in year and the 8 in disc are
> underlined. Why is that? I assume it indicates the value is numeric but I
> defined the type for each column as "c" and "i", respectively.
> 
> Regards,
> 
> Rich
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-11-01 Thread Kevin Thorpe
I do not have a specific answer to your particular problem. All I can say is 
when a CSV import doesn’t work, it can mean there is something in the CSV file 
that is unexpected. When read_csv() fails, I will try read.csv() to compare the 
results.

Kevin


> On Nov 1, 2021, at 12:40 PM, Rich Shepard  wrote:
> 
> The data file, cor-disc.csv begins with:
> site_nbr,year,mon,day,hr,min,tz,disc
> 14171600,2009,10,23,00,00,PDT,8750
> 
> The first 7 columns are character strings; the 8th column is an integer.
> 
> After loading library(tidyverse) I ran read_csv() with this result:
>> cor_disc <- read_csv("../data/cor-disc.csv")
>   
>  Rows: 415263 Columns: 8
> ── Column specification 
> 
> Delimiter: ","
> chr (5): mon, day, hr, min, tz
> dbl (2): site_nbr, year
> 
> ℹ Use `spec()` to retrieve the full column specification for this data.
> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this 
> message.
> 
> 1. What happed to the values in column 'disc?'
> 
> 2. Why are site_nbr and year seen as doubles when they're character strings?
> 
> I've not found answers in the book or in ?read_csv.
> 
> What am I missing?
> 
> Rich
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-10-26 Thread Kevin Thorpe
This looks suspiciously like homework and this list does have a no homework 
policy. If it is not homework, please forgive the assumption.


> On Oct 26, 2021, at 4:09 PM, Anas Jamshed  wrote:
> 
> I need help to these questions
> 
> ### Question 1
> Create a variable containing a sequence of numbers from 1 to 100:
> 
> Iterate over the variables and print those numbers which are prime.
> 
> 
> ### Question 2
> Create a matrix of size 3x3 called mat_1:
> 
> Iterate over all the values one by one and print the element as well as
> the position in the matrix (row, col)
> 
>   [[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.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael’s Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-10-07 Thread Kevin Thorpe
Nice fortune.

In retrospect, maybe it would have worked to re-build the user library. Things 
were acting so strangely to me I opted for the direct, if more dangerous 
approach. :-)


> On Oct 7, 2021, at 11:37 AM, Jeff Newmiller  wrote:
> 
> Sad, more like.
> 
> fortunes::fortune(337)
> 
> You would have done just as well to delete the user library and let R prompt 
> you to re-create it if things were that bad. Note that the default R 
> configuration always looks first in the user library and only falls back to 
> the system library if the desired package is not found in the user library. 
> In most user-administered R installations you are better off acting as though 
> the system library wasn't there.
> 
> On October 7, 2021 7:56:05 AM PDT, Kevin Thorpe  
> wrote:
>> I thought I would close the loop on this. It was really weird and I don’t 
>> understand everything that went on.
>> 
>> First, it was indeed the case that the main library was not writeable so 
>> packages were being installed in a user library.
>> 
>> Here is where it gets confusing to me. Both library paths did appear in 
>> .libPaths(). I could not figure out where that was being set since there was 
>> no user .Rprofile and Rprofile.site was not modified. To start over I got 
>> the user to delete the local library and started R as an administrator and 
>> forced installation in the main library with the lib argument. However, even 
>> with dependencies=TRUE in install.packages() everything was not getting 
>> installed. I then had the user start RStudio as an admin and use the install 
>> packages from the menu, again specifying the main library and asking for 
>> dependencies. When this was done, many additional packages were then 
>> installed that were not installed when running the native R application. 
>> Eventually, after that, tidyverse loaded (I realize it is a wrapper to load 
>> a bunch of other packages). I also had the user install rms (which we use) 
>> and again, various bits did not get installed and had to be manually 
>> requested (I don’t remember which ones).
>> 
>> Anyway, in the end we got his system functioning. I realize that running as 
>> admin to install packages is probably not best practice, but it was the only 
>> way I saw to get things working. I _think_ some of the problems were because 
>> his home directory is synced with OneDrive and the user library path was to 
>> a OneDrive folder.
>> 
>> I am often shocked by the difficulties students have installing packages. 
>> They manage to get errors that I have never seen in all my user of using R. 
>> On a Win10 box of my own, I installed R and packages with no difficulties 
>> so, naturally am surprised when things go this haywire with an installation.
>> 
>> That’s my story. Hope it was entertaining. :-)
>> 
>> Kevin
>> 
>> 
>>> On Sep 24, 2021, at 3:26 PM, Duncan Murdoch  
>>> wrote:
>>> 
>>> It is worth checking that the library where things were most recently 
>>> installed is the first place R looks, i.e. the first entry in .libPaths().  
>>> Often R is installed by an administrator, and users can't write to the main 
>>> library, so when they install packages they go somewhere else.  If 
>>> "somewhere else" isn't first in .libPaths(), R won't see the new installs.
>>> 
>>> Duncan Murdoch
>>> 
>>> On 24/09/2021 2:04 p.m., Kevin Thorpe wrote:
>>>> I did try installing xml2 and it appeared to complete. I will ask him to 
>>>> try again and send me the output.
>>>>> On Sep 24, 2021, at 1:58 PM, Jeff Newmiller  
>>>>> wrote:
>>>>> 
>>>>> Seems like they should install the xml2 package before proceeding to load 
>>>>> whatever (tidyverse).
>>>>> 
>>>>> This kind of "dependency missing" problem tends to be a recurring problem 
>>>>> particularly on Windows but in general when some deeply-embedded 
>>>>> dependency fails to load or is removed in preparation for upgrading.
>>>>> 
>>>>> On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe 
>>>>>  wrote:
>>>>>> Below is some output from one of my students. I have never seen this 
>>>>>> error and tried a few things (updating packages for one) but am at a 
>>>>>> loss to help further. Would appreciate suggestions that I can pass along.
>>>>>> 
>>>>>> Here is the error. I tried an install.packages(“xml2”) which appeared to 
>

Re: [R] Unusual Error Loading tidyverse

2021-10-07 Thread Kevin Thorpe
I thought I would close the loop on this. It was really weird and I don’t 
understand everything that went on.

First, it was indeed the case that the main library was not writeable so 
packages were being installed in a user library.

Here is where it gets confusing to me. Both library paths did appear in 
.libPaths(). I could not figure out where that was being set since there was no 
user .Rprofile and Rprofile.site was not modified. To start over I got the user 
to delete the local library and started R as an administrator and forced 
installation in the main library with the lib argument. However, even with 
dependencies=TRUE in install.packages() everything was not getting installed. I 
then had the user start RStudio as an admin and use the install packages from 
the menu, again specifying the main library and asking for dependencies. When 
this was done, many additional packages were then installed that were not 
installed when running the native R application. Eventually, after that, 
tidyverse loaded (I realize it is a wrapper to load a bunch of other packages). 
I also had the user install rms (which we use) and again, various bits did not 
get installed and had to be manually requested (I don’t remember which ones).

Anyway, in the end we got his system functioning. I realize that running as 
admin to install packages is probably not best practice, but it was the only 
way I saw to get things working. I _think_ some of the problems were because 
his home directory is synced with OneDrive and the user library path was to a 
OneDrive folder.

I am often shocked by the difficulties students have installing packages. They 
manage to get errors that I have never seen in all my user of using R. On a 
Win10 box of my own, I installed R and packages with no difficulties so, 
naturally am surprised when things go this haywire with an installation.

That’s my story. Hope it was entertaining. :-)

Kevin


> On Sep 24, 2021, at 3:26 PM, Duncan Murdoch  wrote:
> 
> It is worth checking that the library where things were most recently 
> installed is the first place R looks, i.e. the first entry in .libPaths().  
> Often R is installed by an administrator, and users can't write to the main 
> library, so when they install packages they go somewhere else.  If "somewhere 
> else" isn't first in .libPaths(), R won't see the new installs.
> 
> Duncan Murdoch
> 
> On 24/09/2021 2:04 p.m., Kevin Thorpe wrote:
>> I did try installing xml2 and it appeared to complete. I will ask him to try 
>> again and send me the output.
>>> On Sep 24, 2021, at 1:58 PM, Jeff Newmiller  
>>> wrote:
>>> 
>>> Seems like they should install the xml2 package before proceeding to load 
>>> whatever (tidyverse).
>>> 
>>> This kind of "dependency missing" problem tends to be a recurring problem 
>>> particularly on Windows but in general when some deeply-embedded dependency 
>>> fails to load or is removed in preparation for upgrading.
>>> 
>>> On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe 
>>>  wrote:
>>>> Below is some output from one of my students. I have never seen this error 
>>>> and tried a few things (updating packages for one) but am at a loss to 
>>>> help further. Would appreciate suggestions that I can pass along.
>>>> 
>>>> Here is the error. I tried an install.packages(“xml2”) which appeared to 
>>>> complete but the error persists.
>>>> 
>>>>> library("tidyverse")
>>>> Error: package or namespace load failed for ‘tidyverse’ in 
>>>> library.dynam(lib, package, package.lib):
>>>> DLL ‘xml2’ not found: maybe not installed for this architecture?
>>>> 
>>>> Here is the sessionInfo()
>>>> 
>>>>> sessionInfo()
>>>> R version 4.1.1 (2021-08-10)
>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>> Running under: Windows 10 x64 (build 19042)
>>>> 
>>>> Matrix products: default
>>>> 
>>>> locale:
>>>> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 
>>>> LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
>>>> [5] LC_TIME=English_Canada.1252
>>>> 
>>>> attached base packages:
>>>> [1] stats graphics grDevices utils datasets methods base
>>>> 
>>>> loaded via a namespace (and not attached):
>>>> [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 
>>>> forcats_0.5.1 tools_4.1.1
>>>> [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 
>>>> gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11
>>>&g

Re: [R] How to install package meta on Linux Ubuntu 21?

2021-09-29 Thread Kevin Thorpe
It looks to me like you do not have the development packages installed in 
Ubuntu. These should be easy to obtain with a suitable apt-get command, but 
since I am not a primary Ubuntu user, I do not know the package names.


> On Sep 29, 2021, at 9:46 AM, Luigi Marongiu  wrote:
> 
> Hello
> I have R version 4.1.1 (2021-08-10) -- "Kick Things", on an Ubuntu 21
> machine. I am trying to install the package meta but I get the
> following error:
> ```
> ...
> ERROR: dependency ‘RcppEigen’ is not available for package ‘lme4’
> * removing ‘/home/gigiux/R/x86_64-pc-linux-gnu-library/4.1/lme4’
> Warning in install.packages :
>  installation of package ‘lme4’ had non-zero exit status
> ERROR: dependency ‘lme4’ is not available for package ‘meta’
> ```
> I tried to install RcppEigen but:
> ```
> ...
> /usr/bin/ld: cannot find -llapack
> /usr/bin/ld: cannot find -lblas
> /usr/bin/ld: cannot find -lgfortran
> collect2: error: ld returned 1 exit status
> make: *** [/usr/share/R/share/make/shlib.mk:10: RcppEigen.so] Error 1
> ERROR: compilation failed for package ‘RcppEigen’
> * removing ‘/home/gigiux/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen’
> Warning in install.packages :
>  installation of package ‘RcppEigen’ had non-zero exit status
> ```
> and lme4 requires RcppEigen.
> I launched
> `$ sudo apt-get install r-cran-rcppeigen`
> installation successful but I got the same error in installing RcppEigen.
> What could be the error?
> -- 
> Best regards,
> Luigi
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-09-24 Thread Kevin Thorpe
Ah. Thanks Duncan. That makes sense based on some other messages I caught a 
glimpse of as we tried some things. I will investigate down this line.


> On Sep 24, 2021, at 3:26 PM, Duncan Murdoch  wrote:
> 
> It is worth checking that the library where things were most recently 
> installed is the first place R looks, i.e. the first entry in .libPaths().  
> Often R is installed by an administrator, and users can't write to the main 
> library, so when they install packages they go somewhere else.  If "somewhere 
> else" isn't first in .libPaths(), R won't see the new installs.
> 
> Duncan Murdoch
> 
> On 24/09/2021 2:04 p.m., Kevin Thorpe wrote:
>> I did try installing xml2 and it appeared to complete. I will ask him to try 
>> again and send me the output.
>>> On Sep 24, 2021, at 1:58 PM, Jeff Newmiller  
>>> wrote:
>>> 
>>> Seems like they should install the xml2 package before proceeding to load 
>>> whatever (tidyverse).
>>> 
>>> This kind of "dependency missing" problem tends to be a recurring problem 
>>> particularly on Windows but in general when some deeply-embedded dependency 
>>> fails to load or is removed in preparation for upgrading.
>>> 
>>> On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe 
>>>  wrote:
>>>> Below is some output from one of my students. I have never seen this error 
>>>> and tried a few things (updating packages for one) but am at a loss to 
>>>> help further. Would appreciate suggestions that I can pass along.
>>>> 
>>>> Here is the error. I tried an install.packages(“xml2”) which appeared to 
>>>> complete but the error persists.
>>>> 
>>>>> library("tidyverse")
>>>> Error: package or namespace load failed for ‘tidyverse’ in 
>>>> library.dynam(lib, package, package.lib):
>>>> DLL ‘xml2’ not found: maybe not installed for this architecture?
>>>> 
>>>> Here is the sessionInfo()
>>>> 
>>>>> sessionInfo()
>>>> R version 4.1.1 (2021-08-10)
>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>> Running under: Windows 10 x64 (build 19042)
>>>> 
>>>> Matrix products: default
>>>> 
>>>> locale:
>>>> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 
>>>> LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
>>>> [5] LC_TIME=English_Canada.1252
>>>> 
>>>> attached base packages:
>>>> [1] stats graphics grDevices utils datasets methods base
>>>> 
>>>> loaded via a namespace (and not attached):
>>>> [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 
>>>> forcats_0.5.1 tools_4.1.1
>>>> [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 
>>>> gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11
>>>> [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 
>>>> fs_1.5.0
>>>> [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 
>>>> glue_1.4.2 R6_2.5.1
>>>> [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 
>>>> purrr_0.3.4 readr_2.0.1
>>>> [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 
>>>> ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-2
>>>> [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1
>>>> 
>>> 
>>> -- 
>>> Sent from my phone. Please excuse my brevity.
> 

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-09-24 Thread Kevin Thorpe
I did try installing xml2 and it appeared to complete. I will ask him to try 
again and send me the output.


> On Sep 24, 2021, at 1:58 PM, Jeff Newmiller  wrote:
> 
> Seems like they should install the xml2 package before proceeding to load 
> whatever (tidyverse).
> 
> This kind of "dependency missing" problem tends to be a recurring problem 
> particularly on Windows but in general when some deeply-embedded dependency 
> fails to load or is removed in preparation for upgrading.
> 
> On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe 
>  wrote:
>> Below is some output from one of my students. I have never seen this error 
>> and tried a few things (updating packages for one) but am at a loss to help 
>> further. Would appreciate suggestions that I can pass along.
>> 
>> Here is the error. I tried an install.packages(“xml2”) which appeared to 
>> complete but the error persists.
>> 
>>> library("tidyverse")
>> Error: package or namespace load failed for ‘tidyverse’ in 
>> library.dynam(lib, package, package.lib):
>> DLL ‘xml2’ not found: maybe not installed for this architecture?
>> 
>> Here is the sessionInfo()
>> 
>>> sessionInfo()
>> R version 4.1.1 (2021-08-10)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 10 x64 (build 19042)
>> 
>> Matrix products: default
>> 
>> locale:
>> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 
>> LC_MONETARY=English_Canada.1252 LC_NUMERIC=C  
>> [5] LC_TIME=English_Canada.1252  
>> 
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base  
>> 
>> loaded via a namespace (and not attached):
>> [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 
>> forcats_0.5.1 tools_4.1.1  
>> [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 
>> gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11  
>> [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 
>> fs_1.5.0  
>> [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 
>> glue_1.4.2 R6_2.5.1  
>> [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 
>> purrr_0.3.4 readr_2.0.1  
>> [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 
>> assertthat_0.2.1 colorspace_2.0-2
>> [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 
>> 
> 
> -- 
> Sent from my phone. Please excuse my brevity.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-09-24 Thread Kevin Thorpe
Below is some output from one of my students. I have never seen this error and 
tried a few things (updating packages for one) but am at a loss to help 
further. Would appreciate suggestions that I can pass along.

Here is the error. I tried an install.packages(“xml2”) which appeared to 
complete but the error persists.

> library("tidyverse")
Error: package or namespace load failed for ‘tidyverse’ in library.dynam(lib, 
package, package.lib):
DLL ‘xml2’ not found: maybe not installed for this architecture?

Here is the sessionInfo()

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 
LC_MONETARY=English_Canada.1252 LC_NUMERIC=C  
[5] LC_TIME=English_Canada.1252  

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

loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 
forcats_0.5.1 tools_4.1.1  
[8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 gtable_0.3.0 
pkgconfig_2.0.3 rlang_0.4.11  
[15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 
fs_1.5.0  
[22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 
glue_1.4.2 R6_2.5.1  
[29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 purrr_0.3.4 
readr_2.0.1  
[36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 
assertthat_0.2.1 colorspace_2.0-2
[43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2021-07-20 Thread Kevin Thorpe
You might get better answers on the r-sig-ME list.

The lmer() function from lme4 handles crossed and non-nested random effects 
quite seamlessly. I cannot comment on whether or not lme() can as well.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On Jul 20, 2021, at 10:32 AM, Juan Liu <21707...@zju.edu.cn> wrote:
> 
> EXTERNAL EMAIL:
> 
> Dear R project,
> 
> I am a doctoral student in Zhejiang university in China, I am using lme 
> function in nlme package and learning the function by Package 'nlme' 
> document. I am writing this email for some help to build a lme model.
> 
> My goal was to include two non-nested random effects in the lme model. the 
> document described how to write the random effects while I found it difficult 
> for me to understand. My problem are as below:
> 
> 
> 
> 
> In these model, site and year were considered as non nested effects. I want 
> to set the structure in lme model the same as lmer model(the 1st model 
> below), and I used the structure "random=list(site=~1,year=~1)"(the 2nd model 
> below) . According to the result, the  lme model was obviously wrong, for the 
> R2 and AIC were different from that of lmer model. I want to know to get the 
> same result as lmer model, how should I set the random argument?
> 
> Below is the model and results in R,
> 
> 
> 
> 
> 1. lmer 
> function
> lmer<-lmer(data, y~x1+x2+x3+(1|site)+(1|year))
> r2(lmer)##58.8%;29.7%
> r.squaredGLMM(lmer)##58.8%; 29.72%;AIC=462.4
> ###2. lme1
> lme1<-lme(data, y~x1+x2+x3,random = list(site=~1,year=~1))
> r2(lme1)## NA(can't get the result)
> r.squaredGLMM(lme1)##92.4%; 30.89%;AIC=533
> 
> 
> 
> 
> I will be appreciated for your help.
> 
> 
> 
> 
> Yours sincerely,
> 
> Juan Liu
> 
> Juan Liu
> 
> PhD candidate
> 
> College of Life Sciences, Zhejiang University
> 
> 866 Yuhangtang Road, Hangzhou
> 
> Zhejiang 310058, P.R.China
> 
> 21707...@zju.edu.cn; liujuan_1...@outlook.com
> 
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Incomplete violin chart representation

2021-05-20 Thread Kevin Thorpe
My guess would be there are only 2 observations contributing to that third 
plot, which is probably not enough to show anything else.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On May 20, 2021, at 5:21 AM, Mahmood Naderan-Tahan  
> wrote:
> 
> EXTERNAL EMAIL:
> 
> Hi
> 
> I use the following command to create a violin chart
> 
> 
> p <- ggplot(mydata, aes(x=BENCH, y=V))
> 
> + geom_violin(trim=FALSE)
> 
> + geom_dotplot(binaxis='y', stackdir='center', dotsize=0.6)
> 
> + scale_y_continuous(trans = scales::pseudo_log_trans(base = exp(1)))
> 
> 
> However, in the output one of them are shown in dots only which is weird 
> https://pasteboard.co/K2KeMZL.png
> 
> Any idea about that?
> 
> 
> 
> Regards,
> Mahmood
> 
>[[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] cox.zph

2021-04-01 Thread Kevin Thorpe
While the statements below about cox.zph are true, plotting the cox.zph result 
does tell you what the HR is doing. I never use one without the other.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On Apr 1, 2021, at 9:00 AM, Bendix Carstensen  
> wrote:
> 
> EXTERNAL EMAIL:
> 
> Further to John Sorkin's post on the cox.zph:
> You get test(s) of whether there is an interaction between a variable, say, 
> sex, and time.
> 
> Suppose it is significant. You will have no clue whether the M/W hazard ratio 
> is increasing or decreasing by time.
> 
> Suppose it is not significant. You will have no clue whether the 
> (non-significant) M/W hazrad ratio exhibits a pattern that is worth looking 
> further into or not.
> 
> In this sense the cox.zph is a perfect tool to allow you to write 'we checked 
> for non proportionality' instead of 'we have no clue of how the M/W ratio 
> varies by time'.
> 
> If you label it what it is, namely a test of interaction, you might realize 
> that you should ESTIMATE the shape and size of the interaction before 
> deriving a test, either ad-hoc by the Shoenfeld residuals or by proper 
> modeling.
> 
> See for example pp 202 ff. in 'Epidemiology with R' by (surprise, surprise) 
> me, published by OUP a few months ago.
> 
> b.r.
> Bendix Carstensen
> Senior Statistician
> Steno Diabetes Center Copenhagen
> Clinical Epidemiology
> Niels Steensens Vej 2-4
> DK-2820 Gentofte
> Denmark
> tel: +45 30 91 29 61
> b...@bxc.dk
> bendix.carsten...@regionh.dk
> http://BendixCarstensen.com
> 
> 
> 
> 
> 
> Region Hovedstaden anvender de personoplysninger, du giver os i forbindelse 
> med din henvendelse. Du kan læse mere om formålet med anvendelsen samt dine 
> rettigheder på vores hjemmeside: www.regionh.dk/persondatapolitik
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] about a p-value < 2.2e-16

2021-03-19 Thread Kevin Thorpe
I have to ask since. Are you sure the journal simply means by exact p-value 
that they don’t want to see a p-value given as < 0.0001, for example, and 
simply want the actual number?

I cannot imagine they really meant exact as in the p-value from some exact 
distribution.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On Mar 19, 2021, at 1:22 PM, Bogdan Tanasa  wrote:
> 
> EXTERNAL EMAIL:
> 
> Dear all, thank you all for comments and help.
> 
> as far as i can see, shall we have samples of 1000 records, only
> "exact=FALSE" allows the code to run:
> 
> wilcox.test(rnorm(1000), rnorm(1000, 2), exact=FALSE)$p.value
> [1] 7.304863e-231
> 
> shall i use "exact=TRUE", it runs out of memory on my 64GB RAM PC :
> 
> wilcox.test(rnorm(1000), rnorm(1000, 2), exact=TRUE)$p.value
> (the job is terminated by OS)
> 
> shall you have any other suggestions, please let me know. thanks a lot !
> 
> On Fri, Mar 19, 2021 at 9:05 AM Bert Gunter  wrote:
> 
>> I **believe** -- if my old memory still serves-- that the "exact"
>> specification uses a home grown version of the algorithm to calculate
>> exact,  or close approximations to the exact, permutation distribution
>> originally developed by Cyrus Mehta, founder of StatXact software.  Of
>> course, examining the C code source would determine this, but I don't care
>> to attempt this.
>> 
>> If this is (no longer?) correct, please point this out.
>> 
>> Best,
>> 
>> 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, Mar 19, 2021 at 8:42 AM Jiefei Wang  wrote:
>> 
>>> Hi Spencer,
>>> 
>>> Thanks for your test results, I do not know the answer as I haven't
>>> used wilcox.test for many years. I do not know if it is possible to
>>> compute
>>> the exact distribution of the Wilcoxon rank sum statistic, but I think it
>>> is very likely, as the document of `Wilcoxon` says:
>>> 
>>> This distribution is obtained as follows. Let x and y be two random,
>>> independent samples of size m and n. Then the Wilcoxon rank sum statistic
>>> is the number of all pairs (x[i], y[j]) for which y[j] is not greater than
>>> x[i]. This statistic takes values between 0 and m * n, and its mean and
>>> variance are m * n / 2 and m * n * (m + n + 1) / 12, respectively.
>>> 
>>> As a nice feature of the non-parametric statistic, it is usually
>>> distribution-free so you can pick any distribution you like to compute the
>>> same statistic. I wonder if this is the case, but I might be wrong.
>>> 
>>> Cheers,
>>> Jiefei
>>> 
>>> 
>>> On Fri, Mar 19, 2021 at 10:57 PM Spencer Graves <
>>> spencer.gra...@effectivedefense.org> wrote:
>>> 
 
 
 On 2021-3-19 9:52 AM, Jiefei Wang wrote:
> After digging into the R source, it turns out that the argument
>>> `exact`
 has
> nothing to do with the numeric precision. It only affects the
>>> statistic
> model used to compute the p-value. When `exact=TRUE` the true
 distribution
> of the statistic will be used. Otherwise, a normal approximation will
>>> be
> used.
> 
> I think the documentation needs to be improved here, you can compute
>>> the
> exact p-value *only* when you do not have any ties in your data. If
>>> you
> have ties in your data you will get the p-value from the normal
> approximation no matter what value you put in `exact`. This behavior
 should
> be documented or a warning should be given when `exact=TRUE` and ties
> present.
> 
> FYI, if the exact p-value is required, `pwilcox` function will be
>>> used to
> compute the p-value. There are no details on how it computes the
>>> pvalue
 but
> its C code seems to compute the probability table, so I assume it
 computes
> the exact p-value from the true distribution of the statistic, not a
> permutation or MC p-value.
 
 
   My example shows that it does NOT use Monte Carlo, because
 otherwise it uses some distribution.  I believe the term "exact" means
 that it uses the permutation distribution, though I could be mistaken.
 If it's NOT a permutation distribution, I don't know what it is.
 
 
   Spencer
> 
> Best,
> Jiefei
> 
> 
> 
> On Fri, Mar 19, 2021 at 10:01 PM Jiefei Wang 
>>> wrote:
> 
>> Hey,
>> 
>> I just want to point out that the word "exact" has two meanings. It
>>> can
>> mean the numerically accurate p-value as Bogdan asked in his first
 email,
>> or it could mean the p-value calculated from the exact distribution
>>> of
 the
>> statistic(In this case, U stat). These two are actually not 

Re: [R] ISO recommendations for plot output format from R to MS Word

2021-02-18 Thread Kevin Thorpe

> On Feb 18, 2021, at 2:03 PM, Robert Dodier  wrote:
> 
> EXTERNAL EMAIL:
> 
> On Thu, Feb 18, 2021 at 10:12 AM Kevin Thorpe  
> wrote:
> 
>> I would think that it would be more seamless to use Rmarkdown.
>> Simply put the plotting code into an Rmarkdown file and send it
>> straight to Word. Is there a reason why this is not a viable option?
> 
> Hi Kevin, thanks for your reply. Well, I started working with Word
> because at least one other person needs to edit it and they want to
> use Word. More fundamentally, it's not clear to me that going through
> Rmarkdown solves the problem of determining the image format -- at
> some point a figure is going to get generated and then pasted into a
> Word document. It's not clear that doing that automatically is going
> to work better or differently than doing it by hand. Anyway I think I
> have a working solution at this point so I leave it to others to
> investigate further possibilities.
> 
> best,
> 
> Robert Dodier

Fair enough. I mentioned it since from my limited experience sending to Word
(I hate Word) the images seem to look fine. Whatever is done seems to work.
With the Rmarkdown generated Word file, I imagine copy/paste into the “master”
Document would work just fine.

Kevin


-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] ISO recommendations for plot output format from R to MS Word

2021-02-18 Thread Kevin Thorpe
I did not see the original thread so this may have been discussed.

I would think that it would be more seamless to use Rmarkdown.
Simply put the plotting code into an Rmarkdown file and send it
straight to Word. Is there a reason why this is not a viable option?

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On Feb 18, 2021, at 12:50 PM, Robert Dodier  wrote:
> 
> EXTERNAL EMAIL:
> 
> Hi, a quick follow-up about the question about putting R-generated
> figures into MS Word.
> 
> I have found by experimenting with some figures and documents that if
> I import an SVG figure generated by svglite (didn't try other output
> functions), I can view it okay in my installation of MS Word (Word for
> Mac 16.16.10), and it looks okay in MS Word for Windows (circa 2016 or
> 2018) on a laptop I have, and two other people can view it okay (one
> on Mac and one on Windows). So that seems safe enough to go ahead.
> YMMV.
> 
> I am informed that MS Word is actually storing a bitmap image of the
> SVG figure, which is displayed by non-SVG-aware versions of Word. So
> that seems like a good safeguard.
> 
> For the record, I converted the SVG to EPS, PNG, PDF, WMF, and EMF via
> Imagemagick. EPS and PNG were tolerable, PDF was too fuzzy, and WMF
> and EMF, at least as generated, could not be displayed (I was a little
> surprised by that). There are, no doubt, many unanswered questions
> here, which unfortunately I cannot take the time to explore right now.
> 
> In summary I found that importing SVG generated by svglite into MS
> Word for Mac seems to work okay to generate a generally-readable file.
> Perhaps this experience is useful in some way to others.
> 
> best,
> 
> Robert Dodier
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] Meta: R-Help reply-to

2020-12-15 Thread Kevin Thorpe
You could send the request to r-help-ow...@r-project.org. That goes to the 
moderators and administrator.

Kevin

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2020-12-15, 12:05 PM, "R-help on behalf of Patrick (Malone Quantitative)" 
 wrote:

EXTERNAL EMAIL:

Ok. If this is a desirable change, of whom would we request it? I was
unable to find a name, and as I said, I got no response from the generic
address.

Pat

On Tue, Dec 15, 2020 at 11:43 AM Pär Leijonhufvud via R-help <
r-help@r-project.org> wrote:

> Unless I am getting senile that should be an option in Mailman...
> 
https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/handlers/docs/reply-to.html
>
> /Pär
>
> --
> Pär Leijonhufvud   .
> par.leijonhuf...@regionjh.se
> Sjukhuskemist
> +46(0)63-153 376, +46-(0)70-242 7006
> Laboratoriemedicin, Östersunds sjukhus
>
> -Original Message-
> From: R-help  On Behalf Of Patrick (Malone
> Quantitative)
> Sent: Tuesday, December 15, 2020 4:52 PM
> To: r-help 
> Subject: [R] Meta: R-Help reply-to
>
> Greetings.
>
> Something I've wondered for some time--is mailman configurable to have a
> default reply-to be set to the list or to reply-all?
>
> Many newcomers who reply to individual R-Help participants may not notice
> that they are doing so, and it seems a source of vexation to some of the
> more frequent helpers.
>
> I wrote to r-help-owner with this query several months ago and never heard
> back.
>
> Pat
>
> --
> Patrick S. Malone, Ph.D., Malone Quantitative NEW Service Models:
> 
https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmalonequantitative.com%2Fdata=04%7C01%7Cpar.leijonhufvud%40regionjh.se%7Cf773b2b128b24916fe2808d8a111c4a5%7Cd3b4cf3aca774a02aefaf4398591468f%7C0%7C0%7C637436444979024301%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=M4XyJrU7fidlWAwaa9NNBC6yUSTCl0VSF2icCKfhfLw%3Dreserved=0
>
> He/Him/His
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>
> 
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=04%7C01%7Cpar.leijonhufvud%40regionjh.se%7Cf773b2b128b24916fe2808d8a111c4a5%7Cd3b4cf3aca774a02aefaf4398591468f%7C0%7C0%7C637436444979034293%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=MV2Y2L86j6AczuXdc%2Fni2PzRl0ZvCcBsnrV1xkrL2b8%3Dreserved=0
> PLEASE do read the posting guide
> 
https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=04%7C01%7Cpar.leijonhufvud%40regionjh.se%7Cf773b2b128b24916fe2808d8a111c4a5%7Cd3b4cf3aca774a02aefaf4398591468f%7C0%7C0%7C637436444979034293%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=wOeXpqKMfqfsSZjSyar%2Bqmhf7ZSFeiH3qwqQkIlfyhs%3Dreserved=0
> and provide commented, minimal, self-contained, reproducible code.
>
> Region Jämtland Härjedalen behandlar dina personuppgifter vid
> kommunikation via e-post. Hanteringen av personuppgifter följer gällande
> dataskyddslagstiftning. Du kan läsa mer om hur vi behandlar dina uppgifter
> på https://regionjh.se/gdpr
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His

[[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] Inappropriate color name

2020-11-16 Thread Kevin Thorpe
This is a standard colour palette name that has been in use for years. R did 
not invent it. It simply uses the standard names. Look up indianred on google. 
You will find Wikipedia entries, hex codes for the colour, etc.

This has nothing to do with R, in my opinion.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2020-11-16, 1:39 PM, "R-help on behalf of Lainey Gallenberg" 
 wrote:

EXTERNAL EMAIL:  Treat content with extra caution.

Hello,

I'm hoping someone on here knows the appropriate place/contact for me to
lodge a complaint about a color name in the "colors" function. I was
shocked to see there are four named color options that include the term
"indianred." Surely these colors can be changed to something less
offensive- my suggestion is "blush." How can I find out who to contact
about making this happen?

Thank you in advance for any suggestions.

Sincerely,
Elaine Gallenberg

[[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] R for mac

2020-09-25 Thread Kevin Thorpe
For Mac specific issues the list R-SIG-Mac might be better. To my knowledge, R 
cannot be installed on a chromebook.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2020-09-25, 12:00 PM, "R-help on behalf of Michael Johnston" 
 
wrote:

Hi

I am club mentor for a group of high school students learning R. The Vice
President of Information Technology is hoping to broaden and deepen her
skill set so she can help others. She is doing well in helping students
install R on the Windows operating system. However, a few have problems
installing R on mac and one student is struggling to install R on
Chromebook. Is there someone who would be willing to provide some pointers?

Thank you for considering this request,
Michael


On Thu, Sep 24, 2020 at 9:10 AM Dirk Eddelbuettel  wrote:

>
> On 23 September 2020 at 15:32, Michael Johnston wrote:
> | Hi
> | I am club mentor for a group of high school students learning R. A few
> have
> | problems installing R on mac. The Vp of information technology is hoping
> | for training so she can help others. Could you recommend someone to help
> | her?
> | Thank you for considering this request
>
> I have nothing to do with R on macOS -- but this mailing list is the place
> for mac-focussed discussion.  Maybe try that, and you likely need to
> subscribe before you can post.
>
> Dirk
>
> | Michael
>
> --
> https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
>

[[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] File names for mac newby

2020-01-21 Thread Kevin Thorpe
You would also need to drop the c: as that is a DOS/Windows thing.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2020-01-21, 1:26 PM, "R-help on behalf of James Spottiswoode" 
 wrote:

OSX is based on BSD UNIX so paths use the forward slash as separator, e.g.

temps <- 
read.table("c:/Users/DFP/Documents/ah/house/HouseTemps.txt",header=T,row.names=1)

Best James

> On Jan 21, 2020, at 9:20 AM, David  wrote:
> 
> I moved to a mac a few months ago after years in windows, and I'm still 
learning basics.  I'm wanting to create a data frame based on a text file 
called HouseTemps.txt.  That's a file within one called house which is within 
one called ah.  That may further be in one called  Documents.  I tried various 
lines like:
> 
> temps <- 
read.table("c:\\Users\\DFP\\Documents\\ah\\house\\HouseTemps.txt",header=T,row.names=1)
> 
> based on my windows DOS experience, but nothing I try works.  So my 
question is, what do complete file names look like in a mac?
> 
> I tried Apple support, but they couldn't help me with R.
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



[[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] Having problems with the ifelse and negative numbers

2019-12-09 Thread Kevin Thorpe
The sqrt(-A) is evaluated for all A. The result returned is conditional on the 
first argument but the other two arguments are evaluated on the entire vector.

Kevin

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2019-12-09, 7:58 AM, "R-help on behalf of rsherry8" 
 wrote:

Please consider the following two R statements:
 A =  runif(20, min=-1,max=1)
 ifelse( A < 0, sqrt(-A), A )

The second statement produces the following error message:
 rt(-A) : NaNs produced

I understand that you cannot take the square root of a negative number 
but I thought the condition A < 0
would take care of that issue. It appears not to be.

What am I missing?

Thanks,
Bob

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

2019-11-04 Thread Kevin Thorpe
Have you read the help pages of the two functions? That is where I would start.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2019-11-04, 1:47 PM, "R-help on behalf of imran damkar" 
 wrote:

Hi,
I would like to know what is the difference between function oneway_test
and independence_test of coin package.
You will highly appreciated
Regards

[[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] Using options(max.print = 1000000) to read in data

2019-07-08 Thread Kevin Thorpe

> On Jul 8, 2019, at 10:06 AM, Spencer Brackett 
>  wrote:
> 
> Hello,
> 
>  I am trying to reload some data into R in order to check to see if it is
> formatted as a matrix. I used the command options(max.print = 1000) to
> account for the 20,000 some rows omitted previously when just using the
> basic version of this function. After entering this command, the dataset
> mostly loaded into R, but 14717 rows were still omitted.
> 
>  Can I simply increase the number indicted after 'max.print =' to read in
> the remaining rows, or should I use 'bigfile.sample <-' or
> 'bigfile.colclass <-' instead? Do I even need to read in all of the rows to
> test for a matrix?
> 
> Best,
> 
> Spencer
> 

I don’t think this option affects how much data is read in, just how much is 
printed to the screen. Use the function str() on your imported object to see 
how many rows, among other things, were brought in. 


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


-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Control the variable order after multiple declarations using within

2019-07-03 Thread Kevin Thorpe


> On Jul 3, 2019, at 3:15 AM, Sebastien Bihorel 
>  wrote:
> 
> Hi, 
> 
> The within function can be used to modify data.frames (among other objects). 
> One can even provide multiple expressions to modify the data.frame by more 
> than one expression. However, when new variables are created, they seem to be 
> inserted in the data.frame in the opposite order they were declared: 
> 
>> df <- data.frame(a=1) 
>> within(df, {b<-a*2; c<-b*3})
>  a c b
> 1 1 6 2 
> 
> Is there a way to insert the variables in an order consistent with the order 
> of declaration (ie, a, b, c)? 
> 

One way is to use mutate() from the dplyr package.


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


-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

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

2019-03-08 Thread Kevin Thorpe
I'm no expert in R internals or floating point computation, however, two things 
come to mind.

First, I suspect the exact value is stored. It is just the printing that looks 
rounded. That is likely because 0.001 completely dominates the rest. To print 
in full precision, you would need over 200 digits for some of your values.

Second, you may be pushing the limits of precision. It seems to me your 
original values are indistinguishable from zero. If they really represent 
materially different values, you might want to rescale them to improve 
computational reliability. 

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2019-03-08, 7:39 AM, "R-help on behalf of akshay kulkarni" 
 wrote:

dear members
 here is a piece of my code:

> tail(YLf14,15)
 [1] 5.706871e-217 2.563877e-218 2.823295e-218 2.694622e-222 1.777409e-226
 [6] 1.134403e-201 5.269464e-215 2.272121e-219 2.794970e-223 1.630978e-187
[11] 1.721529e-213 5.859815e-178 4.842612e-222 1.333685e-193 1.256051e-174
> YLf16 <- YLf14 + 0.001
> tail(YLf16,15)
 [1] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
[13] 0.001 0.001 0.001

Is there any way to avoid the rounding off of YLf16 to 0.001, and take 
exact values?

very many thanks for your time and effort..
yours sincerely,
AKSHAY M KULKARNI


[[alternative HTML version deleted]]

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


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


Re: [R] Importing SAS datasets into R efficiently

2018-10-19 Thread Kevin Thorpe
For some reason, the mailing list got dropped from my reply below.


  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: Kevin Thorpe
Sent: Friday, October 19, 2018 12:30 PM
To: Bert Gunter; Marc Schwartz
Subject: Re: [R] Importing SAS datasets into R efficiently
  

Related to Marc's suggestion, if you have SAS on the same computer as R, try 
the sas.get function in the Hmisc package.

I know it doesn't help you, but I have not had speed issues with haven.

Kevin
  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: R-help  on behalf of Marc Schwartz via 
R-help 
Sent: Friday, October 19, 2018 11:05 AM
To: Bert Gunter
Cc: R-help
Subject: Re: [R] Importing SAS datasets into R efficiently
  

Hi,

'foreign' will only read SAS XPT files, not the proprietary BDAT files, which I 
presume is the case here.

I don't use 'haven', but it looks like the key functions are written in C/C++, 
which should be relatively efficient.

If you are having specific issues with particular files,  because they are 
rather large, and/or have some kind of complex structure, you might want to 
communicate directly with the haven maintainers to see if there are some 
performance bottlenecks that perhaps   they can resolve.

The only other option, to my knowledge, to directly read BDAT files in R, is 
the sas7bdat package on CRAN:

  https://cran.r-project.org/web/packages/sas7bdat/ 
<https://cran.r-project.org/web/packages/sas7bdat/>


CRAN - Package sas7bdat
cran.r-project.org
sas7bdat: SAS Database Reader (experimental) Read SAS files in the sas7bdat 
data format.


CRAN - Package sas7bdat
cran.r-project.org
sas7bdat: SAS Database Reader (experimental) Read SAS files in the sas7bdat 
data format.

However, it looks like it has not been updated in several years, so not sure of 
status.

Another alternative, if you have access to SAS, is to export the BDAT 
datasets(s) to CSV files in SAS, and them import them into R, using read.csv().

Regards,

Marc Schwartz


> On Oct 19, 2018, at 10:41 AM, Bert Gunter  wrote:
> 
> Have you looked at the "foreign" package?
> 
> -- Bert
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Fri, Oct 19, 2018 at 6:48 AM Jomy Jose  wrote:
> 
>> Hi
>> 
>> Is there an efficient way to import SAS datasets into R,presently while
>> using haven package it takes long time...Is there a smart work around this
>> ?
>> 
>> Thanks in advance
>> Jose


    [[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] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe


Thanks Jeff and all others.

I will need to use the tempfile route I guess (I'm running in a Linux OS) for 
the time-being.

After I re-loaded the data frames that were broken before and they seemed fine, 
after using them for awhile they broke again.

I am trying to build my analysis with rmarkdown and tools. I have not been able 
to determine (yet) exactly what set of interactions are "breaking" things. I 
certainly don't expect the list to debug everything I'm doing.

The only thing is can say is that there appears to be some weird interaction 
between SAS data sets imported by haven and other packages. Note that I 
encountered (I think) related issues with an imported data set when I tried 
working with it in the tidyverse.

Maybe I'm getting too old to learn new stuff. :-)

Sorry I am not being much help with my own problem. I just have not been able 
to determine where things break. If can come up with a reproducible example 
that reliably breaks, I'll post it.

Kevin
  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: Jeff Newmiller 
Sent: Monday, July 9, 2018 1:01 PM
To: r-help@r-project.org; Kevin Thorpe; R Help Mailing List
Subject: Re: [R] Using write.csv as a connection for read.csv
  

TL;DR: If you want to do this, go ahead and use a temporary file or text 
connection.

Others have pointed out that write.csv returns NULL rather than a file 
connection, but I haven't seen comments on your impulse to avoid the use of 
files.

*nix operating systems are admirably efficient with multitasking... such that 
shells can efficiently run multiple programs connected by pipes, pausing the 
producers to pause if they get ahead of the consumers and resuming them if the 
consumers run out of data,  thus minimizing the amount of temporary disk space 
usage.

R does not presume this to be among the fundamental capabilities of the 
operating system, rather assuming single tasking capability by default. This 
means that even if you do connect write.csv to a pipe then it will run to 
completion before read.csv gets a  chance to process any of the data. MSDOS 
used to simulate command line program chaining by writing all the data to a 
temporary file before running the consumer program. R is similar... and like 
MSDOS there is little reason to avoid temporary files in R.

set.seed( 42 )
DF <- data.frame( X=1:100, Y=rnorm( 100 ) )
frame <- tempfile()
write.csv( DF, file=fname, row.names=FALSE )
DF2 <- read.csv( file=fname )
all.equal( DF$X, DF2$X ) && all.equal( DF$Y, DF2$Y )
unlink( fname )


On July 9, 2018 7:42:00 AM PDT, Kevin Thorpe  wrote:
>Hi.
>
>I have some data frames I created previously that seem to not be
>working correctly anymore. I *think* the problem is that some of the
>variables in the data frame are of a type called labelled. There are
>other attributes in the data frame as well. I thought that the easiest
>way to fix this was to convert to, say a csv and re-load.
>
>I tried something like read.csv(write.csv(df,row.names=FALSE)) but got
>the error
>
>Error in read.table(file = file, header = header, sep = sep, quote =
>quote,  : 
>  'file' must be a character string or connection
>
>I guess there must be a way to send the output of write.csv to a
>connection that read.csv can use but I was mystified by the help page
>on connections, at least I could not determine how to achieve my
>desired result.
>
>I realize I could write to a file and read it back in, but that feels
>klunky somehow. Maybe my approach to convert my data to strip the
>"weird" stuff is wrong-headed and I would accept alternative
>strategies.
>
>I would like a more general solution to fix this because I expect to
>encounter it some more. For those wondering how I found myself in such
>a mess, the data frames were initially imported from SAS data sets
>through the haven package. I then did some standard manipulation and
>added some additional labels with the upData() function from Hmisc
>(both packages have been updated since initial creation of the data
>frames).
>
>Thanks,
>
>Kevin
> 
>--
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
> 
> 
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE d

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
So, after I sent the initial email I quit that R session entirely. When I 
started it again to try an provide the example data, the original (that I had a 
problem with before) is now behaving itself. Grrr.

Now no one is going to believe I ever had a problem with the data. :-)

  
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 



From: R-help  on behalf of Kevin Thorpe 

Sent: Monday, July 9, 2018 11:17 AM
To: Eric Berger
Cc: R Help Mailing List
Subject: Re: [R] Using write.csv as a connection for read.csv
  

Although your suggestion to provide the data is excellent and one I typically 
agree with, they data are currently unpublished and so should not be publicly 
available. I have tried to make a reproducible example in the past (when 
similar  looking things happened), but was unable to. Maybe I'll try a small 
subset and see if that works.


Kevin


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016


From: Eric Berger 
Sent: Monday, July 9, 2018 10:51:38 AM
To: Kevin Thorpe
Cc: R Help Mailing List
Subject: Re: [R] Using write.csv as a connection for read.csv

Hi Kevin,
It's good that you provided the background to the problem.
Rather than asking this list to "debug" your proposed solution, I think you 
would be better off showing some of the "corrupted" data frame and ask for 
suggestions how to deal with it.
(Suggestions may or may not match your initial attempt.)
Can you output a piece of your suspect data frame via the dput() function and 
post to the list?

Best,
Eric


On Mon, Jul 9, 2018 at 5:42 PM, Kevin Thorpe 
mailto:kevin.tho...@utoronto.ca>> wrote:
Hi.

I have some data frames I created previously that seem to not be working 
correctly anymore. I *think* the problem is that some of the variables in the 
data frame are of a type called labelled. There are other attributes in the 
data frame as well. I thought  that the easiest way to fix this was to convert 
to, say a csv and re-load.

I tried something like read.csv(write.csv(df,row.names=FALSE)) but got the error

  Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
  'file' must be a character string or connection

I guess there must be a way to send the output of write.csv to a connection 
that read.csv can use but I was mystified by the help page on connections, at 
least I could not determine how to achieve my desired result.

I realize I could write to a file and read it back in, but that feels klunky 
somehow. Maybe my approach to convert my data to strip the "weird" stuff is 
wrong-headed and I would accept alternative strategies.

I would like a more general solution to fix this because I expect to encounter 
it some more. For those wondering how I found myself in such a mess, the data 
frames were initially imported from SAS data sets through the haven package. I 
then did some standard  manipulation and added some additional labels with the 
upData() function from Hmisc (both packages have been updated since initial 
creation of the data frames).

Thanks,

Kevin

--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca<mailto:kevin.tho...@utoronto.ca>  Tel: 
416.864.5776  Fax: 416.864.3016


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


    [[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] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
Although your suggestion to provide the data is excellent and one I typically 
agree with, they data are currently unpublished and so should not be publicly 
available. I have tried to make a reproducible example in the past (when 
similar looking things happened), but was unable to. Maybe I'll try a small 
subset and see if that works.


Kevin


--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016


From: Eric Berger 
Sent: Monday, July 9, 2018 10:51:38 AM
To: Kevin Thorpe
Cc: R Help Mailing List
Subject: Re: [R] Using write.csv as a connection for read.csv

Hi Kevin,
It's good that you provided the background to the problem.
Rather than asking this list to "debug" your proposed solution, I think you 
would be better off showing some of the "corrupted" data frame and ask for 
suggestions how to deal with it.
(Suggestions may or may not match your initial attempt.)
Can you output a piece of your suspect data frame via the dput() function and 
post to the list?

Best,
Eric


On Mon, Jul 9, 2018 at 5:42 PM, Kevin Thorpe 
mailto:kevin.tho...@utoronto.ca>> wrote:
Hi.

I have some data frames I created previously that seem to not be working 
correctly anymore. I *think* the problem is that some of the variables in the 
data frame are of a type called labelled. There are other attributes in the 
data frame as well. I thought that the easiest way to fix this was to convert 
to, say a csv and re-load.

I tried something like read.csv(write.csv(df,row.names=FALSE)) but got the error

  Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
  'file' must be a character string or connection

I guess there must be a way to send the output of write.csv to a connection 
that read.csv can use but I was mystified by the help page on connections, at 
least I could not determine how to achieve my desired result.

I realize I could write to a file and read it back in, but that feels klunky 
somehow. Maybe my approach to convert my data to strip the "weird" stuff is 
wrong-headed and I would accept alternative strategies.

I would like a more general solution to fix this because I expect to encounter 
it some more. For those wondering how I found myself in such a mess, the data 
frames were initially imported from SAS data sets through the haven package. I 
then did some standard manipulation and added some additional labels with the 
upData() function from Hmisc (both packages have been updated since initial 
creation of the data frames).

Thanks,

Kevin

--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca<mailto:kevin.tho...@utoronto.ca>  Tel: 
416.864.5776  Fax: 416.864.3016


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


[[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] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
Hi.

I have some data frames I created previously that seem to not be working 
correctly anymore. I *think* the problem is that some of the variables in the 
data frame are of a type called labelled. There are other attributes in the 
data frame as well. I thought that the easiest way to fix this was to convert 
to, say a csv and re-load.

I tried something like read.csv(write.csv(df,row.names=FALSE)) but got the error

  Error in read.table(file = file, header = header, sep = sep, quote = quote,  
: 
  'file' must be a character string or connection

I guess there must be a way to send the output of write.csv to a connection 
that read.csv can use but I was mystified by the help page on connections, at 
least I could not determine how to achieve my desired result.

I realize I could write to a file and read it back in, but that feels klunky 
somehow. Maybe my approach to convert my data to strip the "weird" stuff is 
wrong-headed and I would accept alternative strategies.

I would like a more general solution to fix this because I expect to encounter 
it some more. For those wondering how I found myself in such a mess, the data 
frames were initially imported from SAS data sets through the haven package. I 
then did some standard manipulation and added some additional labels with the 
upData() function from Hmisc (both packages have been updated since initial 
creation of the data frames).

Thanks,

Kevin
 
--
 Kevin E. Thorpe
 Head of Biostatistics,  Applied Health Research Centre (AHRC)
 Li Ka Shing Knowledge Institute of St. Michael's
 Assistant Professor, Dalla Lana School of Public Health
 University of Toronto
 email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 
 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.