小编han*_*000的帖子

创建列表时出现意外的符号错误

我正在尝试为两个因素的特定级别创建一个颜色列表。参数如下:

> 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
Run Code Online (Sandbox Code Playgroud)

由于我不想手动填写 Tank 编号或 Condition,我尝试使用分配的变量创建一个列表,如下所示:

### 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")
)
Run Code Online (Sandbox Code Playgroud)

但这会产生一个错误告诉我:

Error: unexpected '=' in:
"ann_colors <- list(
  Condition = c(Conditions[1]="
Run Code Online (Sandbox Code Playgroud)

当我运行代码时:

ann_colors …
Run Code Online (Sandbox Code Playgroud)

r list unexpected-token

2
推荐指数
1
解决办法
61
查看次数

标签 统计

list ×1

r ×1

unexpected-token ×1