Importing , Checking and Working with Data in R | R Tutorial 1.7 | MarinStatsLectures
HTML-код
- Опубликовано: 23 авг 2024
- Importing Data, Checking the Imported Data and Working with Data in R; learn how to import a dataset into R, How to make sure data was imported correctly into R and How to begin to work with the imported data in R; Find the free Dataset here: (bit.ly/2rOfgEJ)
👍🏼Best Statistics & R Programming Language Tutorials: ( goo.gl/4vDQzT )
►► Like to support us? You can Donate (bit.ly/2CWxnP2), Share our Videos, Leave us a Comment and Give us a Like or Write us a Review! Either way We Thank You!
►In this R video tutorial, we will learn to use read.table function (which reads a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file), and some of the arguments such as header argument and sep argument.
►We will learn to use file.choose function to choose a file interactively
►We will discuss how to use Menu options in RStudio to import data into R
►and we will also learn how to check the imported data to make sure it was imported correctly into R using the dim function to retrieve dimension of an object and specify the number of rows and columns of the imported data, the head function in R (head() function), which returns the first or last parts of a vector, matrix, table, data frame and will let us see the first several rows of the data, the tail function in R (tail() function) to see the last several rows of the data in R, the double square brackets in R to subset data (brackets lets you select or subset data from a vector, matrix, array, list or data frame) , and the names function in R to get the names of an object in R.
►►Practice with Dataset: statslectures....
►► Watch More:
►Export Data from R (CSV , TXT and other formats): bit.ly/2PWS84w
►Getting Started with R (Series 1): bit.ly/2PkTneg
►Graphs and Descriptive Statistics in R (Series 2): bit.ly/2PkTneg
►Probability distributions in R (Series 3): bit.ly/2AT3wpI
►Bivariate analysis in R (Series 4): bit.ly/2SXvcRi
►Linear Regression in R (Series 5): bit.ly/1iytAtm
►ANOVA Concept and with R bit.ly/2zBwjgL
►Linear Regression Concept and with R bit.ly/2z8fXg1
► Intro to Statistics Course: bit.ly/2SQOxDH
◼︎ Table of Content
0:00:07 How to read a dataset into R? we will use read.table function to read a dataset into R and save it as an object
0:00:27 How to access the help menu in R
0:01:02 How to let R know that the first row of our data is header? we can use header argument to let R know that the first row of our data is header
0:01:14 How to let R know how the observations are separated? we will use sep argument to let R know how the observations are separated
0:02:03 How to specify the path to a file in R? we can use file.choose function to specify the path to the file in R
0:03:15 How to use Menu options in R Studio to import data into R
0:05:23 How to prepare the Excel data for importing into R
0:06:15 How to know the dimensions (the number of rows and columns) of the data in R? we will use the dim function to know the dimensions of the data in R
0:06:35 How to see the first several rows of the data? the head function in R let us see the first several rows of the data
0:06:45 How to see the last several rows of the data in R? the tail function in R let us see the last several rows of the data
0:07:18 How to check if the data was read correctly into R? we can use the square brackets and subsetting data to verify that our data was read correctly into R
0:08:21 How to check the variable names in R? in this video, we will use the names function to check the variable names in R
This video is a tutorial for programming in R Statistical Software for beginners, using RStudio.
Follow MarinStatsLectures
Subscribe: goo.gl/4vDQzT
website: statslectures.com
Facebook:goo.gl/qYQavS
Twitter:goo.gl/393AQG
Instagram: goo.gl/fdPiDn
Our Team:
Content Creator: Mike Marin (B.Sc., MSc.) Senior Instructor at UBC.
Producer and Creative Manager: Ladan Hamadani (B.Sc., BA., MPH)
These videos are created by #marinstatslectures to support some courses at The University of British Columbia (UBC) (#IntroductoryStatistics and #RVideoTutorials for Health Science Research), although we make all videos available to the everyone everywhere for free.
Thanks for watching! Have fun and remember that statistics is almost as beautiful as a unicorn!
In this video tutorial, we will learn to use various functions and arguments in R and menu options in Rstudio to read the data into R. You will also get familiar with functions that would help to verify if the data was imported correctly into R (e.g number of rows and columns, names of the objects, etc). Practice with this free dataset: (statslectures.com/r-scripts-datasets); After learning how to import data into R, watch our next video to learn how to export data out of R (csv, txt, and other formats) (bit.ly/2PWS84w); Like to support us? You can Donate (bit.ly/2CWxnP2) or Share our videos with others
8 years later these are still the best R tutorials ever. Thank you very much!
This is a great example of how tutorials on youtube should look! Thank you!
thanks +Berin Tabaković !
OMG, five mins of this video is 100 times better than my prof 2 hrs lecture
Great Tutorial, I was really impressed with the clarity and quality of the video. I learned more here than I learned in class.
This dude is saving my life with his clear and simple explanations
A perfect example of how a tutorial should be like. thumbs up!!!!
thanks +Sreejesh Mohanan !
Where has this R program been all my life. So much nicer than working with data in just Excel
yeah, it's a pretty powerful software, eh +Michael heslar ? Excel has its place, but not really useful for data analysis....and R has really come a long way over the past 10 years!
Thanks man. You make the world a better place by lifting us all up. this is bigger than youtube tutorials, you are actually benifitting lives in so many ways
thanks, we appreciate hearing that!
Thanks a lot Julie! We put a lot of thought into how to lay them out best to make it as simple as possible to learn. Thanks for watching!
Thanks a lot for these tutorials!!! They are so useful and easy to follow!!!
you're welcome Maria Cecilia Santos Popper !
I love the work you did on these videos. so easy to follow, great job mate!
Thanks +obinna okechuku !
Hi William,
Glad that you found these videos useful. I have included the links to the dataset in the video description ( "about" section right under this video ) so you can access and download the dataset from there. Hope that helps.
Your R series is the best one ever.....Thnx a lot for your amazing tutorials!
thanks +Mohammad Gendy , we appreciate that!
Thank you.
We UoPeople students love your videos. It is super helpful ^^ .
Hi Kaizer,
I have included the links to the dataset in the video description ( "about" section right under this video ) so you can access and download the dataset from there.
The illustration is awesome. I don't know why but I got mentally excited sometimes when learning the class....
You're welcome Yi An ! it makes us very happy to hear you say this!
Thank you so much, your lectures are very clear and easy to follow, even for me,a chinese.
that's great to hear +子衿卿卿 !
thank u !!!!
best tutorial ever seen in youtube, coursera or even in the college!
Great videos and great tutorial. I was struggling to understand these concepts but now I am feeling relaxxxxxxxed
Best R tutorial video online, thanks!!!
Thank you for short and clear notes on r. From India.
Sitworld Solutions you're welcome
Marin... Thank you very much. You are doing a great great great job for help people to have a grasp on R
thanks +Badra Sid, we appreciate that!
Thanks for the tutorials ! they are very informative and helped me understand R and its capabilities.
Great stuff! Very easy to follow hacking this into R myself, whilst you speak! And exactly what I need! Cheers, Sven
good to hear +Sven Cammerer !
Great Video right there. Simple and straight to the point. Good job Mate.
thanks +mukong meh !
Thank you for the sharing your knowledge in a very simple and easy way to learn.
Jess.... how pratical and didactic you are! I can follow u very easy, Congrats!
thanks, appreciate that :)
Thank you for the brilliant job you have done. Very excellent and helpful videos for me getting into R.
You're welcome Howard Z , happy to hear you're finding them useful!
Keep spreading the knowledge. I really appreciate your efforts.
These videos are so incredibly helpful! Thank you so much for uploading them :)
You're welcome SuperYayyyyyy , glad you find them useful! thanks for watching!
Thank you, it is clear and simple to understand :)
hi sir martin! i am taking a masteral degree in information management. Your tutorial is a big help. thank you!
you're welcome, we're glad to hear that!
Great Tutorial. Thanks for providing it..!!
you're welcome +Kishore Kumar !
Thanks a bunch! I was struggling to understand these concepts.
Thanks a lot for these wonderful tutorial series. I would really appreciate if you upload some tutorials on analyses of big data (metagenomics or transcriptomics or metabolomics).....once again thank you very much for all the tutorials.
thank you sir, easy to understand and please add more complicated programming videos based on R
Cool and amazing way to teach R ......👍👌🙏🙏🙏
thanks :)
Best TUTOR I have ever seen online
Thanks Avishek Pandey !
Thanks alot!! I found 1.4 - 1.6 a great way to get started.
Muchas gracias. I appreciate you taking your time to answer me, i am going to try your suggestions. Greetings Ike
no problem, happy to help. good luck.
Great Job Marin ... Thank you so much.
I really have to thank you. I was learning on coursera and it is not as interactive as how you show it. I really enjoyed this first video. I like to do things hands and practical so you have made it so much easier for me. thanks a lot.
You're welcome IKE KENNETH , we're happy to hear you're finding our series of videos useful!
Do you guys have a tutorials on writing different functions.
Not at the moment. i'm teaching mostly applied statistics courses right now and creating videos for my classes, so less emphasis on stuff like writing functions. we do plan to create those in the future, but first we will work on videos for generalized linear models (logistic regression, poisson regression, survival analysis, etc) as well as how to deal with missing data. hopefully we can have those up on RUclips by the summer.
Ok. Thank you so much for what you guys do.
You're welcome IKE KENNETH . and thanks for saying that, we really appreciate it!
These are amazing! You are going at such a great pace! i love how you explain everything, and do short reviews of what we learned in old videos. clear voice, no accent makes it easier to understand as well (if you are canadian like you and i)! R seems like a scary place, but it is amazing how codes can be so specific, yet so powerful!
Great job Mike! Thank you very much!
These have been so helpful! Thanks you
you're welcome +Blerina Idrizi !
great video! wish I'd had this a week ago when my columns weren't separating.
Good Tutorial, now I am getting started!
great work sir. I am from india. i really appreciate ur work.
good to hear, thanks +shubham swami !
excellent tutorials. much appreciated.
Prof,
We still await your r videos on time series n Bayesian analysis/mcmc.
Wen I learn that from u, I will consider myself r literate coz I will be able to analyse lots of hydrological data in my possession without the requirement of having to learn any other modeling package....
Happy n blessed new year 2015!
You made my year 2014.
God bless.
Amimo meshaq
Hi meshack amimo ,we are happy that you are finding our videos useful. as I've mentioned before, we make these videos in our spare time in order to serve some of the courses that I am teaching; we make these videos available to public for free as many others can make use of them as well. these videos are built on one another and have a flow to them in a series, and the topics you request are more advanced, and not where our series of videos is at yet.
truly amazing. SUBSCRIBED!
Thank you so much
thanks +Rod Fish , appreciate that!
Hello Mike. I enjoy watching your tutorial videos. It would be helpful if you could make the datasets available so I could follow your video instructions.
Hi Wisdom and Peace , thanks! you can get the datasets from the description section of the videos (right below the video, click on the "show more" and you'll see links there). you can also download them from the "about" section of our channel's page.
thank you very much Marin!!!!!!!! it is very helpful
thumbs up! Thanks for your tutorials!
thanks +Janos Leier !
Very helpful! Appreciate your effort!
Fantastic tutorial. Do you also have videos on a beginner project in R? To better hone one’s skill.
thank you a lot for your tutorials! :) very helpful
you're welcome +Christiana J. , we're glad you're finding them useful!
great job mate... i would love to watch all your videos... better thn ANY fu*k*ng online tuts available out there.. i wl donate someday soon aftr i get the job thru ur videos.. wish u can make videos on SAS , Python, SPSS
Omfg,this channel is awesome!
Thank you!
thanks +Bromoteknada , we appreciate that!
It is so useful for R beginners such as me.
Thanks Yonglin Zhuo ! We have a link to the data in the "About" section of the video, as well as in the "About" section of our Channel.
Thank you, I have found the dataset
Your videos are so good.
thanks +bukenyafz4 !
Appreciate your lectures very much.
One comment you call a backslash a slash. I do not know why. "\t" = backslash t
they are so useful :3 Thank you share it with us :3
great tutorial and great effort
thanks +Mohamed samir !
very good explanation
Thanks +Guddu Sharma !
Thanks for simple tutorials! Do you have tutorials over Statistics also? I'm learning it for analytics.
Vinay Thakur
I like your tutorials,easy to follow
Great tutorial
Hi, just a quick question re the usefulness of R.I am under the impression R is good at handling "large" data. By large, I mean in excess of 1million records, ie something Excel has problems with.What I don't understand is your preferred method of getting data into R.You state you like Excel (so do I!), so you typically get the data in Excel, save it as a csv then import it into R using read.table.But that would mean the size of your data you want to analyse is limited to what Excel can handle? Suppose you want to analyse data that contains 2million records (and is currently stored in Access or SQL Server). how would you import that into R?
Great video! very easy to follow along.
But how do you include different view windows in the console?
Dear Mike, thank you for great videos, in command: read.table(file.choose(),header=T, sep="\t"), I think the sign is a backslash \ not slash, please correct me if I am wrong.
Hi, I was wondering if you have a video on working with Panel Data in R and how to correctly import it from Excel?
Excellent videos! Very helpful for beginners . Can I request you to post DEA i.e. data envelopment analysis with r video?
thanks dulalR Nepal. sorry, but i don't know DEA well enough to create a high quality tutorial for it.
awesome! Thank you sooooo much
You're welcome Yuan Faye !
hey martin. How did the variable x appear in your work space upon using the 'names' function?
Thank you very much for the work you have put into this! These are great videos - very clear and easy to follow and they are making R accessible to me when I was struggling with it before. I would like to work on the LungCapData file to follow your videos and reproduce the work - is it available?
Thank you very much
you're welcome abbas8646
thank you for your help
you're welcome +Maxamed Abuukar !
first of all thanks a lot for these amazing videos, you are making my life much easier...I do have a question though for this chapter. You showed us how to change a variable from numeric to factor, but you used a variable outside the example table. I have a table where one variable is time point which are numbers (1, 3, 10 weeks), but I want to use it as a factor. How do i convert a variable in my table from one format to the other and tell R to save the table with this change?...Thanks a lot again for your great help!!!
Hi Paula Martinez , thanks for the comments! you can make the change as follows...i will refer to your data set as "data" and the variable you want to make into factor "time". if you have attached the data in R, then you can just submit the command: *time
Hi Mike! Great videos. I am following all the course in you channel.
One short question: How can I sort this Data1 (all the columns) by age?
Hi Maximiliano Contreras . there's lots of different ways you can get that done. you're gonna want to use either the *order* command or the *sort* command. i prefer the order command, as its more flexible in what it can do. for help on the command, type *?order* into R to see all that it can do. here's what you'll want to do:
This will create a new variable called *Data1.ordered*, which will be ordered by age...
*Data1.ordered
MarinStatsLectures Thanks again!!
best_R_Tutor
What is the difference between read.table and read.csv or read.delim??
Hey, I have a question about transforming values (for example equity, debt etc.).How can i transform those values that were saved as characters into numeric values?
Please share the dataset, the link in the description doesn't work
Thank you, MarinStatsLectures. That was helpful, especially the file.choose option. It takes away the pain of remembering the file path. Does if work if I use R console instead of RStudio?
Hi Ramanan R. V. , yes, all commands will be the same using just the R console. the only difference with RStudio is that it takes the console, the plot window, etc, and organizes them a bit more neatly.
Thanks!
thanks good guide
Thanks Mike for some great learning material.
... got the same issue as Chris Powley (3 ds ago) that the 'Smoke', 'Gender' and 'Caesarean' are being converted to CHARACTERS instead of as FACTORS in my LungCapData (which I have imported as csv - not able to import as txt.). Any suggestions?
So many thanks!
Hi +Carsten Grube , you can tell R to treat it as a factor instead...just use *Gender
Hi Mike. Hope you are doing well. I am trying to do some cost-effectiveness analysis for my PhD project. Can you suggest some R packages for cost-effectiveness analysis? I am also interested in meta-analysis with R. Thank you.
Yiqun Lin thanks, things are good, hope you're doing well, and progressing with your work! those aren't areas of specialty for me, so i can only recommend things second hand, but not based on my own personal experience with them. for cost-effectiveness, id say to check out "BCEA" or "ICEinfer" , and for meta analysis, there are tons of packages that do different things...check out this link, as it explains a bunch of different packages, and what meta-analysis tools they have: cran.r-project.org/web/views/MetaAnalysis.html
Thanks, Mike..
great job mate! your videos. how can we import txt files if there are any missing values and when in few rows there are some colums more and less.
can i get your emial id
Thank so much
You're welcome Nam Nguyen trung !
Thanks for the great tutorials, I find when I import the text file it coverts the factor fields to characters. How can I make it important same way as your example?
Hi +Chris Powley , you can tell R to treat it as a factor instead...just use *Gender
Great tutorials!! I can't access the data
3:30 is where it shows data import from a text file.
What if I need to separate by more than 3 separators? How can that be done? Levels and sublevels.
Sorry Prof, If the values are separated with the";" how would i manage it. Cuase in this video you speak about ",", and "tab" used for delimitate. Thkls
Hi +3 Foss , in the *read.table* command, you will use *sep=";"* . (e.g.) *data
AH, OK THKS PROF.
happy to help 3 Foss
Great.
hi i am getting junk text in front of my dataname when i print data for example if the first header is qualification it is showing i... qualification can u help. thanks
Where can i get the Tab delimited data file that you are working on?
Hey Marin, I have a problem. When I import your file LungCapData, the variables Smoke, Gender, Caesarean are in a character form. I cannot calculate means here. How can I change this to a factor variable (0,1)?
Also, Mine only says 10 observations. Does anybody know why that might be. I just downloaded this program so I'm thinking it might have to do with no having all the plugins I need or something.