R language learning notes (2) -- Reading data from a file

Source: Internet
Author: User

1. Use getwd () to get the current working directory, and setwd ("E:/rproject") to set the working directory.

Note that it is a slash rather than a backslash.

2. Read. Table ()

Mydata = read. Table ("filepath/FILENAME"), read data from filename, and create an object named mydata in the Data box.

Detailed Syntax of read. Table, use? Read. Table.

3. Scan to read files

Scan is more flexible than read. Table. You can specify the type of the read variable, and scan can be used to create different objects such as vectors, matrices, and data boxes. By default, scan creates a vector.

4. Read. fwf () to read files

Read. fwf () is used to read some data in fixed-width format in the file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.