How to transpose data objects in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! Tabular data objects in R can be easily transposed with t() function. In the following example, we create a matrix of 2 rows and 3 columns, then transpose it, and the rows and columns are interchanged. In the next example, we create a data frame first, then rows and columns are interchanged with t() Read more…

Using with() to simply your object operations in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! with() function in R provides an alternative way of carrying out several operations bypassing inputting object name repeatedly. For example, we have a data frame ‘grade’ on hand, and want to calculate the correlation coefficient between Math and Physics variables and show summary statistics of numerical variables, we can write code as follows: If Read more…

How to use apply() function in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! apply() function in R programming is used to perform a specified function, either a R base installation function or an user-written function, to the rows or columns of a matrix or data frame. The basic for of the function is : apply(object, axis, fun) Where object is a matrix or data frame, axis denotes Read more…

Using probability functions in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! R provides rich availability of using probability functions. Probability functions in R takes the form [dpqr][prob], Where [dpqr] represent which kind of variates the function works on d – probability density p – cumulative probabilty q – quantile value r – random number generation [prob] denotes which probability distribution is taken on. The following Read more…

Subseting datasets in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! When a data frame is created in R, usually parts of it will be used later. Subset of the dataset, either by row or by column, or both can be easily created in R. The following example, only data containing columns for ‘Math’, ‘Physics’, and ‘Chemistry’ are selected and assigned to a new object, Read more…

Merging and combining datasets using merge(), rbind() and cbind() in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! R provides two functions which make combine different datasets easy and feasible. rbind() is used when two datasets have same column variables and data observations are combined and expanded, whereas cbind() combines two datasets when they have the same number of rows. And merge() is used when two datasets have common column variables. The Read more…

How to generate random numbers from Normal, Uniform and Poisson distribution in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! Doing statistics using R is perfect for many data analysts. Dealing with various statistical distributions and generating random numbers from some widely used distributions are mandatory for data science. In this post, we show how to generate random numbers from Normal, Uniform and Poisson distributions in R. Normal variates can be generated by using Read more…

How to generate a set of sample data using sample() function in R

We provide effective and economically affordable training courses for R and Python, click here for more details and course registration ! sample() function in R selects random samples from a given population. The population can be all elements of a vector, observations of a data frame, etc. For example, in the following code example, 10 elements are randomly selected a population of 100 integers, with replacement possible. The basic form of sample() is sample(object, n, Read more…

How to select observations of data frames in R

rdatacode.com provides online training course for R and Python, click here for more info ! When a data frame is applied in data analysis in R, very often some specific rows or observations may be selected. The simplest way to select observations is filling row indices in square brackets. Conditional test can be included into row selection. In the following example, Male students over 23 years old are selected. Date variable can be transformed to Read more…

How to draw multivariate statistical data in R

rdatacode.com provides online training course for R and Python, click here for more info ! In simulation and Bayesian statistics, it is often needed to draw data coming from multivariate variables. R provides a function draw.d.variate.dist() from package ‘MultiRNG’ for such purpose. For example, draw.d.variate.normal() are used to draw multivariate random data coming from variables have joint normal distributions. In the following example, 200 random sample data are drawn from 3 variables which follow joint Read more…