两个基本一致的程序显示不同结果
# the first one
A <- c(1,2,3,
两个基本一致的程序显示不同结果
# the first one
A <- c(1,2,3,3,4,5,6,7)
A <- data.frame(A)
a <- seq(1, length(A$A))
for (i in 1:length(A$A)){
A$rank[i] <- a[i]
}
A
# the second one
appendRank <- function(data,colum){
a <- seq(1, length(data$colum))
for (i in 1:length(data$colum)){
data$rank[i] <- a[i]
}
return(data)
}
A <- c(1,2,3,3,4,5,6,7)
A <- data.frame(A);appendRank(A,A)