Manipulate your data. Data wrangling. R programmning for beginners.
If you are learning to use R programming for data analysis then you're going to love this video. It's an "R programming for beginners" video that deals with manipulating data. What does that mean? Well, before you can do any statistical analysis of your data, you'll need to get it into the right shape. You'll need to select variables and filter rows. You'll need to recode observations and sometimes create new variables.
In this video you'll learn about the mutate function to create new or change existing variables and the if_else function that can be used for conditional changes to observations. If you are learning data science, statistics or are doing quantitative analysis in your research using R, then this is an important step in your management and analysis of data. This video forms part of a series that includes, explore your data, clean your data, summarize your data, manipulate your data, visualize your data and then analyze your data with statistical and modeling techniques.
A huge thank you to Nested Knowledge for supporting the creation of this video. Nested Knowledge. Create and share your Systematic Review on the Internet nested-knowledge.com/
Пікірлер: 139
Get my FREE cheat sheets for R programming and statistics (including transcripts of these lessons) here: www.learnmore365.com/courses/rprogramming-resource-library
I must say it, I was learning stuff on the internet for that past 20 years, I am 36 yo now. I have never seen better tutorials than yours. I feel you can teach anyone anything. Thank you very much for your work sir.
@RProgramming101
Ай бұрын
Wow, thanks! (that's the best feedback I've ever received) - much apprecaited.
Just wanna thank you for the great quality of the videos, im a Brazilian economist and i am looking to develop my habilities in data analysis. I'm doing the edx program of DS offered by the MIT, and honestly, your videos are better, a lot more content in less time, thanks you again, and keep up the amazing job if u can!!! cheers from Brazil!
@RProgramming101
2 жыл бұрын
Thanks for the feedback!
By far the best R tutorial I've seen on KZread. Man you are truly awesome. Your videos have made me understand R better than anything I've ever seen.
Awesome! Can't wait for the next installation.
Finally you come back we waiting for almost 3 weeks 😻
@RProgramming101
2 жыл бұрын
haha - more to come soon Max (I promise) :)
These tutes are fabulous. Thanks for taking the time to share your knowledge in such a great format. If you it fits in with your plans, a video on R equivalent of excel v-lookup to merge datasets and ways to compare two data frames would be super helpful. Thanks again.
Another concept made super duper easy... I am stealing this expression from you by the way. Thanks a lot. Really appreciate your content Dr.
Great tutorial as usual. I'm waiting for the analysis series. Thanks so much for your great videos.
Brilliant as usual. Go on👍
Great stuff. I enjoy your vids. Always learn something new.
Thank you! You made R programming so easy to understand!
I'm here to sincerely thank you for these tutorials. I didn't know where to start with R. Then I came to KZread and found your channel. I'm almost done with ALL your videos and I'm really grateful for them. So Thank You Sir! Also: Tried to use the select() function with gapminder; failed. Took it as a challenge to know what the problem was...found that I need to run library (dplyr) together with library(gapminder) :)
Grrat video. Congrats
Cool video. wow!
Thank you, I have learnt so much from this video
Excellent video! I have become spoiled by your presentations and I for one have a difficult time watching other videos that lack the elegance and detail you give. Too many videos of "those who shall remain unnamed" don't bother explaining what they are doing and often supplied broken data sets. By the way. I noticed that you did not save your data until the end. That might be worth pointing out to beginners since if you run the code and then do View() - then it appears that the changes one has made are not their (and they are not since they are not saved). Finally, great explanation on the pivot_wider/pivot_longer function. In reference to the latter I found it easier to simply type ....pivot_longer(!country, ...) and simply omit the country column rather trying to figure out how many year columns I had. Please keep these coming! Happy New Year and Thanks!
Your videos are great!!! Thank you so much for teaching R!
Thank you mate. Learnt a lot 😀
Clearest, most succinct R tutorials I've seen on youtube. Great job sir!!
@RProgramming101
2 жыл бұрын
Wow, thanks!
Thank you for these tutorials!!!! They are amazing. I wouldn't have been able to finish my thesis without them!!!
@RProgramming101
Жыл бұрын
Happy to help! You are so welcome!
I am blown away! I have used Python but this is the most comfortable language easier than I thought thank you! Keep up the good work!
Man I have been waiting a lot for your videos to learn R Programming Because I couldn't find many resources as informative and structured as yours. Please keep posting Lots of Love from India ❤️
@RProgramming101
2 жыл бұрын
Thanks!!! More to come soon :)
i just love your videos more than anything else.
Thank you so much for this! Your videos are so detailed and easy to process.
Recently finished my Google Certificate in Data Analsysis and your videos really helped me when it came to my project. I think my project was pretty rubbish but was pleased to get it done using R so thanks. One point of major frustration was getting graphs to look how I wanted them to look. I ended up having to use re-order as they did not accept the arrange () function. I have sincd learned it has something to do with factors. The other thing I found difficult was figuring out the different types of data - continous versus discreet and how and when to use what graph, and why didn't R Color Brewer work for one graph but not the other ahahhhh. haha, Fond memories. Anyway, I am subsribed and look forward to future videos.
@RProgramming101
2 жыл бұрын
Thanks for the feedback Dan :)
loved and enjoyed every single second ....
Like first and then watch! Because you know it's high quality :)
Great videos. Thank you
Best best best best!!! Thank you so much!
brilliant tutorial series Greg, thanks so much for putting this together and making it fun to learn R Studio
@RProgramming101
2 жыл бұрын
Thank you for the feedback. Glad you enjoyed it!
Excellente~! Thanks -
Awesome tutorial 🤘🏻
thanks for your help
Good Quality!
It would be a great help to learn the lubridate package for working with date/month/year or time series data from you. Quite a few KZreadrs tried to explain it, but it was hard to follow them. Your tutorial videos are more succinct and informative and give us a great starting point. I wish we get to see your videos on this topic.
Thank you. Thank you, Thank you. Awesome stuff!
@RProgramming101
2 жыл бұрын
You're very welcome!
nice one
Great video!! Supper helpful. I have already learned a lot from you
@RProgramming101
2 жыл бұрын
Thank you for the feedback! Cheers
You are amazing
@RProgramming101
2 жыл бұрын
Very kind of you to say (thanks)
I love Greg's tutorials.
@RProgramming101
11 ай бұрын
I'm glad my videos resonated with you and you found it relatable. Thanks for sharing your experience.
Taking notes every time. Great content!
@RProgramming101
Жыл бұрын
Awesome! Thank you!
You vedios are Lovely and amazing sir
I love this guy! He has helped me so much
@RProgramming101
Жыл бұрын
Happy to help! Thank you for the feedback.
Great job! Thank you!
@RProgramming101
Жыл бұрын
Glad it was helpful! Thank you too for watching!
Your videos are so amazing, informative and easy to understand that my professor from University of Leeds is recommending to see videos from this channel. The only thing I believe might be helpful is that you're speaking quite fastly and to understand properly whatever is being said I have to slow the video speed. There might be people who don't know about doing that. Cheers boss!
I´m from Brazil and i learn a lot with you! Thanks for the classes!
@RProgramming101
Жыл бұрын
Glad to hear that! Thank you for the feedback.
One more thing... Please explain why you prefer to work with a long format rather than wide. Thanks!
you are amazing
"boomshakalaka" 😃)) Of course, I like it) Thank you for this great tutorial lesson. 😉 These videos are good guideline for me.
@RProgramming101
Жыл бұрын
Glad you liked it! Thank you too!
Very clear presentation. Thanks for this series 😀
@RProgramming101
2 жыл бұрын
You're most welcome
Please keep making videos for intermediate and advanced R coding level. I already feel my skills were upgraded because of this series of videos that you made for data analysis. Keep it up! Subscribed :)
@RProgramming101
Жыл бұрын
Thank you for the suggestion. Glad you enjoyed it!
Great video. Can't thank you enough.
@RProgramming101
2 жыл бұрын
Glad you enjoyed it!
Really helpful content, thank you so much,.
@RProgramming101
2 жыл бұрын
Glad it was helpful!
Excellent!!
@RProgramming101
10 күн бұрын
thanks
Thank you for the video
@RProgramming101
Жыл бұрын
Thanks for watching!
Thank you for making such wonderful videos. Very Informative
@RProgramming101
2 жыл бұрын
Glad you like them! My pleasure!
Did you ever make the visualise and analyse videos for this series? This has been very helpful in my journey in learning R. Keep being awesome !
Great video!! Supper helpful. I have already learned a lot from you. But could you please make a video on manipulating dates? For example, If you have a data frame with a date variable column with rows in the form day/month/year, how can you obtain year, month, epidemiological week, day of the month, and day of the week from the date?
Wonderful Tutorials. Be Blessed as I am making significant progress to earn a data science certification. Your vids are an integral part of my journey. Cheers
@RProgramming101
Жыл бұрын
Wow Raphael - what a nice thing to say (thanks!!) Glad you like them!
love this one! I need to do this presentation that contains some long tables; the choice for presentation is Xaringan, is there a way to make the table spread across slides? say u use the iris data set and want to do some summary introduction a few words and inline code and then start the table to continue across slides until it is fully loaded in the presentation. I hope you can help out as this is an important one and currently I do a lot of manual work. Thank you in advance mate.
I am always looking for a credible source to learn skills from, and your videos completely fit the bill Sir!
@RProgramming101
11 ай бұрын
Thank you for engaging with my content and being part of the community. I appreciate your support.
Thanks for your great R programing tutorial, your tutorial helps me to understand more in deep understanding of the R programming, just bit currious for the pivot_longer() first arg for the column names from 2:13 range are the actual years from 1952-2007 from a wide_data data frame that you create before, which we change it to name_of_year = "year" in the secound arg of the pivot_longer() am i right.
I hope you are going to make more videos. They are easy to understand, important and life saving:))
@RProgramming101
2 жыл бұрын
Glad it was helpful! Thank you :) For sure - More to come!
Perfect video, watched 2023.11.10
Teaching myself R after grad school to prepare for a job and I am almost angry that it is so much easier than SAS?? Why did I spend so many hours agonizing over SAS when this existed. Thank you so much your videos are extraordinarily informative
@Zane_Zaminsky
7 ай бұрын
I feel your pain. I am a SAS statistical programmer who started with SAS in 1983. So now, 40 years later and retired, I still use SAS. But I started with R a few weeks ago. And I love it! For yours truly, at least I can reconcile that neither R nor Python existed back in 1983. 😉 There are plenty of jobs that mention R and SAS, so knowing both will be a definite feather in your cap.
Excellent
@RProgramming101
Жыл бұрын
Thank you! Cheers!
Shift-Control-M is a lifesaver! I love your videos but I wish you had given the trick earlier
Could you please make a video on using t-test, chi-square test, ANOVA and regression, please? Would be so much appreciated !..
Thank you!
@RProgramming101
11 ай бұрын
Thank you so much for watching and leaving a comment! I appreciate your support.
I'm really enjoying the videos on this youtube channel. Congratulations! I redid (the pivot_longer) with invented data for exercises and it worked, but I had a problem when it was a little more complex. For example, if I want to organize a table, where there are paired columns. How can do I do it? I would like to create 3 columns (not 2 as this video), like "Hospital", "condition" and "values". If I do it 2 times (pivot_longer), the resulting values are repeated in the table Thank you anyway
Thanks Greg. I sadly cannot find the 'gapminder' dataset, neither can I install a package with that name.
Hi, you are of great help to me. Do you have videos on extreme gradient boosting and comparison to logistic regression?
Thank you so much for all your work, this channel is super helpful! The main difficulty I have is finding some of the information again when rewatching videos - would it be possible for you to timestamp sections of the videos for easier searching?
@RProgramming101
Жыл бұрын
So nice of you - thanks for the great feedback - Much appreciated !!
Great tutorials thank you, I'm learning a lot! However I am having a problem with renaming and recoding the variables. The recoding and renaming codes works fine when I run them, however the "glimpse" and "view" functions will not show the renamed and recoded variables (unless I attach them to the end of the codes with pipe operators). How can I get around this so that the renamed and recoded variables are permanent? Hope that makes sense... thanks!
Hi very useful videos, thank you! How do I create a new variable to tag unique observations with 0 and then duplicated observations with 1, 2, 3, etc ?
Is there an easy way to use "if else" if you want a new variable to be constructed from two variables? Variable 1 is scored 1, 2, 3, 4, 5, and 9. Variable 2 is scored 1100, 1200, 1300, 10000, 9. Variable 3 is 1 if Variable 1 is 2 and Variable 2 is 1300 otherwise Variable 3 is 0. Also 9 is missing for both variables 1 and 2.
4:10, for the rename part, why the "conservation" won't change to "conser" when typing the "View()"? I know for typing "glimpse()" the "conservation" did change to "conser".
@estelleghost
Жыл бұрын
I'm having the same issue!
Thanks a lot for the great videos! Can you please make videos about Shiny packages and how it is used in the medical research!
@RProgramming101
Жыл бұрын
Great suggestion! Thank you for the feedback. Glad you enjoyed it! 😀
@davidispiryan5689
Жыл бұрын
@@RProgramming101 Thank a lot Sir. ))
Love your teaching and your work am very grateful it has helped a lot but please next time tell us to set library(tidyverse) conflict_prefer( dplyr:: filter(), dplyr::lag(), ) sw % Felt like pulling teeth, because my filter function refused to work and my output refused to print. when we got to the filter section. dplyr was being masked by r base
Wish my prof was as clear as you are
@RProgramming101
2 жыл бұрын
Thank you for the feedback. Glad you enjoyed it!
Very useful video. The drumming music in the background is very distracting though
@RProgramming101
Жыл бұрын
Thank you for the feedback :)
How can we add a header (life exp) to the wide data?
Do you share the R codes that you use in these videos? I'd like to download
I tried to run the pivot_longer code but kept getting this error message in console > long_data % + pivot_longer(2:13, + names_to = "year", + values_to = "lifeExp") Error in UseMethod("pivot_longer") : no applicable method for 'pivot_longer' applied to an object of class "NULL"
Thank you, bli could pivots wider, but could not pivot longer as it said the function did not recognise an object of class Null. Could you please help me here, thanks Dr. Greg
@S24W2
Жыл бұрын
Update: I created the object long_data before I viewed it and it worked, strange
at 16:06 can you also arrange by name?
How can I rename multiple headers at once.
Thanks for the easy pissy squessy way you explained everyline
@RProgramming101
Жыл бұрын
Much appreciated !! Thanks
'recode' and 'if_else' functions are almost the same right?
Is it ok to use spread and gather to switch the data format between long and wide?
@RProgramming101
2 жыл бұрын
yes indeed - a lot of people use those functions
When I try to perform: msleep %>% rename("conserv" = "conservation") I get this error: Error in rename(., conserv = "conservation") : Some 'from' names in value not found on 'x': conserv Does anyone know why this is happening? 🤔
I need a cheat sheet.
@RProgramming101
Жыл бұрын
hi there - you can get the Cheat Sheet at the end of my Data Visualisation video. Thanks
You skipped the part where you install gapfinder. I find that extremely frustrating.
@RProgramming101
Жыл бұрын
Sorry
@kiernanpark-egan2528
Жыл бұрын
@@RProgramming101 No, I should be sorry. I just got introduced to coding and had no idea what I was doing, and I panicked. Seems that the step was very simple. Sorry.
The music behind you is distractingly bad
Commented with a similar issue that I experienced in the last video in this series. At 21:55 when going through mutating and recoding, this isn't working for me on the same dataset. Anyone else have the same issue and able to shed any light? size_of_brain %>% mutate(brain_size=recode(brain_size,"large"=1,"small"=2)) I have no idea what this means but this is what I get.. Error in `mutate()`: ℹ In argument: `brain_size = recode(brain_size, large = 1, small = 2)`. Caused by error in `recode()`: ! unused arguments (large = 1, small = 2) --- Backtrace: ▆ 1. ├─size_of_brain %>% ... 2. ├─dplyr::mutate(., brain_size = recode(brain_size, large = 1, small = 2)) 3. └─dplyr:::mutate.data.frame(., brain_size = recode(brain_size, large = 1, small = 2)) 4. └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by) 5. ├─base::withCallingHandlers(...) 6. └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns) 7. └─mask$eval_all_mutate(quo) 8. └─dplyr (local) eval() Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.