1
我每次嘗試在已使用seqformat轉換爲STS格式的數據上運行seqdef時,都會看到此錯誤。我的數據幀的樣品看起來像seqdef在R中的錯誤級別
head(df.new, 10)
user_id orderdate cart to
1 8 1 produce 30
2 8 31 produce 60
3 8 61 produce 70
4 8 71 produce 92
5 10 1 produce 30
6 10 31 produce 42
7 10 43 meat seafood 56
8 10 57 deli 77
9 17 1 beverages 3
10 17 4 beverages 8
它具有總共14000行的訂單並有一些命令在每個用戶的同一天(即訂購日期==到),其發生。以下是我用來創建用作seqdef輸入的STS數據的代碼。
df.form <- seqformat(df.new, id='user_id', begin='orderdate', end='to', status='cart', from='SPELL', to='STS', process=FALSE)
df.seq <- seqdef(df.form, left='DEL', right = 'unknown', xtstep=10, void = 'unknown')
錯誤信息運行seqdef時,我得到的是
[>] found missing values ('NA') in sequence data
[>] preparing 35000 sequences
[>] coding void elements with 'unknown' and missing values with '*'
[>] 21 distinct states appear in the data:
1 = alcohol
2 = babies
3 = bakery
4 = beverages
5 = breakfast
6 = bulk
7 = canned goods
8 = dairy eggs
9 = deli
10 = dry goods pasta
11 = frozen
12 = household
...
[>] adding special state(s) to the alphabet: unknown
Error in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
factor level [24] is duplicated
我試着刪除其中訂購日期==來和相同的錯誤仍然出現這些訂單。我將不勝感激任何幫助,我可以解決這個問題。謝謝。