Everyday R code (8) logistic regression
# we have a data set with all numeric variables (some of the columns only have 0 or 1). And we want to run a […]
# we have a data set with all numeric variables (some of the columns only have 0 or 1). And we want to run a […]
#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 […]
# R is simple to do data analyst work. If you want to write complicated loop and agrithem, that would be another story. Here is […]
#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= […]
#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 […]
#excluding some rows, need to write ‘!’ in front of everything, because the expression df1$id %in% idNums1 produces a logical vector. To negate it, […]
#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 […]
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) […]
Copyright © 2024 | WordPress Theme by MH Themes