R language Practical reading note 2-Create a dataset (bottom)

Source: Internet
Author: User

2.3 Data Entry

2.3.1 entering data using the keyboard

2.3.2 importing data from a delimited text file

You can use Read.table () to import data from a delimited text file. This function can be read into a tabular format

File and save it as a data frame.

Where file is a delimited ASCII text file, the header is a logical value (TRUE or FALSE) that indicates whether the first row contains the variable name, and Sep is used to specify the delimiter separating the data, and Row.names is an optional parameter that specifies one or more of the row labels variable to the identifier.

2.3.3 Importing Excel data

The best way to read an Excel file is to export it as a comma-delimited file (CSV) in Excel and import it into R using the method described earlier in this article.

In the WINDOWS32 bit system, you can also use the RODBC package to access Excel files. The first line of the spreadsheet should contain the name of the variable/column. Download the RODBC package first

Here Myfile.xls is an Excel file, MySheet is the name of the sheet to be read from this workbook, the channel is a RODBC connection object returned by Odbcconnectexcel (), Mydataframe is the data frame returned. RODBC can also be used to import data from Microsoft Access.

2.3.4 access to the database management system

Using RODBC to connect to a database, you first need to register the database's ODBC data source on your computer.

Configuration method: Control Panel---> Administrative Tools---> Data sources (ODBC)

2.4 Data export 2.4.1 exported to txt text

You can use the write.table () function to output an R object to a symbol-delimited file.

2.4.2 Export to CSV text

2.4.3 Export to the database

2.5 using functions for processing data Objects

R language Practical reading note 2-Create a dataset (bottom)

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.