Your code works for me, as long as you (1) fix the column heading to make sure Location is capitalized, and (2) make sure your data frame is actually 3 columns. If it is only a single column, I get the error you get.
Your data should be in 3 columns. You can check:
> dim(df)
[1] 16 3
This is what I get if I read in your data as typed above after I've converted the spaces to tabs so that I get 3 columns. If I read it in as is, I get only a single column because there are multiple spaces separating each field.
If you are reading your data into R and it is space delimited, you can convert it to tab delimited using sed on the command line:
sed 's/ \+/\t/g' test_data.txt > test_data_tabbed.txt
OR, if your data is already in R, but is not a 3 column data frame you can convert it to one as follows (ugly, but works):
# before conversion
dim(df)
[1] 16 1
# split each row element by multiple spaces for a list of elements
foo <- apply(df, 1, function(x){strsplit(x, " +")})
# deconstruct compound list to a simpler list
foo <- lapply(foo, unlist)
# convert list of elements to matrix
df <- do.call(rbind, foo)
# convert matrix to datframe
df <- as.data.frame(df)
colnames(df) <- c("Date", "Location", "count")
# after conversion
dim(df)
[1] 16 3
With the data in 3 columns, the plot works as expected.
What error are problem are you having?
Error in as.character(x) : cannot coerce type 'closure' to vector of type 'character'
Please provide reproducible example data:
dput(head(df)), check the structure of your data,str(df). There is a typo on column name, too location vs Location.