Re: [R] read

2019-08-08 Thread Bert Gunter
I stand corrected!

Bert Gunter

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


On Thu, Aug 8, 2019 at 7:11 PM Jeff Newmiller 
wrote:

> Val 1
> Bert 0
>
> On August 8, 2019 5:22:13 PM PDT, Bert Gunter 
> wrote:
> >read.table() does not have a "text" argument, so maybe you need to go
> >back
> >and go through a tutorial or two to learn R basics (e.g. about function
> >calls and function arguments ?)
> >See ?read.table  (of course)
> >
> >Cheers,
> >
> >Bert Gunter
> >
> >"The trouble with having an open mind is that people keep coming along
> >and
> >sticking things into it."
> >-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> >On Thu, Aug 8, 2019 at 5:11 PM Val  wrote:
> >
> >> Hi all,
> >>
> >> I am trying to red data where single and double quotes are embedded
> >> in some of the fields and prevented to read the data.   As an example
> >> please see below.
> >>
> >> vld<-read.table(text="name prof
> >>   A  '4.5
> >>   B   "3.2
> >>   C   5.5 ",header=TRUE)
> >>
> >> Error in read.table(text = "name prof \n  A  '4.5\n  B
> >> 3.2 \n  C   5.5 ",  :
> >>   incomplete final line found by readTableHeader on 'text'
> >>
> >> Is there a way how to  read this data and gt the following output
> >>   name prof
> >> 1A  4.5
> >> 2B  3.2
> >> 3C  5.5
> >>
> >> Thank you inadvertence
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/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.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

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


Re: [R] read

2019-08-08 Thread Jeff Newmiller
Assuming your actual case is a file containing those characters, your example R 
string has to quote them. However, it seems like you want to disable 
interpreting quotes while you read this file.

vld<-read.table(text=
"name prof
  A  '4.5
  B   \"3.2
  C   5.5 "
,header=TRUE,quote="")

(The escape character isn't really there.)

On August 8, 2019 5:40:08 PM PDT, Val  wrote:
>Thank you  all, I can read the text file but the problem was there is
>a single quote embedded  in  the first row of second column. This
>quote causes the problem
>
>vld<-read.table(text="name prof
>  A  '4.5
>  B   "3.2
>  C   5.5 ",header=TRUE)
>
>On Thu, Aug 8, 2019 at 7:24 PM Anaanthan Pillai
> wrote:
>>
>> data <- read.table(header=TRUE, text='
>>  name prof
>>   A  4.5
>>   B  3.2
>>   C  5.5
>>  ')
>> > On 9 Aug 2019, at 8:11 AM, Val  wrote:
>> >
>> > Hi all,
>> >
>> > I am trying to red data where single and double quotes are embedded
>> > in some of the fields and prevented to read the data.   As an
>example
>> > please see below.
>> >
>> > vld<-read.table(text="name prof
>> >  A  '4.5
>> >  B   "3.2
>> >  C   5.5 ",header=TRUE)
>> >
>> > Error in read.table(text = "name prof \n  A  '4.5\n  B
>> > 3.2 \n  C   5.5 ",  :
>> >  incomplete final line found by readTableHeader on 'text'
>> >
>> > Is there a way how to  read this data and gt the following output
>> >  name prof
>> > 1A  4.5
>> > 2B  3.2
>> > 3C  5.5
>> >
>> > Thank you inadvertence
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/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.

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

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


Re: [R] read

2019-08-08 Thread Jeff Newmiller
Val 1
Bert 0

On August 8, 2019 5:22:13 PM PDT, Bert Gunter  wrote:
>read.table() does not have a "text" argument, so maybe you need to go
>back
>and go through a tutorial or two to learn R basics (e.g. about function
>calls and function arguments ?)
>See ?read.table  (of course)
>
>Cheers,
>
>Bert Gunter
>
>"The trouble with having an open mind is that people keep coming along
>and
>sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>On Thu, Aug 8, 2019 at 5:11 PM Val  wrote:
>
>> Hi all,
>>
>> I am trying to red data where single and double quotes are embedded
>> in some of the fields and prevented to read the data.   As an example
>> please see below.
>>
>> vld<-read.table(text="name prof
>>   A  '4.5
>>   B   "3.2
>>   C   5.5 ",header=TRUE)
>>
>> Error in read.table(text = "name prof \n  A  '4.5\n  B
>> 3.2 \n  C   5.5 ",  :
>>   incomplete final line found by readTableHeader on 'text'
>>
>> Is there a way how to  read this data and gt the following output
>>   name prof
>> 1A  4.5
>> 2B  3.2
>> 3C  5.5
>>
>> Thank you inadvertence
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/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.

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

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


Re: [R] read

2019-08-08 Thread Peter Langfelder
I would remove the quotes using sub, something like

# Read the file as text lines
text = readLines(con = file(yourFileName))
# Remove the offending quotes
text = gsub("'|\"", "", text)
# Concatenate and turn into a data frame
concat = paste(text, collapse = "\n")
df = read.table(text = concat, ...) # Change arguments as needed

HTH,

Peter

On Thu, Aug 8, 2019 at 5:41 PM Val  wrote:
>
> Thank you  all, I can read the text file but the problem was there is
> a single quote embedded  in  the first row of second column. This
> quote causes the problem
>
> vld<-read.table(text="name prof
>   A  '4.5
>   B   "3.2
>   C   5.5 ",header=TRUE)
>
> On Thu, Aug 8, 2019 at 7:24 PM Anaanthan Pillai
>  wrote:
> >
> > data <- read.table(header=TRUE, text='
> >  name prof
> >   A  4.5
> >   B  3.2
> >   C  5.5
> >  ')
> > > On 9 Aug 2019, at 8:11 AM, Val  wrote:
> > >
> > > Hi all,
> > >
> > > I am trying to red data where single and double quotes are embedded
> > > in some of the fields and prevented to read the data.   As an example
> > > please see below.
> > >
> > > vld<-read.table(text="name prof
> > >  A  '4.5
> > >  B   "3.2
> > >  C   5.5 ",header=TRUE)
> > >
> > > Error in read.table(text = "name prof \n  A  '4.5\n  B
> > > 3.2 \n  C   5.5 ",  :
> > >  incomplete final line found by readTableHeader on 'text'
> > >
> > > Is there a way how to  read this data and gt the following output
> > >  name prof
> > > 1A  4.5
> > > 2B  3.2
> > > 3C  5.5
> > >
> > > Thank you inadvertence
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] read

2019-08-08 Thread Val
Thank you  all, I can read the text file but the problem was there is
a single quote embedded  in  the first row of second column. This
quote causes the problem

vld<-read.table(text="name prof
  A  '4.5
  B   "3.2
  C   5.5 ",header=TRUE)

On Thu, Aug 8, 2019 at 7:24 PM Anaanthan Pillai
 wrote:
>
> data <- read.table(header=TRUE, text='
>  name prof
>   A  4.5
>   B  3.2
>   C  5.5
>  ')
> > On 9 Aug 2019, at 8:11 AM, Val  wrote:
> >
> > Hi all,
> >
> > I am trying to red data where single and double quotes are embedded
> > in some of the fields and prevented to read the data.   As an example
> > please see below.
> >
> > vld<-read.table(text="name prof
> >  A  '4.5
> >  B   "3.2
> >  C   5.5 ",header=TRUE)
> >
> > Error in read.table(text = "name prof \n  A  '4.5\n  B
> > 3.2 \n  C   5.5 ",  :
> >  incomplete final line found by readTableHeader on 'text'
> >
> > Is there a way how to  read this data and gt the following output
> >  name prof
> > 1A  4.5
> > 2B  3.2
> > 3C  5.5
> >
> > Thank you inadvertence
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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] read

2019-08-08 Thread Bert Gunter
read.table() does not have a "text" argument, so maybe you need to go back
and go through a tutorial or two to learn R basics (e.g. about function
calls and function arguments ?)
See ?read.table  (of course)

Cheers,

Bert Gunter

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


On Thu, Aug 8, 2019 at 5:11 PM Val  wrote:

> Hi all,
>
> I am trying to red data where single and double quotes are embedded
> in some of the fields and prevented to read the data.   As an example
> please see below.
>
> vld<-read.table(text="name prof
>   A  '4.5
>   B   "3.2
>   C   5.5 ",header=TRUE)
>
> Error in read.table(text = "name prof \n  A  '4.5\n  B
> 3.2 \n  C   5.5 ",  :
>   incomplete final line found by readTableHeader on 'text'
>
> Is there a way how to  read this data and gt the following output
>   name prof
> 1A  4.5
> 2B  3.2
> 3C  5.5
>
> Thank you inadvertence
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] read

2019-08-08 Thread Anaanthan Pillai
data <- read.table(header=TRUE, text='
 name prof 
  A  4.5
  B  3.2
  C  5.5   
 ')
> On 9 Aug 2019, at 8:11 AM, Val  wrote:
> 
> Hi all,
> 
> I am trying to red data where single and double quotes are embedded
> in some of the fields and prevented to read the data.   As an example
> please see below.
> 
> vld<-read.table(text="name prof
>  A  '4.5
>  B   "3.2
>  C   5.5 ",header=TRUE)
> 
> Error in read.table(text = "name prof \n  A  '4.5\n  B
> 3.2 \n  C   5.5 ",  :
>  incomplete final line found by readTableHeader on 'text'
> 
> Is there a way how to  read this data and gt the following output
>  name prof
> 1A  4.5
> 2B  3.2
> 3C  5.5
> 
> Thank you inadvertence
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] read

2019-08-08 Thread Thevaraja, Mayooran
Hi you can save your data file in txt or csv file. Then you can use function " 
vld <-read.table("C:/Users/ .txt",header=T)".

Regards
Mayooran

-Original Message-
From: R-help  On Behalf Of Val
Sent: Friday, 9 August 2019 12:11 PM
To: r-help@R-project.org (r-help@r-project.org) 
Subject: [R] read

Hi all,

I am trying to red data where single and double quotes are embedded
in some of the fields and prevented to read the data.   As an example
please see below.

vld<-read.table(text="name prof
  A  '4.5
  B   "3.2
  C   5.5 ",header=TRUE)

Error in read.table(text = "name prof \n  A  '4.5\n  B
3.2 \n  C   5.5 ",  :
  incomplete final line found by readTableHeader on 'text'

Is there a way how to  read this data and gt the following output
  name prof
1A  4.5
2B  3.2
3C  5.5

Thank you inadvertence

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

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


[R] read

2019-08-08 Thread Val
Hi all,

I am trying to red data where single and double quotes are embedded
in some of the fields and prevented to read the data.   As an example
please see below.

vld<-read.table(text="name prof
  A  '4.5
  B   "3.2
  C   5.5 ",header=TRUE)

Error in read.table(text = "name prof \n  A  '4.5\n  B
3.2 \n  C   5.5 ",  :
  incomplete final line found by readTableHeader on 'text'

Is there a way how to  read this data and gt the following output
  name prof
1A  4.5
2B  3.2
3C  5.5

Thank you inadvertence

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] broken installation on ubuntu 16.04 for 3.4.4-1xenial0

2019-08-08 Thread David Winsemius

The proper place for Ubuntu/Debian questions is r-sig-deb...@r-project.org


--

David

On 8/8/19 12:52 PM, k...@breadfinance.com wrote:

Sorry for unintentionally sending a rich text email.

I have confirmed that installation follows ubuntu guide lines in your link and 
I reproduce the output of git blame of the installation recipe showing that it 
has always been using the right key.  The change before we get these errors are 
on March 2019.  The unauthenticated errors start late july or so.  This recipe 
runs at least once every week for a year or more and only a few weeks ago the 
installation fails.


71637a7e7 (MK 2018-01-08 16:03:26 -0500  40) apt_repository 'rproject' do
71637a7e7 (MK 2018-01-08 16:03:26 -0500  41)   uri 
'http://cran.r-project.org/bin/linux/ubuntu'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  42)   keyserver 'keyserver.ubuntu.com'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  43)   key 'E084DAB9'
71637a7e7 (MK 2018-01-08 16:03:26 -0500  44)   components ['']
71637a7e7 (MK 2018-01-08 16:03:26 -0500  45)   distribution 
node['lsb']['codename'] + '/'
71637a7e7 (MK 2018-01-08 16:03:26 -0500  46)   action :add
5b7928b56 (MK 2018-01-05 13:16:07 -0500  47) end
5b7928b56 (MK 2018-01-05 13:16:07 -0500  48)
5b7928b56 (MK 2018-01-05 13:16:07 -0500  49) package 'r-base' do
5a1e57649 (k z  2018-03-19 19:21:02 -0400  50)   version '3.4.4-1xenial0'
86242e5cf (k z   2019-08-07 08:27:42 -0400  51)   options 
'--allow-unauthenticated'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  52) end




On Aug 6, 2019, at 9:13 PM, Jeff Newmiller  wrote:

As the Posting Guide says... this is a plain text mailing list. You will help 
yourself if you pay attention when posting.

The standard instructions for Ubuntu [1] describe how to set up authentication.

[1] https://cran.r-project.org/bin/linux/ubuntu/README.html

On August 6, 2019 10:52:05 AM PDT, KZ Win  wrote:

We have a test  system for boostrapping a production machine running R
code.  It spins up a new machine and tries to install this version
whenever
there is a new commit to our infrastructure code repo.  This version
has
been in place since Mar 2018 but a few weeks ago this test fails
because it
can no longer install this package even though we have not made any
changes
to this installation process.

The failure comes with this message

```
WARNING: The following packages cannot be authenticated!
r-base-core r-cran-boot r-cran-cluster r-cran-foreign r-cran-mass
r-cran-kernsmooth r-cran-lattice r-cran-nlme r-cran-matrix r-cran-mgcv
r-cran-rpart r-cran-survival r-cran-class r-cran-nnet r-cran-spatial
r-cran-codetools r-recommended r-base r-base-dev r-base-html r-doc-html
STDERR: E: There were unauthenticated packages and -y was used without
--allow-unauthenticated```

Any idea on whether there is a way to install `r-base` without using
`--allow-unauthenticated`

I can provide more information if necessary.

Thank you

[[alternative HTML version deleted]]

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

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

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


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] broken installation on ubuntu 16.04 for 3.4.4-1xenial0

2019-08-08 Thread kz
Sorry for unintentionally sending a rich text email.

I have confirmed that installation follows ubuntu guide lines in your link and 
I reproduce the output of git blame of the installation recipe showing that it 
has always been using the right key.  The change before we get these errors are 
on March 2019.  The unauthenticated errors start late july or so.  This recipe 
runs at least once every week for a year or more and only a few weeks ago the 
installation fails.


71637a7e7 (MK 2018-01-08 16:03:26 -0500  40) apt_repository 'rproject' do
71637a7e7 (MK 2018-01-08 16:03:26 -0500  41)   uri 
'http://cran.r-project.org/bin/linux/ubuntu'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  42)   keyserver 'keyserver.ubuntu.com'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  43)   key 'E084DAB9'
71637a7e7 (MK 2018-01-08 16:03:26 -0500  44)   components ['']
71637a7e7 (MK 2018-01-08 16:03:26 -0500  45)   distribution 
node['lsb']['codename'] + '/'
71637a7e7 (MK 2018-01-08 16:03:26 -0500  46)   action :add
5b7928b56 (MK 2018-01-05 13:16:07 -0500  47) end
5b7928b56 (MK 2018-01-05 13:16:07 -0500  48)
5b7928b56 (MK 2018-01-05 13:16:07 -0500  49) package 'r-base' do
5a1e57649 (k z  2018-03-19 19:21:02 -0400  50)   version '3.4.4-1xenial0'
86242e5cf (k z   2019-08-07 08:27:42 -0400  51)   options 
'--allow-unauthenticated'
5b7928b56 (MK 2018-01-05 13:16:07 -0500  52) end



> On Aug 6, 2019, at 9:13 PM, Jeff Newmiller  wrote:
> 
> As the Posting Guide says... this is a plain text mailing list. You will help 
> yourself if you pay attention when posting.
> 
> The standard instructions for Ubuntu [1] describe how to set up 
> authentication.
> 
> [1] https://cran.r-project.org/bin/linux/ubuntu/README.html
> 
> On August 6, 2019 10:52:05 AM PDT, KZ Win  wrote:
>> We have a test  system for boostrapping a production machine running R
>> code.  It spins up a new machine and tries to install this version
>> whenever
>> there is a new commit to our infrastructure code repo.  This version
>> has
>> been in place since Mar 2018 but a few weeks ago this test fails
>> because it
>> can no longer install this package even though we have not made any
>> changes
>> to this installation process.
>> 
>> The failure comes with this message
>> 
>> ```
>> WARNING: The following packages cannot be authenticated!
>> r-base-core r-cran-boot r-cran-cluster r-cran-foreign r-cran-mass
>> r-cran-kernsmooth r-cran-lattice r-cran-nlme r-cran-matrix r-cran-mgcv
>> r-cran-rpart r-cran-survival r-cran-class r-cran-nnet r-cran-spatial
>> r-cran-codetools r-recommended r-base r-base-dev r-base-html r-doc-html
>> STDERR: E: There were unauthenticated packages and -y was used without
>> --allow-unauthenticated```
>> 
>> Any idea on whether there is a way to install `r-base` without using
>> `--allow-unauthenticated`
>> 
>> I can provide more information if necessary.
>> 
>> Thank you
>> 
>>  [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> -- 
> Sent from my phone. Please excuse my brevity.

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


Re: [R] how to reverse colors on boxplot

2019-08-08 Thread Rui Barradas

Hello,

Maybe I don't understand the question but isn't all you have to do is 
to, well, reverse the colors


col = c("palevioletred1", "royalblue1")

in the boxplot call?

boxplot(flcn_M ~ subject, data = dx,
col = c("palevioletred1", "royalblue1"),
xlab="subjects",
ylab="Expression estimate in delta (log2)",
boxwex = 0.2,
frame.plot = FALSE)
stripchart(flcn_M ~ subject, vertical = TRUE,
   data = dx,
   method = "jitter",
   add = TRUE,
   pch = 20,
   col = rgb(0, 0, 0, 0.5),
   jitter = 0.001)


Hope this helps,

Rui Barradas

Às 18:49 de 08/08/19, Ana Marija escreveu:

Hello,

I made plot in attach using:

boxplot(flcn_M~subject,data=dx,col =
c("royalblue1","palevioletred1"),xlab="subjects",ylab="Expression
estimate in delta (log2)",boxwex = 0.2,frame.plot = FALSE)
stripchart(flcn_M~subject, vertical = TRUE, data = dx,method =
"jitter", add = TRUE,pch = 20, col=rgb(0,0,0,.5),jitter = 0.001)

How do I reverse colors so that PDR is shown in this pink and nDR in blue?

Thanks
Ana

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Extract row as NA with no matching name

2019-08-08 Thread David Winsemius
I don't know a clean way of delivering that result but if you use 
logical indexing you can get an empty matrix with three columns:



str( mdat["nope" %in% rownames(mdat), ] )
 num[0 , 1:3]
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:3] "C.1" "C.2" "C.3"

# it prints thus to the console

 mdat[FALSE,  ]
# C.1 C.2 C.3


If you have a vector, test_vec of possible matches you could use:


mdat[ rownames(mdat) %in% test_vec,  ]


**Yet again I am advising you to post in plain text. It's very easy to 
post in plain text from gmail. Please do so.**



--

David.

On 8/8/19 8:43 AM, Christofer Bogaso wrote:

Hi,

Let say I have below matrix

mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
dimnames = list(c("row1", "row2"),
c("C.1", "C.2", "C.3")))


Now I can extract a raw by rowname as


mdat['row1', ]

C.1 C.2 C.3

   1   2   3


However I am also looking for was to extract values as NA when a
rowname is supplied which is not existing rownames

I should get


mdat['new_raw', ]

C.1 C.2 C.3

   NA   NA   NA


Current it throws error as default functionality. Is there any way to
force R to provide values as NA instead of showing any errore?

[[alternative HTML version deleted]]

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


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


[R] Creating a web site checker using R

2019-08-08 Thread Chris Evans
I use R a great deal but the huge web crawling power of it isn't an area I've 
used. I don't want to reinvent a cyberwheel and I suspect someone has done what 
I want.  That is a program that would run once a day (easy for me to set up as 
a cron task) and would crawl a single root of a web site (mine) and get the 
file size and a CRC or some similar check value for each page as pulled off the 
site (and, obviously, I'd want it not to follow off site links). The other key 
thing would be for it to store the values and URLs and be capable of being run 
in "create/update database" mode or in "check pages" mode and for the change 
mode run to Email me a warning if a page changes.  The reason I want this is 
that two of my sites have recently had content "disappear": neither I nor the 
ISP can see what's happened and we are lacking the very useful diagnostic of 
the date when the change happened which might have mapped it some component of 
WordPress, plugins or themes having updated.

I am failing to find anything such and all the services that offer site 
checking of this sort are prohibitively expensive for me (my sites are zero 
income and either personal or offering free utilities and information).

If anyone has done this, or something similar, I'd love to hear if you were 
willing to share it.  Failing that, I think I will have to create this but I 
know it will take me days as this isn't my area of R expertise and as, to be 
brutally honest, I'm a pretty poor programmer.  If I go that way, I'm sure 
people may be able to point me to things I may be (legitimately) able to 
recycle in parts to help construct this.

Thanks in advance,

Chris

-- 
Chris Evans  Skype: chris-psyctc
Visiting Professor, University of Sheffield 
I do some consultation work for the University of Roehampton 
 and other places but this  
remains my main Email address.
I have "semigrated" to France, see: 
https://www.psyctc.org/pelerinage2016/semigrating-to-france/ if you want to 
book to talk, I am trying to keep that to Thursdays and my diary is now 
available at: https://www.psyctc.org/pelerinage2016/ecwd_calendar/calendar/
Beware: French time, generally an hour ahead of UK.  That page will also take 
you to my blog which started with earlier joys in France and Spain!

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


[R] how to reverse colors on boxplot

2019-08-08 Thread Ana Marija
Hello,

I made plot in attach using:

boxplot(flcn_M~subject,data=dx,col =
c("royalblue1","palevioletred1"),xlab="subjects",ylab="Expression
estimate in delta (log2)",boxwex = 0.2,frame.plot = FALSE)
stripchart(flcn_M~subject, vertical = TRUE, data = dx,method =
"jitter", add = TRUE,pch = 20, col=rgb(0,0,0,.5),jitter = 0.001)

How do I reverse colors so that PDR is shown in this pink and nDR in blue?

Thanks
Ana

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

2019-08-08 Thread Bert Gunter
Jeff:
Fair enough. As I have no data (no experience with crashes), I am happy to
defer to those who do.

Cheers,
Bert

On Thu, Aug 8, 2019 at 10:28 AM Jeff Newmiller 
wrote:

> If R crashes, RStudio typically also crashes... so not necessarily news to
> them.
>
> I will say that reproducible examples are nearly always necessary in cases
> like this to obtain meaningful answers from anyone, and the output of
> sessionInfo() is also usually needed.
>
> On August 8, 2019 8:35:49 AM PDT, Bert Gunter 
> wrote:
> >That is a better path, I agree.
> >
> >However, I suspect that RStudio would still like to know about the
> >issue,
> >even *if* feather/R is what crashes. They probably do not want RStudio
> >to
> >crash even so.
> >
> >-- Bert
> >
> >On Thu, Aug 8, 2019 at 8:29 AM peter dalgaard  wrote:
> >
> >> Alternatively, try running your example from plain R (in a terminal,
> >> R.app, or Rgui, depending on your platform), and see if the problem
> >occurs
> >> without RStudio in the equation. If it does, then the feather package
> >> probably owns the problem.
> >>
> >> -pd
> >>
> >> > On 8 Aug 2019, at 16:34 , Bert Gunter 
> >wrote:
> >> >
> >> > You may have to contact RStudio about this. RStudio is a separate
> >IDE
> >> > independent of R -- i.e. developed and maintained by a separate
> >> > organization from the R project.
> >> >
> >> > Bert Gunter
> >> >
> >> > "The trouble with having an open mind is that people keep coming
> >along
> >> and
> >> > sticking things into it."
> >> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >> >
> >> >
> >> > On Thu, Aug 8, 2019 at 7:08 AM Luigi Marongiu
> >
> >> > wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> since I am encountering a lot of problems exporting dataframes
> >from
> >> >> julia to R (there is always something wrong with the formatting,
> >> >> probably a missing quote) so I am trying to use Feather to do the
> >job.
> >> >>
> >> >> I have installed Feather in Julia with `pkg.add("Feather")` and
> >> >> imported it with `using Feather`. I created a dataframe and saved
> >it
> >> >> with `Feather.write("/dir/dataframe.feather", df)` and it worked.
> >I
> >> >> can even open it back with `df =
> >> >> Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
> >> >> 128544`.
> >> >> The problem is with R. I am using Rstudio to test each step.
> >> >> I installed the package, imported it with `library(feather)` and
> >used it
> >> >> as:
> >> >> ```
> >> >> df = read_feather("/dir/dataframe.feather")
> >> >> ```
> >> >> and then Rstudio simply crashes.
> >> >> any idea why?
> >> >> 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.
> >> >>
> >> >
> >> >   [[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.
> >>
> >> --
> >> Peter Dalgaard, Professor,
> >> Center for Statistics, Copenhagen Business School
> >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> >> Phone: (+45)38153501
> >> Office: A 4.23
> >> Email: pd@cbs.dk  Priv: pda...@gmail.com
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

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


Re: [R] Error exporting dataframe from Julia to R with Feather

2019-08-08 Thread Jeff Newmiller
If R crashes, RStudio typically also crashes... so not necessarily news to them.

I will say that reproducible examples are nearly always necessary in cases like 
this to obtain meaningful answers from anyone, and the output of sessionInfo() 
is also usually needed.

On August 8, 2019 8:35:49 AM PDT, Bert Gunter  wrote:
>That is a better path, I agree.
>
>However, I suspect that RStudio would still like to know about the
>issue,
>even *if* feather/R is what crashes. They probably do not want RStudio
>to
>crash even so.
>
>-- Bert
>
>On Thu, Aug 8, 2019 at 8:29 AM peter dalgaard  wrote:
>
>> Alternatively, try running your example from plain R (in a terminal,
>> R.app, or Rgui, depending on your platform), and see if the problem
>occurs
>> without RStudio in the equation. If it does, then the feather package
>> probably owns the problem.
>>
>> -pd
>>
>> > On 8 Aug 2019, at 16:34 , Bert Gunter 
>wrote:
>> >
>> > You may have to contact RStudio about this. RStudio is a separate
>IDE
>> > independent of R -- i.e. developed and maintained by a separate
>> > organization from the R project.
>> >
>> > Bert Gunter
>> >
>> > "The trouble with having an open mind is that people keep coming
>along
>> and
>> > sticking things into it."
>> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >
>> >
>> > On Thu, Aug 8, 2019 at 7:08 AM Luigi Marongiu
>
>> > wrote:
>> >
>> >> Hello,
>> >>
>> >> since I am encountering a lot of problems exporting dataframes
>from
>> >> julia to R (there is always something wrong with the formatting,
>> >> probably a missing quote) so I am trying to use Feather to do the
>job.
>> >>
>> >> I have installed Feather in Julia with `pkg.add("Feather")` and
>> >> imported it with `using Feather`. I created a dataframe and saved
>it
>> >> with `Feather.write("/dir/dataframe.feather", df)` and it worked.
>I
>> >> can even open it back with `df =
>> >> Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
>> >> 128544`.
>> >> The problem is with R. I am using Rstudio to test each step.
>> >> I installed the package, imported it with `library(feather)` and
>used it
>> >> as:
>> >> ```
>> >> df = read_feather("/dir/dataframe.feather")
>> >> ```
>> >> and then Rstudio simply crashes.
>> >> any idea why?
>> >> 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.
>> >>
>> >
>> >   [[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.
>>
>> --
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Office: A 4.23
>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] gen.geneaslogy

2019-08-08 Thread Thomas Bolger
Hi

Many thanks for your very quick response. I should have spotted the error
in the data. I have corrected it but the error remains. Hopefully. the
package maintainer will be able to help.

Thank you very much for your reply.

Tom

On Thu, 8 Aug 2019 at 15:57, Jeff Newmiller 
wrote:

> This is a rather specialized issue... you probably should be cc'ing the
> package maintainer as added here.
>
> I have never used this package.. but perhaps the fact that 701 is female
> yet listed as a father of 801 and 802 could be causing problems. (If so,
> this may raise issues of family structure flexibility, though it could be
> appropriate for genetics studies.)
>
> On August 8, 2019 7:11:50 AM PDT, Thomas Bolger  wrote:
> >Hi
> >
> >I have just started to do some analysis of genealogies and seem to be
> >doing
> >something wrong when using gen.genealogy. The following is the script
> >and
> >output that I used. Any help greatfully apprciated
> >
> >library(GENLIB)
> >> library(ggenealogy)
> >> library(igraph)
> >> #
> >> #
> >> ###Data input as data frame
> >>
>
> >ind<-c(501,502,601,603,605,608,701,702,703,704,705,706,707,708,709,710,801,802)
> >>
>
> >father<-c(401,411,501,501,501,501,601,601,601,603,603,603,605,605,608,608,701,701)
> >>
>
> >mother<-c(402,412,502,502,502,502,602,602,602,604,604,604,606,607,609,609,711,711)
> >> sex<-c(1,2,1,1,1,1,2,2,1,2,1,2,1,1,1,1,1,2)
> >> gen.df<-data.frame(ind, father, mother, sex)
> >> #print data to check
> >> print (gen.df)
> >   ind father mother sex
> >1  501401402   1
> >2  502411412   2
> >3  601501502   1
> >4  603501502   1
> >5  605501502   1
> >6  608501502   1
> >7  701601602   2
> >8  702601602   2
> >9  703601602   1
> >10 704603604   2
> >11 705603604   1
> >12 706603604   2
> >13 707605606   1
> >14 708605607   1
> >15 709608609   1
> >16 710608609   1
> >17 801701711   1
> >18 802701711   2
> >> #
> >> #
> >> genex<-gen.genealogy(gen.df)
> >Error in gen.genealogy(gen.df) :
> > Invalid 'gen' parameter: identical individual number for both 'father'
> >and 'mother'
> >> #
> >>
>
> --
> Sent from my phone. Please excuse my brevity.
>


-- 
Thomas Bolger
Emeritus Full Professor of Zoology


UCD School of Biology and Environmental Science
Belfield
Dublin 4
Ireland

Telephone : +353-1-7162330

[[alternative HTML version deleted]]

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


Re: [R] conflicting results for a time-varying coefficient in a Cox model

2019-08-08 Thread Therneau, Terry M., Ph.D. via R-help
This is an excellent question.
The answer, in this particular case, mostly has to do with the outlier time 
values.  (I've 
never been convinced that the death at time 999 isn't really a misplaced code 
for 
"missing", actually).    If you change the knots used by the spline you can get 
quite 
different values.
For instance, using a smaller data set:

fit1 <- coxph(Surv(tstart, time, status) ~ trt + prior + karno, veteran)
zph1 <- cox.zph(fit1, transform='identity')
plot(zph1[3])

dtime <- unique(veteran$time[veteran$status ==1])    # all of the death times
veteran2 <- survSplit( Surv(time, status) ~ ., data=veteran, cut=dtime)
fit2 <- coxph(Surv(tstart, time, status) ~ trt + prior + karno +
     karno:ns(time, df=4),  data=veteran2)
tx <- 0:100 * 10    # x positions for plot
ncall <- attr(terms(fit2), "predvars")[[6]]
ty <- eval(ncall, data.frame(time = tx)) %*% coef(fit2)[4:7] + coef(fit2)[3]
lines(tx, ty, col=2)

-

Now it looks even worse!  The only difference is that the ns() function has 
chosen a 
different set of knots.

The test used by the cox.zph function is based on a score test and is solid.  
The plot 
that it produces uses a smoothed approximation to the variance matrix and is 
approximate.  
So the diagnostic plot will never exactly match an actual fit.   In this data 
set the 
outliers exacerbate the issue.  To see this try a different time scale.


zph2 <- cox.zph(fit1, transform= sqrt)
plot(zph2[3])
veteran2$stime <- sqrt(veteran2$time)
fit3 <- coxph(Surv(tstart, time, status) ~ trt + prior + karno +
    karno:ns(stime, df=4),  data=veteran2)

ncall3 <-attr(terms(fit3), "predvars")[[6]]
ty3 <- eval(ncall3, data.frame(stime= sqrt(tx))) %*% coef(fit3)[4:7] + 
coef(fit3)[3]
lines(sqrt(tx), ty3, col=2)



The right tail is now better behaved.   Eliminating the points >900 makes 
things even 
better behaved.

Terry T.




On 8/8/19 9:07 AM, Ferenci Tamas wrote:
> I was thinking of two possible ways to
> plot a time-varying coefficient in a Cox model.
>
> One is simply to use survival::plot.cox.zph which directly produces a
> beta(t) vs t diagram.
>
> The other is to transform the dataset to counting process format and
> manually include an interaction with time, expanded with spline (to be
> similar to plot.cox.zph). Plotting the coefficient produces the needed
> beta(t) vs t diagram.
>
> I understand that they're slightly different approaches, so I don't
> expect totally identical results, but nevertheless, they approximate
> the very same thing, so I do expect that the results are more or less
> similar.
>
> However:
>
> library( survival )
> library( splines )
>
> data( veteran )
>
> zp <- cox.zph( coxph(Surv(time, status) ~ trt + prior + karno,
>   data = veteran ), transform = "identity" )[ 3 ]
>
> veteran3 <- survSplit( Surv(time, status) ~ trt + prior + karno,
> data = veteran, cut = 1:max(veteran$time) )
>
> fit <- coxph(Surv(tstart,time, status) ~ trt + prior + karno +
> karno:ns( time, df = 4 ), data = veteran3 )
> cf <- coef( fit )
> nsvet <- ns( veteran3$time, df = 4 )
>
> plot( zp )
> lines( 0:1000, ns( 0:1000, df = 4, knots = attr( nsvet, "knots" ),
> Boundary.knots = attr( nsvet, "Boundary.knots" ) )%*%cf[
>   grep( "karno:ns", names( cf ) ) ] + cf["karno"],
> type = "l", col = "red" )
>
> Where is the mistake? Something must be going on here, because the
> plots are vastly different...
>
> Thank you very much in advance,
> Tamas


[[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] Extract row as NA with no matching name

2019-08-08 Thread Christofer Bogaso
Hi,

Let say I have below matrix

mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
   dimnames = list(c("row1", "row2"),
   c("C.1", "C.2", "C.3")))


Now I can extract a raw by rowname as

> mdat['row1', ]

C.1 C.2 C.3

  1   2   3


However I am also looking for was to extract values as NA when a
rowname is supplied which is not existing rownames

I should get

> mdat['new_raw', ]

C.1 C.2 C.3

  NA   NA   NA


Current it throws error as default functionality. Is there any way to
force R to provide values as NA instead of showing any errore?

[[alternative HTML version deleted]]

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


Re: [R] Error exporting dataframe from Julia to R with Feather

2019-08-08 Thread Bert Gunter
That is a better path, I agree.

However, I suspect that RStudio would still like to know about the issue,
even *if* feather/R is what crashes. They probably do not want RStudio to
crash even so.

-- Bert

On Thu, Aug 8, 2019 at 8:29 AM peter dalgaard  wrote:

> Alternatively, try running your example from plain R (in a terminal,
> R.app, or Rgui, depending on your platform), and see if the problem occurs
> without RStudio in the equation. If it does, then the feather package
> probably owns the problem.
>
> -pd
>
> > On 8 Aug 2019, at 16:34 , Bert Gunter  wrote:
> >
> > You may have to contact RStudio about this. RStudio is a separate IDE
> > independent of R -- i.e. developed and maintained by a separate
> > organization from the R project.
> >
> > Bert Gunter
> >
> > "The trouble with having an open mind is that people keep coming along
> and
> > sticking things into it."
> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> >
> >
> > On Thu, Aug 8, 2019 at 7:08 AM Luigi Marongiu 
> > wrote:
> >
> >> Hello,
> >>
> >> since I am encountering a lot of problems exporting dataframes from
> >> julia to R (there is always something wrong with the formatting,
> >> probably a missing quote) so I am trying to use Feather to do the job.
> >>
> >> I have installed Feather in Julia with `pkg.add("Feather")` and
> >> imported it with `using Feather`. I created a dataframe and saved it
> >> with `Feather.write("/dir/dataframe.feather", df)` and it worked. I
> >> can even open it back with `df =
> >> Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
> >> 128544`.
> >> The problem is with R. I am using Rstudio to test each step.
> >> I installed the package, imported it with `library(feather)` and used it
> >> as:
> >> ```
> >> df = read_feather("/dir/dataframe.feather")
> >> ```
> >> and then Rstudio simply crashes.
> >> any idea why?
> >> 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.
> >>
> >
> >   [[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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Error exporting dataframe from Julia to R with Feather

2019-08-08 Thread peter dalgaard
Alternatively, try running your example from plain R (in a terminal, R.app, or 
Rgui, depending on your platform), and see if the problem occurs without 
RStudio in the equation. If it does, then the feather package probably owns the 
problem.

-pd

> On 8 Aug 2019, at 16:34 , Bert Gunter  wrote:
> 
> You may have to contact RStudio about this. RStudio is a separate IDE
> independent of R -- i.e. developed and maintained by a separate
> organization from the R project.
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Thu, Aug 8, 2019 at 7:08 AM Luigi Marongiu 
> wrote:
> 
>> Hello,
>> 
>> since I am encountering a lot of problems exporting dataframes from
>> julia to R (there is always something wrong with the formatting,
>> probably a missing quote) so I am trying to use Feather to do the job.
>> 
>> I have installed Feather in Julia with `pkg.add("Feather")` and
>> imported it with `using Feather`. I created a dataframe and saved it
>> with `Feather.write("/dir/dataframe.feather", df)` and it worked. I
>> can even open it back with `df =
>> Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
>> 128544`.
>> The problem is with R. I am using Rstudio to test each step.
>> I installed the package, imported it with `library(feather)` and used it
>> as:
>> ```
>> df = read_feather("/dir/dataframe.feather")
>> ```
>> and then Rstudio simply crashes.
>> any idea why?
>> 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.
>> 
> 
>   [[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.

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

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


Re: [R-es] Gráfico tiempos de supervivencia

2019-08-08 Thread Griera
Hola Francisco:

Muchas gracias por este refinamiento. 

Tienes razón, el gráfico de Lexis representa mucho mejor los datos. 

Y gracias por el código. Lo guardo también para el futuro.

Saludos


On Thu, 8 Aug 2019 09:42:50 +0200
Francisco Viciana  wrote:

> Hola, aunque con un poco de retraso, hago una aportación a este hilo:
> 
> Si tienes un problema con dos escalas de tiempo sobre las que 
> evolucionan las lineas de seguimiento, creo que es mejor que hacer un 
> solo gráfico en forma de   diagrama de Lexis, que dos gráficos 
> independientes. Muestro ejemplo usando el paquete "Epi":
> 
> # Código 
> 
> # Generar Datos 
> rm(list = ls())
> set.seed(20)
> XTIEMPO_2 = c(38, 2, 34, 29, 30, 3, 14, 8, 18, 31) # Per fe el gràfic 
> amb t=0
> set.seed(30)
> XTIEMPO_0 = sample(1:40, 10, replace=F)
> XTIEMPO_F = XTIEMPO_0 + XTIEMPO_2
> set.seed(20)
> XDEF = as.factor(sample(c("Mort", "Viu"), 10, replace=T))
> 
> DATOS <- data.frame (
>    ID = c (1:10)
>    , TIEMPO_0 = XTIEMPO_0
>    , TIEMPO_F = XTIEMPO_F
>    , TIEMPO_2 = XTIEMPO_2 # Per fe el gràfic amb t=0
>    , DEF  = XDEF
> )
> 
> 
> names(DATOS)[2:5] <- c('marriage.age',
>     'output.age',
>     'duration','output')
> 
> DATOS$output <- factor(DATOS$output,levels = c('Casado','Viu','Mort'))
> DATOS$entry  <- factor('Casado',levels = c('Casado','Viu','Mort'))
> 
> # Crea objeto Lexis:
> library(Epi)
> lx.Datos <- Lexis( entry=list(antiguedad.del.matrimonio=0,
>     edad=marriage.age),
>      exit=list(edad=output.age),
>      entry.status = entry ,
>      exit.status = output ,id=ID,data=DATOS,merge=F)
> 
> #  Muestra datos originales y transformados
> DATOS
> lx.Datos
> 
> # Grafica: 
> 
> plot.Lexis(lx.Datos,time.scale = 1:2,col='blue')
> with(lx.Datos, points(x=lex.dur,y=edad+lex.dur,
> pch=c(NA,19,3)[as.integer(lex.Xst)],
>    col=1 ))
> grid()
> legend('bottomright',legend = levels(lx.Datos$lex.Xst)[-1],
>     pch=c(19,3),col=1)
> 
> ## --
> 
> On 19/7/19 15:03, Griera wrote:
> > Hola:
> >
> > Por si a alguien le interesa para un curso, aquí coloco la versión
> > definitiva de los dos gráficos que quería hacer (uno en escala del tiempo 
> > del calendario y la otra el tiempo de seguimiento) realizados gracias a la 
> > ayuda
> > de Carlos Ortega.
> >
> > Muchas gracias y saludos.
> >
> > # Código 
> > set.seed(20)
> > # TIEMPO_2 = sample(1:40, 10, replace=F)
> > XTIEMPO_2 = c(38, 2, 34, 29, 30, 3, 14, 8, 18, 31) # Per fe el gràfic amb 
> > t=0
> > set.seed(30)
> > XTIEMPO_0 = sample(1:40, 10, replace=F)
> > XTIEMPO_F = XTIEMPO_0 + XTIEMPO_2
> > set.seed(20)
> > # XDEF = as.factor(sample(c(0,1), 10, replace=T))
> > XDEF = as.factor(sample(c("Mort", "Viu"), 10, replace=T))
> >
> > DATOS <- data.frame (
> >   ID = c (1:10)
> > , TIEMPO_0 = XTIEMPO_0
> > , TIEMPO_F = XTIEMPO_F
> > , TIEMPO_2 = XTIEMPO_2 # Per fe el gràfic amb t=0
> > , DEF  = XDEF
> > )
> >
> > library(ggplot2)
> >
> > ## Gràfic amb temps calendari
> > ggplot( data = DATOS ) +
> >geom_point( aes(x = TIEMPO_F, y = ID , shape = DEF), size = 5 ) +
> >geom_segment( aes( x = TIEMPO_0, y = ID,   xend = TIEMPO_F, yend = ID ) 
> > ) +
> >scale_shape_manual (values = c(4, 16))  +
> >xlim (0, 70) +
> >xlab ("Data (temps del calendari)") +
> >ylab ("Persones") +
> > guides(colour = FALSE) +
> > labs(shape = ' ', values = c(4, 16)) +
> > scale_y_discrete() +
> >theme_classic() +
> >theme(axis.text.x = element_blank(), axis.ticks.x = element_blank())
> > ## Modificat
> > str (DATOS)
> > ggplot( data = DATOS ) +
> >geom_point( aes(x = TIEMPO_2, y = ID , shape = DEF), size = 5 ) +
> >scale_shape_manual (values = c(4, 16))  +
> >geom_segment( aes( x = 0, y = ID,   xend = TIEMPO_2, yend = ID ) ) +
> >xlim (0, 70) +
> >xlab ("Temps de seguiment") +
> >ylab ("Persones") +
> > guides(colour = FALSE) +
> > labs(shape = ' ', values = c(4, 16)) +
> > scale_y_discrete() +
> >theme_classic()
> >
> > # Código 
> >
> >
> > On Thu, 18 Jul 2019 14:21:24 +0200
> > Carlos Ortega  wrote:
> >  
> >> Hola,
> >>
> >> Sí, lo puedes hacer de esta forma...
> >>
> >> #-
> >> set.seed(20)
> >> DATOS <- data.frame (
> >>  ID  = c (1:10)
> >>, TIEMPO  = sample(1:40, 10, replace=F)
> >>, DEF = as.factor(sample(c(0,1), 10, replace=T))
> >> )
> >>
> >> library(ggplot2)
> >>
> >>ggplot( data = DATOS ) +
> >> geom_point( aes(x = TIEMPO, y = ID , shape = DEF, color = DEF), size = 
> >> 5
> >> ) +
> >> geom_segment( aes( x = 0, y = ID,  xend = TIEMPO, yend = ID ) ) +
> >>  guides(colour = FALSE) +

Re: [R] gen.geneaslogy

2019-08-08 Thread Jeff Newmiller
This is a rather specialized issue... you probably should be cc'ing the package 
maintainer as added here.

I have never used this package.. but perhaps the fact that 701 is female yet 
listed as a father of 801 and 802 could be causing problems. (If so, this may 
raise issues of family structure flexibility, though it could be appropriate 
for genetics studies.)

On August 8, 2019 7:11:50 AM PDT, Thomas Bolger  wrote:
>Hi
>
>I have just started to do some analysis of genealogies and seem to be
>doing
>something wrong when using gen.genealogy. The following is the script
>and
>output that I used. Any help greatfully apprciated
>
>library(GENLIB)
>> library(ggenealogy)
>> library(igraph)
>> #
>> #
>> ###Data input as data frame
>>
>ind<-c(501,502,601,603,605,608,701,702,703,704,705,706,707,708,709,710,801,802)
>>
>father<-c(401,411,501,501,501,501,601,601,601,603,603,603,605,605,608,608,701,701)
>>
>mother<-c(402,412,502,502,502,502,602,602,602,604,604,604,606,607,609,609,711,711)
>> sex<-c(1,2,1,1,1,1,2,2,1,2,1,2,1,1,1,1,1,2)
>> gen.df<-data.frame(ind, father, mother, sex)
>> #print data to check
>> print (gen.df)
>   ind father mother sex
>1  501401402   1
>2  502411412   2
>3  601501502   1
>4  603501502   1
>5  605501502   1
>6  608501502   1
>7  701601602   2
>8  702601602   2
>9  703601602   1
>10 704603604   2
>11 705603604   1
>12 706603604   2
>13 707605606   1
>14 708605607   1
>15 709608609   1
>16 710608609   1
>17 801701711   1
>18 802701711   2
>> #
>> #
>> genex<-gen.genealogy(gen.df)
>Error in gen.genealogy(gen.df) :
> Invalid 'gen' parameter: identical individual number for both 'father'
>and 'mother'
>> #
>>

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

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


Re: [R] Error exporting dataframe from Julia to R with Feather

2019-08-08 Thread Bert Gunter
You may have to contact RStudio about this. RStudio is a separate IDE
independent of R -- i.e. developed and maintained by a separate
organization from the R project.

Bert Gunter

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


On Thu, Aug 8, 2019 at 7:08 AM Luigi Marongiu 
wrote:

> Hello,
>
> since I am encountering a lot of problems exporting dataframes from
> julia to R (there is always something wrong with the formatting,
> probably a missing quote) so I am trying to use Feather to do the job.
>
> I have installed Feather in Julia with `pkg.add("Feather")` and
> imported it with `using Feather`. I created a dataframe and saved it
> with `Feather.write("/dir/dataframe.feather", df)` and it worked. I
> can even open it back with `df =
> Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
> 128544`.
> The problem is with R. I am using Rstudio to test each step.
> I installed the package, imported it with `library(feather)` and used it
> as:
> ```
> df = read_feather("/dir/dataframe.feather")
> ```
> and then Rstudio simply crashes.
> any idea why?
> 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.
>

[[alternative HTML version deleted]]

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


Re: [R] CoxPH multivariate frailty model with coxph (survival)

2019-08-08 Thread Denise b
 Chris,

Thanks a lot for the help and your investigation by simulations.

> Interacting a fixed effect with a strata variable is not uncommon.  No
> main effect of the strata variable is >  possible but the interaction term
> allows the fixed effect variable to have different values in different
>  strata.  I've more often seen it coded as a direct interaction:
> coxph( Surv(Time, Status) ~ treatment*strata(Event_type) + frailty(ID),
> data=example)
> (e.g., page 47 of Therneau and Grambsch)

This formulation works but doesn't provide the beta estimate of Tx on the
second event type (we need to sum the two beta). An equivalent formulation
that provides beta estimates on the two types of events is to create
intermediate variables as proposed page 177 of Therneau and Grambsch and
attached here.



> I don't see anything inherently wrong with your interpretation of the
> model.  While it seems that the
> assumption of no effect of one event on the other is very strong, I don't
> know the context of your
> analysis. I visualized it as a 4-state model.  Everyone starts in 0
> ("neither event").

To clarify the context of this analysis, we are interested to estimate
() the effect of a genetic variant on two time-to-complication traits
(non-competitive based on expert's knowledge), while accounting for
potential unexplained dependency between the traits. Multi-state models can
effectively be an interesting
alternative model formulation that I need to think a bit more in this
context.

> I did not observe much gain from the frailty term (unmeasured covariate)
> with only 2 events in the short > simulation I tried (except when the
> effect was very strong and I got convergence warnings).

I modified your simulation script to plot the beta estimates from r=100 data
replicates obtained from the following model comparisons:
modf  : Cox PH frailty model (model of interest)
modc  : Cox PH including the simulated gamma variable (for comparison with
modf )
modcf : Cox PH frailty model  + gamma (for comparisons with modf & modc; the
introduction of the simulated gamma variable should reduced the variance of
the frailty term; )
modsep: separate Cox PH model for each time-to-event trait (no frailty, no
gamma)

It Overall, I got some expected results:

-modf reduces the bias of Tx effect on event 1 and event2 compared to modsep
(see boxplots)
-modsep show an increased bias, while not for modf when I increase the
variance of the simulated gamma term (see boxplots)
-when the gamma simulated covariate is introduced as a covariate in the
model (modc), the variance of the frailty term is reduced (modcf versus modf
results; see for the last replicates).

So, it validates some conclusions I had before, but :
1) modf returns an estimate of the variance of the frailty term that tends
to be lower than the one specified for the data simulation
2) To be sure the specified model fits exactly what I want, I need to check
the likelihood function especially because they use an equivalence with a
penalized likelihood for the gamma frailty (see help of frailty()).

Regarding the model I specified for the two time-to-event traits, and the
conditional assumption I assume (the two time-to-event traits are assumed
independent given the frailty term),
the contribution of each subject i to the likelihood of the model of
interest should have the form:
 Li = Li_ev1(beta1|ui) * Li_ev2(beta2|ui) * p(ui|zz),
with ui = subject's frailty term and ui~gamma(shape,scale) & p the gamma
distribution
Li_ev1 and Li_ev2 are the contribution of i to the likelihood for event1 &
event2

There is a description of the frailty model in Therneau's  et al paper:
 https://www.mayo.edu/research/documents/frailtypdf/doc-10027273 starting
page 15, detailed page 38.
The formulation is described in a different context, with N individuals
(1<=i<=N) in q independent clusters j (1<=j<=q) with a frailty term that
accounts for the dependence between individuals within each cluster.
In my case, each cluster corresponds to an individual i and dependencies
between the two observations for each subject are accounted by the frailty
term. Using their notations, j= individual and i= type of event.
I still need to clarify if their likelihood covers the likelihood of my
model formulation.

Any comments, suggestions or experiences are welcome. :)


If some have other suggestions of packages to fit this type of model,
please let me know (other potential R packages: parfm, frailtySurv, cph from
rms, mets, MST,..?).

Denise,


I attached below the extension of Chris's code.

###
# Modified Chris's code
###
library(flexsurv)
library(survival)

set.seed(20190729)

res <- NULL
for(r in 1:100) {
# Multiple non-competing outcomes, connected only by frailty (unmeasured
covariate)
nn <- 1000
kk <- 2

# frailty, 1 per individual
# variance of random effect
#tau <- 0.01^2
#tau <- 2^2
#tau <- 0.4^2
tau <- 

[R] gen.geneaslogy

2019-08-08 Thread Thomas Bolger
Hi

I have just started to do some analysis of genealogies and seem to be doing
something wrong when using gen.genealogy. The following is the script and
output that I used. Any help greatfully apprciated

library(GENLIB)
> library(ggenealogy)
> library(igraph)
> #
> #
> ###Data input as data frame
>
ind<-c(501,502,601,603,605,608,701,702,703,704,705,706,707,708,709,710,801,802)
>
father<-c(401,411,501,501,501,501,601,601,601,603,603,603,605,605,608,608,701,701)
>
mother<-c(402,412,502,502,502,502,602,602,602,604,604,604,606,607,609,609,711,711)
> sex<-c(1,2,1,1,1,1,2,2,1,2,1,2,1,1,1,1,1,2)
> gen.df<-data.frame(ind, father, mother, sex)
> #print data to check
> print (gen.df)
   ind father mother sex
1  501401402   1
2  502411412   2
3  601501502   1
4  603501502   1
5  605501502   1
6  608501502   1
7  701601602   2
8  702601602   2
9  703601602   1
10 704603604   2
11 705603604   1
12 706603604   2
13 707605606   1
14 708605607   1
15 709608609   1
16 710608609   1
17 801701711   1
18 802701711   2
> #
> #
> genex<-gen.genealogy(gen.df)
Error in gen.genealogy(gen.df) :
  Invalid 'gen' parameter: identical individual number for both 'father'
and 'mother'
> #
>

-- 
Thomas Bolger
Emeritus Full Professor of Zoology


UCD School of Biology and Environmental Science
Belfield
Dublin 4
Ireland

Telephone : +353-1-7162330

[[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] Error exporting dataframe from Julia to R with Feather

2019-08-08 Thread Luigi Marongiu
Hello,

since I am encountering a lot of problems exporting dataframes from
julia to R (there is always something wrong with the formatting,
probably a missing quote) so I am trying to use Feather to do the job.

I have installed Feather in Julia with `pkg.add("Feather")` and
imported it with `using Feather`. I created a dataframe and saved it
with `Feather.write("/dir/dataframe.feather", df)` and it worked. I
can even open it back with `df =
Feather.read("/dir/dataframe.feather")` and get: `julia> nrow(df)
128544`.
The problem is with R. I am using Rstudio to test each step.
I installed the package, imported it with `library(feather)` and used it as:
```
df = read_feather("/dir/dataframe.feather")
```
and then Rstudio simply crashes.
any idea why?
Thank you

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


Re: [R-es] Completar datos buscando información en otro Data Frame

2019-08-08 Thread Javier Marcuzzi
Estimado Cleiver Yam

Pienso que usted está bien encaminado, pero habría una llave combinada
entre las dos primeras columnas, ¿El id en la base de datos está compuesto
por ambas?, o posiblemente no pero usted podría estar requiriendo esto, es
simple, intente creando una columna con una combinación de ambos y realice
la búsqueda con la misma lógica.

Javier Rubén Marcuzzi

El jue., 8 ago. 2019 a las 8:59, Clei Y ()
escribió:

>
> Hola a todos
>
> Tengo una duda, puede ser un poco básica pero no encuentro la respuesta,
> tengo dos base de datos como la siguiente:
>
> Data frame 1:
>
> Id_1Id_2Dato
> 1   1   3
> 1   2   6
> 1   2   5
> 2   1   2
> 2   1   4
> 2   3   5
>
>
> Data frame 2:
> Id_1Id_2Calificación
> 1   1   10
> 1   2   8
> 2   1   9
> 2   3   6
>
> Lo que necesito es que R tome las primeras dos columnas del data frame 1,
> realice la búsqueda en el data frame 2 y pueda agregar otra columna con el
> dato que le corresponda para quedar de la siguiente manera:
>
> Data frame 1 modificada:
> Id_1Id_2DatoCalificación
> 1   1   3   10
> 1   2   6   8
> 1   2   5   8
> 2   1   2   9
> 2   1   4   9
> 2   3   5   6
>
> Estuve tratando con Merge pero el número de filas es distinto y me termina
> duplicando algunos registros. Es algo como la función BUSCARV del excel.
>
> Saludos a todos
>
> Cleiver Yam
>
> [
> https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif
> ]<
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
> Libre de virus. www.avast.com<
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Simulations of GAM and MARS models : sample size ; Y-outliers and missing X-data

2019-08-08 Thread varin sacha via R-help
Dear Abby,

Many thanks for your response.

To answer your question. For me better all the x variables (collectively), to 
have m% missing values.

When you tell me : "Modify your code so that a single function say sim.test() 
computes your simulated statistics, for n sample size and m missing values, and 
returns the results, say as a two-element list".
I trust you and guess it is a really good idea, but don't know how to do 
that... :=(







Le jeudi 8 août 2019 à 05:29:55 UTC+2, Abby Spurdle  a 
écrit : 





> How can I modify my R codes to simulate the sample size, the presence of 
> Y-outliers and the presence of missing data ?


I don't know what it means for data to have 50% Y-outliers.
That's new to me...

As for the rest of your question.
Modify your code so that a single function, say sim.test() computes your 
simulated statistics, for n sample size and m missing values, and returns the 
results, say as a two-element list.

Then write a top level script (or function), something like:

+ ns = c (50, 100, 200, 300, 500)
+ ms = (1:5) * 0.1

+ n = rep (ns, each=5)
+ m = rep (ms, times=5)
+ GAM.stat = MARS.stat = numeric (25)

+ for (i in 1:25)
+ {   results = sim.test (n [i], m [i], ...other.args...)
+     GAM.stat [i] = results$GAM.stat
+     MARS.stat [i] = results$MARS.stat
+ }

+ cbind (n, m, GAM.stat, MARS.stat)

Note that from past experience, what you are doing may produce misleading 
results.
Because your results are dependent on your simulated data.
(Different simulated data will produce different results, and different end 
conclusions).

I haven't checked how the functions, you've used to fit models, handle missing 
values.
But assuming that missing values are NAs, this should be easy to do.

Do you want *each* x variable to have m% missing values, or *all* the x 
variables (collectively), to have m% missing values?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Completar datos buscando información en otro Data Frame

2019-08-08 Thread Mauricio Monsalvo
Hola.
Como las dos tablas tienen la variable común definida, podés hacerlo simple
con
library(tidyverse)
datos <- inner_join(df1, df2)
Saludos.

El jue., 8 ago. 2019 a las 8:59, Clei Y ()
escribió:

>
> Hola a todos
>
> Tengo una duda, puede ser un poco básica pero no encuentro la respuesta,
> tengo dos base de datos como la siguiente:
>
> Data frame 1:
>
> Id_1Id_2Dato
> 1   1   3
> 1   2   6
> 1   2   5
> 2   1   2
> 2   1   4
> 2   3   5
>
>
> Data frame 2:
> Id_1Id_2Calificación
> 1   1   10
> 1   2   8
> 2   1   9
> 2   3   6
>
> Lo que necesito es que R tome las primeras dos columnas del data frame 1,
> realice la búsqueda en el data frame 2 y pueda agregar otra columna con el
> dato que le corresponda para quedar de la siguiente manera:
>
> Data frame 1 modificada:
> Id_1Id_2DatoCalificación
> 1   1   3   10
> 1   2   6   8
> 1   2   5   8
> 2   1   2   9
> 2   1   4   9
> 2   3   5   6
>
> Estuve tratando con Merge pero el número de filas es distinto y me termina
> duplicando algunos registros. Es algo como la función BUSCARV del excel.
>
> Saludos a todos
>
> Cleiver Yam
>
> [
> https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif
> ]<
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
> Libre de virus. www.avast.com<
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Mauricio

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R-es] Completar datos buscando información en otro Data Frame

2019-08-08 Thread Clei Y


Hola a todos

Tengo una duda, puede ser un poco básica pero no encuentro la respuesta, tengo 
dos base de datos como la siguiente:

Data frame 1:

Id_1Id_2Dato
1   1   3
1   2   6
1   2   5
2   1   2
2   1   4
2   3   5


Data frame 2:
Id_1Id_2Calificación
1   1   10
1   2   8
2   1   9
2   3   6

Lo que necesito es que R tome las primeras dos columnas del data frame 1, 
realice la búsqueda en el data frame 2 y pueda agregar otra columna con el dato 
que le corresponda para quedar de la siguiente manera:

Data frame 1 modificada:
Id_1Id_2DatoCalificación
1   1   3   10
1   2   6   8
1   2   5   8
2   1   2   9
2   1   4   9
2   3   5   6

Estuve tratando con Merge pero el número de filas es distinto y me termina 
duplicando algunos registros. Es algo como la función BUSCARV del excel.

Saludos a todos

Cleiver Yam

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]
  Libre de virus. 
www.avast.com

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Help with if else statement

2019-08-08 Thread Linus Chen
Bert's answer is great, but since there is only two columns to be
used, why not simply
pt$pheno <- pmax( p$phenoQ ,p$phenoH )

Cheers,
Lei

On Wed, 7 Aug 2019 at 21:23, Bert Gunter  wrote:
>
> The ifelse() construction is fast, but after a couple of nested iterations,
> it gets messy and error-prone; so I believe to be avoided.
>
> In your case, there is a much better alternative, ?pmax . Ergo, something
> like:
>
> pt$pheno <- do.call(pmax, pt[, -1])
>
> ?do.call is necessary to pass the list of columns pt[, -1] to pmax.
>
> Cheers,
> 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 Wed, Aug 7, 2019 at 11:55 AM Ana Marija 
> wrote:
>
> > does this look ok:
> >
> > pt$pheno=ifelse(pt$phenoQ==-9 & pt$phenoH==-9,-9,ifelse(pt$phenoH==2 |
> > pt$phenoQ==2,2,1))
> >
> > On Wed, Aug 7, 2019 at 1:40 PM Ana Marija 
> > wrote:
> > >
> > > Hello,
> > >
> > > I have a data frame which looks like this:
> > >
> > > > head(pt)
> > >  eidQ phenoQ phenoH
> > > 1 117 -9 -9
> > > 2 125 -9 -9
> > > 3 138 -9  1
> > > 4 142 -9 -9
> > > 5 156 -9 -9
> > > 6 174 -9 -9
> > > 7   138 -9  1
> > > 8  1000127  2  1
> > > 9  1000690  2 -9
> > > 10  1000711  2 -9
> > > 11 1001431  2  1
> > > 12 1001710 -9  1
> > >
> > > I would like to create the 3rd column called "pheno" which would have
> > > these values:
> > > -9,-9,1,-9,-9,-9,1,2,2,2,2,1
> > >
> > > so in other words:
> > > -if -9 appears in both phenoQ and phenoH I will have -9 in pheno
> > > -if 2 appears in any of phenoQ or phenoH I will have 2 in pheno
> > > -if I have -9 and 1 or 1 and -9 in those columns I will have 1 in pheno
> > > -if I have -9 and 2 or 2 and -9 in those columns I will have 2 in pheno
> > >
> > > Can you please tell me how my if else statement would look like or any
> > > other way how to do that in R if my data frame name is "pt"
> > >
> > > Thanks
> > > Ana
> > > Ana
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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-es] Gráfico tiempos de supervivencia

2019-08-08 Thread Francisco Viciana

Hola, aunque con un poco de retraso, hago una aportación a este hilo:

Si tienes un problema con dos escalas de tiempo sobre las que 
evolucionan las lineas de seguimiento, creo que es mejor que hacer un 
solo gráfico en forma de   diagrama de Lexis, que dos gráficos 
independientes. Muestro ejemplo usando el paquete "Epi":


# Código 

# Generar Datos 
rm(list = ls())
set.seed(20)
XTIEMPO_2 = c(38, 2, 34, 29, 30, 3, 14, 8, 18, 31) # Per fe el gràfic 
amb t=0

set.seed(30)
XTIEMPO_0 = sample(1:40, 10, replace=F)
XTIEMPO_F = XTIEMPO_0 + XTIEMPO_2
set.seed(20)
XDEF = as.factor(sample(c("Mort", "Viu"), 10, replace=T))

DATOS <- data.frame (
  ID = c (1:10)
  , TIEMPO_0 = XTIEMPO_0
  , TIEMPO_F = XTIEMPO_F
  , TIEMPO_2 = XTIEMPO_2 # Per fe el gràfic amb t=0
  , DEF  = XDEF
)


names(DATOS)[2:5] <- c('marriage.age',
   'output.age',
   'duration','output')

DATOS$output <- factor(DATOS$output,levels = c('Casado','Viu','Mort'))
DATOS$entry  <- factor('Casado',levels = c('Casado','Viu','Mort'))

# Crea objeto Lexis:
library(Epi)
lx.Datos <- Lexis( entry=list(antiguedad.del.matrimonio=0,
   edad=marriage.age),
    exit=list(edad=output.age),
    entry.status = entry ,
    exit.status = output ,id=ID,data=DATOS,merge=F)

#  Muestra datos originales y transformados
DATOS
lx.Datos

# Grafica: 

plot.Lexis(lx.Datos,time.scale = 1:2,col='blue')
with(lx.Datos, points(x=lex.dur,y=edad+lex.dur,
pch=c(NA,19,3)[as.integer(lex.Xst)],
  col=1 ))
grid()
legend('bottomright',legend = levels(lx.Datos$lex.Xst)[-1],
   pch=c(19,3),col=1)

## --

On 19/7/19 15:03, Griera wrote:

Hola:

Por si a alguien le interesa para un curso, aquí coloco la versión
definitiva de los dos gráficos que quería hacer (uno en escala del tiempo del 
calendario y la otra el tiempo de seguimiento) realizados gracias a la ayuda
de Carlos Ortega.

Muchas gracias y saludos.

# Código 
set.seed(20)
# TIEMPO_2 = sample(1:40, 10, replace=F)
XTIEMPO_2 = c(38, 2, 34, 29, 30, 3, 14, 8, 18, 31) # Per fe el gràfic amb t=0
set.seed(30)
XTIEMPO_0 = sample(1:40, 10, replace=F)
XTIEMPO_F = XTIEMPO_0 + XTIEMPO_2
set.seed(20)
# XDEF = as.factor(sample(c(0,1), 10, replace=T))
XDEF = as.factor(sample(c("Mort", "Viu"), 10, replace=T))

DATOS <- data.frame (
  ID = c (1:10)
, TIEMPO_0 = XTIEMPO_0
, TIEMPO_F = XTIEMPO_F
, TIEMPO_2 = XTIEMPO_2 # Per fe el gràfic amb t=0
, DEF  = XDEF
)

library(ggplot2)

## Gràfic amb temps calendari
ggplot( data = DATOS ) +
   geom_point( aes(x = TIEMPO_F, y = ID , shape = DEF), size = 5 ) +
   geom_segment( aes( x = TIEMPO_0, y = ID,   xend = TIEMPO_F, yend = ID ) ) +
   scale_shape_manual (values = c(4, 16))  +
   xlim (0, 70) +
   xlab ("Data (temps del calendari)") +
   ylab ("Persones") +
guides(colour = FALSE) +
labs(shape = ' ', values = c(4, 16)) +
scale_y_discrete() +
   theme_classic() +
   theme(axis.text.x = element_blank(), axis.ticks.x = element_blank())
## Modificat
str (DATOS)
ggplot( data = DATOS ) +
   geom_point( aes(x = TIEMPO_2, y = ID , shape = DEF), size = 5 ) +
   scale_shape_manual (values = c(4, 16))  +
   geom_segment( aes( x = 0, y = ID,   xend = TIEMPO_2, yend = ID ) ) +
   xlim (0, 70) +
   xlab ("Temps de seguiment") +
   ylab ("Persones") +
guides(colour = FALSE) +
labs(shape = ' ', values = c(4, 16)) +
scale_y_discrete() +
   theme_classic()

# Código 


On Thu, 18 Jul 2019 14:21:24 +0200
Carlos Ortega  wrote:


Hola,

Sí, lo puedes hacer de esta forma...

#-
set.seed(20)
DATOS <- data.frame (
 ID  = c (1:10)
   , TIEMPO  = sample(1:40, 10, replace=F)
   , DEF = as.factor(sample(c(0,1), 10, replace=T))
)

library(ggplot2)

   ggplot( data = DATOS ) +
geom_point( aes(x = TIEMPO, y = ID , shape = DEF, color = DEF), size = 5
) +
geom_segment( aes( x = 0, y = ID,  xend = TIEMPO, yend = ID ) ) +
 guides(colour = FALSE) +
 labs(shape = 'LEGEND') +
 scale_y_discrete() +
theme_minimal()
#-

E incluso puedes reproducirlo usando fuentes parecidas a la de los comics
con el paquete "xkcd".

Saludos,
Carlos Ortega
www.qualityexcellence.es



El jue., 18 jul. 2019 a las 13:05, Griera-yandex ()
escribió:


Hola Pedro:

Gracias por la ayuda. No conocía esta manera más elegante de mostrar las
curvas de Kaplan-Meier. Te la compro.

En realidad quería mostrar un gráfico con la longitud de les tiempos de
seguimiento y al final un símbolo para indicar el estado. Seria un gráfico
similar a:

https://miro.medium.com/max/700/1*yHhG4TVcAAi29Ln88t0_5Q.png

Pero no encuentro la manera de hacerlo. Igual no se puede.

Muchas