转换数据框时出现警告消息

时间:2020-11-10 21:02:00

标签: r dataframe warnings reshape

我有以下数据框:

DATE           CLINIC_ID    CLINICAL_SYSTEM      CATEGORY               VALUE
2019-01-01     A            ZARK                 syst_pat_training      18
2019-01-01     A            ZARK                 syst_pat_testing       40
2019-01-01     A            ZARK                 Pat_Appts_Enbld        99
2019-01-01     A            ZARK                 Pat_Presc_Enbld        33
2019-01-01     A            ZARK                 pat_presc_training     20
2019-01-01     A            ZARK                 pat_presc_testing      21
2019-02-01     A            ZARK                 syst_pat_training      19
2019-02-01     A            ZARK                 syst_pat_testing       38
                                   ....

我想将此'long'格式的数据帧转换为'wide'格式:我想为每个CATEGORY设置一列:'syst_pat_training','syst_pat_testing',依此类推。我尝试这样做:

df_reshaped <- reshape(df,
                       idvar = c("DATE","CLINIC_ID","CLINICAL_SYSTEM"),
                       timevar = "CATEGORY",
                       direction = "wide")

但是我收到以下警告消息:

Warning messages:
1: In reshapeWide(data, idvar = idvar, timevar = timevar, varying = varying,  :
  multiple rows match for CATEGORY=Pat_Appts_Enbld: first taken
2: In reshapeWide(data, idvar = idvar, timevar = timevar, varying = varying,  :
  multiple rows match for CATEGORY=Pat_Presc_Enbld: first taken

为什么我会收到此警告消息以及如何删除它?

0 个答案:

没有答案