Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python R中的hashmaps列表_Python_R_List_Dictionary_Hashmap - Fatal编程技术网

Python R中的hashmaps列表

Python R中的hashmaps列表,python,r,list,dictionary,hashmap,Python,R,List,Dictionary,Hashmap,我试图在R中列出一个哈希值列表,但我还没有弄明白 我知道用python我可以做到 d1 = { id: 1, name: 'ada' } d2 = { id: 2, name: 'bob' } users = list() users.append(d1) users.append(d2) 有没有一种方法可以让我在R做这样的事情? 其他选项可能只是列表列表并通过索引访问它们。根据您的特定用例,使用数据框可能更容易: df <- data.frame( id = c(1,

我试图在R中列出一个哈希值列表,但我还没有弄明白

我知道用python我可以做到

d1 = { id: 1, name: 'ada' }
d2 = { id: 2, name: 'bob' }
users = list()

users.append(d1)
users.append(d2)
有没有一种方法可以让我在R做这样的事情?
其他选项可能只是列表列表并通过索引访问它们。

根据您的特定用例,使用数据框可能更容易:

df <- data.frame(
        id = c(1, 2),
        name = c("ada", "bob"),
        stringsAsFactors = FALSE)
df$name[df$id == 1]   # answer "ada"