Part 1 - Import and Wragling Codes
Part 1 - Import and Wragling Codes
infant_data<-data.frame(Age=numeric(0),gender=character(0),weight=numeric(0))
mydata<-edit(infant_data)
mydata
# 2 m 3.4
# 3 f 2.8
# 2 m 4.0
# 5 m 3.8
# 4 f 3.0
# 6 f 2.5
mydata<-edit(mydata)
## embeding data
#(1)
2 m 3.4
3 f 2.8
2 m 4.0"
#(2)
install.packages("xlsx")
install.packages("haven")
install.packages("foriegn")
library(xlsx)
library(haven)
library(foreign)
# stata
View(practice)
#SPSS
View(Rain)
install.packages("Hmisc")
library(Hmisc)
Rain1
#EXCEL
View(EastHar)
# CSV file
View(exceldata)
install.packages("readxl")
library(readxl)
## Exporting data
df
##DATA WRAGLING
quiz
quiz$SUM <- quiz$x1 + quiz$x2 # assigned to a new column named "SUM" within the quiz data frame
quiz
#EXTRACTING
str(USArrests)
USArrests[3,2]
USArrests$Assault[3]
Assault[3]
str(USArrests)
USArrests[USArrests$UrbanPop == 80, ]
attach(USArrests)
USArrests[UrbanPop == 80, ]
detach(USArrests)
attach(USArrests)
detach(USArrests)
USArrests[order(USArrests$Murder), ] #Ascending
USArrests[order(-USArrests$Murder), ] #Descending OR
attach(USArrests)
USArrests[order(Murder), ] #Ascending
USArrests[order(-Murder), ] #Descending OR
detach(USArrests)
total <- merge(DF1, DF2, all = TRUE) # include all data from both data frames.
##
str(cars)
## RECODING VARIABLES
str(cars)
attach(cars)
str(cars)
detach(cars)