search for: idiomac

Displaying 4 results from an estimated 4 matches for "idiomac".

Did you mean: idioma
2023 Jun 11
1
Problem with filling dataframe's column
...i is not used in the loop 2) the assignment operator is `<-`, not `==` Here is the loop corrected. for (i in 1:nrow(data2$Layer)){ if (data2$Layer[i] == "Level 12") { data2$LU[i] <- "Park" } } But R is a vectorized language, the following two ways are the idiomac ways of doing what you want to do. i <- data2$Layer == "Level 12" data2$LU[i] <- "Park" # equivalent one-liner data2$LU[data2$Layer == "Level 12"] <- "Park" If there are NA's in data2$Layer it's probably safer to use ?which() in the...
2023 Jun 11
1
Problem with filling dataframe's column
...lt;-`, not `==` > > > Here is the loop corrected. > > for (i in 1:nrow(data2$Layer)){ > if (data2$Layer[i] == "Level 12") { > data2$LU[i] <- "Park" > } > } > > > > But R is a vectorized language, the following two ways are the idiomac > ways of doing what you want to do. > > > > i <- data2$Layer == "Level 12" > data2$LU[i] <- "Park" > > # equivalent one-liner > data2$LU[data2$Layer == "Level 12"] <- "Park" > > > > If there are NA's in dat...
2023 Jun 11
1
Problem with filling dataframe's column
...loop corrected. >> >> for (i in 1:nrow(data2$Layer)){ >> if (data2$Layer[i] == "Level 12") { >> data2$LU[i] <- "Park" >> } >> } >> >> >> >> But R is a vectorized language, the following two ways are the idiomac >> ways of doing what you want to do. >> >> >> >> i <- data2$Layer == "Level 12" >> data2$LU[i] <- "Park" >> >> # equivalent one-liner >> data2$LU[data2$Layer == "Level 12"] <- "Park" >> &gt...
2023 Jun 11
2
Problem with filling dataframe's column
Dear R users; I am trying to fill a column based on a specific value in another column of a dataframe, but it seems there is a problem with the codes! The "Layer" and the "LU" are two different columns of the dataframe. How can I fix this? Sincerely for (i in 1:nrow(data2$Layer)){ if (data2$Layer == "Level 12") { data2$LU == "Park"