Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 108 of 196

What are some examples of data sets with missing values in R?

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

Instructors/educators often need to teach missing value imputation to their students; hence they require datasets that contains some missing values or they need to create one. We also have some data sets with missing values available in R such as airquality data in base R and food data in VIM package. There could be many other packages that contain data sets with missing values but it would take a lot of time to explore them. Thus, we have shared the example of airquality and some data sets from VIM package.Example 1 Live Demohead(airquality, 20)Output Ozone Solar.R Wind Temp Month Day 1 41 ...

Read More

How to detect a binary column defined with 0 and 1 in an R data frame?

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

If a column in an R data frame has only two values 0 and 1 then we call it a binary column but it is not necessary that a binary column needs to be defined with 0 and 1 only but it is a general convention. To detect a binary column defined with 0 and 1 in an R data frame, we can use the apply function as shown in the below examples.ExampleConsider the below data frame − Live Demox1

Read More

How to perform a left outer join using linq extension methods in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 2K+ Views

With INNER JOIN only the matching elements are included in the result set. Non-matching elements are excluded from the result set.With LEFT OUTER JOIN all the matching elements + all the non-matching elements from the left collection are included in the result set.Let us understand implementing Left Outer Join with an example. Consider the following Department and Employee classes. Notice that, Employee Mary does not have a department assigned. An inner join will not include her record in the result set, where as a Left Outer Join will.Examplestatic class Program{    static void Main(string[] args){       var result = Employee.GetAllEmployees() ...

Read More

How to display methods and properties using reflection in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 325 Views

Reflection is the process of describing the metadata of types, methods and fields in a code. The namespace System.Reflection enables you to obtain data about the loaded assemblies, the elements within them like classes, methods and value types. There are numerous classes of System.Reflection but the most commonly used ones are Assembly, AssemblyName, ConstructorInfo, MethodInfo, ParameterInfo, EventInfo, PropertyInfo, and MemberInfo.Examplestatic void Main(string[] args){    TypeInfo myType = typeof(TextInfo).GetTypeInfo();    IEnumerable properties = myType.DeclaredProperties;    IEnumerable methods = myType.DeclaredMethods;    Console.WriteLine(myType);    Console.WriteLine(properties);    Console.WriteLine(methods);    StringBuilder strBuilder = new StringBuilder();    Console.WriteLine();    strBuilder.Append("The properties are:");    foreach (PropertyInfo p ...

Read More

How to implement Open Closed principle using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 568 Views

Software entities like classes, modules and functions should be open for extension but closed for modifications.Definition − The Open Close Principle states that the design and writing of the code should be done in a way that new functionality should be added with minimum changes in the existing code. The design should be done in a way to allow the adding of new functionality as new classes, keeping as much as possible existing code unchanged.ExampleCode Before Open Closed Principleusing System; using System.Net.Mail; namespace SolidPrinciples.Open.Closed.Principle.Before{    public class Rectangle{       public int Width { get; set; }     ...

Read More

How to implement Single Responsibility Principle using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 401 Views

A class should have only one reason to change.Definition − In this context, responsibility is considered to be one reason to change.This principle states that if we have 2 reasons to change for a class, we have to split the functionality in two classes. Each class will handle only one responsibility and if in the future we need to make one change we are going to make it in the class which handles it. When we need to make a change in a class having more responsibilities the change might affect the other functions related to the other responsibility of ...

Read More

How to get formatted JSON in .NET using C#?

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

Use Namespace Newtonsoft.Json.Formatting Newtonsoft.Json.Formatting provides formatting options to Format the JsonNone − No special formatting is applied. This is the default.Indented − Causes child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings.Examplestatic void Main(string[] args){    Product product = new Product{       Name = "Apple",       Expiry = new DateTime(2008, 12, 28),       Price = 3.9900M,       Sizes = new[] { "Small", "Medium", "Large" }    };    string json = JsonConvert.SerializeObject(product, Formatting.Indented);    Console.WriteLine(json);    Product deserializedProduct = JsonConvert.DeserializeObject(json);    Console.ReadLine(); } class Product{    public String[] Sizes ...

Read More

How to run multiple async tasks and waiting for them all to complete in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 3K+ Views

The Task.WaitAll blocks the current thread until all other tasks have completed execution.The Task.WhenAll method is used to create a task that will complete if and only if all the other tasks have complete. In the 1st example, we could see that when using Task.WhenAll the task complete is executed before the other tasks are completed. This means that Task.WhenAll doesn’t block the execution. And in the 2nd example, we could see that when using Task.WaitAll the task complete is executed only after all the other tasks are completed. This means that Task.WaitAll block the execution.Examplestatic void Main(string[] args){   ...

Read More

What is the difference between All and Any in C# Linq?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 2K+ Views

Any() method returns true if at least one of the elements in the source sequence matches the provided predicate. Otherwise, it returns false. On the other hand, the All() method returns true if every element in the source sequence matches the provided predicate. Otherwise, it returns falseExamplestatic void Main(string[] args){    IEnumerable doubles = new List { 1.2, 1.7, 2.5, 2.4 };    bool result = doubles.Any(val => val < 1);    System.Console.WriteLine(result);    IEnumerable doubles1 = new List { 0.8, 1.7, 2.5, 2.4 };    bool result1 = doubles1.Any(val => val < 1);    System.Console.WriteLine(result1);    Console.ReadLine(); }OutputFalse TrueExamplestatic ...

Read More

What is dependency inversion principle and how to implement in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 05-Dec-2020 848 Views

High-level modules should not depend on low-level modules. Both should depend on abstractions.Abstractions should not depend on details. Details should depend on abstractions.This principle is primarily concerned with reducing dependencies among the code modules.ExampleCode Before Dependency Inversionusing System; namespace SolidPrinciples.Dependency.Invertion.Before{    public class Email{       public string ToAddress { get; set; }       public string Subject { get; set; }       public string Content { get; set; }       public void SendEmail(){          //Send email       }    }    public class SMS{       public ...

Read More
Showing 1071–1080 of 1,958 articles
« Prev 1 106 107 108 109 110 196 Next »
Advertisements