Showing posts with label R. Show all posts
Showing posts with label R. Show all posts

Generating a wordcloud of any text - Text Mining in R


Load the below library, if already installed.
If required to install then use the below code:
install.packages("wordcloud")
install.packages("RColorBrewer")

# Generate the WordCloud
library("wordcloud")
library("RColorBrewer")
par(bg="grey30")
png(file="WordCloud.png",width=1000,height=700, bg="grey30") # file shall save in your default directory
wordcloud(d$word, d$freq, col=terrain.colors(length(d$word), alpha=0.9), random.order=FALSE, rot.per=0.3 )
title(main = "Your effort", font.main = 1, col.main = "cornsilk3", cex.main = 1.5)
dev.off()

Check whether data frame has na or not in R

Below is the line of code ...

which(is.na(dat), arr.ind=TRUE)

returns row and column with NA , below is the output


Create data frame for your datasets in R

How to create data frame for data set?

=>
A data frame is used for storing data tables. It is a list of vectors of equal length. You can read data from excel sheet or any table and can create data frame from it.

dat<- read_excel('Data Set.xlsx')
my_data<-dat
df=data.frame(my_data)
View(df) # Can view your data frame.

Check if data frame column is numeric or not in R

 Apply a function to each column of a data frame to check that is numeric or not. If return TRUE means numeric and if FALSE means non-numeric but this logic doesn't give right output incase of data frame


apply(dat, 2, function(x) is.numeric(x))

To check for particular column is numeric or not
is.numeric(Column Name)          or for example                 is.numeric(my_data$SIN_50MM)

7 Stages of Machine Learning - Framework Introduction

Framework Introduction 7 Stages Introduction Stage 1: Problem Definition Stage 2: Data Collection Stage 3: Data Preparation Stage 4: Data Vi...