4/8/2024 0 Comments For loop in r programmingThe third and final iteration of the loop i takes on the value 3. The multiply_columns() function multiplies the city ( aberdeen) and city ( nairobi) columns and stores it in the temp] which is the second element of the temp list. The second iteration of the loop i takes on the value 2. The multiply_columns() function multiplies the city ( porto) and city ( aberdeen) columns and stores it in the temp] which is the first element of the temp list. So in the first iteration of the loop i takes on the value 1. We’ll come back to why we need to subtract 1 from this in a minute. The ncol() function returns the number of columns in our city data frame which is 4 and so our loop runs from i = 1 to i = 4 - 1 which is i = 3. When we specify our for loop notice how we subtracted 1 from ncol(city). Temp <- list() for (i in 1 :( ncol(city) - 1)) # Warning in multiply_columns(x = city, y = city): The function has # produced NAs # Warning in multiply_columns(x = city, y = city): The function has # produced NAs 1.4.2 Integrated developement environements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |