Re: [R] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Jeff Newmiller
Also, R6 is based on R environments... you can access the methods and fields 
like S3 (eff$field) and you can list what methods and fields the object has 
(ls(envir=eff)).

On March 17, 2020 3:13:22 PM PDT, Jeff Newmiller  
wrote:
>OP may find the help page [1] informative as to which fields are which.
>I have never used the imp package. Note that the DESCRIPTION file
>indicates that this package uses the R6 object system rather than the
>more typical S3 or S4.
>
>[1] https://rdrr.io/cran/iml/man/FeatureEffect.html
>
>On March 17, 2020 12:26:33 PM PDT, Bert Gunter 
>wrote:
>>that is, read ?str carefully.
>>
>>data structures are fundamental to any programming language, so if you
>>really aren't getting it, that's a signal that you need to spend some
>>time
>>with R tutorials. The R language Definition manual is a more
>>comprehensive
>>but of course more difficult resource to learn about such matters. I
>>find
>>it readable, however. Others may not.
>>
>>Bert Gunter
>>
>>"The trouble with having an open mind is that people keep coming along
>>and
>>sticking things into it."
>>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>>On Tue, Mar 17, 2020 at 12:22 PM Bert Gunter 
>>wrote:
>>
>>> ?str
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming
>>along and
>>> sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>> On Tue, Mar 17, 2020 at 12:19 PM Sparks, John 
>>wrote:
>>>
 Hi R-Helpers,

 I have recently started working with the iml package (Interpretable
 Machine Learning)  and its associated material, which I generally
>>find very
 helpful.

 I want to recover some values out of the FeatureEffect Object
>>created by
 this library, but the form of the object is completely foreign to
>>me.

 As a reproducible example:


 set.seed(42)​
 library("iml")​
 library("randomForest")​
 data("Boston", package  = "MASS")​
 rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
 ​
 X = Boston[which(names(Boston) != "medv")]​
 predictor = Predictor$new(rf, data = X, y = Boston$medv)​
 imp = FeatureImp$new(predictor, loss = "mae")​
 eff = FeatureEffect$new(predictor, feature = "rm") ​
 eff


 Interpretation method:  FeatureEffect
 features: rm[numerical]
 grid size: 20

 Analysed predictor:
 Prediction task: unknown


 Analysed data:
 Sampling from data.frame with 506 rows and 13 columns.

 Head of results:
.ale .typerm
 1 -2.150574   ale 3.561
 2 -2.610528   ale 5.304
 3 -2.338677   ale 5.593
 4 -2.265673   ale 5.709
 5 -2.142912   ale 5.837
 6 -2.085899   ale 5.885

 How can I refer to and get ahold of the table of 6 records above?

 I tried str(eff) and class(eff), but I am not familiar with the
>>structure
 of the object(s).

 Would someone please tell me how to get inside the eff object, or
>>point
 me to a reference as to what the class or structure of the object
>>is?

 Thanks.
 --John Sparks

 [[alternative HTML version deleted]]

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

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

-- 
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] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Jeff Newmiller
OP may find the help page [1] informative as to which fields are which. I have 
never used the imp package. Note that the DESCRIPTION file indicates that this 
package uses the R6 object system rather than the more typical S3 or S4.

[1] https://rdrr.io/cran/iml/man/FeatureEffect.html

