Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的列表的输入:
structure(c(5L, 3L, 1L), .Label = c("id0", "id1", "id2", "id3", "id4"), class = "factor")
其中,当我们使用print()输出时
print()
[1] id4 id0 id2
这是我想要的减去[1]
[1]
为了摆脱它,我使用cat(),但是当我这样做时,这是输出
cat()
5 3 1
这似乎对应于c(5L,3L,1L)上面的位,但我不明白为什么。
c(5L,3L,1L)
干杯!
因为您的“列表”确实是一个因素……将其转换为字符,您将得到您所期望的。
> l <- structure(c(5L, 3L, 1L), .Label = c("id0", "id1", "id2", "id3", + "id4"), class = "factor") > cat(l, "\n") 5 3 1 > cat(as.character(l),"\n") id4 id2 id0