Fill data frame by column with for loop
问题 I created an empty data frame with 11 columns and 15 rows and subsequently named the columns. L_df <- data.frame(matrix(ncol = 11, nrow = 15)) names(L_df) <- paste0("L_por", 0:10) w <- c(0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3) wu <- 0 L <- 333.7 pm <- c(2600, 2574, 2548, 2522, 2496, 2470, 2444, 2418, 2392, 2366, 2340) The data frame looks like this: head(L_df) L_por0 L_por1 L_por2 L_por3 L_por4 L_por5 L_por6 L_por7 L_por8 L_por9 L_por10 1 NA NA NA NA NA NA NA NA