[R] help

Anna Olofsson anol2900 at student.su.se
Tue Jan 10 23:57:01 CET 2012


Thank you! The c was missing. I don't know if it's ok to continue on this
thread, but I also had another question about reading data. I have this
file containing 3 columns and 19 rows. 

0	0.96	0.21	
0	0.45	0.4
0	0.87	0.1
0	0.56	0.04
0	0.57	0.04
0	0.2	0.7
0	0.45	0.43
0	0.35	0.21
0	0.75	0.56
1	0.63	0.43
1	0.95	0.32
1	0.42	0.2
1	0.12	0.05
1	0.56	0.06
1	0.34	0.3
1	0.1	0.7
1	0.11	0.75
1	0.2	0.21
1	0.95	0.37

I tried to read it into R, but I'm not exactly sure exactly what to use as
input. This is my input line using read.table:

data1 <- read.table(file = "filename.txt", header=FALSE, col.names =
c("class", "P", "1G"))

but in the output I get an X infront of "1G", which disappears when I run
it with the name 'G' instead of '1G'. Am I not allowed to use numerical
values? 

Best,
Anna




On Tue, 10 Jan 2012 23:02:04 +0100, Anna Olofsson <anol2900 at student.su.se>
wrote:
> Hi,
> I'm pretty new at programming and with the R language. I'm just trying
to
> get familiar with R and wrote a script in gedit (should I use emacs
> instead?),
> 
> x <- [10.4  5.6  3.1  6.4 21.7]
> y <- [12,5.6, 7.2, 1.0, 9.3]
> plot(x,y)
> 
> then I went to the command window in the terminal (I'm using unix) to
run
> this with source("name_of_file"), but it doesn't work. Shouldn't a plot
> come up automatically when I run it? What am I doing wrong? It knows
what x
> and y is, but I don't get an error of what might be wrong.
> 
>> source("name_of_file")
>> x
> [1] 10.4  5.6  3.1  6.4 21.7
> 
> 
> Best,
> Anna



More information about the R-help mailing list