**manio » R**, and kindly contributed to R-bloggers)

When I say Ease of Use Improved, I mean you can simply copy, paste and run the codes in this post, without referring to other places, without downloading a data file and read it from R. This is how I like a blog article to be. You don’t need to read the whole article. You just need to Ctrl+F what your need and copy the codes there and run it.

I use R in Windows and sometimes Linux. The version is 2.13.0. The following scripts should be applicable to other versions.

### Read a File to a Table

Hmm.. You can’t copy and run this in your system, since you don’t have that file. *congold *is a table, the first argument of read.table() is the path of the file. In Windows, you should use “/” in the path instead of “\”.

### Boxplot

t = rep(c(1,2),c(5,5))

boxplot(d~t)

### Get subset

subset(df,col2==2)

### Find out how many unique items in a list

length(unique(a))

### Viewing Several Graphs

In Windows

In Linux

In Mac

### Delete Columns by Names

df <- df[,-which(names(df) %in% c("z","t"))]

An easier way:

df <- subset(df, select=-c(z,t))

Actually, it is done by selecting the columns you want. So we have the following:

### Select Columns by Names

df[, c("x","y")]

subset(df, select=c(x,y))

### Print out Column Names

names(df)

### Change Column Names

names(df)[[1]]="newNameForColumn1"

names(df)=c("newNameForColumn1", "newNameForColumn2", "newNameForColumn3","newNameForColumn4")

names(df)[which(names(df)=="y")]= "NewNameOf_y"

### Reduction Plot

x = 1:100

y = rnorm(100)

xyplot(x~y, type=c("r","p"))

### Finding out 95%th, 99%th of Each Category

x = rep(c(1,2),50)

y = rnorm(100)

summaryBy(y~x, data=df, FUN=function(x){quantile(x,c(0.95,0.99))})

y = rnorm(100)

aggregate(y~x, data = df, function(x){quantile(x,0.95)})

aggregate(y~x, data = df, function(x){quantile(x,0.99)})

### Get Median of Each Factor in a data frame (each type has many rows)

y = rnorm(100)

aggregate(y~x, data = df, median)

### To count rows or columns

nrow(df)

ncol(df)

### Create empty matrix or vector

### Replace data in data frame

selected = tmp == 2

selected

tmp[selected] = 22

tmp

### Convert Factor to Number

size

as.numeric(size)

levels(size)[size]

as.numeric(levels(size)[size])

### Change the order of colums

df

df = subset(df, select=c(c,b,a))

df

### Order Data Frame

df = df[order(df$b),]

df

df[order(df$c,df$b),]

Too much to organize from my note…

Maybe I’ll pick it up later, nor not….

**leave a comment**for the author, please follow the link and comment on their blog:

**manio » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...