[R] read floats from file into array

leo mueller llug.dan at googlemail.com
Tue Jul 21 12:09:46 CEST 2009


hi all,

i have a simple question. instead of defining my measurements in a
static way like ...

x <- c(-0.475, -1.553, -0.434, -1.019, 0.395)

... i'd like them to be read from a file ...

x <- read.table("07a673ac0cb1f7f8fa293860566f633c/1/raw0.txt", header=FALSE)
d1 <- density(x, kernel = "gaussian")

with a formatting that looks like:

4.2840000000e-01
6.7583333333e-01
8.2920000000e-01
7.8566666667e-01
6.6336666667e-01
5.4080000000e-01
4.7283333333e-01
4.3770000000e-01
4.3743333333e-01
4.1026666667e-01
3.6283333333e-01
3.2770000000e-01
4.9096666667e-01
[...]

R quits and says:

> d1 <- density(x, kernel = "gaussian")
Error in density.default(x, kernel = "gaussian") :
  argument 'x' must be numeric
Calls: density -> density.default
Execution halted

is there any possibility to convert this / make this work?

big thx for help




More information about the R-help mailing list