在阅读R中的多个标签时,如何跳过空行?
我正在尝试阅读带有多个选项卡的Excel文件。为此,我使用提供的代码在这里。 问题在于,每个选项卡在实际数据开始之前都有不同数量的空行。例如,第一个选项卡有两个空行,第二个选项卡有三个空行,依此类推。
通常,我将在read_excel
函数中使用参数skip
来指示要跳过的空行数。但是,我该如何为有不同数量的行跳过的多个选项卡进行操作呢?
I am trying to read an excel file with multiple tabs. For that, I use the code provided here.
The problem is that each tab has a different number of empty rows before the actual data begins. For example, the first tab has two empty rows, the second tab has three empty rows, and so on.
Normally, I would use the parameter skip
in the read_excel
function to indicate the number of empty lines to skip. But how do I do that for multiple tabs with different numbers of rows to skip?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许最简单的解决方案是阅读它,因为它被删除行,即yourdata< - yourdata [!is.na(yourdata $ columname),],];如果您不希望特定列中的任何NA(例如ID),这将有效。如果您到处都有数据差距,则可以在多个列中测试所有NAS - 让我知道您是否需要。
perhaps the easiest solution would be to read it as it is then remove rows, i.e. yourdata <- yourdata[!is.na(yourdata$columname),] ; this would work if you don't expect any NA's in a particular column, like id. If you have data gaps everywhere you can test for all NAs in multiple columns - let me know if that's what you need.