-1

I have a thing which shouldn't be hard but I somehow cant crack. I have a data frame column website_addresses and I want to use these values as input for a function.

If i have a list like

list <- c("apple", "banana")

and try the function it works

fetch_function(list)

If however I try to input the websiteaddresses from the data.frame it doesn't work

fetch_function(df$website_addresses)

Gives me:

Error in UseMethod("read_xml") : no applicable method for 'read_xml' applied to an object of class "factor"

I assume I have to make a list of df$website_addresses but cant find how to do this. Am I overlooking something really easy?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213

1 Answers1

0

Your website_addresses column is stored as a factor instead of strings. Pass the stringsAsFactors = FALSE argument to your data.frame when you construct it to stop this.

Alternatively put options(stringsAsFactors = FALSE) at the top of your script.

Or check this stackoverflow question explaining how to convert a column from factors to strings.

Community
  • 1
  • 1
James Elderfield
  • 2,389
  • 1
  • 34
  • 39