#Load Libraries and download dataset
library("tidyverse")
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(dplyr)
Norwegian_data <- read.csv("https://storage.googleapis.com/kagglesdsdata/datasets/1752/3039/main_data.csv?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=gcp-kaggle-com%40kaggle-161607.iam.gserviceaccount.com%2F20231217%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20231217T165359Z&X-Goog-Expires=259200&X-Goog-SignedHeaders=host&X-Goog-Signature=93d6078e3147cc124556d4b02e81d804fd3d57ee4a7a295c379f7884a602d94876e2fbcca02ec9c1a209c00887ecce4930ffa62fc715a2a297b520edc0c61b8df7fedaa59f4ece8655a4ea8a3782d357f8d5038ea34437efda823ddbe811ace27e81c187bb3e63f53b9bae76bfe0ff935aeb78ae544c02131e53f7b3b04d6c0f0efd93b02e41d048520ea552517060f0013166b5db373fb2a4f550b0641e0a11fcd476bf0755e021f6c16cf738f1392966cf26aad406d25d9ec3815abb977974219174e9c7ae5fd2c4dbe3848ef36d884691e5af1892a87f8bcaa1be3712502660428021bd504b544fcd74e4219b398d292fedaf1b1c4a0eb2999aa29c1117b6")

When a baby is born, they not only have to understand the fundamentals with how their mouth works, but they also need to understand and acquire their native language. This particular dataset that was chosen helps us with the questions: How fast does a baby/toddler acquire new words? What types of words are these children learning? What age are these children acquiring these words? First, we look at how a child’s initial vocabulary is distributed across different lexical categories.

#Create a density plot to show how a child's initial vocabulary is distributed across broad lexical term categories.
ggplot(data = Norwegian_data, aes(x = VSoA, group = Broad_lex, fill = Broad_lex)) +
  geom_density(adjust = 1.5, alpha=.4) +
  ggtitle("Distribution of Children's Known Words") +
  theme_classic()

The density table above illustrates the distribution of different words of different lexical categories. VSoA, how many other words a child generally knows when they learn new words, points out that children are acquiring predicates more so than other lexical categories. A predicate tells the subject in the sentence what to do, such as, “The cat is sleeping.” “Is sleeping” is the predicate in this simple sentence. What stands out the most with this particular visualization is closed-cased words, such as ‘the’ or ‘that’. Children are learning these words at later ages in their lives. The orange hue for #N/A contain words that were being tested, but created some challenge for children due to the complexity with the words and their age level, such as the deictic pronouns today, tomorrow, tonight, etcetera. This particular information is still important to know for our questions on this dataset, hence why they are still a part of the visualizations.

Next, we will be looking at Age of Acquisition and the learning of new words.

#Create a second density plot, showing the Age of Acquisition of when these children acquired these broad lexical categories. 
ggplot(data = Norwegian_data, aes(x = AoA, group = Broad_lex, fill = Broad_lex)) +
  geom_density(adjust=1.5, alpha=.4) +
  ggtitle("Distribution Age at Word Learning") +
  theme_classic()

This new density chart illustrates that the AoA (Age of Acquisition) of learning predicate words comes to its peak at around 25 months old. However, not all children are the same when it comes to their own personal language development. The range of this lexical category goes from 18 months up to 30 months of age. The lexical category, closed-class is still categorized as being a later stage of language acquisition for children, ranging from 20 months old to 35 months. However, what is significant is that #N/A portion of the visualization. This component provides reassurance that these particular words are too complex for children until they range around 20 months to 35 months. The peak of these complex words are around 28 months of age.

Now we can see how VSoA and AoA correlate.

#Create a scatter plot VSoA vs. AoA. Find what is the correlation between the two. 
ggplot(Norwegian_data, aes(x= AoA, y= VSoA, group = Broad_lex, fill = Broad_lex, color = Broad_lex)) +
  geom_point(stat = "identity") + 
  theme_classic() +
ggtitle("Age at word learning vs words know at that age")

The scatterplot above suggests a large aggregation of already known words by the age children learn words (VSoA) and the acquisition of learning those new words (AoA). This is between the ages of 20 months to 30 months. We are also able to visualize as a child ages, more complex words are being utilized in their vocabulary, which is why you are able to see closed-cased lexical category not being utilized at all up until around 18 months old. Then it is heavily used starting around 22 months old and increases from there.

Now that these correlations are able to help us visualize the relationship between vocabulary words, lexical features, and language acquisition, we can now look at the distribution of words with language acquisition.

#Create a dataset and then the histogram visualization for the Distribution of Language Acquisition.
Norwegian_data <- data.frame(
  AoA = c("15","20","25","30","35") ,
  Count = c(0,50,100,200,250))
ggplot(Norwegian_data, aes(x = AoA, y = Count)) +
  geom_col( fill = "pink", colour = "black") +
  ggtitle("Distribution of Age of Acquisition of Words")

This visualization above indicates that the initial start of language acquisition for children begins at around 20 months old. Around 20 months old children are able to put two words together, say common objects, and follow simple commands. This graph indicates a positive indication that as children get older they acquire more complex vocabularies. At around 35 months old, which is the highest peak on this graph, children are known to want to read, begin signing, and even begin to ask questions.

Based on these four visualizations, we can conclude that as children age, their language becomes more complex. We are able to see that children are more likely to pick up predicates at earlier stages, closed-class lexical items at older ages. As these children progress with their ages, their vocabulary with the lexical category that could not be accurately tested will be fulfilled. We are able to exponentially see that there is an overall exponential increase in children’s acquired language at around 18 months old and it continuously increases as they age.