1

This code was working the other day, now it spits out these object not found errors for the names of the columns I'm trying to pull. All of the columns exist in the CSV I'm importing. Any suggestions?

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
    What is `DF` after this line? `DF <- DF[DF$Type=="AHREF",]` You had probably had an `attach(DF)` or `with` somewhere if this, and exactly this, was working for you before. – M-- Aug 29 '17 at 15:51
  • Welcome to StackOverflow. Please read [How to make a great reproducible example in R?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to make your question more likely to get an answer. Also you may want to take the [tour](https://stackoverflow.com/tour) and read [how to ask?](https://stackoverflow.com/help/how-to-ask) – M-- Aug 29 '17 at 15:55

1 Answers1

2

You didn't specify the dataframe on which you apply the select.
Try this :

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

or

 DF <- DF %>% select(Type,Source,Destination)
Bechir Barkallah
  • 341
  • 1
  • 12