Use of ifelse to assign values to a new dataframe column in R
问题 I have a time series dataframe and would like to create a new numeric column with values which are a function of an existing numeric column and which are assigned according to the day of the week column. For example, I would require something like the following code: Day <- c("Mo", "Mo", "Mo", "Tu", "Tu", "We", "We", "We", "We", "Th") Val <- c(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000) df <- data.frame(cbind(Day,Val)) df$Adj <- ifelse(df$Day == "Mo" || df$Day == "Tu", as