Good afternoon,
I get the following error. However, my data frame is still created and appears to be all there. I’ve looked on this community, the Epi handbook, and as well as stack overflow for reasons for this type of error but have not had much luck for finding the root cause. What I am trying to do is create a “wide” table that colors the most recent year with red if the previous year has a higher total. I have my data both in wide and long format but have not been successful in figuring out how to color a value based on a previous value arranging by year.
Sorry I can’t seem to color but below in bold is what I am trying to do.
County | Measure | Year |
---|---|---|
A | 1 | 2018 |
A | 0 | 2019 |
A | 1 | 2020 |
B | 2 | 2018 |
B | 3 | 2019 |
B | 3 | 2020 |
C | 4 | 2018 |
C | 5 | 2019 |
C | 4 | 2020 |
Here is my code as to where I get my error.
rn_fs ← clean_fs %>%
group_by(county) %>%
arrange(county, desc(clean_fs$year)) %>%
mutate(RN = row_number())
Error in [<-
:
! Assigned data rn_fs <- ...
must be compatible with existing data.
Existing data has 91 rows.
Element 1 of assigned data has 1092 rows.
Only vectors of size 1 are recycled.
Caused by error in vectbl_recycle_rhs_rows()
:
! Can’t recycle input of size 1092 to size 91.
Backtrace:
▆
- ├─base::
[<-
(*tmp*
, “previousTwoYears”, value =<gropd_df[,9]>
) - └─tibble:::
[<-.tbl_df
(*tmp*
, “previousTwoYears”, value =<gropd_df[,9]>
) - └─tibble:::tbl_subassign(x, i, j, value, i_arg, j_arg, substitute(value))
-
└─tibble:::vectbl_recycle_rhs_rows(value, fast_nrow(xo), i_arg = NULL, value_arg, call)