为什么在调用 rcloud.notebook.by.name() 时需要 [1]?

Why do you need the [1] when calling rcloud.notebook.by.name()?

RCloud function rcloud.notebook.by.name(), why do you need the [1] after the function in this example中:

rcloud.execute.asset(name="mtcars.R",
    notebook=rcloud.notebook.by.name(
        user="rclouddocs",
        name="Basic Functionality/Create Reusable Functions/Notebook With R Function in Assets")[1]
)

这个功能returns不仅仅是笔记本id。它还 returns 路径中未被查询使用的任何部分。

继续 rcloud.social

rcloud.notebook.by.name(
    user="rclouddocs",
    name="Basic Functionality/Create Reusable Functions/Notebook With R Function in Assets") 

returns

     id                                 extra.path
[1,] "6c90abc418dec48ec4e9016ad0187f95" ""        

但是如果你在末尾添加更多路径:

rcloud.notebook.by.name(
    user="rclouddocs",
    name="Basic Functionality/Create Reusable Functions/Notebook With R Function in Assets/blablabla

你得到

     id                                 extra.path  
[1,] "6c90abc418dec48ec4e9016ad0187f95" "/blablabla"

这被notebook.R内部使用;它是允许按用户、笔记本路径和资产名称获取资产的代码,例如从具有以下 URL:

的同一笔记本中获取 mtcars.R

https://rcloud.social/notebook.R/rclouddocs/Basic%20Functionality/Create%20Reusable%20Functions/Notebook%20With%20R%20Function%20in%20Assets/mtcars.R