 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1267 of 2650
 
 
			
			3K+ Views
To collapse data frame rows by summing using dplyr package, we can use summarise_all function of dplyr package. For example, if we have a data frame called df that has a categorical column say Group and one numerical column then collapsing of rows by summing can be done by using the command −df%>%group_by(Group)%>%summarise_all(funs(sum))Consider the below data frame −Example Live DemoGroup
 
 
			
			712 Views
Subsetting is one of the most important aspects of data analysis. One such situation could be subsetting the character column based on multiple values. For example, if a character column of an R data frame has 5 categories then we might want to extract only 2 or 3 or 4 values then it can be done by using the filter function of dplyr package with str_detect function of stringr package.Consider the below data frame −Example Live DemoGroup
 
 
			
			194 Views
If a vector value exists in another vector then we might want to find the frequency/count for such values in the other vector. For example, if we have two vectors say x and y, and some of the values in y exists in x as well. Therefore, we can find the frequency of values in x for y values can be found by using the command colSums(outer(x,y,"==")).Example Live Demox1
 
 
			
			564 Views
If we have time series data stored in a data frame then plotting the same as a time series cannot be done directly, also the labels for the series might not be possible directly. Therefore, we first need to convert the data frame to a time series object by using the function ts as shown in the below example and then using the plot function to create the plot, this will display the labels for the series as well.Consider the below data frame −Example Live DemoTime
 
 
			
			700 Views
By subtotal we mean finding the sum of values based on grouping column. For example, if we have a data frame called df that contains three numerical columns as x, y, z and one categorical column say Group then the subtotal of x, y, z for each category in Group can be found by using the command aggregate(cbind(x,y,z)~Group,data=df,FUN=sum).Consider the below data frame −Example Live Demox1
 
 
			
			279 Views
To create a random vector of integers with increasing values, we can do random sampling with sample.int and for increasing values cummax function needs to be used. For example, to create a random vector of integers of size 5 up to values 5 starting from 1 can be done by using the command cummax(sample.int(5)).Example Live Demox1
 
 
			
			2K+ Views
When we perform any type of data analysis, there are many types of objects that are created in the R environment such as vector, data frame, matrix, lists, arrays, etc. If we want to get the list of available data frames in R environment then we can use the below command −names(which(unlist(eapply(.GlobalEnv,is.data.frame))))Example Live Demox1
 
 
			
			4K+ Views
If we have a numeric column in an R data frame and the unique number of values in the column is low that means the numerical column can be treated as a factor. Therefore, we can convert numeric columns to factor. To do this using dplyr package, we can use mutate_if function of dplyr package.Loading dplyr package and converting numerical columns in BOD data set (available in base R) to factor columns −Examplelibrary(dplyr) str(BOD) 'data.frame': 6 obs. of 2 variables: $ Time : num 1 2 3 4 5 7 $ demand: num 8.3 10.3 19 16 15.6 19.8 - ... Read More
 
 
			
			455 Views
Assume, you have a dataframe and the result for trim of minimum and the maximum threshold value, minimum threshold: Column1 Column2 0 30 30 1 34 30 2 56 30 3 78 50 4 30 90 maximum threshold: Column1 Column2 0 12 23 1 34 30 2 50 25 3 50 50 4 28 50 clipped dataframe is: Column1 Column2 0 30 30 1 34 30 2 50 30 3 ... Read More
 
 
			
			318 Views
Assume, you have a dataframe and the result for quantify shape of a distribution is, kurtosis is: Column1 -1.526243 Column2 1.948382 dtype: float64 asymmetry distribution - skewness is: Column1 -0.280389 Column2 1.309355 dtype: float64SolutionTo solve this, we will follow the steps given below −Define a dataframeApply df.kurt(axis=0) to calculate the shape of distribution, df.kurt(axis=0)Apply df.skew(axis=0) to calculate unbiased skew over axis-0 to find asymmetry distribution, df.skew(axis=0)ExampleLet’s see the following code to get a better understanding −import pandas as pd data = {"Column1":[12, 34, 56, 78, 90], "Column2":[23, 30, 45, ... Read More