Re: [R] Calling a function to store values

2011-03-03 Thread Kumaraguru Paramasivam
Hi,

I tried this approach.
cdata_1_1_3 <- readData(cData1,1,3)
cdata_2_4_7 <- readData(cData2,4,7)

Its still not working. The result I get is NULL.

Thanks,
Kumar

On Thu, Mar 3, 2011 at 9:50 AM, David Winsemius wrote:

>
> On Mar 3, 2011, at 10:12 AM, kparamas wrote:
>
>  Hi,
>>
>> I am calling a function with different arguments to read different files
>> and
>> want the results to be stored in
>> different matrices.
>>
>> Ex:
>> cData1 = NULL
>> cData2 = NULL
>>
>> readData = function(cData, start, end)
>> {
>>
>> 
>>  cData = //reads from the file
>> }
>>
>> I am calling the functions using
>> readData(cData1,1,3)
>> readData(cData2,4,7)
>>
>> But After running the code, cData1 and cData2 are not getting updated.
>> Is there a way in R to do this?
>>
> You need to assign the results of the function to an R object in the global
> environment. At the moment calling readData() only creates the cData object
> in the environment of the function which then disappears after function
> completion.
>
> Try :
>
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>


-- 
Thanks 'n' Regards,
Kumaraguru

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calling a function to store values

2011-03-03 Thread David Winsemius

On Mar 3, 2011, at 1:49 PM, Kumaraguru Paramasivam wrote:

> Hi,
>
> I tried this approach.
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
> Its still not working. The result I get is NULL.

Then the function (which you have not provided) is faulty, but there  
is not way we can debug a function we cannot see.

-- 
David.

>
> Thanks,
> Kumar
>
> On Thu, Mar 3, 2011 at 9:50 AM, David Winsemius  > wrote:
>
> On Mar 3, 2011, at 10:12 AM, kparamas wrote:
>
> Hi,
>
> I am calling a function with different arguments to read different  
> files and
> want the results to be stored in
> different matrices.
>
> Ex:
> cData1 = NULL
> cData2 = NULL
>
> readData = function(cData, start, end)
> {
>
> 
>  cData = //reads from the file
> }
>
> I am calling the functions using
> readData(cData1,1,3)
> readData(cData2,4,7)
>
> But After running the code, cData1 and cData2 are not getting updated.
> Is there a way in R to do this?
> You need to assign the results of the function to an R object in the  
> global environment. At the moment calling readData() only creates  
> the cData object in the environment of the function which then  
> disappears after function completion.
>
> Try :
>
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>
>
>
> -- 
> Thanks 'n' Regards,
> Kumaraguru

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calling a function to store values

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:12 AM, kparamas wrote:


Hi,

I am calling a function with different arguments to read different  
files and

want the results to be stored in
different matrices.

Ex:
cData1 = NULL
cData2 = NULL

readData = function(cData, start, end)
{


  cData = //reads from the file
}

I am calling the functions using
readData(cData1,1,3)
readData(cData2,4,7)

But After running the code, cData1 and cData2 are not getting updated.
Is there a way in R to do this?
You need to assign the results of the function to an R object in the  
global environment. At the moment calling readData() only creates the  
cData object in the environment of the function which then disappears  
after function completion.


Try :

cdata_1_1_3 <- readData(cData1,1,3)
cdata_2_4_7 <- readData(cData2,4,7)



--
View this message in context: 
http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.