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)