In that example ref <- system.file("extdata","reference.fa",package="Rsubread") gives the path to a file. You can see this simply by printing it out. For me this is
So you need to get a FASTA file for the genome you want to use, and then use the path to that file for ref, so something like ref <- "c:/path/to/hg19.fa" or ref <- "/path/to/hg19.fa" depending on if you're using Windows or not.
You should then be able to use the buildindex() function in the way described.