命名列表时使用粘贴 [英] Using paste when naming a list

查看:92
本文介绍了命名列表时使用粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命名这样的列表可以很好地工作:

Naming a list like this works fine:

list("mtcars" = mtcars)

但是当我尝试使用paste时,出现错误:

But when I try to use paste, I get an error:

list(paste("mtcars") = mtcars)

Error: unexpected '=' in "list(paste("mtcars") ="

命名列表时如何使用paste?

推荐答案

您可以使用myList <- list()初始化列表,然后使用以下方法添加命名项:

You can initialise the list with myList <- list() and then add named items with:

myList[[paste("mtcars")]] <- mtcars

这篇关于命名列表时使用粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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