随笔分类 -  R

摘要:### subset 函数 airquality <- airquality #选取Temp大于80的行,保留Ozone,temp两列 subset(airquality, Temp > 80, select = c(Ozone, Temp)) #选取day等于1的行,删去temp列 subset( 阅读全文
posted @ 2021-12-24 11:19 西西与维奥拉 阅读(759) 评论(0) 推荐(0)
摘要:ifelse returns a value with the same shape as test which is filled with elements selected from either yes or no depending on whether the element of te 阅读全文
posted @ 2021-12-24 09:55 西西与维奥拉 阅读(695) 评论(0) 推荐(0)
摘要:https://www.jianshu.com/p/44e3de9b7a81原文链接 paste("a","b") #能连接a b ## [1] "a b" paste("a","b","c") ## [1] "a b c" #设置分隔符 paste("a","b",sep = "=")##注意到用 阅读全文
posted @ 2021-11-18 10:21 西西与维奥拉 阅读(693) 评论(0) 推荐(0)
摘要:kk <- dt[which(dt$ITEMCODE=="RDW-SD"&is.na(dt$ITEMNAME)),] kk <- dt[which((dt$ITEMCODE=="PLT-I"|dt$ITEMNAME=="PLT")&is.na(dt$ITEMNAME)),] 阅读全文
posted @ 2021-11-16 17:06 西西与维奥拉 阅读(754) 评论(0) 推荐(0)
摘要:#删去data表中第五列 data<- data[,-5] #删去某几列 data <- data[,-c(6:9)] #subset data <- subset(data,select=-c(colnames5)) data <- subset(data,select=- c(colname6: 阅读全文
posted @ 2021-11-16 16:25 西西与维奥拉 阅读(5255) 评论(0) 推荐(0)
摘要:AA <- dplyr::summarise(group_by(dataframe1,col1,col2),num=n()) col1 和 col2 内容匹配情况下,出现的频率 阅读全文
posted @ 2021-11-16 16:06 西西与维奥拉 阅读(134) 评论(0) 推荐(0)
摘要:test3 <- reshape::cast(dat[,c(1:6)],col1+col2+col3+col4~col5,mean) 阅读全文
posted @ 2021-11-16 15:13 西西与维奥拉 阅读(151) 评论(0) 推荐(0)
摘要:dat$RESULT <- as.numeric(dat$RESULT) 阅读全文
posted @ 2021-11-16 15:08 西西与维奥拉 阅读(1906) 评论(0) 推荐(0)
摘要:dat$CHECKDATE <- as.Date(dat$CHECKDATE) 阅读全文
posted @ 2021-11-16 15:01 西西与维奥拉 阅读(1127) 评论(0) 推荐(0)
摘要:Unite multiple columns into one by pasting strings together 通过将字符串粘贴在一起,将多个列统一为一个 Description Convenience function to paste together multiple columns 阅读全文
posted @ 2021-11-15 09:53 西西与维奥拉 阅读(5931) 评论(0) 推荐(0)
摘要:nchar(qc$sfzh) table(nchar(qc$sfzh)) 阅读全文
posted @ 2021-11-14 22:13 西西与维奥拉 阅读(102) 评论(0) 推荐(0)
摘要:dt <- data.frame(v1=1:3, v2=4:6, v3=letters[1:3], v4=LETTERS[1:3]) dt dt1 <- dt[,c(1,4,3,2)] dat <- dat[,c(19,1,25,7,3,18,8,9)] 行同理 阅读全文
posted @ 2021-11-14 22:11 西西与维奥拉 阅读(1151) 评论(0) 推荐(0)
摘要:dt.21 <- dt$name=='王鹏' 阅读全文
posted @ 2021-11-14 21:59 西西与维奥拉 阅读(467) 评论(0) 推荐(0)
摘要:bb <- data.frame(table(jydat_glu$HIS_ITEMNAME)) 阅读全文
posted @ 2021-11-14 21:57 西西与维奥拉 阅读(76) 评论(0) 推荐(0)
摘要:rbind() jydat <- rbind(jydat1,jydat2) left_join() z_jydat <- left_join(z_jydat,qc,by="zyh") bqlb1 <- left_join(jydat2,gene1,by=c("name","gender")) mer 阅读全文
posted @ 2021-11-14 21:52 西西与维奥拉 阅读(729) 评论(0) 推荐(0)
摘要:qc <- basy[,c(2,7)] qc <- unique(qc) index <- duplicated(qc$sfzh) qc <- qc[!index,] index <- duplicated(qc$zyh) qc <- qc[!index,] sch=sch[!duplicated( 阅读全文
posted @ 2021-11-14 21:36 西西与维奥拉 阅读(222) 评论(0) 推荐(0)
摘要:data$col <- gsub("1","",data$col)# 将data数据框col这一列中含有“1”的字符替换成空格 gsub()可以用于字段的删减、增补、替换和切割,可以处理一个字段也可以处理由字段组成的向量。 具体的使用方法为:gsub("目标字符", "替换字符", 对象). 在gs 阅读全文
posted @ 2021-11-14 21:33 西西与维奥拉 阅读(2982) 评论(0) 推荐(0)
摘要:glu <- grep("*(葡萄糖)",z_jydat$ITEMNAME) jydat_glu <- unique(z_jydat[glu,-1]) HIS <- grep("*(血常规)",z_jydat$HIS_ITEMNAME) jydat_xcg <- unique(z_jydat[HIS 阅读全文
posted @ 2021-11-14 21:26 西西与维奥拉 阅读(875) 评论(0) 推荐(0)
摘要:dataframe <- data col <- val #删除data表里所有缺失值——na.omit() data <- na.omit(data) #选取data表中val列不含NA的行,重新赋给data——which(!is.na()) data <-data[which(!is.na(da 阅读全文
posted @ 2021-11-14 21:21 西西与维奥拉 阅读(5267) 评论(0) 推荐(0)
摘要:dataframe <- datacol <- col## 更改列名 data <- rename(data,col=newcol) 或 colnames(data)[1] <- "name" colnames(data) <- c("A1","A2","A3") 阅读全文
posted @ 2021-11-14 21:14 西西与维奥拉 阅读(16714) 评论(0) 推荐(0)