I have a tibble named "confidence_table". Does anyone know why if I try to add a new column using the mutate verb this does not work?
# A tibble: 12 x 3
# Groups: Age [2]
Age Condition Prop
<fctr> <fctr> <dbl>
0 old 0.73993056
1 old 0.75590278
0 old 0.15069444
1 old 0.13090278
0 new 0.06388889
1 new 0.04965278
0 new 0.05902778
1 new 0.05416667
0 lure 0.23055556
1 lure 0.23645833
0 lure 0.13819444
1 lure 0.12013889
I used this function from base r and it does work
confidence_table$Confidence <- as.factor(rep(c("HC", "LC"), times = 3, each = 2))
# A tibble: 12 x 4
# Groups: Age [2]
Age Condition Prop Confidence
<fctr> <fctr> <dbl> <fctr>
0 old 0.73993056 HC
1 old 0.75590278 HC
0 old 0.15069444 LC
1 old 0.13090278 LC
0 new 0.06388889 HC
1 new 0.04965278 HC
0 new 0.05902778 LC
1 new 0.05416667 LC
0 lure 0.23055556 HC
1 lure 0.23645833 HC
0 lure 0.13819444 LC
1 lure 0.12013889 LC
This is the expected output that works with base r code. However, if I use:
confidence_table <- confidence_table %>%
mutate(Confidence = rep(c("HC", "LC"), times = 3, each = 2))
it says: Error in mutate_impl(.data, dots) : Column Confidence must be length 6 (the group size) or one, not 12
What is wrong with it?