How to calculate binomial distribution in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Binomial distribution is a discrete random distribution modeling the probability of event success number x in N Bernoulli trial. A Bernoulli trial is an experiment of binary (success/fail) result with a constant success rate in each trial. To calculate the probability for individual success number x in R, function dbinom() can be used. Read more…

Using while loop to move items between two lists in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. It is very often that items in list should be moved to another list in Python programming. For example, users trying to register on a website can only be moved to a verified user list after certain conditions are met. In such circumstance, a while loop can be applied. You can also watch videos Read more…

How to copy a list in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. The mechanism for copying a list in Python appears somewhat different than in other programming languages. If you just use equal symbol to assign an existing list to a new one, both objects refer to the same one which is stored in the computers memory. Say we have a list for favorite languages and Read more…

How to pass arbitrary number of information when calling a function in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. After a function is defined and will be called, it is natural to pass required information in the calling statement. In the following example, we create a function about traveling with parameter person and country, for printing the country people have recently traveled. Sometimes, there are multiple elements that will be passed as the Read more…

Using while loop to remove all specific elements from a list in Python

rdatacode provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Python provides function remove() to remove items in a list based on its value, but it removes only the first occurrence of instances if there are more than one such items existing in the list. From the code example above, we can see there is still a “Toyota” present in the list after we Read more…

Conditional test if items in a list in Python

rdatacode provide affordable online training course for Python and R programming at fundamental level, click here for more details. If you want to test if some particular items are in a list, you can use ‘in’ or ‘not in’ keywords in Python. Consider that we have a list containing names of 6 student candidates, then we can test if ‘Bob’ or ‘White’ are in the list. Sometimes you can also test whether some items are Read more…

How to slice a list in Python

rdatacode provide affordable online training course for Python and R programming at fundamental level, click here for more details. Slicing a list in Python is a kind of operation that returns part of a list. The basic form of a slice is using starting and ending index with colon between of a list inside square brackets following a list. Say we have a list for family member, and will get part of a list from Read more…

Use str() to transform variable in Python

We provide affordable online training course for Python and R programming at fundamental level, click here for more details. In Python, if a string variable is concatenated with a numeric value directly, an error comes. In the following code example, a string variable ‘ strva’ is concatenated directly with number 2, Python returns a traceback, because these two data types can not be concatenated without transformation. To overcome this shortage, str() function can be applied Read more…

How to use arrange() function in R to sort dataset

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! arrange() function from Dplyr package in R provides an alternative way as sort() function in R base installation for sorting a data frame with respect to variables, either in ascending or descending order. Moreover, Dplyr is part of a bigger package framework called ‘tidyverse’, and it allows its functions to be chained using Read more…

How to use filter() function to select observations in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration ! Dplyr is a package in R. It belongs to Tidyverse framework, and is allowed to use pipeline structure to chain multiple operations together into one statement. There are many functions in Dplyr package, and one of them is filter(). filter() is used to select observations in terms of specific conditions. For example we Read more…