Challenge 1 Instructions

challenge_1
KhadijatAdeleye
Birds
ggplot2
Reading in data and creating a post
Author

Khadijat Adeleye

Published

March 1, 2023

##Reading in data

Code
df <- read.csv("_data\\birds.csv")

view(df)
Error in view(df): could not find function "view"

#Description of Datasets The second dataset has 14 columns and 30977 observations. From colnames, we get to know that the dataset gives us the values of the dietary energy intake for different countries across different years from 1961-2017. Data types of the columns, value could actually be converted into double type. There were around 11000 missing values found and removed from the data. Many countries were included in this dataset and there are 6 types of birds but only one domain of animals present.

Code
dim(df) 
[1] 30977    14
Code
list(colnames(df))
[[1]]
 [1] "Domain.Code"      "Domain"           "Area.Code"        "Area"            
 [5] "Element.Code"     "Element"          "Item.Code"        "Item"            
 [9] "Year.Code"        "Year"             "Unit"             "Value"           
[13] "Flag"             "Flag.Description"
Code
str(df)
'data.frame':   30977 obs. of  14 variables:
 $ Domain.Code     : chr  "QA" "QA" "QA" "QA" ...
 $ Domain          : chr  "Live Animals" "Live Animals" "Live Animals" "Live Animals" ...
 $ Area.Code       : int  2 2 2 2 2 2 2 2 2 2 ...
 $ Area            : chr  "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
 $ Element.Code    : int  5112 5112 5112 5112 5112 5112 5112 5112 5112 5112 ...
 $ Element         : chr  "Stocks" "Stocks" "Stocks" "Stocks" ...
 $ Item.Code       : int  1057 1057 1057 1057 1057 1057 1057 1057 1057 1057 ...
 $ Item            : chr  "Chickens" "Chickens" "Chickens" "Chickens" ...
 $ Year.Code       : int  1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 ...
 $ Year            : int  1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 ...
 $ Unit            : chr  "1000 Head" "1000 Head" "1000 Head" "1000 Head" ...
 $ Value           : int  4700 4900 5000 5300 5500 5800 6600 6290 6300 6000 ...
 $ Flag            : chr  "F" "F" "F" "F" ...
 $ Flag.Description: chr  "FAO estimate" "FAO estimate" "FAO estimate" "FAO estimate" ...
Code
df <- transform(df,val= as.numeric(Value))
sum(is.na(df))
[1] 2072
Code
df<-na.omit(df)
dim(df)
[1] 29941    15
Code
area<-select(df,Area)
Error in select(df, Area): could not find function "select"
Code
table(area)
Error in table(area): object 'area' not found

#list of items in the dataset

Code
item<-select(df,Item)
Error in select(df, Item): could not find function "select"
Code
table(item)
Error in table(item): object 'item' not found
Code
domain<-select(df,Domain)
Error in select(df, Domain): could not find function "select"
Code
table(domain)
Error in table(domain): object 'domain' not found
Code
plot(val~Year,df)

Code
df_Afghanistan <-df%>% filter(`Area`=='Afghanistan')
Error in df %>% filter(Area == "Afghanistan"): could not find function "%>%"
Code
plot(val~Year,df_Afghanistan)
Error in eval(m$data, eframe): object 'df_Afghanistan' not found