Working with Variables and Data in R (R Tutorial 1.7)

Learn how to check variable types and names and produce summaries in R. You will learn the “$”, “attach” , “detach” , “class”, “levels”, “summary”, and “as.factor” commands. This video is a tutorial for programming in R Statistical Software for beginners.

You can access and download the “LungCapData” dataset from our
Website: http://www.statslectures.com/index.php/r-stats-datasets

OR

Excel format: https://bit.ly/LungCapDataxls
Tab Delimited Text File: https://bit.ly/LungCapData

Here is a quick overview of the topics addressed in this video;

0:01:06 how to use the dollar sign “$” to extract the variable within an object in R

0:02:25 how to call all variables within an object by their name using “attach” command in R

0:03:20 how to un-attach the data in R using “detach” command

0:04:04 how to check the type or class of a variable using the “class” command in R

0:05:04 how to use the “levels” command to ask R what different levels categories are for a factor or categorical variable

0:05:34 how to use the “summary” command in R to produce summaries

0:06:30 how to convert a numeric variable to categorical or factor variable in R using the “as.factor” command

Comments

sujatha gangireddy says:

can i perform this coding by online r-editor? please help me

kerumble says:

These are excellent, thank you very much!

mohamed ahmed says:

Hi, I have a question….. I get “Character” when asking about the class of each of “Smoke, Gender, Caesarian”…. in accordance, I did not get summary for each….. why is that happening?…thx

Christiana Nwoko says:

thanks for this tutorial, i finally have a good start to learning r

nagesh goud says:

Hi Marin, the classes are really awesome… These are really helpful.. .. Do you have any videos where I can read/Learn statistics.

Justin Young says:

Thank you! Just getting started but this is making me feel more comfortable with the language

K SAIRAM REDDY says:

R studio is showing class(caesarean) is a character and not a factor. Can you please say me the difference between character and the factor

Mermaid Lolly says:

Thank you so much for this! I’m studying a Masters degree in Linguistics and now have to use this software for my dissertation. I found it so difficult until I found your videos!

Alberto Ruiz Benitez de Lugo says:

Very very good! Thank you so much!

tingting li says:

Hello,Mike,by learning from your video about RStudio, i find it is very easy to get the knowledge of R language.Thank you and your team very much.Wish you have a good day! I will try my best to get the points.

Badra Sid says:

in the latest rstudio version, there is “import text file” in “Import Dataset”. Only CSV and Excel files are supported….. any comment ?

Maksim Li says:

Man you can open a course on Udemy! I really hope to see some advanced class from you! plz!

diyasini Majumdar says:

I am getting the following error everytime I use plot command.please help
Error in is.data.frame(y) : object ‘growth’ not found

Paulina Lewandowska says:

Thank you very much for your great videos! They are a HUGE help for me, struggling to learn statistics in a right way :)
I wonder if you could advise me something on one problem. I keep getting ‘NULL’ for all columns after calling the ‘levels()’ function, and all materials on R in internet sound like a foreign language to me, I simply don’t know how to solve this :( I tried to attach levels on my own, but then the ‘summary()’ doesn’t reveal more detailed information about the data (like the number of “female” and “male” in “Gender”, etc.). I wonder if there’s something to do about this?

Mohammadhossain Arman says:

Starting a Grad program in predictive analysis this fall.  I have no programming background and this is the software they use for the Stats courses.  Thank you so much for these tutorials!  I’ve been able to following along and mimic you very well.  I feel more confident going into the fall semester.

Raslan Mumtaz says:

> levels(Smoke)
NULL
> levels(Gender)
NULL
> levels(Smoke)
NULL
>
> levels(Gender)
NULL
>

Isaac Cornish says:

If you have a data set that does of have an equal amount of rows (because in an experiment you stopped calculating at a certain point for some of the variables), how do I avoid the error….

Like if I go back to Excel and add 0’s everywhere, that will change the data. Is there like a default (NOT APPLICABLE) type of thing that I can find?

Pedro Fernandes says:

Hi Mike

I’ve not been able to find out how to create lag variables in R.

Can you help me?

Thanks

Neha Pachpande says:

Hello Make,
I am beginner of R and this are very good lectures for beginners. Thanks for sharing such valuable stuff. I have question can you please Ans it:
AS shown in lecture number 7 I found that “types of Class” (Variable type). Its shows Age as “Interger” and LungCap & Height as “Numeric” but when I tried with Rstudio with same example it show me “numeric” for all three variable (LungCap, Age,Height). Why?

Musa Fasih says:

Hey, my Console is showing “character” and not “factor” for smoke, caesarean and gender.

Pratham Amitabh says:

I absolutely love your videos! Thank you :) I just have one question, why does ‘age’ show up as numeric instead of integer for me ? I know I can use as.integer to change that,  but I just wanted to clarify why it show’s up as numeric.

sushant chinchkar says:

Sir, you are doing an awesome job. Videos are proving far better than reading manuals for beginners. Please keep it up. _/_

VJ Robs says:

Great Explanation of very useful stuff in R… Thanks a ton!!!

Swoleja Boii says:

nerd

김중백(정경대학 사회학과)  ­ says:

I am teaching statistics at University; I am using STATA for individual research, but it is too expensive to use in Undergraduate STAT class. Your lecture or R is just awesome. You just use a minimal explanation for lecturing R and it really helps. I plan to suggest this website for students who take my course in advance to be familiar with R, It will really save time and make us happier.Sincerely appreciate your effort !!!

Godson Chikelu says:

Thank you for teaching me the attach command. you are awesome!

Muhammad Nadeem Ferozi says:

HI you have published a great videos and we have learn a lot. Could you please put s video that explain how you could use R by using Tableau??

Geetha Raghukumar says:

Hi Mike,
Your lectures are so clear and easy to follow. I am still at the early stages and when I am trying to start working with the data in LungCapData2, my R Studio is reading the categorical variables gender and smoke etc as character, but when I put in the command for levels of these, it returns it as “NULL” and when I try to summarize, it does not put out the frequencies of the categorical variables. Could you, please, explain, what might be going wrong?
Thanks, GR

Deepak Kota says:

Really good lecture. But I think it’s not the personal preference to use attach, detach, but it is a precaution, because if you are working with a variable “Age”(for instance Age = 8) in this example, it neglects the “Age” column in the working file even though it is attached. For instance if you type mean(Age), it gives 8 instead of mean(LungCapData$Age).

Julian Müller says:

If I use the levels function on my column Group it should say “A” “B”, but it returns NULL. Can someone help me?

Vyshak Kakkat says:

You have some badass tutoring skills! Really appreciate all the effort you have put into making these. Awesome and easy to understand, helped me a lot.

Terry Zih says:

superb!

Badra Sid says:

awesome

Raslan Mumtaz says:

levels command is not working please help me

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours