【发布时间】:2019-05-02 03:07:25
【问题描述】:
我现在在 R 中使用这个当前数据框,我的目标是使用 tidyr 中的单独函数将 song_genre 列分成两列:
songs <- c("Wheel in the Sky", "Smooth Criminal", "Bloodstream", "New Kid in
Town", "You Belong with Me")
length <- c(211, 209, 299, 304, 232)
genre <- c("Rock", "Pop", "Pop", "Classic Rock", "Country Pop")
songList <- data.frame(songs, length, genre)
songList
songUnite <- unite(songList, "songs_genre", c("songs", "genre"), sep=".")
songUnite
但是,当我在命令中输入分隔符时:
songSeparate <- separate(songUnite, col = songs_genre, into = c("songs", "genre"), sep=".")
songSeparate
出现此警告:
警告信息:预计 2 件。额外的碎片被丢弃在 5 行 [1, 2, 3, 4, 5] 中。`
我已经在网上检查了我的格式和变量是否都在正确的位置,但似乎无法在我所写的内容中找到错误。
我还包含库 (tidyr)
【问题讨论】: