This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| library(shiny) | |
| library(gganimate) | |
| library(XML) | |
| library(lubridate) | |
| library(tidyverse) | |
| library(shinydashboard) | |
| library(shinythemes) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub_4<- train %>% | |
| filter(.,no_of_trainings==2) %>% | |
| select(.,department,education,gender,is_promoted) | |
| head(sub_4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| sub_3 <- train %>% | |
| select(.,department,education,gender,is_promoted,no_of_trainings) %>% | |
| filter(.,no_of_trainings==2) | |
| head(sub_3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub_2 <- train[which(train$no_of_trainings == 2),names(train) %in% | |
| c("department","education","gender","is_promoted")] | |
| head(sub_2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| train <- read.csv("~/Analytics Vidhya/HR analytics/train_LZdllcl.csv", header=T) | |
| head(train) | |
| #subset first few rows and columns | |
| sub <- train[1:5000,1:6] | |
| head(sub) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # assign column names | |
| colnames(x) <- c("A", "B", "C") | |
| x | |
| #subset using the names | |
| x[,c('A')] | |
| #using the subset function | |
| subset(x,select=c('A')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <- matrix(1:6,nrow=2,ncol=3) | |
| x | |
| #selecting an element | |
| x[1,1] | |
| #selecting just one row | |
| x[2,] | |
| # selecting one or more columns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <-c(10,12,23,45,84,25,15,56,09) | |
| #selecting one element | |
| x[1] | |
| #selecting multiple elements | |
| x[c(3,9)] | |
| #dropping certain elements | |
| x[-c(1,2)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data<- data.frame(variable1 = rep(LETTERS[1:3], each = 3), | |
| variable2 = rep(paste0("factor", c(1, 2, 3)), 3), | |
| num = 1:9) | |
| head(data) | |
| spread(data,variable2,num) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <- "AnaLytics VidHya 001" | |
| str_to_lower(x) | |
| str_to_upper(x) |
NewerOlder