When was the first story to have a main character who turns out to be a ghost but didn’t know it?

I’m trying to dredge it up. I may even have the sexes reversed in my description. I’m pretty sure, though, that the song in question was written about in one of Sharyn McCrumb’s “ballad” novels. Problem is, I’ve read too damn many of them and don’t recall which one had that song embedded in it.

You could probably search the ebooks of all her writings online, simple Control F type search.

True, but it works less well on the ink-and-paper copies we have floating around. I assume the ebooks aren’t free. Although I might be able to check them out from the library.