Function to save results

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Function to save results

R help mailing list-2
Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors
attr <- sink("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//output.txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors
Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

Eric Berger
Some comments:
1. sink() does not return a value. There is on point to set attr <-
sink(...). Just give the command sink("C://....etc")
2. to complete the saving to the file you must give a second sink command
with no argument:  sink()
So your code would be (pseudo-code, not actual code)

sink( "filename" )
do something that prints output which will be captured by sink
sink()

HTH,
Eric



On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]
> wrote:

> Hi,I want the results to be saved automatically in a output text file
> after the script has finished running.
>
> I used the sink function in the following example, but the results file
> (output.txt) was empty.
>
> net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all
> genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")#
> First I loaded theinput file for which I want to identify attractors
> attr <- sink("C://Users//Priya//Desktop//Attractor analysis_all
> genes//synaptogenesis//output.txt")# used the sink function to save the
> results from attr function
>
> attr <- getAttractors(net, type="asynchronous")# then ran the script for
> identifying attractors
> Is there any function to save the results before setting the script to
> run, so that results are automatically saved in a text file after the
> script has finished running?
>
> Thank youPriya
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

R help mailing list-2
Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)

net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")sink("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//attr.txt")


sink()

attr <- getAttractors(net, type="asynchronous")
 Priya
 

    On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]> wrote:
 

 Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code)
sink( "filename" )do something that prints output which will be captured by sinksink()
HTH,Eric


On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]> wrote:

Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors
attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors
Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________ ________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.




   
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

Eric Berger
Hi Priya,

You did not follow the logic of the pseudo-code.
The sink("filename"), sink() pair captures whatever output is generated
between the first sink statement and the second sink statement.
You need (possibly) to do:

sink("C://Users//Priya//Desktop//Attractor analysis_all
genes//synaptogenesis//attr.txt")


net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all
genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")

attr <- getAttractors(net, type="asynchronous")


sink()


HTH,

Eric






On Wed, Nov 1, 2017 at 4:10 PM, Priya Arasu <[hidden email]> wrote:

> Hi Eric,
> I tried as you suggested but I could not find the output in the text file
> I created (attr.txt)
>
> net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")
>
> sink("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//attr.txt")
>
>
> sink()
>
> attr <- getAttractors(net, type="asynchronous")
>
>
> Priya
>
>
> On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]>
> wrote:
>
>
> Some comments:
> 1. sink() does not return a value. There is on point to set attr <-
> sink(...). Just give the command sink("C://....etc")
> 2. to complete the saving to the file you must give a second sink command
> with no argument:  sink()
> So your code would be (pseudo-code, not actual code)
>
> sink( "filename" )
> do something that prints output which will be captured by sink
> sink()
>
> HTH,
> Eric
>
>
>
> On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <
> [hidden email]> wrote:
>
> Hi,I want the results to be saved automatically in a output text file
> after the script has finished running.
>
> I used the sink function in the following example, but the results file
> (output.txt) was empty.
>
> net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all
> genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")#
> First I loaded theinput file for which I want to identify attractors
> attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all
> genes//synaptogenesis//output. txt")# used the sink function to save the
> results from attr function
>
> attr <- getAttractors(net, type="asynchronous")# then ran the script for
> identifying attractors
> Is there any function to save the results before setting the script to
> run, so that results are automatically saved in a text file after the
> script has finished running?
>
> Thank youPriya
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________ ________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/ listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html <http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

R help mailing list-2
Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the file before starting to run the analysis, so the file gets saved automatically after the script has finished running
Priya
 


    On Wednesday, 1 November 2017 7:53 PM, Eric Berger <[hidden email]> wrote:
 

 Hi Priya,
You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement.You need (possibly) to do:
sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")
net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net, type="asynchronous")
sink()
HTH,Eric


 
On Wed, Nov 1, 2017 at 4:10 PM, Priya Arasu <[hidden email]> wrote:

Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")


