Cite a R function/implementation from a website
If you use a script written by someone else, it is best to acknowledge them in some way. Citations are common, and many R packages define citations explicitly. Some authors will write papers documenting the code and publish them in journals, allowing you to cite the documentation rather than the code directly. However for one-off functions like your example, these options are usually not available. The information can be included in a footnote, or you can create a full citation. 

You can cite an online resource in bibtex using the @online record and include the URL and access date. I would recommend the following bibtex record for this resource:

@online{zhoucode,
  author="Mai Zhou",
  title="LogRank1 function",
  url="http://www.ms.uky.edu/~mai/splus/LogRank1.r",
  addendum="Accessed: 26 May 2020"
}


In the latex document, you can cite this using \cite{zhoucode} 

This should not be the only method by which a reader can access the source code. For reproducibility, it is best to make your analysis scripts publicly available for review so that future researchers can repeat your calculations exactly, and it is best to include a footnote in your text that links to a stable repository of your code. This can be accomplished in a number of ways.


@louic in another answer recommends publishing the script as supplemental materials (with the script writer's permission) which if available is the best option because the materials will always be available with the paper. This may not always be possible or reasonable depending on journals or the amount of code.
Some scholars use Github to host their materials and analysis scripts. Github is stable, publicly accessible, and maintains a history of changes made to your analysis scripts allowing review of the process and not simply the end point. Other public code repositories such as Bitbucket and sourceforge exist but are less popular in my experience. 
If you preregister your experiment and analysis through the Open Science Foundation website, they allow uploads of analysis scripts. Preregistration is useful in its own right, but uploading your analysis scripts makes them available to others in a stable repository linked to your work.
Have the internet archive save the page and link to the archived copy. This solution is far worse than the above recommendations because it doesn't show how the script was used by you, only what the source code of that function was. While other methods should be used, this method is better than nothing.