Programming Articles

Page 1145 of 2547

How to standardize only numerical columns in an R data frame if categorical columns also exist?

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

The standardization of a numerical column can be easily done with the help of scale function but if we want to standardize multiple columns of a data frame if categorical columns also exist then mutate_if function of dplyr package will be used. For example, if we have a data frame df then it can be done as df%>%mutate_if(is.numeric, scale)Example1Consider the below data frame −> x1 x2 df1 df1Output   x1 x2 1   c  4 2   c  1 3   a  4 4   a  1 5   b  0 6   c  4 7   c  2 8   ...

Read More

How to find the number of groupwise missing values in an R data frame?

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

In data science, we often face the problem of missing values and we need to define a way to replace them with an appropriate value or we can complete remove them. If we want to replace the missing then we also need to know how many missing values are there. Therefore, if we have a data frame with grouping column then finding the number of groupwise missing values can be done with aggregate function as shown in the below examples.Example1Consider the below data frame −> Group x df1 df1Output   Group  x 1      A  2 2      A ...

Read More

How to change the tick size using ggplot2 in R?

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

To change the tick size using ggplot2, we can use theme function with argument axis.ticks.length. For example, if we have a data frame called df that contains two columns say x and y then the scatterplot between x and y with larger size of tick marks can be created by using the below command −ggplot(df,aes(x,y))+geom_point()+theme(axis.ticks.length=unit(0.8,"inch"))ExampleConsider the below data frame −x

Read More

Unsafe Operation in Rust Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 284 Views

Unsafe Operations are done when we want to ignore the norm that Rust provides us. There are different unsafe operations that we can use, mainly:dereferencing raw pointersaccessing or modifying static mutable variablescalling functions or methods which are unsafeThough it is not recommended by Rust that we should use unsafe operations at all, we should use them only when we want to bypass the protections that are put in by the compiler.Raw Pointers In Rust, the raw pointers * and the references &T perform almost the same thing, but references are always safe, as they are guaranteed by the compiler to point ...

Read More

Vectors in Rust Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 494 Views

Vectors in Rust are like re-sizable arrays. They are used to store objects that are of the same type and they are stored contiguously in memoryLike Slices, their size is not known at compile-time and can grow or shrink accordingly. It is denoted by Vec in RustThe data stored in the vector is allocated on the heap.ExampleIn the below example, a vector named d is created using the Vec::new(); function that Rust provides.fn main() {    let mut d: Vec = Vec::new();    d.push(10);    d.push(11);    println!("{:?}", d);    d.pop();    println!("{:?}", d); }We push the elements into a ...

Read More

While and For Range in Rust Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 247 Views

We know that Rust provides a loop keyword to run an infinite loop. But the more traditional way to run loops in any programming language is with either making use of the while loop or the for range loop.While LoopThe while loop is used to execute a code of block until a certain condition evaluates to true. Once the condition becomes false, the loop breaks and anything after the loop is then evaluated. In Rust, it is pretty much the same.ExampleConsider the example shown below:fn main() {    let mut z = 1;    while z < 20 {   ...

Read More

How to convert the row values in a matrix to row percentage in R?

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

To convert the row values in a matrix to row percentage, we can find the row sums and divide each row value by this sum. For example, if we have a matrix called M then we can convert the row values in M to row percentage by using the commandround((M/rowSums(M))*100,2)ExampleConsider the below matrix −M1

Read More

Golang Program to update the ith index node value, when index is at 0 index.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 180 Views

ExamplesApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Initialize the index as i := 0.Step 4 − Iterate the given linked list from its head.Step 5 − If index i matches with given index (to be updated), then update that node.Step 6 − Else, return the head.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next ...

Read More

How to create horizontal lines for each bar in a bar plot of base R?

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

To create horizontal lines for each bar in a bar plot of base R, we can use abline function and pass the same values as in the original barplot with h argument that represents horizontal with different color to make the plot a little better in terms of visualization.Examplex

Read More

Golang Program to update the ith index node value, when index is at the last index.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 169 Views

ExampleApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Initialize the index as i := 0.Step 4 − Iterate the given linked list from its head.Step 5 − If index i matches with the given index (to be updated), then update that node.Step 6 − Else, return head.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next ...

Read More
Showing 11441–11450 of 25,466 articles
Advertisements