我正在尝试为两个因素的特定级别创建一个颜色列表。参数如下:
> df.coldata
Condition Tank
R235 Control T6
R236 LowExposure T6
R239 HighExposure T6
R241 Control T8
R242 LowExposure T8
R245 HighExposure T8
R247 Control T14_3
R248 LowExposure T14_3
R250 HighExposure T14_3
由于我不想手动填写储罐编号或条件,因此我试图使用分配的变量创建一个列表,如下所示:
### Specify colors ####
Tanks <- levels(df.coldata$Tank)
Conditions <- levels(df.coldata$Condition)
ann_colors <- list(
Condition = c(Conditions[1]="lightskyblue", # This doenst work ... BUGS here!!!
Conditions[3]="royalblue1",
Conditions[2]="navyblue"),
Tank = c(Tanks[1]="gray90",
Tanks[2]="gray65",
Tanks[3]="gray40")
)
但这会产生一个错误,告诉我:
Error: unexpected '=' in:
"ann_colors <- list(
Condition = c(Conditions[1]="
当我运行代码时:
ann_colors <- list(
Condition = c(Control="lightskyblue",
LowExposure="royalblue1",
HighExposure="navyblue"),
Tank = c(T14_3="gray90",
T6="gray65",
T8="gray40")
)
它就像一个魅力。我究竟做错了什么?我错过了什么吗?