boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple0")
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple1")
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple10")
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple7")
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple3")
knitr::opts_chunk$set(echo = TRUE)
res <- with(d, table(性别, 分型)); res
barplot(res, legend = TRUE,col=c("red","blue"))     #legend输出行变量分类
barplot(res, legend = FALSE)
barplot(res, beside=TRUE, legend=TRUE)   #并排条形图
pairs(trees)
curve(1 - 3*x - x^2, -4, 2)
curve((1-x^4)^(1/4),0,1)
curve(1 - 3*x - x^2, -4, 2)
curve((1-x^4)^(1/4),0,2)
curve(1 - 3*x - x^2, -4, 2)
curve((1-x^4)^(1/4),-1,1)
plot(疗程 ~ 年龄, data = d, main = "疗程与年龄的关系")  #原始图表
plot(疗程 ~ 年龄, data = d, main = "疗程与年龄的关系",
pch= 16, col = "blue", cex = 2)
plot(疗程 ~ 年龄, main = "疗程与年龄的关系", data = d,
col=ifelse(性别=='男', 'blue', 'red'), pch=16) #用ifelse区别性别颜色
plot(疗程 ~ 年龄, main = "疗程与年龄的关系", data = d,
col=ifelse(性别=='男', 'blue', 'red'), pch=16,
cex = 1 + (入院时间- min(入院时间))/(max(入院时间)- min(入院时间)))
#散点图矩阵
pairs(trees)
plot(疗程 ~ 年龄, data = d, main = "疗程与年龄的关系")  #原始图表
plot(疗程 ~ 年龄, data = d, main = "疗程与年龄的关系",
pch= 5, col = "blue", cex = 1)
plot(疗程 ~ 年龄, main = "疗程与年龄的关系", data = d,
col=ifelse(性别=='男', 'blue', 'red'), pch=16) #用ifelse区别性别颜色
plot(疗程 ~ 年龄, main = "疗程与年龄的关系", data = d,
col=ifelse(性别=='男', 'blue', 'red'), pch=16,
cex = 1 + (入院时间- min(入院时间))/(max(入院时间)- min(入院时间)))
#散点图矩阵
pairs(trees)
x <- seq(-3, 3, length = 100)
y <- x
phi <- dnorm(x)
normal.mat <- phi %o% phi
x <- seq(-3, 3, length = 100)
y <- x
phi <- dnorm(x)
normal.mat <- phi %o% phi
persp(normal.mat)
x <- seq(-3, 3, length = 100)
y <- x
phi <- dnorm(x)
normal.mat <- phi %o% phi
persp(normal.mat,col="blue")
x <- seq(-3, 3, length = 100)
y <- x
phi <- dnorm(x)
normal.mat <- phi %o% phi
persp(normal.mat,col="blue")
contour(x, y, normal.mat)
image(x, y, normal.mat, col=terrain.colors(20))
contour(x, y, normal.mat, add = TRUE)
x <- seq(0, 2*pi, length=200); y <- sin(x)
plot(x, y, type='l')
points((0:4)*pi/2, sin((0:4)*pi/2), col = "red", pch = 16, cex = 2)
#VS
x <- seq(0, 2*pi, length=20); y <- sin(x)
plot(x, y, type='b')
x <- seq(0, 2*pi, length=200);
plot(x, sin(x), type='l', col = "red")
lines(x, cos(x), col= "blue")
lines(x, sin(x/2), col="green", lty=2)
abline(h = 0, col = "gray")
legend(0, -0.7, col=c("red", "blue"), lty=c(1,1), lwd=c(2,2), legend=c("sin", "cos"))
legend("topleft", col=c("red", "green"), lty=c(1,2),lwd=c(2,2), legend=c("sin(x)", "sin(x/2)"))
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # ax
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),7,10), las=2) # la
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # ax
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),6,10))
text(which.max(x)-2, max(x), "最高峰") # 前两个参数是坐标位置，第三个参数 `lab
mtext(paste("边缘", 1:4), side = 1:4, line = 2)
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # ax
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),6,10))
text(which.max(x)-3, max(x), "最高峰") # 前两个参数是坐标位置，第三个参数 `lab
mtext(paste("边缘", 1:4), side = 1:4, line = 2)
library(showtext)
show::showtext.begin()
library(showtext)
download.packages(showtext)
install.packages(showtext)
install.packages("showtext")
library(showtext)
show::showtext.begin()
install.packages("show")
library(showtext)
show::showtext.begin()
av <- available.packages(filters=list())
av[av[, "show"] == pkg , ]
av <- available.packages(filters=list())
av[av[, "包"] == "show" , ]
av <- available.packages(filters=list())
av[av[, "包"] == show , ]
av <- available.packages(filters=list())
av[av[, "Package"] == show , ]
av <- available.packages(filters=list())
av[av[, "Package"] == "show" , ]
install.packages("show")
library(showtext)
showtext::showtext.begin()
showtext::showtext_begin()
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "blue", main = '年龄', xlab = '', ylab = '频数')
hist(d[!idx, "年龄"], freq = FALSE, col = "pink", add = FALSE)
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(range(d$年龄)))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE)
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(min(d$年龄),max(d$年龄)))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE)
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(0,max(d$年龄)))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE)
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(0,max(d$年龄)))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE,xlim=c(0,max(d$年龄)))
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(0,100))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE)
idx <- d$性别=="女"
hist(d[idx, "年龄"], freq = FALSE, col = "pink", main = '年龄', xlab = '', ylab = '频数',xlim=c(0,(max(d$年龄)%/%10+1)*10))
hist(d[!idx, "年龄"], freq = FALSE, col = rgb(0,0.5, 0.5, 0.5), add = TRUE)
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple1")
boxplot(d$年龄~d$性别)
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple1")
boxplot(年龄~性别)
boxplot(d$年龄)
boxplot(年龄 ~ 性别, data = d,col="purple1")
boxplot(d$年龄 ~ d$性别)
seq(1,10,length=10)
seq(0,1,length=10)
seq(1,length=10)
seq(1,11,length=10)
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, at=seq(x),labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, at=seq(x),labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
#axis()
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
seq(1,20,length=10)
x <- table(as.Date(as.character(d[,"入院时间"]), format = "%Y%m%d"))
plot(x, type="b", main = "入院人数（按天计）", ylab ="入院人数", axes = FALSE) # axes 暂时禁止坐标轴生成，从而添加自定义坐标轴
axis(2); axis(1, at = seq(along = x), labels = substr(names(x),7,10), las=2) #刻度线标签平行（=0）还是垂直（=2）于坐标轴
layout(matrix(c(1,1,2,3), 2,2, byrow = TRUE))
install.packages("ggplot2")
knitr::opts_chunk$set(echo = TRUE)
res1<-table(df$性别,df$分型);res1
setwd("D:/homework_R/HW2")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
setwd("D:/homework_R/HW2")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
res1<-table(df$性别,df$分型);res1
barplot(res1,main="Sex distribution of patients with different disease types",beside=TRUE,col=c("cyan","darkgoldenrod"),legend=TRUE)
df_copy<-df
df_copy[df$性别=="男","性别"]<-"male"
df_copy<-df
df_copy[df_copy$性别=="男","性别"]<-"male"
df_copy[df_copy$性别=="男","性别"]<-as.character("male")
df_copy<-df
df_copy[(df_copy$性别=="男"),"性别"]<-as.character("male")
df_copy[(df_copy$性别=="男"),]
df_copy[(df_copy$性别=="男"),]
df_copy<-df
df_copy
df_copy[df_copy$性别=="男",]
df_copy[(df_copy$性别=="男"),"性别"]<-as.character("male")
df_copy<-df
df_copy
df_copy[df_copy$性别=="男",]
View(df_copy)
res1<-table(df$性别,df$分型);res1
barplot(res1,main="Sex distribution of patients with different disease types",beside=TRUE,col=c("cyan","darkgoldenrod"),legend=TRUE)
#idx.na <- apply(is.na(df), 1, any)
#df[idx.na, ]
boxplot(年龄~性别,col=c("cyan","darkgoldenrod"),data=df)
df_copy<-df
df_copy<-df
df_copy
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
knitr::opts_chunk$set(echo = TRUE)
setwd("D:/homework_R/HW2")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
getwd()
setwd("D:/homework_R/第二次实验")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_copy
hist(df[, "疗程"],  main = 'Frequency(number) distribution histogram of treatment', xlab = 'Treatment', ylab = 'Frequency(number)')
hist(df[, "疗程"],  main = 'Frequency(proportion) distribution histogram of treatment', xlab = 'Treatment', ylab = 'Frequency(proportion)',freq=FALSE)
lines(density(df[, "疗程"]), lwd = 5, col = "black")
knitr::opts_chunk$set(echo = TRUE)
setwd("D:/homework_R/第二次实验")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
setwd("D:/homework_R/第二次实验")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
View(df)
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
View(df4)
knitr::opts_chunk$set(echo = TRUE)
setwd("D:/practice_for_course/Week3")
d <- read.csv("covid19.csv", header = TRUE)
head(d) # 查看前面几行，默认是6行。
table(d$性别)
#na.strings = x 指定 x 为缺失值。如在该数据中，空的字符串为缺失值
d <- read.csv("covid19.csv", header = TRUE, na.strings = "") # 第二个病人的性别没有
head(d, n = 3)
knitr::opts_chunk$set(echo = TRUE)
setwd("D:/homework_R/EXP2")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
setwd("D:/homework_R/EXP2")
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
setwd("D:/homework_R/EXP2")
#第一题
df1 <- read.csv("covid19.csv",header=TRUE,fileEncoding="GBK",na.string="")
head(df1,n=5)
#第二题
df2 <- read.csv("covid19-2.csv",header=TRUE,fileEncoding="GBK")
tail(df2,n=3)
#第三题
df3 <- read.csv("covid19-3.csv",header=TRUE,fileEncoding="GBK")
tail(df3,n=3)
#第四题
df4<- rbind(df2,df3)
df4<-df4[!duplicated(df4),]
dim(df4)
df4
#第五题
df<- merge(df1,df4,by="序号",all.x=TRUE)
dim(df)
#第六题
df[is.na(df$疗程),]
df_copy<-df
df_copy
df_copy[,"入院时间"] <- as.Date(as.character(df_copy[,"入院时间"]), format = "%Y%m%d")
df_copy[,"出院时间"] <- as.Date(as.character(df_copy[,"出院时间"]), format = "%Y%m%d")
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_copy<-df
df_copy
df_1[df_1$性别=="男",]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1$性别=="男",]
df_1[df_1$性别=="男",]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1$性别=="男","性别"]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1$性别=="男","性别"]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1$性别=="男","性别"]<-df_1[df_1$性别=="男","male"]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1$性别=="男","性别"]<-df_1[,"male"]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1[,3]=="男","性别"]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1[,3]=="男",]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[df_1[,3]=="男",3]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[(df_1[,3]=="男"),3]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[(df_1$性别=="男"),"性别"]<-as.character(male)
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[(df_1$性别=="男"),"性别"]<-as.character("male")
df_1[(df_1$性别=="男"),"性别"]
df[is.na(df$疗程),"疗程"]
df[is.na(df$疗程),"疗程"]
df_1[(df_1$性别=="男"),]
<-as.character("male")
df_1[(df_1$性别=="男"),]
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[(df_1$性别=="男"),]<-"male"
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[!is.na(df_1$性别=="男"),]<-"male"
df_1[!is.na(df_1$性别=="男"),]<-"male"
df_1
df_1
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[!is.na(df_1$性别=="男"),"性别"]<-"male"
df_1
df_1
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[!is.na(df_1$性别)&df_1$性别=="男","性别"]<-"male"
df_1
df_1
df_1<-df
df_1
df[is.na(df$疗程),"疗程"]<- as.numeric(df_copy[is.na(df_copy$疗程),"出院时间"]-df_copy[is.na(df_copy$疗程),"入院时间"])
df_1[!is.na(df_1$性别)&df_1$性别=="男","性别"]<-"male"
df_1[!is.na(df_1$性别)&df_1$性别=="女","性别"]<-"female"
df_1
df_1
