0

I have this data

acic2

> acic2
# A tibble: 21 x 9
   PCC    V1.1  V2.2  V3.3  V4.4  V5.5  V6.6  V7.7 Vtotal
   <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>
 1 A      8.33  5.33  6     6.5   7.67   7    5.33   6.60
 2 A      8.67  4.33  6.25  7     7.5    7    5.67   6.63
 3 B      9     4.33  7     7.25  7.83   6.8  6.17   6.91
 4 C      5.17  3.33  5.25  2.75  3.17   4    4.5    4.02
 5 C      8     6     6.25  3.5   6.17   5.6  6      5.93
 6 D      6.5   5.67  7.25  5.75  5.33   6.4  4      5.84
 7 D      6     4.67  6     5.25  3.67   4.6  5      5.03
 8 E      6.5   7     6     7     4.33   5.4  5.67   5.99
 9 E      9     5.67  6.5   8     6.17   3.6  5      6.28
10 F      9.17  8     6.5   6.25  7      6.4  6.67   7.14
# ... with 11 more rows
> 

I want to create a separate data set called acic3 by taking the average of columns with the same letters in PCC. So I'll get one row for every letter which contains the average score for each column.

Hani
  • 35
  • 4

1 Answers1

0

You can group_by and summarize(across(...)) in dplyr

acic3 <- acic2 %>%
   group_by(PCC) %>%
   summarize(across(starts_with("V"), mean)
Ben Norris
  • 5,639
  • 2
  • 6
  • 15