Install Azure PowerShell Cmdlets

Chirag Nagrekar
Updated on 04-Jan-2021 09:47:50

719 Views

Before Installing the Azure cmdlets for PowerShell, it is recommended to upgrade it to the PowerShell version 7.X to leverage the new features.To install the PowerShell cmdlets for Azure, you need to download and install the AZ module.Install-Module -Name Az -AllowClobber -Scope CurrentUserTo install it for all the users, Install-Module -Name Az -AllowClobber -Scope AllUsersIf the AzureRM module is already installed, you first need to uninstall it because both modules AzureRM and AZ cannot reside in the same console and the AzureRm module is going to decommission soon. So anyway we need to upgrade it to the latest AZ Module.To ... Read More

Connect Azure Account Using PowerShell

Chirag Nagrekar
Updated on 04-Jan-2021 09:46:43

3K+ Views

To connect the azure account with PowerShell, we can use the Connect-AZAccount command. If we check the command parameters from the below URL, there are multiple methods we can connect to the azure account but in this article, we will use the simple methods to connect.Using the Interactive console to connect portalUsing DeviceLogin method.Using Credentials method.Using the Interactive console method to connect the portal.When we use the Connect-AZAccount directly without any parameter, it will open a popup for the azure portal credential.You need to enter your Azure credentials there.Using Device Login method.In this method, Connect-AZAccount uses the parameter -DeviceLogin. Once ... Read More

Create a Residual Plot in R with Better Looking Aesthetics

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:57:21

368 Views

The default residual plot can be created by using the model object name in base R but that is not very attractive. To create a residual plot with better looking aesthetics, we can use resid_panel function of ggResidpanel package. It is created in the same way as the residual plot in base R, also it results in all the relevant graph in one window.ExampleConsider the below data frame −Live Demo> x y df dfOutputx y 1 0.48508894 0.217379409 2 0.75113573 -0.657179470 3 -0.13075185 -0.549613217 4 -0.26867557 1.156736294 5 0.40407850 0.640387394 6 -0.23816272 -0.807847198 7 -0.57278583 0.600249694 8 -0.78222676 -0.711133218 9 ... Read More

Create Combinations for Each String Value in Two Vectors in R

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:56:05

679 Views

If we have two string vectors, each containing more than two values then it becomes a little difficult to create the combinations for each string value in those two vectors. For this purpose, we can make use of do.call function paste0 and expand.grid as shown in the below examples.ExampleLive Demo> x1 y1 do.call(paste0, expand.grid(x1, y1))Output[1] "AK" "BK" "CK" "DK" "EK" "FK" "GK" "HK" "IK" "JK" "AL" "BL" "CL" "DL" "EL" [16] "FL" "GL" "HL" "IL" "JL" "AM" "BM" "CM" "DM" "EM" "FM" "GM" "HM" "IM" "JM" [31] "AN" "BN" "CN" "DN" "EN" "FN" "GN" "HN" "IN" "JN" "AO" "BO" "CO" ... Read More

Get Top Values of a Numerical Column in R Data Frame

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:54:16

7K+ Views

To get the top values in an R data frame, we can use the head function and if we want the values in decreasing order then sort function will be required. Therefore, we need to use the combination of head and sort function to find the top values in decreasing order. For example, if we have a data frame df that contains a column x then we can find top 20 values of x in decreasing order by using head(sort(df$x, decreasing=TRUE), n=20).ExampleConsider the CO2 data frame in base R −Live Demo> str(CO2)OutputClasses ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and 'data.frame': 84 obs. of ... Read More

Create a Column in an R Data Frame for Multiplication of Two Columns

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:52:43

2K+ Views

Sometimes we need the multiplication of two columns and create a new column so that the multiplication can be used further for analysis. For example, to calculate BMI we need mass and height and the height is squared, therefore, we would be needing the square of height. For this purpose, we can either multiply height with height or simply take the square both the ways work. Hence, if only have height column in an R data frame then we can multiply it with itself.ExampleConsider the below data frame −Live Demo> set.seed(957) > x y z df dfOutputx y z 1 ... Read More

Change Width of Whisker Lines in Boxplot Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:50:59

2K+ Views

In R, by default the whisker lines are as wide as the box of the boxplot but it would be great if we reduce that width or increase it because it will get attention of the viewer in that way. This can be done by using the width argument inside the stat_boxplot function of ggplot2 package. Check out the below example to understand how it works.ExampleConsider the below data frame −ExampleLive Demo> x y df dfOutputx y 1 B 5 2 B 4 3 A 6 4 A 9 5 B 2 6 B 4 7 B 6 8 B ... Read More

