Data Frame Error

I am absolutely new to R and programming in general, so kindly excuse my language.
I am using twitteR package to get tweets of certain hashtag. I wanted to export these tweets into xlsx file and I am facing this error:

Error in is.data.frame(x) : object 'x' not found

I am writing the export line as follows: write_xlsx(x, path = "cars.xlsx", col_names = TRUE)

I am certainly missing on something here. Would appreciate any help!

The error message suggests you have no data frame called x in your working environment, so there is nothing to be saved as xlsx, to give you better help. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ: