-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDDP_week3.Rmd
131 lines (109 loc) · 3.07 KB
/
DDP_week3.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
title: "DDP_week3"
author: "Yohann Potier"
date: "7/4/2019"
output: html_document
---
## Week 3 Developer Data product exercise
<!-- # Week 3 Developer product exercise
# Create a web page presentation using R Markdown that features a plot created with Plotly.
# Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document,
# and it must contain a plot created with Plotly.
# We would love to see you show off your creativity!-->
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Melanoma dataset
```{r, eval=FALSE}
library(plotly)
library(knitr)
load(file="Melanoma.RData")
kable(Melanoma[1:5,], caption = "Melanoma table content")
```
```{r, echo=FALSE}
library(plotly)
library(knitr)
load(file="Melanoma.RData")
kable(Melanoma[1:5,], caption = "Melanoma table content")
```
* time
+ Survival time in days since the operation, possibly censored.
* status
+ The patients status at the end of the study. 1 indicates that they had died from melanoma, 2 indicates that they were still alive and 3 indicates that they had died from causes unrelated to their melanoma.
* sex
+ The patients sex; 1=male, 0=female.
* age
+ Age in years at the time of the operation.
* year
+ Year of operation.
* thickness
+ Tumour thickness in mm.
* ulcer
+ Indicator of ulceration; 1=present, 0=absent.
## build linear model based on data for plotting
```{r, eval=FALSE}
time<-Melanoma$time
status<-Melanoma$status
status<-as.factor(status)
age<-Melanoma$age
thickness<-Melanoma$thickness
ulcer<-Melanoma$ulcer
model<-glm(ulcer~time+thickness,
family = binomial(link = "logit"), data = Melanoma)
```
```{r, echo=FALSE}
time<-Melanoma$time
status<-Melanoma$status
status<-as.factor(status)
age<-Melanoma$age
thickness<-Melanoma$thickness
ulcer<-Melanoma$ulcer
model<-glm(ulcer~time+thickness,
family = binomial(link = "logit"), data = Melanoma)
```
## Update legend, axis labels and font
```{r, eval=FALSE}
f <- list(
family = "Arial, monospace",
size = 18,
color = "#7f7f7f"
)
x <- list(
title = "Time",
titlefont = f
)
y <- list(
title = "Prediction of ulcer based on time and thickness",
titlefont = f
)
Melanoma$sex <- factor(Melanoma$sex,
levels = c(0,1),
labels = c("female", "male"))
```
```{r, echo=FALSE}
f <- list(
family = "Arial, monospace",
size = 18,
color = "#7f7f7f"
)
x <- list(
title = "Time",
titlefont = f
)
y <- list(
title = "Prediction of ulcer based on time and thickness",
titlefont = f
)
Melanoma$sex <- factor(Melanoma$sex,
levels = c(0,1),
labels = c("female", "male"))
```
## Plotting linear predictive model of ulcer as a function of time and tumor thickness
```{r, eval=FALSE}
plot_ly(Melanoma, x = ~time, y = ~model, type = "scatter", mode = "lines", color = ~factor(sex)) %>%
layout(xaxis = x, yaxis = y)
```
```{r, echo=FALSE}
plot_ly(Melanoma, x = ~time, y = ~model, type = "scatter", mode = "lines", color = ~factor(sex)) %>%
layout(xaxis = x, yaxis = y)
```