When we deal with large data then the problem of printing the data or output of the analysis arises. Due to this problem, it becomes difficult to have a look at our complete but it can be avoided. Before importing any large data or performing any calculation that may result in big output, we can change the limit of the printing by using max.print option.Example> set.seed(1) > sample(1:1000, 555555, replace=TRUE)Output[99681] 223 62 961 304 5 262 519 357 415 167 855 523 268 486 [99695] 370 916 703 179 813 833 177 154 72 789 924 918 486 647 [99709] ... Read More
The aspect ratio of a chart can be changed in ggplot2 and this will be useful if we want a smaller image of the chart. Sometimes, we don’t have large space where the chart will be pasted therefore this functionality becomes useful. Mostly, in research reports we see charts that are of small size, hence R becomes helpful to create charts that can be pasted in the desired space. This can be done with the help of theme function.ExampleConsider the below data frame −> set.seed(100) > x df library(ggplot2)Creating the plot with aspect ratio 4/3 −> ggplot(df, aes(x))+ + geom_bar()+ ... Read More
The warning “removed n rows containing missing values” occurs when we incorrectly specify the range of the values for X-axis or Y-axis. We can this range in ggplot function using scale_x_continuous(limits=c(?, ?)) for x axis and scale_y_continuous(limits=c(?, ?)) for y axis. If the range will be larger than the actual data range then there will be no warning otherwise, we will get the warning for the number of missing values.ExampleConsider the below data frame −> set.seed(2) > x y df library(ggplot2)Creating the plot with Y-axis limits from 0 to 5−> ggplot(df, aes(x, y))+ + geom_point()+ + scale_y_continuous(limits=c(0, 5)) Warning message: ... Read More
Since visualization is an essential part of data analysis, we should make sure that the plots are created in a form that is easily readable for users. For this purpose, the facets in a bar chart helps us to understand the factor variable levels for another factor. To create such type of bar chart, we can use facet_grid function of ggplot2 package.ExampleConsider the below data frame −> set.seed(99) > y class quantity df library(ggplot2)Creating the plot with class on X-axis and y on Y-axis without any facet −> ggplot(df, aes(class, y))+ + geom_bar(stat="identity")OutputCreating the plot with class on X-axis, y ... Read More
There are some annoying messages we get while loading a package in R and they are not useful until and unless we are not loading a new package. Since these messages looks like outputs they might be confusing especially when we are analysing string data. Therefore, we must get rid of them.An example of message while loading BSDA package:>> library(BSDA)Loading required package − latticAttaching package − ‘BSDA’The following object is masked from ‘package:datasets’ −OrangeHere we have some messages while loading the package BSDA but we might not be interested in those messages if we are sure that package is installed ... Read More
Here we will see what is the balanced binary search tree. The binary search trees (BST) are binary trees, who has lesser element at left child, and greater element at right child.The average time complexity for searching elements in BST is O(log n). It is depending on the height of the binary search tree. To maintain the properties of the binary search tree, sometimes the tree becomes skewed. So the skewed tree will be look like this −This is actually a tree, but this is looking like a linked list. For this kind of trees, the searching time will be ... Read More
In this section we will see what is Brent’s Method related to open addressed hashing. This method is a heuristic. This attempts to minimize the average time for a successful search in a hash table.This method was originally applying on double hashing technique, but this can be used on any open addressing techniques like linear and quadratic probing. The age of an element x, is stored in an open addressing hash table, is the minimum value i, such that x is placed at A[xi]Brent’s Method tries to minimize the total age of all elements. If we insert an element x, ... Read More
In this section we will see what is Double Hashing technique in open addressing scheme. There is an ordinary hash function h´(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) when the space is not empty, then perform another hash function to get some space to insert.$$h_{1}(x)=x\:mod\:m$$$$h_{2}(x)=x\:mod\:m^{\prime}$$$$h(x, i)=(h^{1}(x)+ih^{2})\:mod\:m$$The value of i = 0, 1, . . ., m – 1. So we start from i = 0, and increase this until we get one free space. So initially when i = ... Read More
In this section we will see what is quadratic probing technique in open addressing scheme. There is an ordinary hash function h’(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) and attach some another part with it to make one quadratic equation.h´ = (𝑥) = 𝑥 𝑚𝑜𝑑 𝑚ℎ(𝑥, 𝑖) = (ℎ´(𝑥) + 𝑖2)𝑚𝑜𝑑 𝑚We can put some other quadratic equations also using some constantsThe value of i = 0, 1, . . ., m – 1. So we start from i ... Read More
In this section we will see what is linear probing technique in open addressing scheme. There is an ordinary hash function h´(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) and attach some another part with it to make one linear equation.h´(𝑥) = 𝑥 𝑚𝑜𝑑 𝑚ℎ(𝑥, 𝑖) = (ℎ´(𝑥) + 𝑖)𝑚𝑜𝑑 𝑚The value of i| = 0, 1, . . ., m – 1. So we start from i = 0, and increase this until we get one freespace. So initially ... Read More