Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 129 of 196

How to set the diagonal elements of a matrix to 1 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Nov-2020 1K+ Views

First thing we need to understand is diagonal elements are useful only if we have a square matrix, otherwise it would not make sense to set diagonal elements, this is known to almost all mathematicians but some freshman might get confused because we can create diagonal in a non-square matrix which should not be called a diagonal. In R, we can set the diagonal elements of a matrix to 1 by using diag function.Example1Live Demo> M1 M1Output     [, 1] [, 2] [, 3] [, 4] [, 5] [1, ]   1    6   11   16   21 ...

Read More

How to create normal quantile-quantile plot for a logarithmic model in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Nov-2020 301 Views

How to create normal quantile-quantile plot for a logarithmic model in R?A logarithmic model is the type of model in which we take the log of the dependent variable and then create the linear model in R. If we want to create the normal quantile-quantile plot for a logarithmic model then plot function can be used with the model object name and which = 2 argument must be introduced to get the desired plot.Example1Live Demo> x1 x1Output[1]  4.735737 3.631521 5.522580 5.538314 5.580952 4.341072 4.736899 2.455681 [9]  4.042295 5.534034 4.717607 6.146558 4.466849 5.444437 5.390151 4.491595 [17] 4.227620 4.223362 5.452378 5.690660 5.321716 ...

Read More

How to remove multiple rows from an R data frame using dplyr package?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Nov-2020 584 Views

Sometimes we get unnecessary information in our data set that needs to be removed, this information could be a single case, multiple cases, whole variable or any other thing that is not helpful in achieving our analytical objective, hence we want to remove it. If we want to remove such type of rows from an R data frame with the help of dplyr package then anti_join function can be used.ExampleConsider the below data frame:Live Demo> set.seed(2514) > x1 x2 df1 df1Output x1 x2 1 5.567262 4.998607 2 5.343063 4.931962 3 2.211267 ...

Read More

How to generate passwords with varying lengths in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 06-Nov-2020 244 Views

To generate passwords, we can use stri_rand_strings function of stringi package. If we want to have passwords of varying length then we need to create the passwords using the particular size separately. For example, for a size or length of the password equals to 8, we can use the argument length in the stri_rand_strings function.Loading stringi package:> library(stringi)Example1> stri_rand_strings(n=5, length=8, pattern="[0-9a-zA-Z]") [1] "YkIEDYQz" "t42JCzYO" "rOE9YN8U" "2lu9AonY" "6lDUxScX"Example2> stri_rand_strings(n=20, length=8, pattern="[0-9a-zA-Z]") [1] "glH3ysoX" "X0Sgvg3F" "P3YOePTa" "45GOb2hA" "tLCwszus" "CerCi1ks" [7] "UtFwzrSc" "pG8AJCQX" "NTCdMRHj" "5thI1wKb" "Ic8Rol1Y" "JakWa1Wd" [13] "9AfeXo7T" "SFJVn9XV" "lIRhLbJ9" "DNFyAbkJ" "jV4jJRZk" "IthkzfEU" [19] "talj9nBq" "Nak9Tidh"Example3> ...

Read More

How to use String Format to show decimal up to 2 places or simple integer in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 4K+ Views

Converts the value of objects to strings based on the formats specified and inserts them into another string.Namespace:System Assembly:System.Runtime.dllEach overload of the Format method uses the composite formatting feature to include zero-based indexed placeholders, called format items, in a composite format string. At run time, each format item is replaced with the string representation of the corresponding argument in a parameter list. If the value of the argument is null, the format item is replaced with String.Empty.Exampleclass Program{    static void Main(string[] args){       int number = 123;       var s = string.Format("{0:0.00}", number);     ...

Read More

How to convert string to title case in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 789 Views

Title case is any text, such as in a title or heading, where the first letter of major words is capitalized. Title case or headline case is a style of capitalization used for rendering the titles of published works or works of art in English.When using title case, all words are capitalized except for "minor" words unless they are the first or last word of the title.The current implementation of the ToTitleCase in the example yields an output string that is the same length as the input string.Example 1class Program{    static void Main(string[] args){       string myString ...

Read More

How to set a property value by reflection in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 6K+ Views

The System. Reflection namespace contains classes that allow you to obtain information about the application and to dynamically add types, values, and objects to the application.Reflection objects are used for obtaining type information at runtime. The classes that give access to the metadata of a running program are in the System. Reflection namespace.Reflection allows view attribute information at runtime.Reflection allows examining various types in an assembly and instantiate these types.Reflection allows late binding to methods and properties.Reflection allows creating new types at runtime and then performs some tasks using those types.ExampleGetProperty(String)Searches for the public property with the specified name.GetType(String, Boolean)Gets ...

Read More

How to rethrow InnerException without losing stack trace in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 1K+ Views

In c#, the throw is a keyword and it is useful to throw an exception manually during the execution of the program and we can handle those thrown exceptions using try−catch blocks based on our requirements.By using throw keyword in the catch block, we can re-throw an exception that is handled in the catch block. The re-throwing an exception is useful when we want to pass an exception to the caller to handle it in a way they want.Following is the example of re−throwing an exception to the caller using throw keyword with try-catch blocks in c#.Exampleclass Program{    static ...

Read More

How to use “not in” query with C# LINQ?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 7K+ Views

Except operator are designed to allow you to query data which supports the IEnumerable

Read More

How to Deserializing JSON to .NET object using Newtonsoft json in C# and pick only one value from the array?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Nov-2020 636 Views

The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.The WebClient class uses the WebRequest class to provide access to resources. WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.DownloadString Downloads a String from a resource and returns a String.If your request requires an optional header, you must add the header to the Headers collectionExampleIn the below example we are calling the url "https://jsonplaceholder.typicode.com/posts"The example is then deserialized to User arrayFrom the user array we are printing the first array valueExampleclass ...

Read More
Showing 1281–1290 of 1,958 articles
« Prev 1 127 128 129 130 131 196 Next »
Advertisements