R-更改列表中元素的顺序 [英] R - Change the order of elements in a list

查看:84
本文介绍了R-更改列表中元素的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改list中元素的顺序.在其他有关排序或排序列表的问题中,我找不到专利答复.

I need to change the order of elements in a list. I don't find a patent response in others questions about sort or order a list.

这是一个简单的例子.

Freedom <- c(1, 2, 3, 2, 1, 2)
Equality <- c(2, 3, 1, 1, 2, 1)
TypeCountry <- c("South", "East", "East", "North", "South", "West")

Example <- list(Freedom, Equality, TypeCountry)
names(Example) <- c("Freedom", "Equality", "TypeCountry")

list的顺序为FreedomEquality然后是TypeCountry,我希望能够更改元素的顺序(例如,EqualityFreedom然后是TypeCountry).

The list has the order Freedom, Equality then TypeCountry and I want to be able to change the order of the elements (for example Equality, Freedom then TypeCountry).

推荐答案

只需执行以下操作:

Ex <- Example[c("TypeCountry","Freedom", "Equality")]

您指定所需的顺序.

这篇关于R-更改列表中元素的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