i have function print , save charts using ggplot. data frame being used plots has nas in of columns - subset data first (and not in ggplot). when run function first time, works (and when run code in r line-by-line , not function, works inputs). however, when try run function second time input, receive error: error in data.frame(x = c(1, 21, 41, 53, 75, 80, 87, 100), y = c(1000, : arguments imply differing number of rows: 8, 6 after research, i'm convinced i'm not calling out correct data frame somewhere in ggplot layers, , environment variable getting used instead of input variable. but, cannot pinpoint error. i've listed sample data works in function. smpl_data <- data.frame(c(2011,2011,2011,2011,2012,2012,2012,2012),c(1,21,41,53,75,80,87,100),c(1000,1100,1200,1300,950,1050,1150,1250),c(2100,na,2200,2300,2050,2150,na,2350)) names(smpl_data) <- c("year","date_rank","modws_00x_3","modws_53x_3") #the following