Rstudio can't run the whole code as it stopped when it reaches the last function and do nothing, also I can't run any other code. I tried the memory functions to increase the memory but it did not solve the proplem.
adult<-read.csv('adult_sal.csv')
head(adult)
library(dplyr)
adult <- adult <- select(adult,-X)
head(adult)
summary(adult)
str(adult)
table(adult$type_employer)
unemp <- function(job){
job <- as.character(job)
if(job== 'Never-worked' | job=='Without-pay'){
return('Unemployed')
}else{
return(job)
}
}
adult$type_employer <- sapply(adult$type_employer,unemp)
group_emp <- function(job){
if (job=='Local-gov' | job=='State-gov'){
return('SL-gov')
}else if (job=='Self-emp-inc' | job=='Self-emp-not-inc'){
return('self-emp')
}else{
return(job)
}
}
adult$type_employer <- sapply(adult$type_employer,group_emp)
table(adult$type_employer)
status.m <- function(married){
if(married=='Married-spouse-absent' | married == 'Married-AF-spouse' | married== 'Married-civ-spouse'){
return('Married')
}else if (married=='Separated' | married=='Divorced' | married=='Widowed'){
return('Not-Married')
}else{
return(married)
}
}
adult$marital <- sapply(adult$marital,status.m)
table(adult$marital)
table(adult$country)
Asia <- c('China','Hong','India','Iran','Cambodia','Japan', 'Laos' ,
'Philippines' ,'Vietnam' ,'Taiwan', 'Thailand')
North.America <- c('Canada','United-States','Puerto-Rico' )
Europe <- c('England' ,'France', 'Germany' ,'Greece','Holand-Netherlands','Hungary',
'Ireland','Italy','Poland','Portugal','Scotland','Yugoslavia')
Latin.and.South.America <- c('Columbia','Cuba','Dominican-Republic','Ecuador',
'El-Salvador','Guatemala','Haiti','Honduras',
'Mexico','Nicaragua','Outlying-US(Guam-USVI-etc)','Peru',
'Jamaica','Trinadad&Tobago')
Other <- c('South')
group_country <- function(ctry){
if (ctry %in% Asia){
return('Asia')
}else if (ctry %in% North.America){
return('North.America')
}else if (ctry %in% Europe){
return('Europe')
}else if (ctry %in% Latin.and.South.America){
return('Latin.and.South.America')
}else{
return('Other')
}
adult$country <- sapply(adult$country,group_country)
table(adult$country)
adult<-read.csv('adult_sal.csv')
head(adult)
library(dplyr)
adult <- adult <- select(adult,-X)
head(adult)
summary(adult)
str(adult)
table(adult$type_employer)
unemp <- function(job){
job <- as.character(job)
if(job== 'Never-worked' | job=='Without-pay'){
return('Unemployed')
}else{
return(job)
}
}
adult$type_employer <- sapply(adult$type_employer,unemp)
group_emp <- function(job){
if (job=='Local-gov' | job=='State-gov'){
return('SL-gov')
}else if (job=='Self-emp-inc' | job=='Self-emp-not-inc'){
return('self-emp')
}else{
return(job)
}
}
adult$type_employer <- sapply(adult$type_employer,group_emp)
table(adult$type_employer)
status.m <- function(married){
if(married=='Married-spouse-absent' | married == 'Married-AF-spouse' | married== 'Married-civ-spouse'){
return('Married')
}else if (married=='Separated' | married=='Divorced' | married=='Widowed'){
return('Not-Married')
}else{
return(married)
}
}
adult$marital <- sapply(adult$marital,status.m)
table(adult$marital)
table(adult$country)
Asia <- c('China','Hong','India','Iran','Cambodia','Japan', 'Laos' ,
'Philippines' ,'Vietnam' ,'Taiwan', 'Thailand')
North.America <- c('Canada','United-States','Puerto-Rico' )
Europe <- c('England' ,'France', 'Germany' ,'Greece','Holand-Netherlands','Hungary',
'Ireland','Italy','Poland','Portugal','Scotland','Yugoslavia')
Latin.and.South.America <- c('Columbia','Cuba','Dominican-Republic','Ecuador',
'El-Salvador','Guatemala','Haiti','Honduras',
'Mexico','Nicaragua','Outlying-US(Guam-USVI-etc)','Peru',
'Jamaica','Trinadad&Tobago')
Other <- c('South')
group_country1 <- function(ctru){
if (ctru %in% Asia){
return('Asia')
}else if (ctru %in% North.America){
return('North.America')
}else if (ctru %in% Europe){
return('Europe')
}else if (ctru %in% Latin.and.South.America){
return('Latin.and.South.America')
}else{
return('Other')
}
adult$country <- sapply(adult$country,group_country1)
table(adult$country)