我在R中有这个代码:
j <- 1
k <- nrow(group_IDs)
while (j <= k)
{
d_clust <- Mclust(Customers_Attibutes_s[which (Customers_Attibutes_s$Group_ID == group_IDs$Group_ID[j]),3:7], G=2:7)
temp <- cbind(Customers_Attibutes[which (Customers_Attibutes$Group_ID == group_IDs$Group_ID[j]),], as.data.frame (predict.Mclust(d_clust, Customers_Attibutes[which(Customers_Attibutes$Group_ID == group_IDs$Group_ID[j]), 3:7]))[1])
temp_ <- rbind(temp,temp_)
j <- j+1
}
while语句中的 j <= k
返回此错误:
缺少需要TRUE / FALSE的值。
group_IDs
不为null,在这种情况下它实际上包含值8。
它似乎进入循环并在第二轮崩溃。
答案 0 :(得分:0)
由于SELECT Posts.post_title AS Title, ImgURL.guid AS Imgguid, Posts.guid, Posts.post_content
FROM `wp_posts` AS Posts
INNER JOIN `wp_postmeta` AS Meta ON Posts.ID = Meta.post_id
INNER JOIN `wp_postmeta` AS Featured ON Posts.ID = Featured.post_id
INNER JOIN `wp_postmeta` AS StartF ON Posts.ID = StartF.post_id
INNER JOIN `wp_postmeta` AS EndF ON Posts.ID = EndF.post_id
INNER JOIN `wp_postmeta` AS ImgID ON Posts.ID = ImgID.post_id
INNER JOIN `wp_posts` AS ImgURL ON ImgID.meta_value = ImgURL.ID
WHERE
(Featured.meta_key = '_ecp_custom_22' AND Featured.meta_value = 'yes')
AND
(StartF.meta_key = '_ecp_custom_23' AND CAST(StartF.meta_value AS DATETIME) <= CURDATE())
AND
(EndF.meta_key = '_ecp_custom_27' AND CAST(EndF.meta_value AS DATETIME) >= CURDATE())
AND
(ImgURL.post_type = 'attachment')
AND
(Posts.ID IN (SELECT relationships.object_id FROM `wp_terms` AS terms
INNER JOIN `wp_term_taxonomy` AS taxonomy ON terms.term_id = taxonomy.term_id
INNER JOIN `wp_term_relationships` AS relationships ON taxonomy.term_taxonomy_id = relationships.term_taxonomy_id
WHERE terms.name = 'Sydney'))
GROUP BY Title
LIMIT 300
是向量,请尝试group_ IDs
而不是length(group_IDs)
。矢量没有行,因此等价物为nrow
。
这是我怀疑发生的事情:
length
答案 1 :(得分:0)
您可以使用for
解决索引问题,例如:
for (ID in group_IDs) {}
当然,这假设group_ID是值的向量。
注意:您的代码在循环group_IDs$Group_ID[j]
中显示以下内容,这意味着除了向量之外的其他内容;也许你的意思是group_IDs[j]
?