hello, guys, my name is khan, and actually, in today's video we will discuss that how you will be able to publish your app so what does it mean by publishing is your app that once you publish your app you can share the link with other users and then they don't need to have uh r in their computer they will be using it as a web page so I will start in this video we will mainly discuss that how be publishing your app but before that I will like to show that how you can add a counter which will be counting that how many people view your app so we will start by making the encounter and then after that, I will show you how to launch the app so I will be using the quad file that I have used in my previous video so I will open it up
so this is the core file that we have created I will open it into a separate window so that you guys can able to see properly so this is the very basic code file that we have created I will control I will execute it first to show what it's doing
so actually this part of this code profile was about that how you can format things how you can create nested rows nested columns uh in r shine so what I will do I like to add a line below this table that okay so if the people view this app there will be a title here or text here which will be saying that the number of people views the app one two or three it keeps increasing as the people keeps on viewing my app so let's see how we can do it so the first thing that I will start with this server currently in our server we don't have anything so I will start with creating an output id and my id will be named as count and doublet just make
text function
and within the rendered text I will be using the if condition because for this counter I will be creating an r data file so what I will do I will be saying if there is no file exist
so what is the file so I'll be just naming it as my counter
dot or data
you can name this file whatever you want so it's not necessary to be counted on my counter and then I'm saying that if this file doesn't exist then create an object named as
and then after creating this object I will be saying save it to
servicing save
this counting object
into my this, I will name the file save this my counter door data
so the first time when you will come here will be no one view the file so if this file doesn't exist it will come here and it will convert it to one so the first so if the file doesn't exist and you run the first to run the app first time it will be saying counting and make it as one because you will be the first viewer and then save this file and then close that closed here
so as you can see this is the prefix closing for this condition and then I'm saying else if this file already exists so this file will already exist for those you who are viewing after the first time so the people who are the government so if someone is doing the viewing the app after two or three viewers so this file will exist this file will not exist for the first viewer so I will be saying else what are the statements I want so as
a file already exists then load the file
file the name of the file is
this
and once after loading the file I will be saying make it as plus one hour
plus one so now if this file already exists it will increase it by one and then I'm saying save this file
so I can use the same code from above
now saving an updated copy which will be adding one by one then each new visitor will come and here the thing is that I also want to show uh I want to paste something in my dashboard that how many people view this app for that I will be using a paste
function
and here I will be stating the number of people
the app
space and after that
here but here I will also copy this thing again and I will also mention it within when the file didn't exist and we are saving it for the first time because the first viewer will also come to know that he's the first viewer here so let's rerun this app but before running this app I also have to put it into the output text so I'll go into my user interface
which is
so now let's see what happens so if I read on it so this is the first time I have run this now so I think I got an error so let me check why the error would happen
actually, the error occurred because of a very
I have to mention here the file is equal to the file this is the file name will be in here again
this is the first time I open this app so you can see that actually, I have already run it that's why I'm seeing that number of people use the apps too
#publish #shinyapp #web
R Shiny Playlist: • Learn Building R Shiny Dashboard with Us