[R] help
Sarah Goslee
sarah.goslee at gmail.com
Tue Jan 10 23:21:06 CET 2012
There might be an x in your R session, but not from that script. Try
it by pasting
those three lines at the command line:
> x <- [10.4 5.6 3.1 6.4 21.7]
Error: unexpected '[' in "x <- ["
> y <- [12,5.6, 7.2, 1.0, 9.3]
Error: unexpected '[' in "y <- ["
> plot(x,y)
Error in plot(x, y) : object 'x' not found
You should get an error message when you try to source the script, I
would think.
Try instead:
x <- c(10.4, 5.6, 3.1, 6.4, 21.7)
y <- c(12, 5.6, 7.2, 1.0, 9.3)
plot(x, y)
and rereading your introductory materials.
If that still doesn't work then we'll need more information, like OS
and version of R.
Sarah
On Tue, Jan 10, 2012 at 5:02 PM, 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
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list