Programming Articles

Page 1126 of 2547

How to create a histogram with Y-axis values as count using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 4K+ Views

To create a histogram with Y-axis values as count using ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, use geom_histogram function of ggplot2 package with aes to create the histogram with Y-axis values as count.Create the data frameLet's create a data frame as shown below −> df head(df, 20)On executing, the above script generates the below output(this output will vary on your system due to randomization) −          x 1    -0.008015477 2    -0.981227322 3     1.144050354 4     0.207177231 5     0.179782914 6   ...

Read More

Iterator class in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

Iterator class in Dart is an interface that is used when we want to get items, one at a time, from an object.The iterator is initially positioned before the first element. Before accessing the first element the iterator need to be advanced using the moveNext to point to the first element. If we reached the end of the object then moveNext returns false, and all further calls to moveNext will also return false.It should be noted that if change anything in the object during the iteration, then the behaviour is unspecified.We make use of the current property of the Iterator ...

Read More

Lexical Scoping in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

Dart is a lexically scoped language. Lexically scoped means that as we move downwards to the latest variable declaration, the variable value will depend on the innermost scope in which the variable is present.ExampleConsider the example shown below −void main(){    var language = 'Dart';    void printLanguage(){       language = 'DartLang';       print("Language is ${language}");    }    printLanguage(); }In the above example, we changed the value of the language variable inside the scope of the printLanguage() function and since we are printing the value inside the printLanguage() function, the innermost scope is the one inside the ...

Read More

How to subtract column values from column means in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

To subtract column values from column means in R data frame, we can follow the below steps −First of all, create a data frame.Then, find the column means using colMeans function.After that, subtract column values from column means.Creating the data frameLet's create a data frame as shown below −> x1 x2 x3 df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −   x1  x2  x3 1  54  73  57 2  79  52  92 3  87  51  47 4  13  12   1 5  70  90  19 6  15  99   ...

Read More

How to find the sum of numbers stored in character vector separated with a special character in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 500 Views

To find the sum of numbers stored in character vector separated with a special character in R, we can follow the below steps −First of all, create a vector having numbers stored in character vector separated with a special character.Then, use sapply and strsplit function to find the sum of numbers.Example1Create a vector with numbers stored in character vector separated with hyphen −> x1 x1On executing, the above script generates the below output(this output will vary on your system due to randomization) − [1] "11-2-15-19-10"   "11-2-15-19-10"    "13-12-75-29-18"  "15-25-52-91-10"  [5] "15-25-52-91-10"  "17-27-55-91-100"  "13-12-75-29-18"  "15-25-52-91-10"  [9] "13-12-75-29-18"  "10-4-5-19-10"     "17-27-55-91-100" ...

Read More

How to create violin plot for categories with grey color palette using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 392 Views

To create violin plot for categories with grey color palette using ggplot2, we can follow the below steps −First of all, create a data frame.Then, create the violin plot for categories with default color of violins.Create the violin plot for categories with color of violins in grey palette.Creating the data frameLet's create a data frame as shown below −> Group Score df dfOn executing, the above script generates the below output(this output will vary on your system due to randomization) −     Group  Score 1   Second   405 2    Third   947 3    First    78 4 ...

Read More

Method Overriding in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

We know that we can access the methods that are present in the superclass from a subclass by making use of the super keyword or by simply creating objects of the subclass. Though, there may be different occasions when we want the subclass object to do things differently to the same method when invoked using subclass objects. We can achieve this by defining the same method again in the subclass with the same name, same arguments and same return type as in the same method that is present inside the superclass.Now, when we invoke that method, the method present in ...

Read More

Methods in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

A method is a combination of statements which is used to attach some behavior to the class objects. It is used to perform some action on class objects, and we name methods so that we can recall them later in the program.Methods help in making the core more modular and in increasing the re-usability of the program.Information can be passed to methods through the parameters and then it can perform some operation on that information or it can even return values.Methods in a class are of two types, these are −Instance methodsClass methodsInstance MethodsInstance methods are methods that are present ...

Read More

table.pack() function in Lua programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 6K+ Views

When we want to return a table as a result from multiple values passed into a function, then we make use of the table.pack() function. The table.pack() function is a variadic function.Syntaxtable.pack(x, y, z, ....)ExampleThe table.pack() function provides a table formed with all the values that are passed to it as an argument, consider the example shown below −a = table.pack(1, 2, 3) print(a) print(a.n)In the above example, we passed three numbers to the table.pack() function as an argument and then we are printing the returned value, i.e., which will hold the address of the table that contains the value ...

Read More

Mixins in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 3K+ Views

Mixins in Dart are a way of using the code of a class again in multiple class hierarchies. We make use of the with keyword followed by one or more mixins names.Mixins can be used in two ways, the first case is when we want to make use of class code in such a way that the class doesn't have any constructor and the object of the class is extended. In such a case, we use the with keyword.Another case is when we want our mixin to be usable as a regular class, then we make use of the mixin keyword ...

Read More
Showing 11251–11260 of 25,466 articles
Advertisements