Find Sum of Division in R if Zero Exists in Vectors

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:49:25

259 Views

To find the sum of division if zero exists in the vectors, we need to assign NA to zeros in both the vectors and then use the sum function with na.rm set to TRUE. For example, if we have two vectors x and y that contains some zeros then we can divide x by y using the below commands −x[x==0] y yOutput[1] 1 5 3 1 9 1 3 8 9 0 1 7 3 2 3 3 2 9 3 1 9 5 5 2 5 4 4 7 4 5 9 1 9 9 4 2 3 [38] ... Read More

Difference Between Kolmogorov-Smirnov Test and Chi-Square Goodness of Fit Test in R

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:48:00

1K+ Views

The Chi Square Goodness of fit test is used to test whether the distribution of nominal variables is same or not as well as for other distribution matches and on the other hand the Kolmogorov Smirnov test is only used to test to the goodness of fit for a continuous data. The difference is not about the programming tool, it is a concept of statistics.ExampleLive Demo> x xOutput[1] 0.078716115 -0.682154062 0.655436957 -1.169616157 -0.688543382 [6] 0.646087104 0.472429834 2.277750805 0.963105637 0.414918478 [11] 0.575005958 -1.286604138 -1.026756390 2.692769261 -0.835433410 [16] 0.007544065 0.925296720 1.058978610 0.906392907 0.973050503Example> ks.test(x, pnorm) One-sample Kolmogorov-Smirnov test data: x ... Read More

Create Boxplot for Matrix Columns in R

Nizamuddin Siddiqui
Updated on 04-Jan-2021 06:46:07

3K+ Views

To create a boxplot for data frame columns we can simply use boxplot function but it cannot be done directly for matrix columns. If we want to create boxplot for matrix columns then we need to convert the matrix into data frame and then use the boxplot function. For example, if we have a matrix called M then the boxplot for columns in M can be created by using boxplot(as.data.frame(M)).ExampleLive Demo> M MOutput[,1] [,2] [,3] [,4] [,5] [1,] 1.688556 1.697216 1.9469573 1.873956 2.010246 [2,] 1.655357 1.927145 2.0937415 2.273638 1.966972 [3,] 1.886917 1.182852 2.0291452 2.507944 2.338664 [4,] 2.013053 1.995526 1.8122830 2.531708 2.483359 [5,] 1.812015 1.950053 1.8902859 2.453222 2.123253 [6,] 1.781764 1.786285 2.3384120 2.275382 2.509708 [7,] 1.836378 1.192781 1.5382031 2.012324 2.290340 [8,] 2.061482 1.705481 2.5542404 1.958202 1.991252 [9,] 2.162214 1.958862 1.8096081 1.810033 1.856942 [10,] 1.897020 1.614834 2.3407207 2.199068 1.807968 [11,] 2.491147 2.317192 2.4486029 2.131722 1.947841 [12,] 1.860307 1.932982 2.2034280 1.982581 2.720482 [13,] 1.814205 2.214286 1.6917036 1.854341 2.150684 [14,] 1.224437 1.800944 1.7600398 1.503382 2.775012 [15,] 2.309462 2.534766 1.5111472 2.058761 1.823550 [16,] 2.190564 1.588298 1.8854163 1.694651 1.939035 [17,] 2.521611 2.339012 2.2959581 2.501148 1.951673 [18,] 1.808799 2.314207 1.8704730 1.937851 1.877917 [19,] 2.476626 1.806194 2.7111663 2.156506 1.521197 [20,] 1.819725 1.633549 1.9438948 2.213533 2.247944 [21,] 2.412117 1.797531 2.5320892 1.889267 2.586912 [22,] 1.679395 2.276218 1.6120445 1.648766 1.889033 [23,] 2.286285 2.221312 0.9408758 1.896072 1.996449 [24,] 2.274975 2.398884 2.0146319 1.814092 2.350100 [25,] 2.106620 1.640401 1.6416454 2.452356 1.638885 [26,] 1.556329 1.706762 1.8324196 2.348518 1.593293 [27,] 2.171867 1.707615 1.9667116 2.191344 1.595531 [28,] 1.796751 2.753674 2.1741976 1.623239 2.399018 [29,] 2.635992 2.180735 2.2114669 2.258419 2.277367 [30,] 1.874671 2.113165 2.3653358 2.231705 1.919449Example> boxplot(as.data.frame(M))Output

Advertisements