英文:
How to reference a variable containing plus sign?
问题
数据集blood_storage
来自包medicaldata,包含一个名为BN+
的变量。我如何在模型的公式中原样输入该变量?以下代码将导致错误:
lm(TimeToRecurrence ~ RBC.Age.Group + Median.RBC.Age + Age + AA + FamHx + PVol + TVol + T.Stage +
bGS + BN+ + OrganConfined, data=blood_storage)
是否有解决办法,可以重命名变量以去除+
符号?
英文:
The dataset blood_storage
from the package medicaldata contains a variable BN+
. How can I enter that variable as is in a model's formula? The following code will cause an error:
lm(TimeToRecurrence ~ RBC.Age.Group + Median.RBC.Age + Age + AA + FamHx + PVol + TVol + T.Stage +
bGS + BN+ + OrganConfined, data=blood_storage)
Is there a workaround of the variable must be renamed to remove the +
sign?
答案1
得分: 1
答案相同,对于具有空格的变量,请使用反引号。
lm(TimeToRecurrence ~ RBC.Age.Group + Median.RBC.Age + Age + AA + FamHx + PVol + TVol + T.Stage + bGS + `BN+` + OrganConfined, data=blood_storage)
英文:
The answer is the same for variables that have spaces in them. Use backticks.
lm(TimeToRecurrence ~ RBC.Age.Group + Median.RBC.Age + Age + AA + FamHx + PVol + TVol + T.Stage + bGS + `BN+` + OrganConfined, data=blood_storage)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论