Presentation on demonstrating function "sink" in R
Ashu Guru
Author
03/07/2019
Added
538
Plays
Description
Presentation on demonstrating function "sink" in R
Searchable Transcript
Toggle between list and paragraph view.
- [00:00:00.360]Many time in our we would like the output to go to a text file or an external file
- [00:00:06.398]rather than being printed onto the console.
- [00:00:10.280]This may be needed because we may want to share the output or e-mail it to somebody
- [00:00:15.600]or many times also use another application with the output.
- [00:00:19.400]This can be done in our using a function call which is called a sync and let's
- [00:00:24.712]take a look.
- [00:00:25.520]So the first step is I'm going to set my working directory and I set it to a
- [00:00:30.453]certain folder and let's define a new vector.
- [00:00:33.400]So I'm defining a new vector, I'm calling it A and it has to strings
- [00:00:38.920]hello and world as elements and then 1, 2 and three as elements.
- [00:00:44.120]So let me just print the output on the screen.
- [00:00:47.080]So it says it basically prints the vector console or the screen.
- [00:00:51.920]Now with the help of a sync command, I instructed R that whatever is printed
- [00:01:00.857]on the console from this statement onwards should be saved in a file called
- [00:01:09.678]my output file .TXT.
- [00:01:12.520]And since I was working in my working folder that I defined up here,
- [00:01:17.914]this file will be created in this folder.
- [00:01:21.400]So now if I print a again, we don't see anything on the console
- [00:01:26.983]because the output has gone to that file.
- [00:01:30.840]I'm going to print it two more times.
- [00:01:33.880]And then now I want that to close the file handle.
- [00:01:38.400]So to do that, I say sync with the empty parameter list.
- [00:01:45.840]And what it has done is that now my output from the RF commands is back onto
- [00:01:52.346]the console.
- [00:01:53.360]So one more time, if I print a, it's back to the console that I'm working
- [00:01:59.055]with.
- [00:01:59.680]And now let me show you the file that it wrote to and here is the output in my my
- [00:02:07.498]output file .TXT.
The screen size you are trying to search captions on is too small!
You can always jump over to MediaHub and check it out there.
Log in to post comments
Embed
Copy the following code into your page
HTML
<div style="padding-top: 56.25%; overflow: hidden; position:relative; -webkit-box-flex: 1; flex-grow: 1;"> <iframe style="bottom: 0; left: 0; position: absolute; right: 0; top: 0; border: 0; height: 100%; width: 100%;" src="https://mediahub.unl.edu/media/10752?format=iframe&autoplay=0" title="Video Player: Presentation on demonstrating function "sink" in R" allowfullscreen ></iframe> </div>
Comments
0 Comments