0

I saved a dataframe in notepad named as ANOVA :

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

when I 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 by readTableHeader on 'ANOVA.txt'

What is the reason of this warning massage? How can I prevent it?

again when I run the apply() command that

> apply("ANOVA.txt",2,sum)
Error in apply("ANOVA.txt", 2, sum) : dim(X) must have a positive length

Why this error occuring? How can i prevent it?

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
time
  • 921
  • 3
  • 12
  • 15

1 Answers1

1

Here somebody had the same trouble, and got answered. Basically, the last line of your file doesn't end with a EOL character

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

About the second question, the apply function doesn't work on files but variables, you need to read the table first. So, either use:

variable<-read.table("ANOVA.txt")

apply(variable,2,sum)

Or directly

apply(read.table("ANOVA.txt"),2,sum)
Community
  • 1
  • 1
Rwak
  • 316
  • 1
  • 3
  • 11