-1

I know drop_na is a tidyverse function, so I installed the packages and everything then ran the code but the function won't work

I am assuming the problem has to do with the name in the parenthesis but I am not entirely sure what the correct label should be for the function to run

library(dplyr)
DesignInfo <- read.csv(file="C:\\Users\\ahmed\\Documents\\Assignment 3\\design_info.csv", header=TRUE, sep=",")
InspectionInfo <- read.csv(file="C:\\Users\\ahmed\\Documents\\Assignment 3\\inspection_info.csv", header=TRUE, sep=",")
left_join(DesignInfo, InspectionInfo, by = "weld_id")
library(tidyverse)
drop_na(DesignInfo and InspectionInfo)

With this code, the result should be a combine table of DesignInfo and InspectionInfo with no NA values but I end up with the following error message:

Error: unexpected symbol in "drop_na(DesignInfo and"
joran
  • 169,992
  • 32
  • 429
  • 468
Jack
  • 57
  • 4
  • `and` isn't a keyword in R. What are you trying to do with that line? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Oct 15 '19 at 18:58

1 Answers1

0

If I understand your code right, what you really want is this:

library(dplyr)
library(tidyverse)

DesignInfo <- read.csv(file="C:\\Users\\ahmed\\Documents\\Assignment 3\\design_info.csv", header=TRUE, sep=",")
InspectionInfo <- read.csv(file="C:\\Users\\ahmed\\Documents\\Assignment 3\\inspection_info.csv", header=TRUE, sep=",")

newData <- DesignInfo %>%
  left_join(InspectionInfo, by = "weld_id") %>%
  drop_na()

The pipeline at the end creates a new data set called newData using DesignInfo as the base. From there, it joins InspectionInfo using weld_id as the key and then drops all rows that have missing data in any column.

Trent
  • 771
  • 5
  • 19
  • Yup that's exactly what I wanted as an outcome. I just couldn't figure out how to label my new combined dataset and drop the NAs. Thank you! – Jack Oct 15 '19 at 20:59