Archive for the ‘R Programming’ Category

Differences between length and nchar in R

length(x) will give how many elements are there in a vector. nchar(x) will give how many letters in each element of x. Examples:

Installation of r package dplyr

dplyr is R package for data manipulation using the Split Apply Combine Methodology, the next iteration of the very popular plyr package. As per R documentation dplyr is “A Grammar of Data Manipulation”. It’s the next iteration of plyr, focused on tools for working with data frames > install.packages(“dplyr”) Installing package into ‘C:/Users/pinnapav/Documents/R/win-library/3.3’

How to get first and last rows of Data Frame in R

We can get first n rows of Data Frame using head() function and can get last n rows of Data Frame using tail() function. Syntax of head() and tail() functions: head(data.frame,number_of_first_rows) tail(data.frame,number_of_last_rows)

Convert List to Vector in R

A list can be converted to a Vector in R. So that the elements of the vector can be used for further manipulation. All arthimetic operations o vectors can be applied after the the list is converted to vectors. We can convert list to vector using unlist() function. It takes list as input and produces […]

How to get list of User defined Variables in R

Variables are containers to for storing data in any programming language. We get the list of variables defined in R Programming Language using ls(), objects() functions. R Variables starting with dot(.) are hidden, they can be listed using ls(all:names=TRUE). Examples:

Powered by k2schools