On March 17, 2020 12:26:33 PM PDT, Bert Gunter  wrote:
>that is, read ?str carefully.
>
>data structures are fundamental to any programming language, so if you
>really aren't getting it, that's a signal that you need to spend some
>time
>with R tutorials. The R language Definition manual is a more
>comprehensive
>but of course more difficult resource to learn about such matters. I
>find
>it readable, however. Others may not.
>
>Bert Gunter
>
>"The trouble with having an open mind is that people keep coming along
>and
>sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>On Tue, Mar 17, 2020 at 12:22 PM Bert Gunter 
>wrote:
>
>> ?str
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming
>along and
>> sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Tue, Mar 17, 2020 at 12:19 PM Sparks, John 
>wrote:
>>
>>> Hi R-Helpers,
>>>
>>> I have recently started working with the iml package (Interpretable
>>> Machine Learning)  and its associated material, which I generally
>find very
>>> helpful.
>>>
>>> I want to recover some values out of the FeatureEffect Object
>created by
>>> this library, but the form of the object is completely foreign to
>me.
>>>
>>> As a reproducible example:
>>>
>>>
>>> set.seed(42)​
>>> library("iml")​
>>> library("randomForest")​
>>> data("Boston", package  = "MASS")​
>>> rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
>>> ​
>>> X = Boston[which(names(Boston) != "medv")]​
>>> predictor = Predictor$new(rf, data = X, y = Boston$medv)​
>>> imp = FeatureImp$new(predictor, loss = "mae")​
>>> eff = FeatureEffect$new(predictor, feature = "rm") ​
>>> eff
>>>
>>>
>>> Interpretation method:  FeatureEffect
>>> features: rm[numerical]
>>> grid size: 20
>>>
>>> Analysed predictor:
>>> Prediction task: unknown
>>>
>>>
>>> Analysed data:
>>> Sampling from data.frame with 506 rows and 13 columns.
>>>
>>> Head of results:
>>>.ale .typerm
>>> 1 -2.150574   ale 3.561
>>> 2 -2.610528   ale 5.304
>>> 3 -2.338677   ale 5.593
>>> 4 -2.265673   ale 5.709
>>> 5 -2.142912   ale 5.837
>>> 6 -2.085899   ale 5.885
>>>
>>> How can I refer to and get ahold of the table of 6 records above?
>>>
>>> I tried str(eff) and class(eff), but I am not familiar with the
>structure
>>> of the object(s).
>>>
>>> Would someone please tell me how to get inside the eff object, or
>point
>>> me to a reference as to what the class or structure of the object
>is?
>>>
>>> Thanks.
>>> --John Sparks
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
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] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Bert Gunter
that is, read ?str carefully.

data structures are fundamental to any programming language, so if you
really aren't getting it, that's a signal that you need to spend some time
with R tutorials. The R language Definition manual is a more comprehensive
but of course more difficult resource to learn about such matters. I find
it readable, however. Others may not.

Bert Gunter

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


On Tue, Mar 17, 2020 at 12:22 PM Bert Gunter  wrote:

> ?str
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Mar 17, 2020 at 12:19 PM Sparks, John  wrote:
>
>> Hi R-Helpers,
>>
>> I have recently started working with the iml package (Interpretable
>> Machine Learning)  and its associated material, which I generally find very
>> helpful.
>>
>> I want to recover some values out of the FeatureEffect Object created by
>> this library, but the form of the object is completely foreign to me.
>>
>> As a reproducible example:
>>
>>
>> set.seed(42)​
>> library("iml")​
>> library("randomForest")​
>> data("Boston", package  = "MASS")​
>> rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
>> ​
>> X = Boston[which(names(Boston) != "medv")]​
>> predictor = Predictor$new(rf, data = X, y = Boston$medv)​
>> imp = FeatureImp$new(predictor, loss = "mae")​
>> eff = FeatureEffect$new(predictor, feature = "rm") ​
>> eff
>>
>>
>> Interpretation method:  FeatureEffect
>> features: rm[numerical]
>> grid size: 20
>>
>> Analysed predictor:
>> Prediction task: unknown
>>
>>
>> Analysed data:
>> Sampling from data.frame with 506 rows and 13 columns.
>>
>> Head of results:
>>.ale .typerm
>> 1 -2.150574   ale 3.561
>> 2 -2.610528   ale 5.304
>> 3 -2.338677   ale 5.593
>> 4 -2.265673   ale 5.709
>> 5 -2.142912   ale 5.837
>> 6 -2.085899   ale 5.885
>>
>> How can I refer to and get ahold of the table of 6 records above?
>>
>> I tried str(eff) and class(eff), but I am not familiar with the structure
>> of the object(s).
>>
>> Would someone please tell me how to get inside the eff object, or point
>> me to a reference as to what the class or structure of the object is?
>>
>> Thanks.
>> --John Sparks
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Sparks, John
From my previous email:

