Sort Function - RDocumentation
Maybe your like
base (version 3.6.2)
Description
Usage
Arguments
Value
Details
References
See Also
Examples
Run this code# NOT RUN {require(stats) x <- swiss$Education[1:25] x; sort(x); sort(x, partial = c(10, 15)) ## illustrate 'stable' sorting (of ties):sort(c(10:3, 2:12), method = "shell", index.return = TRUE) # is stable## $x : 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 12## $ix: 9 8 10 7 11 6 12 5 13 4 14 3 15 2 16 1 17 18 19sort(c(10:3, 2:12), method = "quick", index.return = TRUE) # is not## $x : 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 12## $ix: 9 10 8 7 11 6 12 5 13 4 14 3 15 16 2 17 1 18 19 x <- c(1:3, 3:5, 10) is.unsorted(x) # FALSE: is sortedis.unsorted(x, strictly = TRUE) # TRUE : is not (and cannot be)# sorted strictly# }# NOT RUN {## Small speed comparison simulation:N <- 2000 Sim <- 20 rep <- 1000 # << adjust to your CPUc1 <- c2 <- numeric(Sim) for(is inseq_len(Sim)){ x <- rnorm(N) c1[is] <- system.time(for(i in1:rep) sort(x, method = "shell"))[1] c2[is] <- system.time(for(i in1:rep) sort(x, method = "quick"))[1] stopifnot(sort(x, method = "shell") == sort(x, method = "quick")) } rbind(ShellSort = c1, QuickSort = c2) cat("Speedup factor of quick sort():\n") summary({qq <- c1 / c2; qq[is.finite(qq)]}) ## A larger testx <- rnorm(1e7) system.time(x1 <- sort(x, method = "shell")) system.time(x2 <- sort(x, method = "quick")) system.time(x3 <- sort(x, method = "radix")) stopifnot(identical(x1, x2)) stopifnot(identical(x1, x3)) # }Run the code above in your browser using DataLab
Tag » How To Sort In R
-
Sorting Data - Quick-R
-
Sorting In R Using Order() Tutorial - DataCamp
-
How Can I Sort My Data In R? | R FAQ - Statistical Consulting
-
R Sort A Data Frame Using Order() - Guru99
-
How To Sort A Data Frame By Multiple Columns In R - Chartio
-
How To Sort A DataFrame In R ? - GeeksforGeeks
-
SORT In R With Sort() And Order() Functions [vectors, Data Frames, ...]
-
How To Sort An R Data Frame (multiple Ways, Multiple Columns)
-
R – Sorting A Data Frame By The Contents Of A Column - R-bloggers
-
Sorting Or Ordering Vectors - R
-
Sort In R: How To Sort Data In R - R-Lang
-
How To Sort Data In R - ProjectPro
-
Sort Table In R (3 Examples) - Statistics Globe
-
Chapter 16 Arranging (Sorting) Data | R For HR: An Introduction To ...