Server Side Programming Articles

Page 1120 of 2109

How to change the position of missing values to the end of data frame in R?

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

Most of the times we need to deal with missing values in data science projects and these missing values can be occurred at any position. We might want to change the position of these missing values and send them to the end of the columns in the data frame. This can be done with the help of lapply function as shown in the below examples.Example1Consider the below data frame −> x1 x2 x3 df1 df1Output   x1 x2 x3 1  0  0  2 2  1  1  NA 3  1  NA 0 4  0  NA 2 5  1  NA 2 6  NA ...

Read More

How to remove rows in an R data frame column that has duplicate values greater than or equal to a certain number of times?

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

To remove rows from the data frame that duplicate values greater than a certain number of times, we can create a subset for rows having duplicate values less than the certain number of times. For this purpose, we first need to extract the rows and then subset the data frame with the particular column as shown in the below examples.Example1Consider the below data frame −> x1 x2 df1 df1Output   x1 x2 1  0  0 2  0  0 3  1  0 4  0  1 5  0  0 6  1  1 7  0  1 8  1  1 9  1  2 10 0 ...

Read More

Golang Program to create a doubly linked list and traverse forward.

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

A doubly linked list node contains three items, where two items point to the next and previous nodes, and the third item contains the value of that node.ExampleApproachStep 1 − Define a method that accepts the head of a doubly linked list.Step 2 − Initialize temp:=head.Step 3 − Iterate temp until it becomes nil.Step 4 − Print temp.value.Examplepackage main import "fmt" type Node struct {    prev *Node    value int    next *Node } func CreateNewNode(value int) *Node{    var node Node    node.next = nil    node.value = value    node.prev = nil    return &node } func ...

Read More

How to find the number of numerical columns in an R data frame?

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

We know that a data frame can contain any type of columns such as numerical, character, logical, factor, etc. And if a data frame contains multiple type of columns then we might want to find the number of columns for each type or of one type say numerical. For this purpose, we can use select_if function of dplyr package along with the length function as shown in the below examples.Example1Consider the below data frame −> x1 x2 x3 x4 df1 df1Output   x1      x2          x3    x4 1  a  -0.18404831  0.1082741 2 2  b  -0.28597330 ...

Read More

Golang program to create an integer array that takes inputs from users.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 4K+ Views

ExampleApproachAsk the user to enter the size of array.Make an integer array of given size.Ask the user to enter elements.At the end, print the array.Examplepackage main import (    "fmt" ) func main(){    fmt.Printf("Enter size of your array: ")    var size int    fmt.Scanln(&size)    var arr = make([]int, size)    for i:=0; i

Read More

How to extract the split string elements in R?

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

To split string vector elements, we can use strsplit function. And if we want to extract the string elements after splitting then double and single square brackets will be used. The double square bracket will extract the string vector element and the single square will extract the element after splitting. Check out the examples to understand how it works.Example1> x1 x1Output[1] "Tutorialspoint is an E-learning platform" [2] "E-learning is important" [3] "It helps in learning and growing at a faster rate"Example> x1 x1Output[[1]] [1] "Tutorialspoint" "is" "an" "E-learning" [5] "platform" [[2]] [1] "E-learning" "is" "important" [[3]] [1] "It" ...

Read More

Golang program to traverse a given input array, with Boolean flag, using arrays and struct.

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

ExampleApproachAsk the user to enter the size of array.Make a string array of given size.Ask the user to enter elements.At the end, print the array.Examplepackage main import "fmt" func main(){    arr := []int{10, 20, 30, 60, 40, 50}    boolArr := []bool{true, false, true, false, true, false}    fmt.Println("Input Array is: ", arr)    fmt.Println("Input Boolean Array is: ", boolArr)    visitedArray := []struct{       i int       b bool    }{       {10, true},       {20, false},       {30, true},       {60, false},       {40, true},       {50, false},    }    fmt.Println("Boolean array using struct: ", visitedArray) }OutputInput Array is: [10 20 30 60 40 50] Input Boolean Array is: [true false true false true false] Boolean array using struct: [{10 true} {20 false} {30 true} {60 false} {40 true} {50 false}]

Read More

How to convert the character values in an R data frame column to lower case?

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

The character values can be stored in uppercase, lowercase, or a mixture of the two. If we have values that are either in uppercase or the mixture of lower and upper then we can convert those character values to only lowercase by using tolower function. We simply need to pass the vector or column of the data frame inside the tolower function as shown in the below examples.Example1Consider the below data frame −> x1 y1 df1 df1Output   x1     y1 1  C  -0.1036851 2  C  -0.6176530 3  B   0.5763786 4  A   0.1943794 5  C   1.1196470 6 ...

Read More

Golang program to calculate the absolute and scale of a vertex.

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

ExampleAbs(x, y) => √(x)2+(y)2Scale(f) => (x*f, y*f)ApproachDefine a vertex as a struct.Initialize the vertex with some x and value.Define a method to calculate absolute(x, y).Define a method to calculate scale(x*f, y*f).Examplepackage main import (    "fmt"    "math" ) type Vertex struct {    X, Y float64 } func Abs(v Vertex) float64{    return math.Sqrt(v.X*v.X + v.Y*v.Y) } func Scale(v *Vertex, f float64) {    v.X = v.X * f    v.Y = v.Y * f } func main() {    v := Vertex{3, 4}    fmt.Println("Given vertex is: ", v)    fmt.Println("Absolute value of given vertex is: ", Abs(v)) ...

Read More

How to subset columns that has less than four categories in an R data frame?

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

If column is categorical then there can be at least two categories and there is no limit for the total number of categories but it will also depend on the total number of cases. If we have a data frame that contain some categorical columns having more or less categories than 4 then we might want to subset columns having less than four categories. This could be required in situations when we want to subset the data biasedly or have some predefined data characteristics that allows this change. The subset of such columns can be done with the help of ...

Read More
Showing 11191–11200 of 21,090 articles
Advertisements