在阅读R中的多个标签时,如何跳过空行?

发布于 2025-01-30 03:11:43 字数 288 浏览 4 评论 0原文

我正在尝试阅读带有多个选项卡的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笔一画续写前缘 2025-02-06 03:11:43

也许最简单的解决方案是阅读它,因为它被删除行,即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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文