Monday, May 22, 2017

R-Programming

Reading Table data from Desktop 

File name; Testdata
Source:C:\Users\Dr.D.D.Roy\Desktop\Testdata.txt

R command:

1. test <- read.table("C:/Users/Dr.D.D.Roy/Desktop/Testdata.txt", header=TRUE)

Path direction has been changed from | to /. Header indicates name of column variable.

2. list(test)

List command for display of data. The data has been stored in the array named 'test'

> list(test)
[[1]]
  Price Floor Area Rooms Age Cent.heat
1 52.00   111  830     5 6.2        no
2 54.75   128  710     5 7.5        no
3 57.50   101 1000     5 4.2        no
4 57.50   131  690     6 8.8        no
5 59.75    93  900     5 1.9       yes

Reading no of rows and columns


> dim(test)
[1] 5 6
> str(test)
'data.frame':   5 obs. of  6 variables:
 $ Price    : num  52 54.8 57.5 57.5 59.8
 $ Floor    : num  111 128 101 131 93
 $ Area     : int  830 710 1000 690 900
 $ Rooms    : int  5 5 5 6 5
 $ Age      : num  6.2 7.5 4.2 8.8 1.9
 $ Cent.heat: Factor w/ 2 levels "no","yes": 1 1 1 1 2


Help command
Before we get deeper into the use of R, it is good to know how to seek help when we get stuck. Two functions are illustrated here. If you know the name of a function or the topic, you may use the function help(…) with your function name or topic inside the parenthesis. For example, if you are interested in the function plot(), you can type
> help(plot)

and it will pop-up a help manual for plot function. This can be done more quickly by typing a question mark in front of the function in question.
> ?plot

Sometimes, you may want to find something related to a certain keyword. Then you may find help.search() useful. Function help.search() will search for all the functions that have the word you specified in their help document such as name, title, concept, keyword. For example,
> help.search("sort")
will list all functions that have the word 'sort' as an alias or in their title. The dunction help.search() also has a shortcut consisting of two question marks preceding the keyword (e.g., ??sort). If you want to learn more about the help function, you may type help(help). Besides the official help pages, you can also explore the Internet, which has many resources.

More commands

http://www.personality-project.org/r/r.commands.html





Q1. What is R?





Why Use R?
If you currently use another statistical package, why learn R?
It's free! If you are a teacher or a student, the benefits are obvious.
It runs on a variety of platforms including Windows, Unix and MacOS.
It provides an unparalleled platform for programming new statistical methods in an easy and straightforward manner.
It contains advanced statistical routines not yet available in other packages.
It has state-of-the-art graphics capabilities.
Obtaining R
R is available for Linux, MacOS X, and Windows (95 or later) platforms. Software can be downloaded from one of the Comprehensive R Archive Network(CRAN) mirror sites.
Feedback
I constantly strive to improve these pages. Feedback and suggestions are always welcome! 
- Rob Kabacoff

No comments:

Post a Comment