Using search term "knn classification" on rseek.org brought up many relevant hits.
Among them, the knn() function in package "class" seems relevant -- but there are others, as you will see. Your second question is about statistics and is largely off topic here. Per the posting guide (linked below): "*Questions about statistics:* The R mailing lists are primarily intended for questions and discussion about the R software. However, questions about statistical methodology are sometimes posted. If the question is well-asked and of interest to someone on the list, it *may* elicit an informative up-to-date answer. See also the Usenet groups sci.stat.consult (applied statistics and consulting) and sci.stat.math (mathematical stat and probability)." However, the rseek.org hits also may be helpful for that. Alternatively, try stats.stackexchange.com for statistical questions for which you do not receive a response here. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Feb 27, 2021 at 6:14 PM Bijesh Mishra <bjs.mi...@gmail.com> wrote: > I have pathogen (1/0) as a dependent variable and total (count) as > independent variable. I have to get 1) KNN on total and 2) get the training > error and training TPR and FPR for k = 5 nearest neighbors using total as a > predictor. and 3) get a plot of training error vs. k for k = 1, 2, ..., 10 > with k on the x-axis. > > I am not sure how to do this in R. Also, how to know which value(s) of K > would be the most biased in the training error estimate? > > Help would be appreciated. > > Thanks > Bijesh Mishra. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.