Remove Multiple Columns from Matrix in R Using Their Names

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:24:26

421 Views

To remove multiple columns from matrix in R by using their names, we can follow the below steps −First of all, create a matrix.Then, add names to columns of the matrix.After that, subset the matrix by deselecting the desired columns with negation and single square brackets for subsetting.ExampleCreate the matrixLet’s create a matrix as shown below −M

Difference Between DFA and NFA in Compiler Design

Ginni
Updated on 08-Nov-2021 10:23:06

3K+ Views

Deterministic Finite Automata (DFA)Deterministic means that on each input there is one and only one state to which the automata can have the transition from its current state. In deterministic finite automata, the head can move only in one direction to scan the input tape symbols. But in the case of two-way, finite automata on scanning an input symbol the head of the tape may move in right or left from its current position.There are two ways to represent Deterministic finite Automata −Transition DiagramIt is a directed graph or flow chart having states and edges. A strong path through a ... Read More

Combine Two Columns in R Data Frame Ignoring Missing Values

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:17:34

3K+ Views

To combine two columns by ignoring missing values if exists in one column in R data frame, we can use paste function and is.na function.For Example, if we have a data frame called df that contains two columns say C1 and C2 where C2 contains some missing values then we can use the below mentioned command to combine C1 and C2 by ignoring missing values in C2 −cbind(df,Combined=paste(df[,1],replace(df[,2],is.na(df[,2]),"")))Example 1Following snippet creates a sample data frame −x1

Find Index of Values in Matrix Column in R

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:17:00

361 Views

To find the index of values in R matrix column if they occur once, we can follow the below steps −First of all, create a matrix.Then, use which function along with duplicated function and single square brackets for subsetting to find the index of values in a column if they occur once.Example 1Create the data frameLet’s create a data frame as shown below −M1

What is an Activation Record

Ginni
Updated on 08-Nov-2021 10:16:59

14K+ Views

An Activation Record is a data structure that is activated/ created when a procedure/function is invoked, and it includes the following data about the function.Activation Record in 'C' language consist ofActual ParametersNumber of ArgumentsReturn AddressReturn ValueOld Stack Pointer (SP)Local Data in a function or procedureHere, Old SP stores the value of stack pointer of Activation Record of procedure which has called this procedure which leads to the generation of this Activation Record, i.e., It is a pointer to the activation record of the caller.In Stack Allocation Scheme, when procedure A calls Procedure B, the activation record for B will be ... Read More

Subset R Data Frame by Specifying Columns Containing NA

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:14:09

401 Views

To subset an R data frame by specifying columns that contains NA, we can follow the below steps −First of all, create a data frame with some columns containing NAs.Then, use is.na along with subset function to subset the data frame by specifying columns that contains NA.ExampleCreate the data frameLet’s create a data frame as shown below −x

Lists and Self-Organizing Lists in Compiler Design

Ginni
Updated on 08-Nov-2021 10:11:44

1K+ Views

ListsIt is conceptually simplest and easy to implement a data structure for the symbol table in a linear list of records, as shown below −It can use an individual array to store the name and its associated information. New Names are inserted to the list in the order in which they are encountered. It can retrieve data about a name we search from the starting of the array up to the position marked by the pointer AVAILABLE which indicates the beginning of the empty portion of the array.When the name is placed, the associated data can be discovered in the ... Read More

Find Common Elements Between Two Columns of an R DataFrame

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:10:25

5K+ Views

To find the common elements between two columns of an R data frame, we can use intersect function.For Example, if we have a data frame called df that contains two columns say X and Y then we can find the common elements between X and Y by using the below command −intersect(df$X,df$Y)Example 1Following snippet creates a sample data frame −x1

Count Non-Missing Values in R Data Frame Groups

Nizamuddin Siddiqui
Updated on 08-Nov-2021 10:04:49

348 Views

To find the number of non-missing values in each group of an R data frame, we can convert the data frame to data.table object and then use the sum function with negation of is.na.For Example, if we have a data frame called df that contains a grouping column say Group and a numerical column with few NAs say Num then we can find the number of non-missing values in each Group by using the below given command −setDT(df)[,sum(!is.na(df)),by=.(Group)]Example 1Following snippet creates a sample data frame −Grp

Search Tree and Hash Tables in Compiler Design

Ginni
Updated on 08-Nov-2021 10:03:11

3K+ Views

Search TreeA more effective technique to symbol table organization is to add two link fields, LEFT and RIGHT, to every record. We use these fields to link the records into a binary search tree.This tree has the property that all names NAME (j) accessible from NAME (i) by following the link LEFT (i) and then following any sequence of links will precede NAME (i) in alphabetical order (symbolically, NAME (j) < NAME (i))Similarly, all names NAME (k) accessible starting with RIGHT (i) will have the property that NAME (i) < NAME (k). Thus, if we are searching for NAME and ... Read More

Advertisements