Articles on Trending Technologies

Technical articles with clear explanations and examples

How to subset an R data frame by specifying columns that contains NA?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 465 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

Read More

What are Lists and Self-Organizing lists in compiler design?

Ginni
Ginni
Updated on 08-Nov-2021 2K+ 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 the common elements between two columns of an R dataframe.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 6K+ 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

Read More

Find the number of non-missing values in each group of an R data frame.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 440 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

Read More

What is Search Tree and Hash Tables in compiler design?

Ginni
Ginni
Updated on 08-Nov-2021 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

How are access links and displays used to access non-local names?

Ginni
Ginni
Updated on 08-Nov-2021 7K+ Views

An access link is a pointer to each activation record that obtains a direct implementation of lexical scope for nested procedures. In other words, an access link is used to implement lexically scoped language. An “access line” can be required to place data required by the called procedure.An improved scheme for handling static links defined at various lexical levels is the usage of a data structure called display. A display is an array of pointers to the activation records. Display [0] contains a pointer to the activation record of the most recent activation of a procedure defined at lexical level ...

Read More

Create stacked bar chart with percentages on Y-axis using ggplot2 in R.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 1K+ Views

To create stacked bar chart with percentages on Y-axis using ggplot2 in R, we can use fill argument inside geom_bar and put the second categorical variable with position set to fill.For Example, if we have a data frame called with two categorical columns say C1 and C2 then we can create stacked bar chart with percentages on Y-axis using the below mentioned command −ggplot(df,aes(C1))+geom_bar(aes(fill=C2),position="fill")ExampleFollowing snippet creates a sample data frame −f1

Read More

What is Types of Representative Scope Information?

Ginni
Ginni
Updated on 08-Nov-2021 2K+ Views

Representing scope information is a concept in which the scope of each variable name is preserved in the symbol table so that we can use the same name in different blocks and different locations. Representing name in symbol table along with an indicator of the block in which it appears.Suppose we have a variable name 'a' in block A and the same variable in block B. Suppose it can store 'a' in the symbol table without block information. In that case, it will only keep the first instance of 'a' which it encounters, hence to overcome this problem names are ...

Read More

Subset groups that occur greater than equal to n times in R dataframe.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 521 Views

To subset groups that occur less than n times in R data frame, we can use filter function of dplyr package.For Example, if we have a data frame called df that contains a grouping column say Group then we can subset groups that occur less than 4 times by using the below mentioned command −df%%group_by(Group)%%filter(n()=4)Example 1Following snippet creates a sample data frame −Grp

Read More

How to find the sum of rows of a column based on multiple columns in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 08-Nov-2021 1K+ Views

To find the sum of rows of a column based on multiple columns in R data frame, we can follow the below steps −First of all, create a data frame.Then, use aggregate function to find the sum of rows of a column based on multiple columns.ExampleCreate the data frameLet’s create a data frame as shown below −Grp1

Read More
Showing 47531–47540 of 61,297 articles
Advertisements