[R] Problem in executing R-script

Sarah Goslee sarah.goslee at gmail.com
Mon May 7 20:06:31 CEST 2012


Hi Suhaila,

You don't need to make a function: your script should just contain:
med <- read.csv("medicalData.csv")

If you do want to make a function, then you need to assign the
resulting value to something, eg:

med <- readData()

but there's no reason to do that. Values that are assigned within a
function don't persist in the global environment.

Sarah

On Mon, May 7, 2012 at 1:41 PM, Suhaila Haji Mohd Hussin
<bell_beauty12 at hotmail.com> wrote:
>
> Hello. I'm a newbie here.
> In my script (I name it readData.R), I wrote the followings:
> readData <-function(){  med = read.csv("medicalData.csv");}
> Then I tested the script by 'Source R Code' then on the command I typed 'readData()' then I typed 'med' to check if the variable contains the medical data but it returned 'Object med is not found'. What did I do wrong? Please help.
> Cheers,Suhaila

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list