2

Possible Duplicate:
R seems to multiply my data by -1

I have a simple csv file. Looks like this

x y 1 2 1 3 2 1 2 3

I created it in MS Excel, saved as csv etc.

I read it using this command

ttest<--read.csv("ttest.csv", header = TRUE)

The resulting data looks like this

x y -1 -2 -1 -3 -2 -1 -2 -3

I've opened the original csv file in a text editor and it looks like it should

4

1 回答 1

6

原因是您的命令:

ttest<--read.csv("ttest.csv", header = TRUE)

... 在 之后有一个额外的破折号<-,R 将其解释为负号,因此在将数据加载到ttest.

此外,read.csv()用于读取逗号分隔值文件的 和之间可能存在一些混淆read.table(),后者将读取如下文件:

x y 
1 2 
1 3 
2 1 
2 3

...这更像是我认为您的文件最初的样子。

于 2013-01-19T05:07:21.837 回答