小编Nav*_*MSN的帖子

将非结构化 csv 文件转换为数据框

我正在学习 R 进行文本挖掘。我有一个 CSV 格式的电视节目时间表。节目通常从早上 06:00 开始,一直持续到第二天早上 05:00,这被称为广播日。例如:15/11/2015 的节目从早上 06:00 开始,到第二天早上 05:00 结束。

这是一个示例代码,显示了日程安排的样子:

 read.table(textConnection("Sunday|\n 01-Nov-15|\n 6|Tom\n some information about the program|\n 23.3|Jerry\n some information about the program|\n 5|Avatar\n some information about the program|\nMonday|\n 02-Nov-15|\n 6|Tom\n some information about the program|\n 23.3|Jerry\n some information about the program|\n 5|Avatar\n some information about the program|"), header = F, sep = "|", stringsAsFactors = F)
Run Code Online (Sandbox Code Playgroud)

其输出如下:

  V1|V2
Sunday |  
01-Nov-15 |       
6 | Tom  
some information about the program |       
23.3 |  Jerry …
Run Code Online (Sandbox Code Playgroud)

r reshape dataframe

5
推荐指数
2
解决办法
1468
查看次数

标签 统计

dataframe ×1

r ×1

reshape ×1