Instruction: Given a scenario where an R script is performing suboptimally on a large dataset, outline the steps you would take to diagnose and optimize the script.
Context: This question assesses the candidate's ability to analyze, diagnose, and optimize R code performance issues, particularly in handling large datasets. Candidates should demonstrate knowledge of profiling tools, vectorization, and other R-specific optimization techniques.