Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 181 of 196

How to visualize the normality of a column of an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 230 Views

The first step to analyze a variable is checking whether it is normally distributed or not and to visually do this, we create a histogram. If the histogram depicts a bell then we consider that the variable is normally distributed otherwise, it is not. We can create a histogram for any column of an R data frame by using hist function.ExampleConsider the below data frame −set.seed(9) df

Read More

How to create a Venn diagram in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 517 Views

A Venn diagram helps to identify the common and uncommon elements between two or more than two sets of elements. This is also used in probability theory to visually represent the relationship between two or more events. To create a Venn diagram in R, we can make use of venn function of gplots package.ExampleConsider the below vectorsx

Read More

How to find monthly sales using date variable in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 521 Views

Sales analysis requires to find monthly sales mean, total, range, and often standard deviation. This is mostly required by FMCG (Fast-Moving Consumer Goods) companies because they want to track their sales on daily basis as well as monthly basis. If we have daily sales data then we need to create another column for months in an R data frame to find the monthly sales and this can be done with the help of strftime and aggregate function.ExampleConsider the below data frame −date

Read More

How to add a month to a date in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 21-Aug-2020 767 Views

We have to deal with date data in time series analysis, also sometimes we have a time variable in data set that is recorded to perform another type of analysis. Depending on our objective, we need to process the data and the time variable is also converted into appropriate form that we are looking for. If we want to create a sequence of months from date data then we can do it by adding a month to each upcoming month. This can be easily done by using AddMonths function of DescTools package.ExampleInstalling DescTools package −install.packages("DescTools") Loading DescTools package: library(DescTools) AddMonths(as.Date('2020/01/31'), ...

Read More

How to create a vector with zero values in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 20-Aug-2020 710 Views

In data analysis, sometimes we need to use zeros for certain calculations, either to nullify the effect of a variable or for some other purpose based on the objective of the analysis. To deal with such type of situations, we need a zero value or a vector of zeros. There are many ways to create a vector with zeros in R. The important thing is the length of the vector.Examples> x1 x1 [1] 0 0 0 0 0 0 0 0 0 0 > x2 x2 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

Read More

How to merge two unequal data frames and replace missing values to 0 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Aug-2020 1K+ Views

Often, we get data frames that are not of same size that means some of the rows or columns are missing in any of the data frames. Therefore, to merge these types of data frames we can merge them with all of their values and convert the missing values to zero if necessary. This can be done by using merge function and replacement of missing values NA to zeros should be done by using single square brackets.ExampleConsider the below data frames −> C1 df1 df1 C1 1 A 2 B 3 C 4 D 5 E 6 F 7 G ...

Read More

How to find the date after a number of days in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Aug-2020 212 Views

In our daily life, often we want to know what will be date after some number of days. This is also required in professional life, especially in those professions where we work on projects and have tight deadlines. To find the date after a number a certain number of days we can just use plus sign after reading the date with as.Date.Example> as.Date("2001-01-01")+30 [1] "2001-01-31" > as.Date("2020-06-30")+30 [1] "2020-07-30" > as.Date("2020-06-30")+50 [1] "2020-08-19" > as.Date("2020-06-30")+100 [1] "2020-10-08" > as.Date("2020-06-30")+120 [1] "2020-10-28" > as.Date("2020-06-30")+15 [1] "2020-07-15" > as.Date("2020-06-30")+45 [1] "2020-08-14" > as.Date("2020-06-30")+40 [1] "2020-08-09" > as.Date("2020-12-25")+20 [1] "2021-01-14" > as.Date("2020-12-25")+300 [1] ...

Read More

How to create a plot in R with a different plot window size using plot function?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Aug-2020 12K+ Views

We can create plots in R with having different plot window sizes. This will be helpful when we want to express X-axis or Y-axis differently. Also, the change in the size of the plot window will help us to paste the plot in places that are short or large. For example, if we want to present the plot in a business meeting then we can increase its size and if we want to publish it in a paper then its size can be decreased.ExampleConsider the below vectors x and y −> x y plot(x, y)OutputPlotting with 10-inch-wide and 5 inch ...

Read More

How to subset rows that do not contain NA and blank in one of the columns in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Aug-2020 5K+ Views

It is possible that we get data sets where a column contains NA as well as blank, therefore, it becomes necessary to deal with these values. One of the ways to deal with these values is selecting the rows where we do not have them. This can be done by subsetting through single square brackets.ExampleConsider the below data frame −> set.seed(1) > x1 x2 x3 df df x1 x2 x3 1 4 1 5 2 39 5 3 1 3 5 4 34 4 5 5 23 1 6 43 7 14 3 8 18 ...

Read More

How to convert a list to matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Aug-2020 12K+ Views

If we have a list that contain vectors having even number of elements in total then we can create a matrix of those elements. example, if a list contain 8 vectors and the total number of elements in those 8 vectors is 100 or any other multiple of 2 then we can create a matrix of those elements. This can be done by using unlist function inside matrix function.ExampleConsider the below list x −> x x [[1]]   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [[2]]   [1] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [[3]]   [1] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [[4]]   [1] 76 77 78 79 80  81 82 83 84 85 86 87 88 89 90 91 92 93 94  [20] 95 96 97 98 99 100 [[5]]  [1] 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 [20] 120 121 122 123 124 125 [[6]]  [1] 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 [20] 145 146 147 148 149 150 [[7]]  [1] 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 [20] 170 171 172 173 174 175 [[8]]  [1] 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 [20] 195 196 197 198 199 200 > Matrix_x Matrix_x      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]  [1,]   1   2   3    4    5    6    7    8    9   10  [2,]  11  12  13   14   15   16   17   18   19   20  [3,]  21  22  23   24   25   26   27   28   29   30  [4,]  31  32  33   34   35   36   37   38   39   40  [5,]  41  42  43   44   45   46   47   48   49   50  [6,]  51  52  53   54   55   56   57   58   59   60  [7,]  61  62  63   64   65   66   67   68   69   70  [8,]  71  72  73   74   75   76   77   78   79   80  [9,]  81  82  83   84   85   86   87   88   89   90 [10,]  91  92  93   94   95   96   97   98   99  100 [11,] 101 102 103  104  105  106  107  108  109  110 [12,] 111 112 113  114  115  116  117  118  119  120 [13,] 121 122 123  124  125  126  127  128  129  130 [14,] 131 132 133  134  135  136  137  138  139  140 [15,] 141 142 143  144  145  146  147  148  149  150 [16,] 151 152 153  154  155  156  157  158  159  160 [17,] 161 162 163  164  165  166  167  168  169  170 [18,] 171 172 173  174  175  176  177  178  179  180 [19,] 181 182 183  184  185  186  187  188  189  190 [20,] 191 192 193  194  195  196  197  198  199  200 > Matrix_x Matrix_x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]  [1,]  1  21 41 61 81 101 121 141 161 181  [2,]  2  22 42 62 82 102 122 142 162 182  [3,]  3  23 43 63 83 103 123 143 163 183  [4,]  4  24 44 64 84 104 124 144 164 184  [5,]  5  25 45 65 85 105 125 145 165 185  [6,]  6  26 46 66 86 106 126 146 166 186  [7,]  7  27 47 67 87 107 127 147 167 187  [8,]  8  28 48 68 88 108 128 148 168 188  [9,]  9  29 49 69 89 109 129 149 169 189 [10,] 10  30 50 70 90 110 130 150 170 190 [11,] 11  31 51 71 91 111 131 151 171 191 [12,] 12  32 52 72 92 112 132 152 172 192 [13,] 13  33 53 73 93 113 133 153 173 193 [14,] 14  34 54 74 94 114 134 154 174 194 [15,] 15  35  55 75 95 115 135 155 175 195 [16,] 16  36 56 76 96 116 136 156 176 196 [17,] 17  37  57 77 97 117 137 157 177 197 [18,] 18  38  58 78 98 118 138 158 178 198 [19,] 19  39  59 79 99 119 139 159 179 199 [20,] 20  40  60 80 100 120 140 160 180 200

Read More
Showing 1801–1810 of 1,958 articles
« Prev 1 179 180 181 182 183 196 Next »
Advertisements