"I tried str(eff) and class(eff), but I am not familiar with the structure of 
the object(s)."

--JJS


From: Bert Gunter 
Sent: Tuesday, March 17, 2020 2:22 PM
To: Sparks, John 
Cc: r-help@r-project.org ; christoph.mol...@gmail.com 

Subject: Re: [R] Get Data Table from iml FeatureEffect Object

?str

Bert Gunter

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


On Tue, Mar 17, 2020 at 12:19 PM Sparks, John 
mailto:jspa...@uic.edu>> wrote:
Hi R-Helpers,

I have recently started working with the iml package (Interpretable Machine 
Learning)  and its associated material, which I generally find very helpful.

I want to recover some values out of the FeatureEffect Object created by this 
library, but the form of the object is completely foreign to me.

As a reproducible example:


set.seed(42)​
library("iml")​
library("randomForest")​
data("Boston", package  = "MASS")​
rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
​
X = Boston[which(names(Boston) != "medv")]​
predictor = Predictor$new(rf, data = X, y = Boston$medv)​
imp = FeatureImp$new(predictor, loss = "mae")​
eff = FeatureEffect$new(predictor, feature = "rm") ​
eff


Interpretation method:  FeatureEffect
features: rm[numerical]
grid size: 20

Analysed predictor:
Prediction task: unknown


Analysed data:
Sampling from data.frame with 506 rows and 13 columns.

Head of results:
   .ale .typerm
1 -2.150574   ale 3.561
2 -2.610528   ale 5.304
3 -2.338677   ale 5.593
4 -2.265673   ale 5.709
5 -2.142912   ale 5.837
6 -2.085899   ale 5.885

How can I refer to and get ahold of the table of 6 records above?

I tried str(eff) and class(eff), but I am not familiar with the structure of 
the object(s).

Would someone please tell me how to get inside the eff object, or point me to a 
reference as to what the class or structure of the object is?

Thanks.
--John Sparks

[[alternative HTML version deleted]]

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

[[alternative HTML version deleted]]

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


Re: [R] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Bert Gunter
?str

Bert Gunter

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


On Tue, Mar 17, 2020 at 12:19 PM Sparks, John  wrote:

> Hi R-Helpers,
>
> I have recently started working with the iml package (Interpretable
> Machine Learning)  and its associated material, which I generally find very
> helpful.
>
> I want to recover some values out of the FeatureEffect Object created by
> this library, but the form of the object is completely foreign to me.
>
> As a reproducible example:
>
>
> set.seed(42)​
> library("iml")​
> library("randomForest")​
> data("Boston", package  = "MASS")​
> rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
> ​
> X = Boston[which(names(Boston) != "medv")]​
> predictor = Predictor$new(rf, data = X, y = Boston$medv)​
> imp = FeatureImp$new(predictor, loss = "mae")​
> eff = FeatureEffect$new(predictor, feature = "rm") ​
> eff
>
>
> Interpretation method:  FeatureEffect
> features: rm[numerical]
> grid size: 20
>
> Analysed predictor:
> Prediction task: unknown
>
>
> Analysed data:
> Sampling from data.frame with 506 rows and 13 columns.
>
> Head of results:
>.ale .typerm
> 1 -2.150574   ale 3.561
> 2 -2.610528   ale 5.304
> 3 -2.338677   ale 5.593
> 4 -2.265673   ale 5.709
> 5 -2.142912   ale 5.837
> 6 -2.085899   ale 5.885
>
> How can I refer to and get ahold of the table of 6 records above?
>
> I tried str(eff) and class(eff), but I am not familiar with the structure
> of the object(s).
>
> Would someone please tell me how to get inside the eff object, or point me
> to a reference as to what the class or structure of the object is?
>
> Thanks.
> --John Sparks
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Get Data Table from iml FeatureEffect Object

2020-03-17 Thread Sparks, John
Hi R-Helpers,

I have recently started working with the iml package (Interpretable Machine 
Learning)  and its associated material, which I generally find very helpful.