sink()

attr <- getAttractors(net, type="asynchronous")
 Priya
 

    On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]> wrote:
 

 Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code)
sink( "filename" )do something that prints output which will be captured by sinksink()
HTH,Eric


On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]> wrote:

Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors
attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors
Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________ ________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.




   



   
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

David Carlson
Let's try a simple example.

> # Create a script file of commands
> # Note we must print the results of quantile explicitly
> cat("x <- rnorm(50)\nprint(quantile(x))\nstem(x)\n", file="Test.R")
>
> # Test it by running it to the console
> source("Test.R")
        0%        25%        50%        75%       100%
-2.4736219 -0.7915433 -0.1178056  0.7023577  2.9158617

  The decimal point is at the |

  -2 | 510
  -1 | 7631110
  -0 | 9988777333333211
   0 | 01124455557777889
   1 | 00045
   2 | 19

>
> # Now run it and save the file
> sink("Testout.txt")
> source("Test.R")
> sink()
>
> # What is located in "Testout.txt"?
> cat(readLines("Testout.txt"), sep="\n")
         0%         25%         50%         75%        100%
-2.47511893 -0.47919111  0.05761628  0.67403447  1.79825459

  The decimal point is at the |

  -2 | 5
  -2 | 4
  -1 |
  -1 | 432000
  -0 | 87755
  -0 | 4433332110
   0 | 001244
   0 | 55666667777789
   1 | 113
   1 | 5788

> # Success

Depending on your operating system, you may also be able to save the output with File | Save to File.

---------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: R-help [mailto:[hidden email]] On Behalf Of Priya Arasu via R-help
Sent: Wednesday, November 1, 2017 9:57 AM
To: Eric Berger <[hidden email]>
Cc: [hidden email]
Subject: Re: [R] Function to save results

Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the file before starting to run the analysis, so the file gets saved automatically after the script has finished running Priya
 


    On Wednesday, 1 November 2017 7:53 PM, Eric Berger <[hidden email]> wrote:
 

 Hi Priya,
You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement.You need (possibly) to do:
sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt") net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net, type="asynchronous")
sink()
HTH,Eric


 
On Wed, Nov 1, 2017 at 4:10 PM, Priya Arasu <[hidden email]> wrote:

Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")


sink()

attr <- getAttractors(net, type="asynchronous")
 Priya
 

    On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]> wrote:
 

 Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code) sink( "filename" )do something that prints output which will be captured by sinksink() HTH,Eric


On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]> wrote:

Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________ ________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.




   



   
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

R help mailing list-2
Hi David,Thank you for the example.When I try to use the cat function, I get an error

cat(attr<-getAttractors(net, type="asynchronous"))Error in cat(attr <- getAttractors(net, type = "asynchronous")) :
  argument 1 (type 'pairlist') cannot be handled by 'cat'

Please let me know, if I have used the function in right way?.
Thank you
Priya






 
 

    On Wednesday, 1 November 2017 9:32 PM, David L Carlson <[hidden email]> wrote:
 

 Let's try a simple example.

> # Create a script file of commands
> # Note we must print the results of quantile explicitly
> cat("x <- rnorm(50)\nprint(quantile(x))\nstem(x)\n", file="Test.R")
>
> # Test it by running it to the console
> source("Test.R")
        0%        25%        50%        75%      100%
-2.4736219 -0.7915433 -0.1178056  0.7023577  2.9158617

  The decimal point is at the |

  -2 | 510
  -1 | 7631110
  -0 | 9988777333333211
  0 | 01124455557777889
  1 | 00045
  2 | 19

>
> # Now run it and save the file
> sink("Testout.txt")
> source("Test.R")
> sink()
>
> # What is located in "Testout.txt"?
> cat(readLines("Testout.txt"), sep="\n")
        0%        25%        50%        75%        100%
