我(我应该)可以使用R属性来保存物理单位和类似信息作为用户的提示吗?
epsilon0 <- 8.854188e-12
# name <- "electric constant"
# source <- "CODATA"
# unit <- "F m-1"
答案 0 :(得分:5)
您可以使用此代码:
attributes(epsilon0) <- list(name = "electric constant", source = "CODATA", unit="F m-1")
答案 1 :(得分:4)
除了@ MatthewLundberg的回答,您还可以设置和获取个别属性,如:
> attr(epsilon0,"name") <- "electric constant"
> epsilon0
[1] 8.854188e-12
attr(,"name")
[1] "electric constant"
> attr(epsilon0,"name")
[1] "electric constant"