Everyday R code (7)

October 15, 2016 lilo 0

#If some code does not work, we need to figure out if it is because some library is not loaded. Like filter, we need dplyr […]

Everyday R code (6)

October 15, 2016 lilo 0

# R is simple to do data analyst work. If you want to write complicated loop and agrithem, that would be another story. Here is […]

Everyday R code (5)

October 15, 2016 lilo 0

#This is the most commonly used R code at work everyday. #read data from data.txt file and data2.txt file PP_C<-read.delim(“data1.txt”,header=T,sep=’\t’,comment.char=””,quote=””,row.names=NULL, stringsAsFactors= FALSE ) CES<-read.delim(“data2.txt”,header=T,sep=’\t’,comment.char=””,quote=””,row.names=NULL, stringsAsFactors= […]

Everyday R code (4)

September 15, 2016 lilo 0

#otherwise, we usually write it into a flag column this way, before we pivot it into excel and using excel pivot table there to make tons filter […]

Everyday R code (3)

September 14, 2016 lilo 0

  #excluding some rows, need to write ‘!’ in front of everything, because the expression df1$id %in% idNums1 produces a logical vector. To negate it, […]

Everyday R code (2)

September 9, 2016 lilo 1

#filter test<-c(1,4) control<-c(2,5) data2<-filter(data, type %in% c(test,control) & freq!=1) #rank based on ID, for the same ID, choose one record of it data$value<-seq(1,nrow(data)) #get a […]

Everyday R code (1)

September 8, 2016 lilo 0

Importing Data #call commonly used libraries library(RSQLite) library(plyr) library(dplyr) library(data.table) library(reshape) #Importing Data #Importing .txt file data<-read.delim(“skill.txt”,header=T,sep=’\t’,comment.char=””,quote = “”, row.names = NULL, stringsAsFactors = FALSE) […]