-2.47511893 -0.47919111  0.05761628  0.67403447  1.79825459

  The decimal point is at the |

  -2 | 5
  -2 | 4
  -1 |
  -1 | 432000
  -0 | 87755
  -0 | 4433332110
  0 | 001244
  0 | 55666667777789
  1 | 113
  1 | 5788

> # Success

Depending on your operating system, you may also be able to save the output with File | Save to File.

---------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: R-help [mailto:[hidden email]] On Behalf Of Priya Arasu via R-help
Sent: Wednesday, November 1, 2017 9:57 AM
To: Eric Berger <[hidden email]>
Cc: [hidden email]
Subject: Re: [R] Function to save results

Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the file before starting to run the analysis, so the file gets saved automatically after the script has finished running Priya
 


    On Wednesday, 1 November 2017 7:53 PM, Eric Berger <[hidden email]> wrote:


 Hi Priya,
You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement.You need (possibly) to do:
sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt") net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net, type="asynchronous")
sink()
HTH,Eric


 


Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")


sink()

attr <- getAttractors(net, type="asynchronous")
 Priya


    On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]> wrote:


 Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code) sink( "filename" )do something that prints output which will be captured by sinksink() HTH,Eric


On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]> wrote:

Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________ ________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.




 



 
    [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.


   
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

Eric Berger
In reply to this post by David Carlson
Hi Priya,
I think your original question may have been phrased in a way that caused
David and me some confusion.
I think sink() may not be the function that is appropriate in your case.
Sink() is used to capture output to the console (so to speak).
You are trying to save the results of calculations returned, in this case
in the variable 'attr'.
You need to do something like:

attr <- getAttractors( ... )
saveRDS( attr, "filename.RDS")

and then later you can read the results back in another R session:

savedAttr <- readRDS("filename.RDS")

Look at the documentation ?saveRDS and ?readRDS

HTH,
Eric

On Wed, Nov 1, 2017 at 6:02 PM, David L Carlson <[hidden email]> wrote:

> Let's try a simple example.
>
> > # Create a script file of commands
> > # Note we must print the results of quantile explicitly
> > cat("x <- rnorm(50)\nprint(quantile(x))\nstem(x)\n", file="Test.R")
> >
> > # Test it by running it to the console
> > source("Test.R")
>         0%        25%        50%        75%       100%
> -2.4736219 -0.7915433 -0.1178056  0.7023577  2.9158617
>
>   The decimal point is at the |
>
>   -2 | 510
>   -1 | 7631110
>   -0 | 9988777333333211
>    0 | 01124455557777889
>    1 | 00045
>    2 | 19
>
> >
> > # Now run it and save the file
> > sink("Testout.txt")
> > source("Test.R")
> > sink()
> >
> > # What is located in "Testout.txt"?
> > cat(readLines("Testout.txt"), sep="\n")
>          0%         25%         50%         75%        100%
> -2.47511893 -0.47919111  0.05761628  0.67403447  1.79825459
>
>   The decimal point is at the |
>
>   -2 | 5
>   -2 | 4
>   -1 |
>   -1 | 432000
>   -0 | 87755
>   -0 | 4433332110
>    0 | 001244
>    0 | 55666667777789
>    1 | 113
>    1 | 5788
>
> > # Success
>
> Depending on your operating system, you may also be able to save the
> output with File | Save to File.
>
> ---------------------------------------
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
> -----Original Message-----
> From: R-help [mailto:[hidden email]] On Behalf Of Priya
> Arasu via R-help
> Sent: Wednesday, November 1, 2017 9:57 AM
> To: Eric Berger <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [R] Function to save results
>
> Hi Eric,Thanks for the explanation. Is there a way to save the results
> automatically after the analysis gets over?. As I recently lost the
> results, because I didn't save the results. I don't want to run the sink or
> save command after the analysis is over rather run the command for saving
> the file before starting to run the analysis, so the file gets saved
> automatically after the script has finished running Priya
>
>
>
>     On Wednesday, 1 November 2017 7:53 PM, Eric Berger <
> [hidden email]> wrote:
>
>
>  Hi Priya,
> You did not follow the logic of the pseudo-code. The sink("filename"),
> sink() pair captures whatever output is generated between the first sink
> statement and the second sink statement.You need (possibly) to do:
> sink("C://Users//Priya// Desktop//Attractor analysis_all
> genes//synaptogenesis//attr. txt") net <- loadNetwork("C://Users//Priya/
> /Desktop//Attractor analysis_all genes//synaptogenesis//
> regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net,
> type="asynchronous")
> sink()
> HTH,Eric
>
>
>
> On Wed, Nov 1, 2017 at 4:10 PM, Priya Arasu <[hidden email]>
> wrote:
>
> Hi Eric,I tried as you suggested but I could not find the output in the
> text file I created (attr.txt)
>
> net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all
> genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya//
> Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")
>
>
> sink()
>
> attr <- getAttractors(net, type="asynchronous")
>  Priya
>
>
>     On Wednesday, 1 November 2017 6:54 PM, Eric Berger <
> [hidden email]> wrote:
>
>
>  Some comments:1. sink() does not return a value. There is on point to set
> attr <- sink(...). Just give the command sink("C://....etc")2. to complete
> the saving to the file you must give a second sink command with no
> argument:  sink()So your code would be (pseudo-code, not actual code) sink(
> "filename" )do something that prints output which will be captured by
> sinksink() HTH,Eric
>
>
> On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <
> [hidden email]> wrote:
>
> Hi,I want the results to be saved automatically in a output text file
> after the script has finished running.
>
> I used the sink function in the following example, but the results file
> (output.txt) was empty.
>
> net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all
> genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")#
> First I loaded theinput file for which I want to identify attractors attr
> <- sink("C://Users//Priya// Desktop//Attractor analysis_all
> genes//synaptogenesis//output. txt")# used the sink function to save the
> results from attr function
>
> attr <- getAttractors(net, type="asynchronous")# then ran the script for
> identifying attractors Is there any function to save the results before
> setting the script to run, so that results are automatically saved in a
> text file after the script has finished running?
>
> Thank youPriya
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________ ________________ [hidden email]
> mailing list -- To UNSUBSCRIBE and more, see 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.
>
>
>
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

David Carlson
In reply to this post by R help mailing list-2
No. You have not used it correctly. It was an example. Put your commands between the two sink functions. That will save any printed out put that results from those commands. It will not save attr, but you did not ask how to do that.

David C

On Nov 1, 2017 12:21 PM, Priya Arasu <[hidden email]> wrote:
Hi David,
Thank you for the example.
When I try to use the cat function, I get an error


cat(attr<-getAttractors(net, type="asynchronous"))

Error in cat(attr <- getAttractors(net, type = "asynchronous")) :
  argument 1 (type 'pairlist') cannot be handled by 'cat'

Please let me know, if I have used the function in right way?.
Thank you
Priya











On Wednesday, 1 November 2017 9:32 PM, David L Carlson <[hidden email]> wrote:


Let's try a simple example.

> # Create a script file of commands
> # Note we must print the results of quantile explicitly
> cat("x <- rnorm(50)\nprint(quantile(x))\nstem(x)\n", file="Test.R")
>
> # Test it by running it to the console
> source("Test.R")
        0%        25%        50%        75%      100%
-2.4736219 -0.7915433 -0.1178056  0.7023577  2.9158617

  The decimal point is at the |

  -2 | 510
  -1 | 7631110
  -0 | 9988777333333211
  0 | 01124455557777889
  1 | 00045
  2 | 19

>
> # Now run it and save the file
> sink("Testout.txt")
> source("Test.R")
> sink()
>
> # What is located in "Testout.txt"?
> cat(readLines("Testout.txt"), sep="\n")
        0%        25%        50%        75%        100%
-2.47511893 -0.47919111  0.05761628  0.67403447  1.79825459

  The decimal point is at the |

  -2 | 5
  -2 | 4
  -1 |
  -1 | 432000
  -0 | 87755
  -0 | 4433332110
  0 | 001244
  0 | 55666667777789
  1 | 113
  1 | 5788

> # Success

Depending on your operating system, you may also be able to save the output with File | Save to File.

---------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: R-help [mailto:[hidden email]<mailto:[hidden email]>] On Behalf Of Priya Arasu via R-help
Sent: Wednesday, November 1, 2017 9:57 AM
To: Eric Berger <[hidden email]<mailto:[hidden email]>>
Cc: [hidden email]<mailto:[hidden email]>
Subject: Re: [R] Function to save results

Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the file before starting to run the analysis, so the file gets saved automatically after the script has finished running Priya



    On Wednesday, 1 November 2017 7:53 PM, Eric Berger <[hidden email]<mailto:[hidden email]>> wrote:


Hi Priya,
You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement.You need (possibly) to do:
sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt") net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net, type="asynchronous")
sink()
HTH,Eric



On Wed, Nov 1, 2017 at 4:10 PM, Priya Arasu <[hidden email]<mailto:[hidden email]>> wrote:

Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")


sink()

attr <- getAttractors(net, type="asynchronous")
 Priya


    On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]<mailto:[hidden email]>> wrote:


Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code) sink( "filename" )do something that prints output which will be captured by sinksink() HTH,Eric


