I have a dataframe
TableName Function Argument
A func1 3
B func1 4
A func2 6
B func2 2
C func1 5
>
Here is a dplyr
solution where we create a variable with the row_number()
, and use that as our index, i.e.
df %>%
mutate(new = row_number()) %>%
group_by(TableName) %>%
summarise(Index = toString(new))
which gives,
# A tibble: 3 x 2 TableName Index
1 A 1, 3 2 B 2, 4 3 C 5
You can also save them as lists rather than strings, which will make future operations easier, i.e.
df %>%
mutate(new = row_number()) %>%
group_by(TableName) %>%
summarise(Index = list(new))
which gives,
# A tibble: 3 x 2 TableName Index
1 A
2 B 3 C