Let’s learn the very basic things of R


Hello friends, today we will the basics of R. So lets begin….

 What is Package?

A package is a collection or group of objects that R can use. A package may contain function data frame or other objects such as dynamically loaded libraries of compiled code.

How do I load a package?

A R command to load the package is: library(“<package name>”), for example we want to load ggplot2 for this ‘library(“ggplot2”)’.

How do I see the documanetation for a particular package?

A R command to see the documentation: library(help=”<package name>”) or help(package=”<package name>”).

How do I see the help file for a specific function?

A R command to for this is : help(“<function_ name>”) or ?<function_name>

How can  save my work?

You can save all the object and function that you have created in an ‘.R Data’ file, by using the save or the save.image function. It is very important that you remember to include the ‘.R Data’ extension when indicating the file path because R will not add it for you [e.g. save(file=’D:/<file_name>.RData’)].

How can I retrieve the work that I have saved using save.image function?

A R command for this is: load(“D:/<file_name>.RData”)

How can I see a list of the objects or projects that are currently available in my working directory?

A R command for this is: objects() or ls().

How do I remove unwanted objects and functions?

 A R command for this is: rm(object_name1, object_name2, ..)

What is the first thing to check if a function or object is behaving strangely and unexpectedly?

A R command for this is: masked().

NOTE 1 : I will post other basic things in future in next post.

Note 2 : <something>: this means ‘something’ is replaceable with other value

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