Everyday R Code (19) – A function example to compare loops and vectorization speed
#to compare speed of 2 methods: loops and vectorization n=10 #generate 100 numbers between 1 and 1000, and then make a 10 by 10 matrix […]
#to compare speed of 2 methods: loops and vectorization n=10 #generate 100 numbers between 1 and 1000, and then make a 10 by 10 matrix […]
Calculation1 Subtract different value from multiple columns b <- matrix(rep(1:20), nrow=4, ncol=5) c <- c(1,2,4) b c for(i in 1:nrow(b)) { b[i,3:5] <- b[i,3:5] […]
Pivot table in R to replace excel Step1 #converting data format using data.table library(data.table) live<-data.table(live) Step2 #finding unique count for each bucket using […]
There are many methods that we used to select questions from tons of survey questions. 1. Correlation If 2 questions are highly correlated with each […]
There are several techniques for text mining. Word Cloud https://www.r-bloggers.com/word-cloud-in-r/ Association rule http://www.rdatamining.com/examples/association-rules k-means clustering https://www.r-bloggers.com/clustering-search-keywords-using-k-means-clustering/ LDA Topic modeling A gentle introduction to topic modeling […]
###########sentiment analysis################ ##use RTextTools package ## this one works well##### #you need 3 files with the following format #positive comment flag like it 0 good […]
If the data set regular have 2 columns ‘ID’ and ‘Answer’, but the ‘ID’ is not unique. That means one ID can have 2 or […]
################################### ####Writing data into excel function######### ################################### #Method one # Write the first data set in a new workbook write.xlsx(Data1, file=”exportedata.xlsx”,sheetName=”USA-ARRESTS”, append=FALSE) # Add a second […]
##Association rule or Market basket library(“arules”) removewords=c(names(termFrequency)[which(termFrequency==1)],’en’,’f’,’nicht’,’es’,’luck’,’giving’,’thought’,’value’,’indeed’,’almost’,’apparently’,’exist’,’d’,’net’,’ture’,’dans’,’des’,’et’,’ne’,’une’,’le’) VerbList=sapply(DATA_.input, function(x){strsplit(x[[1]],’ ‘)}) VerbList=sapply(VerbList, function(x){ Idx=which(x==”” | x %in% removewords) if(length(Idx)>0)x=x[-Idx] else x=x x=unique(x)} ) VerbList=sapply(VerbList,function(x){ paste(x,collapse=’,’)}) temp=which(VerbList==”) […]
# word cloud is easy #we need cleanDescription.r file as follows. It was used to write some similar words into one word. For example, write […]
Copyright © 2024 | WordPress Theme by MH Themes