Publications by Hossein Kermani

Factors

31.05.2021

Factors Hossein Kermani May 31, 2021 Creating factors In R, factors are used to work with categorical variables, variables that have a fixed and known set of possible values. To work with factors, we use forcats package. To create a factor we must start by creating a list of the valid levels. tweet_types <- c( "News", "Fun", "Quotation", "Comme...

2679 sym R (1108 sym/13 pcs) 2 img

Functions

29.05.2021

Functions Hossein Kermani May 29, 2021 Basics Writing functions has several advantages over other types of writing code in R.For instance it helps coders to avoid repeating themselves. Other benefits are: You can give a function an evocative name that makes your code easier to understand. As requirements change, you only need to update code in ...

3785 sym R (282 sym/3 pcs)

Strings

23.05.2021

Stringr Hossein Kermani May 23, 2021 Working with strings stringr is a powerful package to work with strings. First, two important points to be considered. This packages uses REGEX to identify and match patterns in a string. You could refer to REGEX handout to read more about them. Of particular significance is that stringr uses strings to repre...

4468 sym R (1687 sym/18 pcs)

REGEX

22.05.2021

REGEX Hossein Kermani May 22, 2021 REGEX Beside regular regexs, e.g., ordinary sequences; there are some special characters which do something different from their regular job. For instance, . points to any alphamutric character. When a string includes on of them, we should escape them by adding a . Thus, it is a case with stringr package. This...

2903 sym 1 img 1 tbl

Import/Export data in R

20.05.2021

Data Import/Export Hossein Kermani May 20, 2021 Data import with readr On of the best packages to import data is readr. First, we should install it. install.packages("readr") library(readr) readr has multiple functions to read different type of files. Here, I am concerned with reading CSV files. To this, we should use read_csv(). The first argu...

6669 sym R (950 sym/8 pcs)

N-gram Language Models

20.05.2021

N-grams Hossein Kermani May 21, 2021 What? N-Grams are a simple class of Language Models (lmS). LMs are models that assign probabilities to sequences of words. With this, we can predict the chance of emerging a word in a given position, for instance the last word of an n-gram given the previous words. An n-gram then is a sequence of N words: a 2...

2383 sym 4 img