19. Nested Columns, Fluid Rows and Formatting in R Shiny

Опубликовано: 23 Март 2026
на канале: Learn data analytics with us
1,237
6

hello, guys, my name is khan, and actually, in today's video I will talk about formatting the shiny dashboard again uh so for this video I have already created two r code files and I will go one by one and I have given in each r code I have given an example of different formatting styles that you can use in r shiny so let's start with this r code which is named as column nesting that how you can do it so I will open it up

so this is the code file that I have I will maximize it into a separate window so that you guys can able to see it more properly so this is the quad file that I will discuss with you guys and the point not here is that in both of my a court file that I will discuss in today's video I will not be creating main panel or sidebar panels so I will be using the whole browser window as a canvas where I can uh where I can put my things according to the way I want so first I will execute the whole code and then I will show you that what this code is doing and ctrl-a control a and then control enter

so we have constructed a very simplistic dashboard in which uh actually this dashboard is more about formatting so what I have done here is that I have created a one fluid row and then within uh below that I've created another fluid row and but below within that fluid row I have also created uh two nested columns and one you can see that on my right-hand side I have created a cell within that fluid row so I think it's better to go through the cold will be a bit easier for you guys to understand I'm not going to close this window because I will keep soon coming back to this window and I will show you guys that how I am doing it so let's go back to the code so again the first thing that we as we are using shiny a shiny package so I will I upload the shine library and then I have defined a user interface object I am using fluid page and after using the fluid page I have first defined my fluid row so as you can see here the first blue row the maximum width of our fluid row is 12. that's why here you're seeing that the first argument within a fluid row I have seen create a column within a fluid row and I want the whole I just want one column that's why I have to find the width of 12. so if that's why you can see it's starting from one end of the screen to the right end of the screen but suppose if I decrease the column width to 10 so let me close this window now let's see how it looks like if I execute the code let's run app save select it

so you can see that width get produced but I want to be seen on the whole screen that's why I will be using the fluid with the first argument is with you can even write down like this is equal to 12 but I am happy to write down 12 only and then I am using uh argument line in the center that whatever I want to paste in that cell or within that column it should appear in the center and after that, I am writing down the text that I want to write down but within this so if you have a plot or you have a size so you suppose you have a select input or you have any other object you can also write down you can call that object here instead of writing down fluid 12 I have created a very basic so, therefore, I am just writing the text here that print this thing within that column so that's why you can execute it control s run

you can see that fluid 12 is written down here but suppose if you have a graph or a table you can even put that thing here

back to my code so the next thing is the style which is a very important thing when you will be dealing with shiny dashboard formatting so in the style, I'm defining the style for the given column so I am saying that okay give the height so the width you have already defined because if you have inserted a fluid row and then you have defined the width of your fluid row by 12 now you can play around with the height here in the style so I am saying the height is 22 px the background color I want is yellow that's why you are seeing that that row is colored as yellow but let's see if I increase the height here 24 so let's

read on that so as you can see that the width got increased using now the yellow color is appearing here so you can play around with things like this I will make it back to 22.

and now the important thing to note here is that we are still in our column I haven't closed this column yet and below that, I am creating a new fluid row so what will be happening is that it went to re-run it

#nested #columns #fluid #row # formatting #rshiny
R Shiny Playlist:    • Learn Building R Shiny Dashboard with Us  
How to change the styling or look of your R Shiny Dashboard.