1276251155734027
Loading...

R Tutorials | Statistics and Data Analysis with R | #rstats

What is R?
R Statistics and Data Analysis
Using R or R-Studio for Data Analysis and Statistics

#rstats


Installing R 

Linux, Windows, Mac

Rconsole, RStudio R online

Packages and Libraries

Basic commands in R

First and foremost, we need to be able to manipulate data in R.

1. Our first action would be to find a working directory or set a new one in R (functions getwd() and setwd() in R). The procedure is the following:

r | getwd() | setwd()






2. Next, we enter our data. In R, we can 1) enter the data manually or 2) load an already existing data file:

1) creating the dataset (function data.frame()) and entering the data manually (function edit()) in R:

enter the dataset manually in r | enter and edit the data manually in r







2) loading a data file in R (reading a .csv or a .txt file) by means of the R function read.table():

load a .csv or .txt file in R
We can enter either the entire address or just the name of the file provided that we have specified the working directory (see above - getwd() and setwd())








3. Having loaded the data file, we need to upload it (or 'attach') to the working memory of R - attach():

upload a file to R | attach a file to R



4. To open or visualise a file in R, we type its name in R:

how to open a data file in r



5. We can analyse the structure of the data file by means of the R function str():

data file structure in R



6. Finally, we can save the data file (e.g. in .csv format) by using the function write.csv():


7. Other important commands in R:
  • to add a variable to a dataset, we can use the command cbind()
          cbind(mydata, weight)
  • to recode a variable, we use the function recode()
          country<- recode(region, '"OECD"=1; else=2; ', as.factor.result=TRUE)
  • to order information in a file in an increasing/decreasing order with respect to a variable, we use the command order():
          mydata[order(-weight),]
  • to create a subset of a dataset, we use the command subset():
          OECD<-subset(mydata, subset=(region=="OECD"))
  • to define a variable as a label variable, we use the function row.names():
          row.names(mydata)<-number


Using R for Statistics


4. Hierarchical Clustering Models (HCM) with R

More info about R as well as other R language tutorials you can find on the homepage of the R programming language - r-project.org as well as on r-bloggers.com, a website which accumulates the knowledgebase of the R programming language all over the net. You are also very welcome to subscribe to the R-bloggers' podcast - http://feeds.feedburner.com/RBloggers

statistics with R 7885954147171997916

Post a Comment

Home item

More links from #glfintech:

#glfintech Newsletter

#glfintech Recommends

#glfintech on Twitter

Statistics


Partner and Clients

Warmboutique

Webstore selling textile goods

Adblock is enabled

Hi! We have detected that you are using adblock on your web browser and take this chance to ask you to pause it just for this site. Time is money and we invest lots of time in the content that we work really hard on, and advertising is the only source of income for this particular project.
Thanks.

No harming software. We promise!