2017-08-29 56 views
0

這段代碼在其他日子裏工作,現在它吐出這些對象未找到錯誤,我想要拉列的名稱。所有列都存在於我正在導入的CSV中。有什麼建議麼?選擇函數返回對象沒有找到

DF <- read.csv2("FILE PATHWAY", header=TRUE, sep = ",", stringsAsFactors = 
F, skip=1) 
DF <- DF[DF$Type=="AHREF",] 
DF <- select(Type,Source,Destination) 
# Error occurs here with this: Error in select(Type, Source, Destination) : object 'Type' not found 
DF <- as.data.frame(sapply(DF,gsub,pattern="#URL DELETED",replacement="")) 
DF <- as.data.frame(sapply(DF,gsub,pattern="#URL DELETED",replacement="")) 
DF <- as.data.frame(sapply(DF,gsub,pattern="\"",replacement="")) 
DF <- subset(DF, !grepl("^https", DF$Source)) 
DF <- subset(DF, !grepl("^https", DF$Destination)) 
colnames(DF) <- c("From","To") 
rownames(DF) <- NULL 
graphObject = graph.data.frame(DF, directed = TRUE) 
graphObject = simplify(as.undirected(graphObject)) 
+1

這是什麼行後'DF'? 'DF < - DF [DF $ Type ==「AHREF」,]'如果是這樣的話,你可能在某個地方有一個「附加(DF)」或「帶有」的地方,而這正是之前爲你工作的地方。 – Masoud

+0

歡迎來到StackOverflow。請閱讀[如何在R中創建一個很好的重現示例](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example),使您的問題更可能得到答案。另外,您可能需要[tour](https://stackoverflow.com/tour)並閱讀[如何提問?](https://stackoverflow.com/help/how-to-ask) – Masoud

回答

1

您沒有指定應用select的數據幀。
試試這個:

DF <- select(DF,Type,Source,Destination) 

DF <- DF %>% select(Type,Source,Destination) 
+0

Reurns:Error在overscope_eval_next(overscope,expr)中:object'Type'not found –

+0

輸出是什麼:names(DF)? –

+0

[1]「From」「To」不適用不適用不適用不適用不適用 –