Finding the index or unique values from a dataframe column

后端 未结 4 805
慢半拍i
慢半拍i 2021-01-22 06:33

I have a dataframe

TableName Function Argument
A         func1    3
B         func1    4
A         func2    6
B         func2    2
C         func1    5
         


        
4条回答
  •  猫巷女王i
    2021-01-22 07:11

    No need for any package. Try out:

    aggregate(rownames(df) ~ TableName, df, c)
      TableName rownames(df)
    1         A         1, 3
    2         B         2, 4
    3         C            5
    # or
    setNames(aggregate(rownames(df) ~ TableName, df, c),
             c("TableName", "Index"))
      TableName Index
    1         A  1, 3
    2         B  2, 4
    3         C     5
    

提交回复
热议问题