r - Error when reading txt file -


i saved dataframe in notepad named anova :

143 141 150 146 148 152 149 137 143 0 134 136 132 127 0 129 127 132 129 130 

when used read.table() command in r console ,that is,

> read.table("anova.txt") v1  v2  v3  v4  v5 1 143 141 150 146 148 2 152 149 137 143   0 3 134 136 132 127   0 4 129 127 132 129 130  warning message: in read.table("anova.txt") : incomplete final line found readtableheader on 'anova.txt' 

what reason of warning massage? how can prevent it?

again when run apply() command that

> apply("anova.txt",2,sum) error in apply("anova.txt", 2, sum) : dim(x) must have positive length 

why error occuring? how can prevent it?

here had same trouble, , got answered. basically, last line of file doesn't end eol character

https://stackoverflow.com/a/5996412/2123175

about second question, apply function doesn't work on files variables, need read table first. so, either use:

variable<-read.table("anova.txt")  apply(variable,2,sum) 

or directly

apply(read.table("anova.txt"),2,sum) 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -