tôi cũng gặp phải lỗi tương tự:
## step1: encountered the error as below while joining two tables
screens_temp_2 = sqldf("SELECT a.* , b.ue as 'sp_used_ue' , b.te as
'sp_used_te' from screens_temp a left outer join sp_temp b on
a.screen_name = b.screen_name ")
Error: Cannot pass NA to dbQuoteIdentifier()
In addition: Warning message:
In field_types[] <- field_types[names(data)] :
number of items to replace is not a multiple of replacement length
## step2: while checking the column names , this is what i found
colnames(screens_temp)
[1] "screen_name" "usv" "tsv" "20_ue" "20_te"
[6] "40_ue" "40_te" "60_ue" "60_te" "80_ue"
[11] "80_te" "100_ue" "100_te" "sp_load_ue" "sp_load_te"
[16] "sp_load_ue" "sp_load_te"
Kết quả trên cho thấy sp_load_ue và sp_load_te được lặp đi lặp lại.
## below i corrected the column names:
colnames(screens_temp) <- c("screen_name", "usv", "tsv", "20_ue", "20_te", "40_ue" , "40_te" , "60_ue" , "60_te" , "80_ue" , "80_te" ,"100_ue" , "100_te" , "sp_load_ue" , "sp_load_te" , "sp_used_ue" , "sp_used_te")
write.table(screens_temp, "screens_temp_corrected.csv", row.names = FALSE ,col.names = TRUE, sep = ",")
## again i ran step 1, it worked fine.
Lưu ý: Tôi nghĩ rằng có lỗi trong sqldf do nó cho phép tên cột được lặp lại trong khi gán đầu ra cho một khung dữ liệu. Nó sẽ ném một lỗi/cảnh báo trong khi gán đầu ra cho một khung dữ liệu để người dùng có thể đổi tên các cột một cách thích hợp.
Nguồn
2017-08-30 10:16:47
Vui lòng xem lại [ask] và [mcve]. –