I'm a new rstudio user, and hoping for some guidance. I have imported data into r, and am trying to sort one column (crop yield) based on a 2nd column (precipitation). Specifically, I'm trying to take the average crop yield of the 5 wettest years.
My current code is as follows:
Data = read.table("crop.output.dat-ARL-0N-SCEN1")
colnames(Data) <- c("Year","PFT","Yield (bu/ac)","Fertilizer+Manure N (kg/ha)","N-Minearalization(kg/ha)"," Crop N uptake (kg/ha)","NO3-N leaching (kg/ha)", "NO3-N leaching (ppm)", "Harvest Index", "Leaf N concentration", "Stem N concentration", "Root N concentration", "Grain N concentration", "Grain N (kg/ha)", "Drainage (mm/yr)","Precip (mm/yr)", "Irrigation(mm/yr)", "LAI max", "N fixation (kg/ha)", "SOC kg/m2", "Planting DOY", "Harvest DOY")
Data[
with (Data, order(Data$`Precip (mm/yr)`)),
]
If you need more specific help, please provide a minimal REPRoducible EXample (reprex) illustrating your issue. A reprex makes it much easier for others to understand your issue and figure out how to help.
If you've never heard of a reprex before, you might want to start by reading this FAQ: