
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Found 2038 Articles for R Programming

97 Views
We can convert a factor to integer or numeric variable by using as.numeric function with defining the levels of the factor or by defining the characters of the factorExample> f f [1] 0.323049098020419 0.916131897130981 0.271536672720686 0.462429489241913 [5] 0.657008627429605 0.462429489241913 0.462429489241913 0.212830029195175 [9] 0.271536672720686 0.497305172728375 7 Levels: 0.212830029195175 0.271536672720686 ... 0.916131897130981Using as.numeric> as.numeric(levels(f))[f] [1] 0.3230491 0.9161319 0.2715367 0.4624295 0.6570086 0.4624295 0.4624295 [8] 0.2128300 0.2715367 0.4973052 > Using as.numeric(as.character( )) > as.numeric(as.character(f)) [1] 0.3230491 0.9161319 0.2715367 0.4624295 0.6570086 0.4624295 0.4624295 [8] 0.2128300 0.2715367 0.4973052

363 Views
We can replace all NA values by using is.na functionExample> Data df df V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 9 7 3 0 3 7 7 3 9 9 2 9 2 3 0 2 0 1 4 6 7 3 5 0 9 2 4 8 8 7 NA 5 4 7 3 1 2 6 NA 7 1 1 8 5 3 2 9 6 4 7 0 5 6 1 6 8 5 6 5 3 9 6 0 7 0 7 8 3 4 NA NA 0 2 4 2 NA 8 6 9 9 9 4 0 6 1 7 NA 9 5 5 NA 8 1 NA 0 9 9 3 10 1 1 0 7 1 1 4 1 2 1Replacing NA’s by 0’s> df[is.na(df)] df V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 9 7 3 0 3 7 7 3 9 9 2 9 2 3 0 2 0 1 4 6 7 3 5 0 9 2 4 8 8 7 0 5 4 7 3 1 2 6 0 7 1 1 8 5 3 2 9 6 4 7 0 5 6 1 6 8 5 6 5 3 9 6 0 7 0 7 8 3 4 0 0 0 2 4 2 0 8 6 9 9 9 4 0 6 1 7 0 9 5 5 0 8 1 0 0 9 9 3 10 1 1 0 7 1 1 4 1 2 1

1K+ Views
We can use regression model object name with $r.squared to find the R-squared and a user defined function to extract the p-value.ExampleExtracting R-Squared> x y LinearRegression summary(LinearRegression)$r.squared [1] 0.2814271Extracting p-value> Regressionp

292 Views
We can sort a data frame by multiple columns using order function.ExampleConsider the below data frame −> df df x1 x2 x3 x4 1 Hi A 4 9 2 Med B 7 5 3 Hi D 5 7 4 Low C 3 4Let’s say we want to sort the data frame by column x4 in descending order then by column x1 in ascending order.It can be done follows −> df[with(df, order(-x4, x1)), ] x1 x2 x3 x4 1 Hi A 4 9 3 Hi D 5 7 2 Med B 7 5 4 Low C 3 4We can do ... Read More

425 Views
In this article, we will learn how to install and configure R on Ubuntu 16.01. “R” is an open-source programming language which can be specially used for statistical computing and performing analytical data. Where “R” has the community well know for the packages generated by the users in a specific area of study. We will install the “R” package using the CRAN (Comprehensive “R” Archive Network).PrerequisitesWe need a Linux machine install with Ubuntu 16.04 server with a minimum of 1 GB of RAM.A non-root user with Sudo permissions on the machine.Adding the CRAN repository to the Machine and Install R ... Read More