Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Cannot figure out what I am doing wrong with the following R code. I ended up deleting the final two lines of code for the
Cannot figure out what I am doing wrong with the following R code. I ended up deleting the final two lines of code for the plots, but even with the complete code it would not run properly. Please help.
Dataset-csv file
\begin{tabular}{|r|r|r|r|r|r|r|r|} \hline \multicolumn{1}{|c|}{ Subject } & & \multicolumn{1}{l|}{ A } & \multicolumn{1}{l|}{ B } & C & D & \multicolumn{1}{|l|}{ E } \\ \hline row names & 1 & 16.47 & 47.99 & 0 & 3 & 12.45 \\ \hline 2 & 2 & 22.75 & 73.26 & 2 & 4 & NA \\ \hline 3 & 3 & 4.30 & 11.02 & 1 & 4 & NA \\ \hline 4 & 4 & 21.22 & 58.91 & 1 & 6 & 9.23 \\ \hline 5 & 5 & NA & 45.84 & 0 & 6 & NA \\ \hline 6 & 6 & 16.48 & 52.52 & 0 & 3 & NA \\ \hline 7 & 7 & 12.26 & 64.22 & NA & 6 & NA \\ \hline 8 & 8 & 10.10 & NA & 0 & NA & NA \\ \hline 9 & 9 & 10.09 & 25.97 & 0 & 3 & NA \\ \hline 10 & 10 & 20.01 & 11.25 & 1 & 3 & NA \\ \hline \end{tabular} \# In the "Files" panel of the lower right window, there is a CSV file called Module2assignment. \# Using the practical example given in the lesson section "SQL and Practical Example in R" as reference, \# complete the following tasks. Then, you can save your work directly into this class cloud workspace by \# clicking the "Save" button at the top-left corner of this window. \# install all the three R packages needed for this assignment. install.packages(c("sqldf", "dplyr", "readr"), repos='http://cran.us.r-project.org') \# import the Module2bonus file into this R session library(readr) Module2Assignment =c(E) ) \#it is always a good habit to keep the original data file unchanged. Module2Assignment_v1 \# calculate medians of A and B columns and modes of C and D columns (excluding the missing values). library(sqldf) median_AA!= "NA"')) median_B2% mutate_at(c("A"), ifelse(is.na(A), median_A, A)) \%>\% mutate_at(c("B"), ifelse(is.na(B), median_B, B)) \%>\% mutate_at(c("C"), ifelse(is.na(C), mode_C, C)) \%>\% mutate_at(c("D"), ifelse(is.na(D), mode_D, D)) \%>\% Module2Assignment_v2 \#Use the SQL syntax to extract the two columns A and B which we suspect include outliers outliersZ scores of the values under A and B columns for (i in 1:nrow(outliers)) \{ outliers@z_A[i]=(outliers $A[i] mean(outliers $A))/ sd(outliers $A) outliers@z_B[i]=(outliers\$B[i]-mean(outliers $B))/sd( outliers $B) \} outliers \# remove the outliers based on their Z scores \# create a scatter plot using A and B columns and highlight the scatter which appears to be \# a relationship outlierStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started