From 2f5c8bb7b14e9fff6fa25eb4b603ef9dfbe398e3 Mon Sep 17 00:00:00 2001 From: J Date: Wed, 10 Oct 2018 13:53:33 +0200 Subject: [PATCH] Linear Search R Language --- r-linear-search.r | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 r-linear-search.r diff --git a/r-linear-search.r b/r-linear-search.r new file mode 100644 index 0000000..69c50bb --- /dev/null +++ b/r-linear-search.r @@ -0,0 +1,5 @@ +> v <- c(3, 4, 0, 2, 1) +> target <- 2 +> found <- 2 %in% v # TRUE +> sv <- sort(v) +> idx <- which.max(v) # idx = 2