14. File Input (fileInput) option in R Shiny

Опубликовано: 28 Октябрь 2024
на канале: Learn data analytics with us
4,534
38

in this video, I will discuss How to upload a file in R Shiny Dashboard by the user through the user interface. as the as you can see on your screens too that this dashboard is about how to upload files in shiny dashboard through the dashboard so i have created this button which is input file button but before that i also have created two options that that in this dashboard you can upload to kind of taps two kind of data csv or tab delimited data so first the user have to tell okay is it a csv file or a tab delimited files i'm uploading csc file then i'm browsing it so i will go this is the data set that i am looking for so i have tab delimited data and csv there are two different data set so i will suppose if i choose data underscore csv open so you can see here what's happening here is that when you can use this button that which is this function from which allow us to a load the data sets into dashboard is named as input file so actually when you use input files the main thing it will capture is this thing that it will create this table which will be having the data name data size data type and data path and once we will be using the from this input file we will be using this data path to retrieve this data set which is then i'm showing it here so in this video i will show you guys that how you can create input file function that will allow you to upload data into shiny and then i will be using and then once i will be a lot the data after that i will i'm showing it here in a tabular form you can do different kind of other analysis too on the file that you have uploaded in dash through the dashboard and again here i can show you guys that if you uh if i rerun it and i want to import tab delimited data so first like that now i am going to select tab browse it so this is my tab data tab limited data open it so you can see that then in this we have data related to the four questions and this data is about a survey a hypothetical survey data so let's see and start making our codes which will allow us to create a similar dashboard close it close this

so the first thing is that for this video I will be starting with this input file which is uh kind of a blank uh dashboard

i will maximize it in a separate file so actually this is a kind of a blank dashboard as you can see that we don't have any sidebar panel functionalities don't have any main panel the shiny server is empty so it's just a blank dashboard that i have in this code and then i will keeps on adding code in this file to show you guys that how i can you can upload the data into a dashboard so first i will execute it ctrl a and ctrl enter as you can see this dashboard is blank and now what i will do i will start a start adding functions in this code so the first thing is that you guys remember i will be creating a radio button in my sidebar panel so so if for for the user so that they're able to select which data type they are they are going to upload into the dashboard so i'll be using radio and within the radio button the first thing as you can see i'll be using the input id and then i will be giving the label to my radio button and finally what are the choices i'm giving within this radio button so the id that i want to give is suppose i am calling it as data underscore t so t for type coma i will be labeling it as

select the data type you are uploading okay and the last thing is that what are the choices that I want to give so I want to give two choices csv or tab-delimited so I'll be creating a vector

I'll be saying okay csv is equal to the csv is equal to comma actually csv will be it will be written down as a label and the actual value will be this comma and then the second option that I want to give is tab okay equal to

so for the tab, I will be giving the tab because I will be calling this thing when I will be using a function read on the table so this is our radio button so the next thing we have to add is uh that we need to use some sort of function which will allow us to upload the data into the dashboard for that we will be using a new function which we have never used in our previous video which files import as you can see this file input is a shiny function which will be giving input id label so input even you can select if I go to input id you can say see that the arguments that we can give is input id label and even we can give that if you want to select multiple files but in this video, we will be selecting just one file

so the first thing is that label id which I want to give so for this the id that I want to give is data underscore file so f for the file again you can name it whatever you want there is no need to write of data on this graph for you so the next thing is

#file #input #rshiny

R Shiny Playlist:    • Learn Building R Shiny Dashboard with Us