我对整形数据框很感兴趣,但我不想使用标准dcast函数(如mean),而是使用自定义函数。具体来说,我有兴趣使用ifelse语句来分配二进制值。 这里有一个重复的例子: # dataframe that includes extraneous information
df <- data.frame(sale_id=c(1,1,1,2,2,2,3,3,4,5),project_id=c(501,
我有一个数据帧,看起来像: DF-> Elmt1 Elmt2 Type
1 1 8 Red
2 5 3 Blue
3 5 1 Blue
4 7 2 Red
5 3 2 Red
6 5 2 Red
这看起来像一个向量: 时间< - 以次(1,8,1) 我需要建立一个新的数据帧,看起来像 newdf-> Time Elmt1Red Elemt1B