无法将 csv 文件中的两列与 R 分开

发布于 2025-01-20 20:13:20 字数 338 浏览 2 评论 0原文

我尝试将两列添加到 R 的新 csv 文件中,问题是这两列位于 A 列中,而不是位于单独的列中,

您可以看到我的代码和结果: 在此处输入图片说明

在此处输入图片描述

输入图片描述这里

I tried to add two columns into a new csv file from R, and the problem that the two columns are in column A, instead to be in separate columns

you can see my code and the result:
enter image description here

enter image description here

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

沧桑㈠ 2025-01-27 20:13:20

尝试使用 tidyverse 包中的 mutate()

Rstudio 中的一个内置数据集 cars 我用它作为演示

car_new <- mutate(cars, time = dist/speed, distance_new = dist + 100)

#>    speed dist      time distance_new
#> 1      4    2 0.5000000          102
#> 2      4   10 2.5000000          110
#> 3      7    4 0.5714286          104
#> 4      7   22 3.1428571          122
#> 5      8   16 2.0000000          116
#> 6      9   10 1.1111111          110
#> 7     10   18 1.8000000          118
#> 8     10   26 2.6000000          126
#> 9     10   34 3.4000000          134
#> 10    11   17 1.5454545          117

Try to use mutate() from tidyverse package.

One built-in dataset cars in Rstudio and I use it as the demo

car_new <- mutate(cars, time = dist/speed, distance_new = dist + 100)

#>    speed dist      time distance_new
#> 1      4    2 0.5000000          102
#> 2      4   10 2.5000000          110
#> 3      7    4 0.5714286          104
#> 4      7   22 3.1428571          122
#> 5      8   16 2.0000000          116
#> 6      9   10 1.1111111          110
#> 7     10   18 1.8000000          118
#> 8     10   26 2.6000000          126
#> 9     10   34 3.4000000          134
#> 10    11   17 1.5454545          117
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文