rstudio导入数据_将数据导入r的不同方法

本文介绍了如何在RStudio中导入数据,详细讲解了不同方法,涵盖了从基础到进阶的各种选项,帮助数据科学家更有效地处理数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

rstudio导入数据

I have completed two courses at DataCamp that introduced me to the concept of importing data into R. There are numerous ways to import the data. I would like to discuss in detail some of the methods that I learned in the course. Let’s get started.

我已经在DataCamp完成了两门课程,向我介绍了将数据导入R的概念。有很多方法可以导入数据。 我想详细讨论我在本课程中学到的一些方法。 让我们开始吧。

Data can come from many sources. Some of the most common ones are

数据可以来自许多来源。 一些最常见的是

  • Flat Files — CSV, txt, tsv, etc

    平面文件-CSV,txt,tsv等
  • Data from Excel

    来自Excel的数据
  • DataBases — Postgresql, Mysql, etc

    数据库-Postgresql,Mysql等
  • Web

    网页
  • Statistical Softwares — SAS, SPSS, STATA

    统计软件-SAS,SPSS,STATA

平面文件 (Flat-Files)

What is a flat-file?

什么是平面文件?

According to Wikipedia, A flat-file database is a database stored in a file called a flat-file. Records follow a uniform format, and there are no structures for indexing or recognizing relationships between records. The file is simple. A flat file can be a plain text file or a binary file.

根据Wikipedia的说法, 平面文件数据库是存储在称为Flat文件的文件中的数据库。 记录遵循统一的格式,并且没有索引或识别记录之间关系的结构。 该文件很简单。 平面文件可以是纯文本文件或二进制文件。

Listed below are some of the packages that will help you to deal while working with the Flat-Files in R.

下面列出了一些软件包,可以帮助您在使用R中的Flat-Files时进行处理。

UTIL

UTIL

This package is loaded by default when you load R.

默认情况下,在加载R时会加载此软件包。

  • read.table(): Main function. Reads a file in table format and creates a data frame from it. It offers many arguments to classify the incoming data.

    read.table() :主要功能。 读取表格式的文件并从中创建数据框。 它提供了许多参数来分类传入的数据。

  • read.csv(): Wrapper function for read.table(). Used to read comma-separated (CSV) files.

    read.csv() :read.table()的包装函数。 用于读取逗号分隔(CSV)文件。

  • read.delim(): Wrapper Function used to read tab-separated files. read.delim() is used if the numbers in your file use periods(.) as decimals.

    read.delim() :包装函数,用于读取制表符分隔的文件。 如果文件中的数字使用点号(。)作为小数,则使用read.delim()。

  • read.csv2() : read.csv() and read.csv2() are identical. The only difference is that they are set up depending on whether you use periods or commas as decimal points in numbers.

    read.csv2() :read.csv()和read.csv2()相同。 唯一的区别是,它们的设置取决于您使用句点还是逗号作为数字的小数点。

  • read.delim2() : read.delim2 is used when the numbers in your file use commas(,) as decimals.

    read.delim2() :当文件中的数字使用逗号(,)作为小数时,将使用read.delim2。

Image for post
read.csv() function read.csv()函数的输出

Specialized Packages

专业套餐

readr

阅读器

This package makes our life easier. It is fast, convenient, and more efficient than the utils package. I tend to use this always.

这个包裹使我们的生活更轻松。 它比utils包更快,更方便且更高效。 我倾向于总是使用它。

read_r supports seven file formats with seven functions:

read_r支持具有七个功能的七种文件格式:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值