On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]<mailto:[hidden email]>> wrote:

Hi,I want the results to be saved automatically in a output text file after the script has finished running.

I used the sink function in the following example, but the results file (output.txt) was empty.

net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function

attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?

Thank youPriya



        [[alternative HTML version deleted]]

______________________________ ________________ [hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/ <https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=veMGHMCNZShld-KX-bIj4jRE_tP9ojUvB_Lqp0ieSdk&m=0lwqkbol4cK6IWihnScmuGPoCwJqLAUtPYFjA8-ZvcE&s=CFc0GZ3acaXstJwZ-4_sa6VyWMYBAefLT8bl5XF5VtY&e=> listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/ <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.r-2Dproject.org_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=veMGHMCNZShld-KX-bIj4jRE_tP9ojUvB_Lqp0ieSdk&m=0lwqkbol4cK6IWihnScmuGPoCwJqLAUtPYFjA8-ZvcE&s=wcRmk52RCDGqEMXMWwXPSmoZZCePwhACPhEVr3JkZtc&e=> posting-guide.html and provide commented, minimal, self-contained, reproducible code.










    [[alternative HTML version deleted]]

______________________________________________
[hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=veMGHMCNZShld-KX-bIj4jRE_tP9ojUvB_Lqp0ieSdk&m=0lwqkbol4cK6IWihnScmuGPoCwJqLAUtPYFjA8-ZvcE&s=pFgUol7cBhhv83zYVjM7DgjhrD3_QSjy-FUEB4ZUH8E&e=>
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.r-2Dproject.org_posting-2Dguide.html&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=veMGHMCNZShld-KX-bIj4jRE_tP9ojUvB_Lqp0ieSdk&m=0lwqkbol4cK6IWihnScmuGPoCwJqLAUtPYFjA8-ZvcE&s=_tTiMicLMGdHIKg3A9nPOpCYxcm_zGZecdMMAxTu7i0&e=>
and provide commented, minimal, self-contained, reproducible code.




        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Function to save results

Rui Barradas
In reply to this post by R help mailing list-2
Hello,

If cat is giving you an error try print(attr <- ...etc...)

Hope this helps,

Rui Barradas

Em 01-11-2017 17:21, Priya Arasu via R-help escreveu:

> Hi David,Thank you for the example.When I try to use the cat function, I get an error
>
> cat(attr<-getAttractors(net, type="asynchronous"))Error in cat(attr <- getAttractors(net, type = "asynchronous")) :
>    argument 1 (type 'pairlist') cannot be handled by 'cat'
>
> Please let me know, if I have used the function in right way?.
> Thank you
> Priya
>
>
>
>
>
>
>
>
>
>      On Wednesday, 1 November 2017 9:32 PM, David L Carlson <[hidden email]> wrote:
>
>
>   Let's try a simple example.
>
>> # Create a script file of commands
>> # Note we must print the results of quantile explicitly
>> cat("x <- rnorm(50)\nprint(quantile(x))\nstem(x)\n", file="Test.R")
>>
>> # Test it by running it to the console
>> source("Test.R")
>          0%        25%        50%        75%      100%
> -2.4736219 -0.7915433 -0.1178056  0.7023577  2.9158617
>
>    The decimal point is at the |
>
>    -2 | 510
>    -1 | 7631110
>    -0 | 9988777333333211
>    0 | 01124455557777889
>    1 | 00045
>    2 | 19
>
>>
>> # Now run it and save the file
>> sink("Testout.txt")
>> source("Test.R")
>> sink()
>>
>> # What is located in "Testout.txt"?
>> cat(readLines("Testout.txt"), sep="\n")
>          0%        25%        50%        75%        100%
> -2.47511893 -0.47919111  0.05761628  0.67403447  1.79825459
>
>    The decimal point is at the |
>
>    -2 | 5
>    -2 | 4
>    -1 |
>    -1 | 432000
>    -0 | 87755
>    -0 | 4433332110
>    0 | 001244
>    0 | 55666667777789
>    1 | 113
>    1 | 5788
>
>> # Success
>
> Depending on your operating system, you may also be able to save the output with File | Save to File.
>
> ---------------------------------------
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
> -----Original Message-----
> From: R-help [mailto:[hidden email]] On Behalf Of Priya Arasu via R-help
> Sent: Wednesday, November 1, 2017 9:57 AM
> To: Eric Berger <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [R] Function to save results
>
> Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the file before starting to run the analysis, so the file gets saved automatically after the script has finished running Priya
>
>
>
>      On Wednesday, 1 November 2017 7:53 PM, Eric Berger <[hidden email]> wrote:
>
>
>   Hi Priya,
> You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement.You need (possibly) to do:
> sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt") net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")attr <- getAttractors(net, type="asynchronous")
> sink()
> HTH,Eric
>
>
>
>
>
> Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt)
>
> net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//attr. txt")
>
>
> sink()
>
> attr <- getAttractors(net, type="asynchronous")
>   Priya
>
>
>      On Wednesday, 1 November 2017 6:54 PM, Eric Berger <[hidden email]> wrote:
>
>
>   Some comments:1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://....etc")2. to complete the saving to the file you must give a second sink command with no argument:  sink()So your code would be (pseudo-code, not actual code) sink( "filename" )do something that prints output which will be captured by sinksink() HTH,Eric
>
>
> On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help <[hidden email]> wrote:
>
> Hi,I want the results to be saved automatically in a output text file after the script has finished running.
>
> I used the sink function in the following example, but the results file (output.txt) was empty.
>
> net <- loadNetwork("C://Users//Priya/ /Desktop//Attractor analysis_all genes//synaptogenesis// regulationof_dopamine_ signaling_submodule3.txt")# First I loaded theinput file for which I want to identify attractors attr <- sink("C://Users//Priya// Desktop//Attractor analysis_all genes//synaptogenesis//output. txt")# used the sink function to save the results from attr function
>
> attr <- getAttractors(net, type="asynchronous")# then ran the script for identifying attractors Is there any function to save the results before setting the script to run, so that results are automatically saved in a text file after the script has finished running?
>
> Thank youPriya
>
>
>
>          [[alternative HTML version deleted]]
>
> ______________________________ ________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.
>
>
>
>
>
>
>
>
>
>      [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see 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.
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.