[R] Question on Import

Alexander Engelhardt alex at chaotic-neutral.de
Mon Apr 25 10:53:26 CEST 2011


Am 25.04.2011 09:58, schrieb Georgina Salazar:
> Hi!
>
> I have the data in a tab delimited text file titled "ken_data_try_anova." I
> tried to import it into R entering
>
>> read.delim(ken_data_try_anova)
>
> but received the error message
>
> Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
>    object 'ken_data_try_anova' not found
>
> I have another file called 10423nad.txt.
>
> I tried
>> data<-as.matrix(read.table(C:\Users\gtsalazar1979\Documents\TANOVA_1.0.0\10423nad.txt))
>> )

You shall escape filenames with quotes:
read.delim("ken_data_try_anova")

Otherwise R thinks you have a variable named ken_data_try_anova. But you 
need a string containing the filename (and the difference between 
strings and variables are the quotes).
The following, for example, would also work:

derp <- "ken_data_try_anova"
read.delim(derp)

What you also want to do, is not only read the table, but also store it 
in a data frame:

mydata <- read.delim("ken_data_try_anova")

Have fun,
  Alex



More information about the R-help mailing list