I want to recover some values out of the FeatureEffect Object created by this 
library, but the form of the object is completely foreign to me.

As a reproducible example:


set.seed(42)​
library("iml")​
library("randomForest")​
data("Boston", package  = "MASS")​
rf = randomForest(medv ~ ., data = Boston, ntree = 50)​
​
X = Boston[which(names(Boston) != "medv")]​
predictor = Predictor$new(rf, data = X, y = Boston$medv)​
imp = FeatureImp$new(predictor, loss = "mae")​
eff = FeatureEffect$new(predictor, feature = "rm") ​
eff


Interpretation method:  FeatureEffect
features: rm[numerical]
grid size: 20

Analysed predictor:
Prediction task: unknown


Analysed data:
Sampling from data.frame with 506 rows and 13 columns.

Head of results:
   .ale .typerm
1 -2.150574   ale 3.561
2 -2.610528   ale 5.304
3 -2.338677   ale 5.593
4 -2.265673   ale 5.709
5 -2.142912   ale 5.837
6 -2.085899   ale 5.885

How can I refer to and get ahold of the table of 6 records above?

I tried str(eff) and class(eff), but I am not familiar with the structure of 
the object(s).

Would someone please tell me how to get inside the eff object, or point me to a 
reference as to what the class or structure of the object is?

Thanks.
--John Sparks

[[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-es] Bibliografía

2020-03-17 Thread Carlos Ortega
En la Web de la Fundación tienen documentos en diferentes idiomas entre
ellos español:

https://cran.r-project.org/other-docs.html

Saludos,
Carlos Ortega
www.qualityexcellence.es

El mar., 17 mar. 2020 a las 6:23, Jorge Orenos ()
escribió:

> Estoy buscando bibliografía en español para la utilización de R. Gracias.
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.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] Analyzing Baseball Data With R

2020-03-17 Thread John via R-help
On Mon, 16 Mar 2020 15:35:36 -0700
"Phillip Heinrich"  wrote:

> Can’t get past first step of Chapter 7 page 164.
> 
> Opened a new RStudio window.  Loaded tidyverse and keyed in
> library(tidyverse) which of course includes dplyr.  The working
> directory is: C:/Users/Owner/Documents.
> 
> Then keyed in: db <- src_sqlite(“data/pitchrx.sqlite”,create=TRUE)
> 
> And got the following error: Error: Could not connect to database:
> unable to open database
> file
> 
> Googled everything I could think of to find the sqlite function and
> the pitchrx.sqlite empty data base.  Can someone give me some
> direction?
> 
> I wondering if I have configured RStudio incorrectly.  Why doesn’t my
> by RStudio point to the correct data file?
> 
I get the idea that this might be homework.  There's a good deal of
information missing if you want help, and probably you've neglected a
few steps that need to be taken before you can proceed.  You also need
to understand the difference between R and RStudio.  

What you could do is type in "??src_sqlite() and see what it tells you.
For instance, have you installed the package RSQlite? If you haven't
you need to install it.  

It also appears that you might be running Windows.  Have you installed
sqlite?  And so on ...

JWD

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

2020-03-17 Thread Emilio L. Cano
Hola Jorge,

Los dos primeros capítulos de mi libro de apuntes te pueden servir de punto de 
partida:

http://emilio.lcano.com/b/adr/ 


Un saludo,

Emilio L. Cano
http://emilio.lcano.com



> El 17 mar 2020, a las 6:23, Jorge Orenos  escribió:
> 
> Estoy buscando bibliografía en español para la utilización de R. Gracias.
> 
>   [[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] Analyzing Baseball Data With R

2020-03-17 Thread William Michels via R-help
Hi Phillip,

Generally these problems come down to knowing/setting your working
directory. The first question is whether you have a directory named
"data" inside your "C:/Users/Owner/Documents" directory? You may need
to create this directory first, outside of R and/or RStudio (using
your Windows OS).

Below is some example code (on a Mac). You might want to try 1)
creating the "data" directory in Windows as mentioned earlier, 2)
setting your working directory to "C:/Users/Owner/Documents/data",
then 3) re-running your src_sqlite() command giving "pitchrx.sqlite”
as the database file name.

