CSV全称Comma Separated Values是"逗号分隔值"的英文缩写.通常是纯文本文件,可以被文本编辑软件,Excel或WP...
z<-strsplit(y,"-") sapply(z,"[",1) #提取列表第1个元素 sapply(z,"[",2) #提取列表中第2个元素 1. 2. 3. 4. AI检测代码解析 第一行:定义一个向量y 第二行:使用strsplit函数对向量y 按照“-”符号进行分割,得到一个列表z 第三行:使用sapply函数提取列表z的第1个和第2个位置元素,输出结果...
## Group.1 Group.2 x## 1 Primary Tumor Stage I 56.0## 2 Solid Tissue Normal Stage I 68.5## 3 Primary Tumor Stage IA 49.0## 4 Solid Tissue Normal Stage IA 63.0## 5 Primary Tumor Stage IIA 67.5## 6 Solid Tissue Normal Stage IIA 78.0## 7 Primary Tumor Stage IIB 63.0## 8 Solid...
1、测试1 a <- c("3_k","4_f","2_t","8_s") a b <- strsplit(a, "_") b class(b) c <- sapply(b, "[",1) c d <- sapply(b, "[",2) d ... supply函数 转载 mb607022e25a607 2021-05-18 18:28:49 1747阅读 2评论 R语言 apply,sapply,lapply,tapply,vapply, ...
(strsplit(as.character(x),"@")[[1]]))[1,] On 04/11/08 04:12, Dennis Fisher wrote: > Colleagues, > > I have some text: > TEXT <- c("a", "bb;ccc", "dddd;eeeee;ffffff") > > I want to retrieve the portion of each element before the first ...
[1] "X1" "X2" "X3" "X4" str(a) 'data.frame': 3 obs. of 4 variables: X2: int 4 5 6 X4: int 10 11 12 lapply(a, function(x) x+3) $X1 [1] 4 5 6 $X2 [1] 7 8 9 $X3 [1] 10 11 12 $X4 [1] 13 14 15 a1 <- lapply(a, function(x) sum(x)+3) a1 $X1...
## 1 1 one ## 2 1 two 999 ## 3 3 three 999 ## 4 4 four 90 20 再比如,让空白的地方变成NA: tmp[tmp ==""] <-NA tmp ## a b d e ## 1 1 one <NA> ## 2 1 two 999 ## 3 3 three 999 <NA> ## 4 4 four 90 20 ...