May 13, 2017
R Programming functions You should Learn
In this article, we will learn about same basic functions of R which will helps us to explore R in depth. As we have mentioned R in Programming languages you shouldn’t miss in 2017? Lets Dive into Learning important R basics –
By default sample() randomly reorders the elements passed as the first argument.
Plot the Graph
Plotting a graph is must with the data. We can plot be this in built function
Let’s focus towards inbuilt data set mtcars(Motor Trend Car Road Tests) comprises fuel consumption and provides performance for 32 automobiles.We’ll try to filter data and process them.
This will allow you to print all the data present in the data set.
This will allows you to print the head elements of data set. Head elements are the top most elements of the data set.
This will help you to sort the data by the field ‘mpg’.’mpg’ is miles per gallon related to automobiles.To sort a data frame in R, use the order( ) function. By default, sorting is ASCENDING. Prepend the sorting variable by a minus sign to indicate DESCENDING order.
Assign one variable newdata the sorted value by execution of this command, newdata <- mtcars[order(mpg),]
and the print newdata by this : print(newdata)
Assign one variable data the sorted value by execution of this command, data <- mtcars[order(-mpg),]
and the print data by this : print(data)
** Ctrl + L is used to clear the console.