replace multiple values using ifelse

Based on the code and data below how can I replace values in the date column with new values using ifelse. Error: Warning message: Problem while computing `date = ifelse(…)`. ℹ longer object length is not a multiple of shorter object length Data and code: df = structure(list(id = c(1, 2, 3, 4, 5, 6,… Read More replace multiple values using ifelse

How to use loop or other codes to get a ratio by divided first row in R?

I have a data frame called year year pedal_cycles cars_and_taxis all_hgvs <int> <dbl> <dbl> <dbl> 1 1993 2489980831. 210084884699. 15071438165. 2 1994 2495693171. 214388644505. 15394423667. 3 1995 2573600860. 218175790767. 15810086788. 4 1996 2531689966. 223645671968. 16301368043. 5 1997 2536137453. 227296395346. 16686840160. I want to get ratios relative to the first row (year==1993), I used the following… Read More How to use loop or other codes to get a ratio by divided first row in R?

Getting value not found while running chisq_test using dplyr?

I have two factors, day and the other group. The value is how many totals in each group. x <- c(5,17,31,9,17,10,30,28,16,29,14,34) y <- c(1,2,3,4,5,6,7,8,9,10,11,12) day <- as.character (c ( 1,2,3,4,5,6,7,8,9,10,11,12) ) df1 <- data.frame(x, y, day) df2 <- reshape2::melt(df1, id.vars=’day’) colnames (df2)[2] = "group" > df2 day group value 1 1 x 5 2 2… Read More Getting value not found while running chisq_test using dplyr?

Group Weeks in Columns into Months in Column in a Data Frame in R

I was wondering if there is a possibility to group data which is in weeks into months for simple consolidation. The data frame looks like: structure(list(c("PCE", "PCE", "PCE", "PCE", "PCE", "PCE"), c("3", "0", "0", "0", "0", "0"), c("2", "0", "0", "0", "0", "0"), c("4", "0", "0", "0", "0", "0"), c("5", "0", "0", "0", "0", "0"),… Read More Group Weeks in Columns into Months in Column in a Data Frame in R