sapply(x301[,9],function(x)ifelse(substr(x,1,2)=="19",paste(x),paste("19",substr(x,1,6),sep = "")))
sapply(x301[,9],function(x)ifelse(substr(x,1,2)=="19",x,paste("19",substr(x,1,6),sep = "")))
这两个函数返回的结果不一致
x301[,9]的数值为
2 19470313
3 51111025
4 37111515
5 19620122
6 19560312
7 19730605
8 19740324
9 19681020
前者返回结果为
[2,] "19470313"
[3,] "19511110"
[4,] "19371115"
[5,] "19620122"
[6,] "19560312"
[7,] "19730605"
[8,] "19740324"
[9,] "19681020"
后者
[2,] "10199"
[3,] "19511110"
[4,] "19371115"
[5,] "16364"
[6,] "13921"
[7,] "21085"
[8,] "21406"
[9,] "19111"
原因在哪里呢?