Combine Values of Two Columns Separated with Hyphen in R Data Frame

Nizamuddin Siddiqui
Updated on 28-Oct-2021 09:29:59

949 Views

To combine values of two columns separated with hyphen in an R data frame, we can use apply function.For Example, if we have a data frame called df that contains only two columns say X and Y then we can combine the values in X and Y by using the below command given below −df$X_Y

Find Class of Columns in R Data Frame

Nizamuddin Siddiqui
Updated on 28-Oct-2021 08:48:14

6K+ Views

To find the class of columns of an R data frame, we can use class function along with sapply and as.data.frame function.For Example, if we have a data frame called DF then we can find the class of columns in DF by using the command as follows −data.frame(sapply(DF, class))Example 1Consider the below data frame −head(mtcars, 20) The following dataframe is created                      mpg  cyl   disp   hp  drat     wt   qsec  vs am gear carb Mazda RX4           21.0    6  160.0  110  3.90 ... Read More

Check Which List Element Contains a Particular Value in R

Nizamuddin Siddiqui
Updated on 28-Oct-2021 08:16:42

1K+ Views

A list in R can have large number of elements and also of different types. If we have a list that contain vectors and we want to check which list element contains a particular value then we can use which function along with sapply function.For Example, if we have a list called LIST then we can find which element of LIST contains 5 then we can use the command given below −which(sapply(LIST, FUN=function(X) 5 %in% X))Example 1Consider the List given below −List1

Convert Strings in R Data Frame to Unique Integers

Nizamuddin Siddiqui
Updated on 28-Oct-2021 07:55:11

2K+ Views

To convert strings in R data frame to unique integers, we first need to extract the unique strings in the data frame and then read them inside data.frame function with as.numeric along with factor function.Check out the below Examples to understand how it works.Example 1Consider the below data frame −x1

Create Date Column in R Excluding Weekends

Nizamuddin Siddiqui
Updated on 28-Oct-2021 07:33:11

3K+ Views

If we have a vector of dates that contains all days in a week then we can use that vector to create a date column by excluding weekends with the help of subsetting the vector as shown in the below Examples. After subsetting the vector, we will just need to pass the vector in data.frame function.Example 1Consider the below vector of dates −x

Change Border Line Type in Base R Boxplot

Nizamuddin Siddiqui
Updated on 28-Oct-2021 07:23:02

809 Views

The default boxplot in R has straight border line type that display end point(s) excluding outliers. To change these border lines from a boxplot, we can use staplelty argument.For Example, if we have a vector called X then we can create the boxplot of X with different border line type by using the command boxplot(X,staplelty=15). The argument can take different values. Check out the below Examples to understand how it works.ExampleConsider the below vector −x

Use of Callbacks in Layered Architecture

Ayushi Bhargava
Updated on 28-Oct-2021 07:18:51

463 Views

Layered ArchitectureA layered architecture splits a system into many groups, each of which contains code that addresses a specific issue area, and these groups are referred to as layers.The majority of enterprise-level apps have a three-layer high-level application architecture.The Presentation layerThe Business layerThe Persistence layerWhat is a Callback?A callback, sometimes known as a "call-after" function in computer programming, is any executable code that is supplied as an argument to other code, with the expectation that the other code will call back (execute) the input at a specific time. This execution can take place at once, as in a synchronous callback, ... Read More

Types of Wireless and Mobile Device Attacks

Ayushi Bhargava
Updated on 28-Oct-2021 07:17:33

2K+ Views

SMiShingWith the widespread usage of cellphones, smishing has grown more prevalent. Short Message Service (SMS) is used by SMiShing to transmit fraudulent text messages or links. By calling, the crooks deceive the user. Victims may provide sensitive information like credit card numbers, account numbers, and so on. When a user visits a website, he or she may unwittingly download malware that infects the device.War DrivingWar driving is a method employed by attackers to locate entrance points wherever they are. They may drive about and acquire a massive quantity of information in a short period of time because of the availability ... Read More

Types of VPN and Its Protocols

Ayushi Bhargava
Updated on 28-Oct-2021 07:14:43

2K+ Views

VPN is an abbreviation for Virtual Private Network. It allows a person to safely and discreetly connect to a private network over the Web. VPN establishes a secure channel known as a VPN tunnel, through which all Internet traffic and conversation is routed.Remote Access VPNA Remote Access VPN allows people to connect to a private network and remotely access all of its resources and services. The person's connection to the private network is made over the Internet, and the connectivity is safe and confidential. Remote Access VPN is beneficial to both residential and business users.While away from the office, a ... Read More

TCP Client-Server Program to Check Palindrome String

Ayushi Bhargava
Updated on 28-Oct-2021 07:10:30

2K+ Views

A Palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., "madam" or "nurses run".TCP Client-Server ProgramClient and server configuration in which a client connects transmits a string to the server, and the server displays the original string and sends a confirmation to the client through socket connection whether the string is a palindrome or not.Input − WOWOutput − PalindromeInput − soapOutput − Not PalindromeHow Does It Work?First, establish a client-server connection.After the connection is established, the client utilizes the send system function to deliver the user input string to the server.The server will wait ... Read More

Advertisements