Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 139 of 196

How to check whether a string is in lowercase or uppercase in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 4K+ Views

We can use str_detect function to check whether a single string or a vector of strings is in lowercase or uppercase. Along with str_detect function, we need to use either upper or lower to check whether the string is in lowercase or uppercase and the output will be returned in TRUE or FALSE form, if the string will be in lowercase and we pass lower with str_detect function then the output will be TRUE and vice-versa.Example Live Demox1

Read More

How to find the rank of a vector elements in R from largest to smallest?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 2K+ Views

To find the rank of a vector of elements we can use rank function directly but this will result in ranks from smallest to largest. For example, if we have a vector x that contains values 1, 2, 3 in this sequence then the rank function will return 1 2 3. But if we want to get ranks from largest to smallest then it would be 3 2 1 and it can be done in R as rank(-x).Example Live Demox1

Read More

How to change column names to capital letters from lower case or vice versa in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 2K+ Views

Mostly, we get data that contain column names in lowercase or just first letter is in upper case. If we want to convert those column names to all capital letter words or uppercase then toupper function can be used to the names of the columns. This can be done by using the below syntax −Syntaxnames(“data_frame_name”)

Read More

How to extract odds ratio of intercept and slope coefficient from simple logistic model in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 356 Views

To create the simple logistic model, we need to use glm function with family = binomial because the dependent variable in simple logistic model or binomial logistic model has two categories, if there are more than two categories then the model is called as multinomial logistic model. If we want to extract the odds ratio of slope and intercept from the simple logistic model then exp function needs to be used with model object as shown in the below examples.Example Live Demoset.seed(999) x1

Read More

How to repeat a column of a data frame and join it with another data frame in R by rows?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 274 Views

Suppose we have a data frame df1 that contains 5 columns and another data frame df2 that contains only column but the data type of the columns in both the data frames is same. Now we might want to add the column of the second data frame starting at the end of the rows of the first data frame by creating the same number of columns as in first data frame. This might be required by researchers to understand the impact of an external variable on the result of the analysis and it can be done with the help of ...

Read More

How to convert data.table object into a matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 395 Views

A data.table object is very similar to a data frame in R, therefore, converting a data.table object to a matrix is not a difficult job. We just need to use as.matrix function and store the data.table object into a new object that will belong to the matrix, otherwise R will not be able to convert the data.object to a matrix. For example, if we have a data.table object DT then to convert it into a matrix, we should use the below example code −DT_matrix

Read More

How to visualize two categorical variables together in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 16-Oct-2020 5K+ Views

The categorical variables can be easily visualized with the help of mosaic plot. In a mosaic plot, we can have one or more categorical variables and the plot is created based on the frequency of each category in the variables. To create a mosaic plot in base R, we can use mosaicplot function. The categories that have higher frequencies are displayed by a bigger size box and the categories that have less frequency are displayed by smaller size box.Consider the below data frame −Example Live Demox1

Read More

How to create a line chart in R using plot function with larger width?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Oct-2020 229 Views

To create a line chart in base R using plot function, we need to use type = "l" so that R understand the plot needs to have a line instead of points. If we want to increase the width of the line then lwd argument can be used. The value lwd = 0 is the default value for the width.Consider the below vector and create the line chart −Examplex

Read More

How to create a chart by covering the area of the plot from bottom left to upper right in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Oct-2020 161 Views

The plot area in plot window is fixed by default and we can create a lint chart with extended width so that the chart covers the area of the plot from bottom left to upper right. This can be done by using very large width of the line chart with the help of lwd argument.Consider the below vector and create the very wide line chart to cover the plot area −Examplex

Read More

How to create varying width bar chart using barplot function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 14-Oct-2020 377 Views

The barplot function create the bars of equal width but if we have equal or unequal width values for each bar then we can use width within the barplot function. Thus, the newly generated barplot will have different width of the bars. For example, if we the width are defined for four categories as 0.25 each then each bar will be of equal width and if they vary as 0.30, 0.40, 0.20, 0.45 then the width of the bars will be different based on these widths.Consider the below vector x and the corresponding width vector −x

Read More
Showing 1381–1390 of 1,958 articles
« Prev 1 137 138 139 140 141 196 Next »
Advertisements