问题描述
我有一个包含两列的数据集(照片)(一列用于图像 ID,另一列用于图像 url)。 插入 Google Cloud Platform 凭据后,我运行以下代码来生成关键字:
require(RoogleVision)
#add extra columns for 10 x 3 rows of data (keyword,probability score,and topicality score)
photos[,3:32] <- NA
##Loop##
for(i in 1:length(photos$url)){
te <- getGoogleVisionResponse(photos$url[i],feature="LABEL_DETECTION",numResults = 10)
#If not successful,return NA matrix
if(length(te)==1){ te <- matrix(NA,10,4)}
if (is.null(te)){ te <- matrix(NA,4)}
te <- te[,2:4]
#if successful but no. of keywords <10,put NAs in remaining rows
if(length(te[,1])<10){
te[(length(te[,1])+1):10,] <- NA}
#Append all data!
photos[i,3:12] <- te[,1] #keywords
photos[i,13:22] <- te[,2] #probability scores
photos[i,23:32] <- te[,3] #topicality scores
cat("<row",i,"/",length(photos[,1]),"> ")
}
我收到以下错误
Error: Assigned data `te[,1]` must be compatible with row subscript `i`.
x 1 row must be assigned.
x Assigned data has 10 rows.
ℹ Row updates require a list value. Do you need `list()` or `as.list()`?
Run `rlang::last_error()` to see where the error occurred.
非常感谢任何帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)