Skip to menu

SOS

UnuDIo 2019.09.02 21:22 Views : 1830

교수님, 안녕하세요?

몇가지 어려움이 있어서 조언을 구합니다.


1.  교수님께서 colname의 순서를 변경하는 방법을 알려주셔서 CP$Group1 = factor(CP$Group, levels = c("Placebo", "Cyclophosphamide"))로 잘 변경하였는데, 

동시에 CP$Sex1=factor(CP$Sex,levels=c("Male","Female"))까지 사용하여 순서를 변경하면 첨부한 PDF의 Table 4에서와 같이 Male, Female이 1, 2로 표시되고 순서 변경이 되지 않습니다.


2. rename column을 하고싶은데 방법을 모르겠습니다.

예를 들면, Time.to.occlusion..min.을 Time to occlusion (min)로 변경하려면 어떻게 하면 될지요?


3. parallelTables를 실행하면 오류가 나는데 잘못된 부분이 있는지 검토 부탁드립니다.

parallelTables(width=c(0.5, 0.5),list(zt, zt1))


항상 감사합니다.


---

title: "Cyclophosphamide"

author: "UnuDio"

date: "9/2/2019"

output:

  pdf_document:

    includes:

      in_header: header.tex

  html_document: default

  word_document: default

---


```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = FALSE)

```


```{r, message=FALSE, comment=NA}

library(moonBook)

library(ztable)

library(dplyr)

library(magrittr)

```

```{r}

rm(list=ls())

setwd("~/Data/Statistics/R/Project/Leukopenia")

CP <- read.csv("CP190902-4.csv", na.strings = c("NA","#N/A","#DIV/0!"), stringsAsFactors = FALSE, header = TRUE)

```

```{r}

summary(CP)

```

```{r}

CP$Sex1=factor(CP$Sex,levels=c("Male","Female"))

CP$Group1 = factor(CP$Group, levels = c("Placebo", "Cyclophosphamide"))

```

```{r, results='asis'}

z <- mytable(Group1 ~ Weight+Time.to.occlusion..min.+Length+Area+CD41+TER119+Fibrinogen+Tissue.factor, data = CP, method = 1, digits = 1, exact =  TRUE, catMethod = 2, max.ylev = 0)

zt <- ztable(z, tabular=TRUE) %>%

     addSigColor(level = 0.05, bg = "unmellowyellow", color = "red")

print(zt, type="latex", caption = "Table 1.")


z1 <- mytable(Group1 ~ RBC+WBC+Platelet+Neutrophil+Lymphocyte+Monocyte+Basophil+Eosinophil, data = CP, method = 1, digits = 1, exact =  TRUE, catMethod = 2, max.ylev = 0)

zt1 <- ztable(z1, tabular=TRUE) %>%

     addSigColor(level = 0.05, bg = "unmellowyellow", color = "red")

print(zt1, caption = "Table 2.", type="latex")


```

```{r, results='asis'}

z2 <- mytable(Sex + Group1 ~ Weight+Time.to.occlusion..min.+Length+Area+CD41+TER119+Fibrinogen+Tissue.factor, data = CP, method = 1, digits = 1, exact =  TRUE, catMethod = 2, max.ylev = 0)

zt2 <- ztable(z2, tabular=TRUE) %>%

     addSigColor(level = 0.05, bg = "unmellowyellow", color = "red")

print(zt2, caption = "Table 3", type="latex")


z3 <- mytable(Sex1 + Group1 ~ RBC+WBC+Platelet+Neutrophil+Lymphocyte+Monocyte+Basophil+Eosinophil, data = CP, method = 1, digits = 1, exact =  TRUE, catMethod = 2, max.ylev = 0)

zt3 <- ztable(z3, tabular=TRUE) %>%

     addSigColor(level = 0.05, bg = "unmellowyellow", color = "red")

print(zt3, caption = "Table 4.", type="latex")

```