Bar Charts and Pie Charts in R | R Tutorial 2.1 | MarinStatsLectures

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024

Комментарии • 104

  • @marinstatlectures
    @marinstatlectures  10 лет назад +9

    In this R video tutorial, we will learn to produce bar charts and pie charts with R; we will also learn to produce frequency table in R, and customize the plots in R by adding titles, changing axes labels, adding a box around the plot, and many other modifications to these plots. This tutorial explains how to use "table", "barplot", and "pie" functions and "main", "lab", "las", "names.arg", "horiz" arguments. Like to support us? You can Donate ( statslectures.com/support-us ), Share our Videos, Leave us a Comment and Give us a Thumbs up! Either way We Thank You!

  • @kylemccready5081
    @kylemccready5081 3 года назад

    Just wanted to thank you R has been a struggle and my lecturer isn't great at helping during these covid times so thank you.

  • @marinstatlectures
    @marinstatlectures  10 лет назад +1

    You're very welcome, glad we could help! Thanks for watching!

  • @kamilkhel115
    @kamilkhel115 5 лет назад +1

    Good to have you Martin....

  • @jayk4250
    @jayk4250 8 лет назад +1

    Apologies Marin I sorted it out :). I looked at an earlier video to download the text file instead and that definitely works.
    Thank you.

  • @jiahuicai576
    @jiahuicai576 5 лет назад +2

    Great tutorials. I am new to R and your sharing helps a lot thank you so much Martin.

    • @marinstatlectures
      @marinstatlectures  5 лет назад

      you are very welcome @Jasmine Cai! glad you found them useful. Please share these tutorials with your friends and help us reach more people!

    • @jiahuicai576
      @jiahuicai576 5 лет назад

      I made a mistake spelling your name Marin, so sorry for that. Certainly I will share them with my friends they can't afford the miss!!

  • @jeremieskando8926
    @jeremieskando8926 5 лет назад +2

    Great stuff Marin

    • @marinstatlectures
      @marinstatlectures  5 лет назад

      thanks @jeremies kando, Please share these tutorials with anyone who would find them useful!

  • @iliofornasero1547
    @iliofornasero1547 9 лет назад

    Cool! Even the 2nd series is very good and helpful. That means being "customer (trainee)-oriented"!
    Great work, really!

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Thanks Ilio Fornasero , we appreciate you saying that!

  • @jiminbao2256
    @jiminbao2256 9 лет назад

    Really GREAT videos!!! Just start to learn R, and feel your videos are really helpful!!!! Thanks a lot, Marin!

  • @xunzhou8744
    @xunzhou8744 6 лет назад +1

    Hi Mike, many thanks for your videos! In the bar charts, the values on the y-axis are displayed as real values not percentage points, which could be confusing for readers.

  • @lutingye5942
    @lutingye5942 9 лет назад +1

    Thank you for the fantastic job!

  • @fordchung9770
    @fordchung9770 2 года назад

    Thank you!!!!!!!!

  • @the_batman6506
    @the_batman6506 9 лет назад

    It is just WONDERFUL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @ChandanG94805
    @ChandanG94805 8 месяцев назад

    superb

  • @lemyul
    @lemyul 5 лет назад +1

    good stuff

  • @mohammadj.shamim9342
    @mohammadj.shamim9342 6 лет назад +1

    Dear Sir, I know that most of the videos especially in that latter ones are talking about descriptive statistics. In bar charts, I would like to show the mean for two categorical values. but when I do that, it shows me frequency. for example, I would like to show the mean of gas exchange for two genotypes using bar charts. I will really appreciate if you can have a lecture about it.

  • @natalieazevedo
    @natalieazevedo 9 лет назад +1

    Great video!

  • @namnguyentrung4585
    @namnguyentrung4585 9 лет назад +2

    Thanks for sharing

  • @talithaskyegreer2415
    @talithaskyegreer2415 4 года назад +1

    Hi do you by any chance demonstrate ggplot in any of these learning resource playlists?

  • @nukulsharma7711
    @nukulsharma7711 4 года назад

    you are amazing pls make more like this valuabe r programming so thank you very much ,,plz make one or two videos for how to get job in the filed of R Programming and where we can get the job and what type of nature and what about the salary etc..... plz make for us and thank you so much for your valuable teaching style ,, i really want to learn the R software rather than the python

  • @rameshkummam1
    @rameshkummam1 9 лет назад

    Mind blowing explanation sir :)
    Would you help me in below query:
    How to add a respective numerical value over a bar.
    Example:If male count=30 and female count=60.When I am plotting a bar,it should show respective values over the bar.Help is really appreciated.

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi Ramesh Kummam , thanks for the compliment! you can add text onto a plot pretty easily using the *text* command in R. i have a video explaining all of this, so i will direct you there rather than try to explain it all here. you can check out this video: ruclips.net/video/Zx3Nspy8sws/видео.html

  • @zhangjim5833
    @zhangjim5833 8 лет назад

    great work, thanks

  • @sushantkmr
    @sushantkmr 8 лет назад

    Thanks for the awesome tutorial. I request you the share the data to replicate the statistics on the same data set.

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      you're welcome +Sushant Kumar ! under the video, if you click on "SHOW MORE" you will see a link to download the data, as well as more detailed info on the video, and at which time points in the video certain topics are discussed.

  • @sameersachan7598
    @sameersachan7598 7 лет назад

    Hello Marin , Followed all previous videos on R and wanna thanks for sharing the knowledge . U Rock !!.
    Here regarding Bar Chart , how to create one with multiple variables ?

    • @marinstatlectures
      @marinstatlectures  7 лет назад +1

      you're welcome +sameer sachan ...following this video, we have 2 other videos in this series, on for making side-by-side box plots for comparing groups, and one for making stratified box plots. you can check out those two other videos for more on making box plots for multiple variables.

  • @pratibhacdri
    @pratibhacdri 6 лет назад

    Hi Martin, thanks for your tutorials. these are very useful. I am completely naive to R so wanted your help, as i am unable to give the right command. I have two variables as group and concentration and wanted to plot the barplot using mean values for concentration (on y axis) and with groups shown on x axis. please help me with the right commands as i got stukced here.Thanks in advance.

  • @anissurianiibrahim444
    @anissurianiibrahim444 9 лет назад

    thanks

  • @arpitsharma7695
    @arpitsharma7695 8 лет назад

    Hello Mark.
    Great Videos.Learning A LOTTTT through them.
    One Question though-
    @3:30 you show the use of names.arg=c("Female","Male")
    NOW,
    If we switch this to names.arg=c("Male","Female") the label does change but then it is wrongly labeled.
    How can we make sure that the label is as we show in the names.arg command and the actual value also changes accordingly.
    Any link that can answer my question would also help.
    Thanks

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +Arpit Sharma , that is correct...using the *names.arg* just tells R what to label the axes, but it will not change the order in which things are plotted. do change the order that they are plotted in, you can do the following:
      i will assume that you have a vector named "x", and it is a *factor* in R, with 3 levels (a, b, c). by default, R will plot them in that order. suppose that you wanted to change the order to have "b" plotted first, then "c" and then "a". to do so, you can use the following command:
      *x

  • @saysongkhamsayavong525
    @saysongkhamsayavong525 7 лет назад

    Hello Mike,
    I have watched your video in R that it is very useful for me. so, i would like to know how to make a chart of cross tabulation of land use change during 2000 to 2010 for example.
    Year 2000
    Forest Rubber Paddy
    Year 2010 Forest 162,577 402 1,117
    Rubber 16,788 192 836
    Paddy 1,553 27 2,338
    Thank you in advance.

  • @Henpukacaemblu
    @Henpukacaemblu 4 года назад

    Could please tell me if you know how to display values of observations on pie graphic (or percentage). Thanks.

  • @sebastienlozano742
    @sebastienlozano742 8 лет назад

    Hi, thank you very much for the tutorials. Is there any option like names.arg = c("Name1","Name2") for pie charts ?
    Thanks in advance

  • @ragethewolf
    @ragethewolf 8 лет назад

    Hi, Thanks for the help in understanding how to create a bar chart..
    However, need your help in understanding how to adjust width in R as I'm new to the world of programming.

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +ragethewolf , you will have to play around with the *space*, *width*, and *xlim* commands to find the right values, depending on the number of bar in your plot. here's a simple example with just 2 bars, and you can modify this to your needs. Consider making a barplot of *x

    • @ragethewolf
      @ragethewolf 8 лет назад

      +MarinStatsLectures It worked thank you so much watching and learning from your videos currently will bug you some more if I have more doubts :P

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      glad to hear it did the trick ragethewolf !

  • @jemu776helps2
    @jemu776helps2 7 лет назад

    I spent the whole day doing R, but struggled. Please help. If you make a chart in excel for two variables, how would you graph it on a bar and pie chart (example, x-axis, countries (qualitative), y-axis-total amount of chocolate consumed(quantitative)-my question is different but very similar to this). Any help greatly appreciated.

  • @immigrationIQ
    @immigrationIQ 10 лет назад

    Excellent video
    please give me some inputs on how to make such videos tutorials
    is there any specific software tools

    • @marinstatlectures
      @marinstatlectures  10 лет назад

      Hi Sudhakar Paul , thanks! theres many ways to make videos like these. the first thing you'll need is screen-capture software. we use Adobe Captivate, Camtasia, or Snagit, depending on the video were making. but there are others that will work just as well. we also use Photoshop and Powerpoint at times as well. Of course, many other software will do the trick just fine. hope that helps you get started. good luck ;-)

  • @paulcap9688
    @paulcap9688 4 года назад

    Hi, thanks for the videos. Just wondering, why is it that when I type in "class(Gender)" do I get the response "character" rather than "factor" ? Sorry if it's a dumb question

  • @yilmazbingol6953
    @yilmazbingol6953 6 лет назад

    prob.table(count)===table(Gender)/725

  • @ariaseeva4226
    @ariaseeva4226 10 лет назад

    Hi I am new to R
    I need Help ON load multiple data file such as 001.csv ... 332.csv in R and how to loop the file number 001 -> 332 in R

  • @alisaber502
    @alisaber502 Год назад

    When I want to see the class of LungCapData it results like this: "data.frame"
    Also it shows the class of Gender like this: "character"
    What should I do?
    please help

  • @hodemary1322
    @hodemary1322 3 года назад

    Hello Sir,
    I'm having error working with the LunCapData. When I run function with any of the column names it returns error. Eg. class(Age) or mean(Age[Gender=="female" ] ) Thanks.

  • @sanjayboga4791
    @sanjayboga4791 6 лет назад

    Sir, I couldn't be able to open Box Plot on Rstudi. What package I need to install. Can u suggest me what r all the packages I need to install for this tutorial.

  • @nsengajado3188
    @nsengajado3188 6 месяцев назад

    How to compute return of financial data in r

  • @LucasReis71
    @LucasReis71 6 лет назад

    What if I get the data from database? I mean, I have done what you did with the table command with a count and group by in sql, but I'm not able to show it in a barchart.

  • @KishoreOlii
    @KishoreOlii 10 лет назад

    Nice tutorial.
    Hello Marin, I need one help.
    I have a excel file of 50,000 rows and 11 columns.
    I need to draw pie chart using the above data in a webpage. How to do that?
    Can you help please?

    • @marinstatlectures
      @marinstatlectures  10 лет назад

      Hi Kishore Olii having 11 columns means you should have 11 variables. you can make a pie chart of a variable by using *pie(table(VariableName))*, after having attached the data, and know ing the name of the variable (which you can check using names(data)), replacing "data" with the name of the data you have read in.

  • @UPPERKEES
    @UPPERKEES 6 лет назад

    LungCapData was introduced earlier? This is the first video of this playlist..

    • @marinstatlectures
      @marinstatlectures  6 лет назад

      this video is tutorial 2.1...there is a whole "series 1" of videos that come before this. i have created a few different playlists, that combine different sets of videos (e.g. series 1 is a playlist, series 2 is a playlist, ...., all of the videos are on a complete playlist, etc, etc. so there may, at times, be something i say which refers to a video outside of a given playlist and/or series. hope that helps...

  • @rabinkc831
    @rabinkc831 8 лет назад

    I have data for different yield of wheat at two levels of fertilizers. now how do I make a bar graph for yield V fertilizer levels?

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +Rabin KC , you'll want to make side-by-side box plots, one box plot of yield for each of the fertilizers. bar plots are for categorical variables, so you wont want to make one of those. i show how to do that in the following video (here, i make box plots of lung capacities for males and for females, so same idea as yours): ruclips.net/video/U64yNvlhv9I/видео.html

  • @nqddn
    @nqddn 2 года назад

    Hi all, what if I want to go further by classifying male/female in relation to smoke yes/no? Can anyone help me on this? Thanks!

  • @amirkadir6743
    @amirkadir6743 6 лет назад

    hello, sir how we can detect there anomaly in our dataset. Thanks in advance

  • @nilanjanjoshi9027
    @nilanjanjoshi9027 9 лет назад

    Hi,
    How can I set different bin sizes in same mosaic plot? I have data ranging from 0 to 50000. Many entries are decimal values and very less entries are above 10000. For now I can loose the outlying data.
    Please guide about this. Thanks in advance.

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi +Nilanjan Joshi , iv'e answered your question in the other place you posted it as well...but here's the answer again. first worth noting is that the bar chart is for categorical variables, and the variable you describe here is numeric. so, you will have to convert it to a categorical variable first, before you can make a bar plot. i have a video showing how to change a numeric variable into a categorical one, so i will direct you there to see how to change it, so that you can produce a bar chart: ruclips.net/video/EWs1Ordh8nI/видео.html

  • @AkashKumar-vc5yl
    @AkashKumar-vc5yl 7 лет назад

    Hello Sir,
    when I am trying to make the pie chart, it is saying that x must be positive although all the entries are positive, I even tried to make a pie chart from its absolute value but still it is displaying the same message. Kindly suggest me something regarding the same

    • @marinstatlectures
      @marinstatlectures  7 лет назад

      Hi +Akash Kumar , if yo let me know a bit more, i may be able to help....i can't really know what the error is without knowing the commands you are entering, what "x" is, etc...
      in general, the command is: *pie(table(x))* , where "x" is a categorical variable/factor...

  • @josecurcio416
    @josecurcio416 9 лет назад

    I have a problem making the table. Below my data appears the number 1 below each value

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi Jose Curcio , can you clarify your question for me and i can try to help you out? I'm unclear on what you mean when you say that "below your data the number 1 appears below each value"

  • @jemu776helps2
    @jemu776helps2 7 лет назад

    also how did the 358 and 367 appear?

  • @jayk4250
    @jayk4250 8 лет назад

    Hello Marin. I have an issue with downloading the LungCapData. I clicked on the excel file under "Show More" and then downloaded the file onto Excel. Then I typed LungCapData

  • @dhruvd8725
    @dhruvd8725 8 лет назад

    what if i want different colors of bar in barplot?? :)
    how should i change the 'col' argument in the barplot() function?? :)

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +Dhruv Dangwal , just set the *col* argument to have multiple colours, e.g. assuming you have 3 bars, and you want them to be red/blue/pink, use *col=c("red", "blue", "pink")* (note, you can also use numbers for colours, col=c(2, 4, 6))

    • @dhruvd8725
      @dhruvd8725 8 лет назад +1

      MarinStatsLectures thanks sir!! :)

  • @lucasallori
    @lucasallori 7 лет назад

    Hello Marin, I am using the barplot graph with the command beside=TRUE. But when I do that the x axis stay in a descontinuos manner. What can I do to make the x axis continuous?

    • @marinstatlectures
      @marinstatlectures  7 лет назад

      Hi +Lucas Henrique Allori Glauss , can you clarify your question? the bar chart is for a categorical variables, so there isn't a way to make it continuous....so i think something in your question is not coming across clearly...

    • @lucasallori
      @lucasallori 7 лет назад

      Sorry about that, let me try again. Whem we create a legend in plot, we can add a box using the command bty="O" or "L". I wanna do this for my graphics, I wanna put lines in the axis side 1 and 2, like a "L". I read in some place the command type="L", but it dosen't works here. sorry one more time, I hope u can understand now :)

  • @b11918
    @b11918 7 лет назад

    i have a excel with 5608 records when i am plotting the graph its only showing ibb.co/iJT2fa(image snapshot)
    its not showing the graph how to reolve it ?

  • @saurabhtosawad2237
    @saurabhtosawad2237 9 лет назад

    Hello,
    When I put in the statement class(Gender/Age/or any other object)
    I get the output as object not found, even though the table has been attached. Is it because of the separator function? Because when I put in names(LungCap) it gives me an output Gender.Age. Lungcap. Height.
    Please advice.

    • @marinstatlectures
      @marinstatlectures  9 лет назад

      Hi +Saurabh Tosawad it sounds like you have not *attached* the data? you either need to do this, by entering the command *attach(LungCapData)*. or, if you don't attach the data, then you have to use the $ to extract the variables, (e.g.) *class(LungCapData$Gender)*
      i explain the use of the *attach* command in the earlier intro videos, but the main thing is that you must either use *data.name**$**variable.name* anytime you want to call on a variable, or you can *attach* the data and then call on the variable names without using the $.
      i explain the use of "$" vs. "attach" in this video here: ruclips.net/video/1BcGnHwUT6k/видео.html

    • @saurabhtosawad2237
      @saurabhtosawad2237 9 лет назад

      +MarinStatsLectures Hello Marin, After playing around a little with the syntax I realized something:
      -> When I do not give the sep = "\t", the variables are imported separately. Whereas when I do give the sep function, it is concatenating the variable tables in the imported data.
      This should not happen! But for the time being I am able to get around the barplot, mean, and attaching the file to the workspace. Appreciate your insightful videos and replies!

  • @rockstarvarun1995
    @rockstarvarun1995 7 лет назад

    Object 'Gender' not found....Why? What is wrong with my RStudio...I have linked my .csv file with it too :(

    • @marinstatlectures
      @marinstatlectures  7 лет назад +2

      you have to either attach the data using $attach(data.name)$ or use the $ to extract the variable, e.g. *table(data.name$Gender)* . in one of our first videos on "Working with Data in R" i explain the use of the $ vs attach and all that stuff, so check that out for a more detailed explanation...

    • @malluk4127
      @malluk4127 6 лет назад

      table(LungCapData$Gender)

  • @travel_geek_banglore
    @travel_geek_banglore 8 лет назад

    Hey Marin, I am unable to save the LungCapdata set in my Mac. Did we need microsoft excel for that? Because with Numbers i am unable to store the data set with .csv extension. Could you please help on that.

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +Flora Priyadarsini , I'm not sure exactly why you are having trouble with this, but it wont have to do with Mac. I'm also using a Mac. you should be able to save the file as a .csv file just about anywhere (eg) you can open and save it in any text editor as well, not just in Numbers.

    • @travel_geek_banglore
      @travel_geek_banglore 8 лет назад

      MarinStatsLectures thanks dude. I am able to access that .txt extension

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      good to hear Flora Priyadarsini !

  • @Analytics121
    @Analytics121 4 года назад

    where is the link to download the data for practice

    • @marinstatlectures
      @marinstatlectures  4 года назад

      you can find the dataset (Lungcap Data) here statslectures.com/r-scripts-datasets

  • @jrippee05
    @jrippee05 8 лет назад

    You have allot of knowledge about R but don't forget who your audience might be.

  • @shrion3128
    @shrion3128 5 лет назад

    how do you combine two barplots into one plot

    • @marinstatlectures
      @marinstatlectures  5 лет назад

      Hi, we have a separate video showing how to make stacked or clustered bar-lots, so this should answer your question... you can check that out here: ruclips.net/video/rl1tB9p3FLg/видео.html

  • @ikramsghaier5476
    @ikramsghaier5476 8 лет назад

    Hi can anyone help me to group a barplots ?? ANY HELP I'LL BE EXTREMELY GRATEFULL

    • @marinstatlectures
      @marinstatlectures  8 лет назад

      Hi +Ik ram , we have another videos showing how to make grouped bar plots...stacked, or side-by-side...you can check that out here: ruclips.net/video/rl1tB9p3FLg/видео.html

  • @zae5pm
    @zae5pm 7 лет назад

    where is pie chart %