sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.4.3 plyr_1.8.3 tidyr_0.3.1 gridExtra_2.0.0 scales_0.3.0
[6] ggplot2_1.0.1 RPostgreSQL_0.4 DBI_0.3.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 lubridate_1.3.3 assertthat_0.1 digest_0.6.8 MASS_7.3-44
[6] R6_2.1.1 grid_3.2.2 gtable_0.1.2 magrittr_1.5 stringi_0.5-5
[11] reshape2_1.4.1 proto_0.3-10 tools_3.2.2 stringr_1.0.0 munsell_0.4.2
[16] parallel_3.2.2 colorspace_1.2-6 memoise_0.2.1
例如,我在一列中有 n 个字符串,如下所示。我想根据最后一个单词对字符串进行排序。
dput(dsp)
c("handlingstation / cropping/ forward / Linie 1", "handlingstation / cropping/ forward / Linie 2",
"conveyorstation / Linie 1", "conveyorstation / Linie 2", "soft / handling / cleaning / backward / Linie 3",
"jumper / doublejumper / Linie 1", "jumper / doublejumper / Linie 2"
)
dsp
[1] "handlingstation / cropping/ forward / Linie 1"
[2] "handlingstation / cropping/ forward / Linie 2"
[3] "conveyorstation / Linie 1"
[4] "conveyorstation / Linie 2"
[5] "soft / handling / cleaning / backward / Linie 3"
[6] "jumper / doublejumper / Linie 1"
[7] "jumper / doublejumper / Linie 2"
期望的输出
dsp_sorted
[1] "handlingstation / cropping/ forward / Linie 1"
[2] "conveyorstation / Linie 1"
[3] "jumper / doublejumper / Linie 1"
[4] "handlingstation / cropping/ forward / Linie 2"
[5] "conveyorstation / Linie 2"
[6] "jumper / doublejumper / Linie 2"
[7] "soft / handling / cleaning / backward / Linie 3"
我希望根据最后一个单词对特定列中的所有字符串进行排序。这里应该是基于 Linie 1, Linie 2 等等。
有人可以让我知道我该怎么做。