> getwd()
[1] "/Users/homedir/R_Dir"
> setwd("/Users/homedir/R_Dir/data")
Error in setwd("/Users/homedir/R_Dir/data") :
  cannot change working directory
>

HTH, Bill.

W. Michels, Ph.D.


On Mon, Mar 16, 2020 at 3:35 PM Phillip Heinrich  wrote:
>
> Can’t get past first step of Chapter 7 page 164.
>
> Opened a new RStudio window.  Loaded tidyverse and keyed in 
> library(tidyverse) which of course includes dplyr.  The working directory is: 
> C:/Users/Owner/Documents.
>
> Then keyed in: db <- src_sqlite(“data/pitchrx.sqlite”,create=TRUE)
>
> And got the following error: Error: Could not connect to database:
> unable to open database file
>
> Googled everything I could think of to find the sqlite function and the 
> pitchrx.sqlite empty data base.  Can someone give me some direction?
>
> I wondering if I have configured RStudio incorrectly.  Why doesn’t my by 
> RStudio point to the correct data file?
>
>
>
>
> [[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] Bibliografía

2020-03-17 Thread Jaume Tormo
Hola Jorge,

En esta web:
http://luiscayuela.blogspot.com/
En la columna de la derecha tienes unos apuntes de un curso.

Aprovecho para felicitar al autor, Luis Cayuela, los apuntes son estupendos.

Jaume.

El mar., 17 mar. 2020 a las 6:23, Jorge Orenos ()
escribió:

> Estoy buscando bibliografía en español para la utilización de R. Gracias.
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>


-- 
Jaume Tormo.
https://es.linkedin.com/in/jaumetormo
https://acercad.wordpress.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] Some seemingly odd behavior of survfit in library survival

2020-03-17 Thread Heinz Tuechler

Jeff Newmiller wrote/hat geschrieben on/am 17.03.2020 05:39:

The coxph function appears to rely on finding the name of the data argument in 
the environment in which the formula was created. The lm function does not have 
this problem.

Oh, and df is the name of the F distribution density function, which explains why the 
error complained about a "closure".

new<-as.data.frame(list(t=1:4,d=rep(1,4),s=c(1,0,0,1)))
library(survival)
mine<-function(ff,df){
fit<-coxph(as.formula(ff),data=df)
 survfit(fit,df)
}
mine("Surv(t,d)~s",new)



Therefore a workaround could be to use the character string for the
formula as argument and apply as.formula() within the function.

mine2 <-function(fstr,df){
fit<-coxph(as.formula(fstr),data=df)
out<-survfit(fit,df)
out
}

mine2("Surv(t,d)~s",new)

Heinz


On March 16, 2020 7:23:26 PM PDT, John Kolassa  wrote:

I ran across an issue that looks like variable scoping in survfit is
not acting as I would expect.  Here's a minimal example:

new<-as.data.frame(list(t=1:4,d=rep(1,4),s=c(1,0,0,1)))
library(survival)
mine<-function(ff,df){
   fit<-coxph(ff,data=df)
   out<-survfit(fit,df)
}
mine(as.formula("Surv(t,d)~s"),new)

I would expect this to fit the proportional hazards regression model
using formula Surv(t,d)~s, using data set new, and then calculate a
separate fitted survival curve for each member of the data set.
Instead I get an error

Error in eval(predvars, data, env) :
 invalid 'envir' argument of type 'closure'

The code runs without error if I modify it by copying the data set new
to the local variable within the function mine before running:

new<-as.data.frame(list(t=1:4,d=rep(1,4),s=c(1,0,0,1)))
library(survival)
mine<-function(ff,df){
   fit<-coxph(ff,data=df)
   out<-survfit(fit,df)
}
df<-new
mine(as.formula("Surv(t,d)~s"),new)

which leads me to believe that there's some variable scoping error.
Can anyone point out what I'm doing wrong?  Thanks, John

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