DateTimeDateTime is a structure of value Type like int, double etc. It is available in System namespace and present in mscorlib.dll assembly.It implements interfaces like IComparable, IFormattable, IConvertible, ISerializable, IComparable, IEquatable.DateTime contains properties like Day, Month, Year, Hour, Minute, Second, DayOfWeek and others in a DateTime object.TimeSpanTimeSpan struct represents a time interval that is difference between two times measured in number of days, hours, minutes, and seconds.TimeSpan is used to compare two DateTime objects to find the difference between two dates. TimeSpan class provides FromDays, FromHours, FromMinutes, FromSeconds, and FromMilliseconds methods to create TimeSpan objects from days, hours, minutes, seconds, ... Read More
Tuple can be used where you want to have a data structure to hold an object with properties, but you don't want to create a separate type for it. The Tuple class was introduced in .NET Framework 4.0. A tuple is a data structure that contains a sequence of elements of different data types.Tuple person = new Tuple (1, "Test", "Test1");A tuple can only include a maximum of eight elements. It gives a compiler error when you try to include more than eight elements.Tuples of Listvar tupleList = new List { (1, "cow1"), (5, "chickens1"), (1, "airplane1") ... Read More
Replace() method is a string method. This method is used to replace all the specified Unicode characters or specified string from the current string object and returns a new modified string. This method can be overloaded by passing arguments to it.Example 1To replace even the case sensitive charaters Regular expressions provide a powerful, flexible, and efficient method for processing text. The extensive pattern-matching notation of regular expressions enables you to quickly parse large amounts of text to:Find specific character patterns.Validate text to ensure that it matches a predefined pattern (such as an email address).Extract, edit, replace, or delete text substrings.Add ... Read More
C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values.C# 2.0 introduced nullable types that allow you to assign null to value type variables. You can declare nullable types using Nullable where T is a type.Nullable types can only be used with value types.The Value property will throw an InvalidOperationException if value is null; otherwise it will return the value.The HasValue property returns true if the variable contains a value, or false if it is null.You can only use == and != operators with a nullable type. ... Read More
The readonly keyword is used to declare a member variable a constant, but allows the value to be calculated at runtime. This differs from a constant declared with the const modifier, which must have its value set at compile time. Using readonly you can set the value of the field either in the declaration, or in the constructor of the object that the field is a member of.The 'readonly' modifier can be used in a total of four contexts:Field declarationReadonly struct declarationReadonly member definitionRef read only method returnWhen we use the field declaration context, we need to know that the ... Read More
In data analysis, we encounter many problems with a lot of variations among them. One such problem is we have some information in a place that needs to be checked through a different place and these places can be data frames. Therefore, we need to find the position of a data frame’s column value based on a column value of another data frame. In R, we can easily do it with the help of which function.Example Live DemoConsider the below data frame −set.seed(12121) x1
Finding the distance among matrix values means that we want to find the distance matrix and it can be directly found by using dist function with the matrix name. For example, suppose we have a matrix of size 5x5 named as M then the distance matrix can be calculated as dist(M).Example1M1
By default, the X−axis labels are plotted on the bottom−axis of the plot and that is referred to as the first axis of axis 1, the second axis is the axis on the left−side, the third axis is the axis on the upper side of the plot, and the fourth axis is on the right−side of the plot. If we want to plot the X−axis labels on the upper−side of the plot then we can use xaxt="n" inside the plot function then define axis for upper−side using axis(3) with semi−colon.Example1xRead More
A list may contain many objects such as vector, matrix, data frame, list etc. In this way, we can have access to all the necessary objects at the same time. If we want to add a data frame inside a list then we can use the length of the list. For example, if we have a list defined as List and we want to add a data frame df to the List then it can be added as follows −List[[length(List)+1]]
The group−wise linear regression means creating regression model for group levels. For example, if we have a dependent variable y and the independent variable x also a grouping variable G that divides the combination of x and y into multiple groups then we can create a linear regression model for each of the group. In R, we can convert data frame to data.table object, this will help us to create the regression models easily.Example Live DemoConsider the below data frame −G1