# Task 1 - A list of at least 3 columns (or values) in the data which are unclear until we read the documentation.

# Loading necessary libraries
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# Load the data from the CSV file
NY_House_Dataset <- read.csv("C:\\Users\\velag\\Downloads\\NY-House-Dataset.csv")

# Columns and values that are unclear 
unclear_columns <- c("BATH", "LONG_NAME", "PRICE")
unclear_values <- c("2.373860858", "Regis Residence", "-111 Fifth Ave")

# Explanation to Reader:
# These columns and values may be unclear without proper documentation. 

#BATH: The meaning of "2.373860858" in the "BATH" column is ambiguous without further context. It could represent the number of bathrooms, but the exact interpretation is uncertain.

#LONG_NAME: The value "Regis Residence" in the "LONG_NAME" column lacks clarity without additional information. It is unclear what this value represents within the dataset.

#PRICE: The value "-111 Fifth Ave" in the "PRICE" column seems unusual and requires clarification. It is unexpected for a price value to be represented by a street address.

#Understanding the context and intended meaning of these columns and values is crucial for accurate analysis. Failure to interpret them correctly could lead to misinterpretation of the data and erroneous conclusions. Further investigation or consultation of the dataset documentation is necessary to clarify these uncertainties.

unclear_columns
## [1] "BATH"      "LONG_NAME" "PRICE"
unclear_values
## [1] "2.373860858"     "Regis Residence" "-111 Fifth Ave"
# Extract values from the specified columns
bath_values <- unique(NY_House_Dataset$BATH)
long_name_values <- unique(NY_House_Dataset$LONG_NAME)
price_values <- unique(NY_House_Dataset$PRICE)

# Display the extracted values
print("Distinct values in the 'BATH' column:")
## [1] "Distinct values in the 'BATH' column:"
print(bath_values)
##  [1]  2.000000 10.000000  1.000000  2.373861 16.000000  3.000000  4.000000
##  [8]  6.000000  8.000000  5.000000  9.000000  7.000000 32.000000 13.000000
## [15] 50.000000 20.000000 11.000000 12.000000 24.000000 43.000000  0.000000
## [22] 17.000000
# Extract and display the first few unique values for the 'PRICE' column
print("First few distinct values in the 'PRICE' column:")
## [1] "First few distinct values in the 'PRICE' column:"
head(unique(NY_House_Dataset$PRICE))
## [1]    315000 195000000    260000     69000  55000000    690000
# Extract and display the first few unique values for the 'LONG_NAME' column
print("First few distinct values in the 'LONG_NAME' column:")
## [1] "First few distinct values in the 'LONG_NAME' column:"
head(unique(NY_House_Dataset$LONG_NAME))
## [1] "Regis Residence"  "West 57th Street" "Sinclair Avenue"  "East 55th Street"
## [5] "East 64th Street" "Park Place"
# Task 2 - At least one element or data that is unclear even after reading the documentation

# Load the dataset
NY_House_Dataset <- read.csv("C:\\Users\\velag\\Downloads\\NY-House-Dataset.csv")

# Check unique values in the "TYPE" column
unique_types <- unique(NY_House_Dataset$TYPE)

# Print unique values
print(unique_types)
##  [1] "Condo for sale"             "House for sale"            
##  [3] "Townhouse for sale"         "Co-op for sale"            
##  [5] "Multi-family home for sale" "For sale"                  
##  [7] "Contingent"                 "Land for sale"             
##  [9] "Foreclosure"                "Pending"                   
## [11] "Coming Soon"                "Mobile house for sale"     
## [13] "Condop for sale"
#Explanation to Reader:
#After reading the documentation provided for the dataset, one element of the data that remains unclear is the encoding or representation of the "TYPE" column, which denotes the type of property (e.g., Condo, House, Co-op). The documentation describes the types of properties that may appear in this column but does not specify how these types are encoded within the dataset. It's unclear whether the types are represented as strings, numerical codes, or categorical values.

#Further investigation is necessary to understand the specific encoding scheme used for the "TYPE" column. This could involve examining the unique values in the column, checking for any numerical codes or abbreviations, or consulting additional documentation or data dictionaries if available. Understanding the encoding of this column is essential for accurate analysis and interpretation of the data.
# Task 3 - Visualization Highlighting Unclear Element:

# Loading necessary libraries
library(ggplot2)


# Create a histogram of property prices
ggplot(NY_House_Dataset, aes(x = PRICE)) +
  geom_histogram(fill = "skyblue", color = "black") +
  labs(title = "Distribution of Property Prices",
       x = "Price",
       y = "Frequency") +
  theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

# Add annotation for negative prices
annotation <- paste("Negative prices observed:", sum(NY_House_Dataset$PRICE < 0))
ggplot(NY_House_Dataset, aes(x = PRICE)) +
  geom_histogram(fill = "skyblue", color = "black") +
  annotate("text", x = min(NY_House_Dataset$PRICE), y = 50, label = annotation, color = "red", size = 5) +
  labs(title = "Distribution of Property Prices",
       x = "Price",
       y = "Frequency") +
  theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

# Explanation:

#The visualization consists of a histogram showing the distribution of property prices. However, we noticed that some prices are negative, which is unexpected for property prices. To highlight this issue, we added an annotation indicating the number of negative prices observed in the dataset.

#Significance:

#Negative prices for properties are unusual and may indicate errors or inconsistencies in the data collection process. Such anomalies could lead to inaccurate analyses and conclusions if not addressed properly.
# Task 4 - Risks and Mitigation Strategies:

# Risks and mitigation strategies
significant_risks <- c("Risk 1: Misinterpretation of unclear values may lead to incorrect analysis.",
                       "Risk 2: Unclear elements may affect the accuracy of predictive models.",
                       "Risk 3: Incomplete documentation may result in overlooked data biases.")

mitigation_strategies <- c("Strategy 1: Seek clarification from data providers or experts.",
                           "Strategy 2: Perform sensitivity analysis to assess the impact of unclear elements.",
                           "Strategy 3: Document assumptions made when dealing with unclear data.")

# Explanation to Reader:
# These identified risks underscore the importance of clarity in data interpretation. By implementing mitigation strategies, such as seeking clarification and conducting sensitivity analysis, we can reduce the likelihood of errors and ensure the reliability of our findings.

significant_risks
## [1] "Risk 1: Misinterpretation of unclear values may lead to incorrect analysis."
## [2] "Risk 2: Unclear elements may affect the accuracy of predictive models."     
## [3] "Risk 3: Incomplete documentation may result in overlooked data biases."
mitigation_strategies
## [1] "Strategy 1: Seek clarification from data providers or experts."                    
## [2] "Strategy 2: Perform sensitivity analysis to assess the impact of unclear elements."
## [3] "Strategy 3: Document assumptions made when dealing with unclear data."