A data frame can be created by using data.frame function but in this case R generates the column names using the values we pass for the data. For example, if we pass a probability distribution as shown in the below examples then its name will be there. If we want to change those names then setNames function can be used along with the data frame name.Example Live Demodf1
To find the position of odd numbers in an R vector, we can find the position of values that are divisible by 2 with the help of which function. For example, if we have a vector called x then we can find the position of odd numbers using the command which(x%%2==1). Check out the below examples to understand how it works.Example Live Demox1
%matplotlib would return the backend value.%matplotlib auto would return the name of the backend, over Ipython shell.ExampleIn [1]: %matplotlib autoOutputUsing matplotlib backend: GTK3Agg
In this problem, we are given a doubly linked list and a value sum. Our task is to find pairs with a given sum in a doubly linked list.Let’s take an example to understand the problem, Inputhead − 2 5 6 9 12 x = 11Output(2, 9), (5, 6)ExplanationFor pairs (2, 9), the sum of values is 11 For pairs (5, 6), the sum of values is 11Solution ApproachA simple solution to the problem is traversing the whole linked-list and taking elements one by one and finding the element in the remaining linked list whose sum ... Read More
To generate random numbers with sequence and storing them in a data frame column, we can use sample function with seq. For example, if we want to create a data frame column having random sequence of values of size 50 between 1 to 100 by considering every tenth value then we can use the commanddf
To create a random vector for a range of values, we can use sample function. We just need to pass the range and the sample size inside the sample function. For example, if we want to create a random sample of size 20 for a range of values between 1 to 100 then we can use the command sample(1:100,20) and if the sample size is larger than 100 then we can add replace=TRUE as shown in the below examples.Example Live Demox1
To create a table for the number of unique values in list of vectors, we can use mtabulate function of qdapTools package. For example, if we have a list of vectors say LIST that contains some vectors then the table for the number of unique values in the vectors of LIST can be found by using mtabulate(LIST).ExampleConsider the below list − Live Demox1
To find the sum of squared values of an R data frame column, we can simply square the column with ^ sign and take the sum using sum function. For example, if we have a data frame called df that contains a column say V then the sum of squared values of V can be found by using the command sum(df$V^2).ExampleConsider the below data frame − Live DemoID
If the numeric values are being read as character then we need to convert them into numeric values by using the function as.numeric. For example, if we have a data frame called df that contains a column say x which has numerical values stored in character format then we can convert them into numeric values using the command as.numeric(df$x).ExampleConsider the below data frame − Live Demox1
To find the number of unique values for each column in data.table object, we can use uniqueN function along with lapply. For example, if we have a data.table object called DT that contains five columns each containing some duplicate values then the number of unique values in each of these columns can be found by using DT[,lapply(.SD,uniqueN)].ExampleConsider the below data.table object −x1
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP