Import Data Importing data into R is fairly simple. The data can be imported from selected files like excel, txt, SPSS, SAS and STATA. The following simple command will help you to import data from text file. sudheesh<-read.table("C:\\Documents and Settings\\Administrator\\Desktop\\mydata.txt", header=T) or sudheesh<-read.table("C:/Documents and Settings/Administrator/Desktop/mydata.txt", header=T) Please make sure that the path is written carefully and note that we are using double slash instead of single. Otherwise the path should be given as in Linex. To import from excel it is better to covert the excel file in to comma delimited format and then import from it using the following command sudheesh<-read.csv("C:/Documents and Settings/Administrator/Desktop/mydata.csv", header=T) If we want to export from file like SPSS we have to specify the library as the command will not work in base package. The particular package can be installed in your pc using the command install.packages("package name") Then specify the library. For Stata and Systat, use the foreign package. For SPSS and SAS use the Hmisc package From SPSS Note that we have to From SAS
|