- x<-1:3
- y<-4:6
- df <- data.frame(X=x, Y=y)
- for (i in 1:nrow(df)){
- df$Z[i] <- c(df$X[i],df$Y[i])
- # df$Z[i] <- max(df$X[i],df$Y[i])
- }
- print(df)
X Y Z
1 1 4 1
2 2 5 2
3 3 6 3
Warning messages:
1: In df$Z <- c(df$X, df$Y) :
number of items to replace is not a multiple of replacement length
2: In df$Z <- c(df$X, df$Y) :
number of items to replace is not a multiple of replacement length
3: In df$Z <- c(df$X, df$Y) :
number of items to replace is not a multiple of replacement length


雷达卡


京公网安备 11010802022788号







