rinterpretationexcelloess

LOESS residual output in R


When I extract residuals from a LOESS regression the output is in multiple columns instead of just 2- the line number and the result. LOESS regression output

Once you export this to excel it will spit it out with all sorts of errors or requiring shifting some lines over a few columns and always reducing everything to 2 columns which takes forever. Is there a way to adjust the output format in R?LOESS residual out in excel


Solution

  • Your R-output is a vector, with the integers indicating the data point (i.e. first, second, ...). In other words: no, you don't have multiple columns; this is an artefact when opening/reading it into Excel.

    When you export it, simply use write.csv or alike and you will get a friendly, single-column file (or two-column, if you have and keep the row names).

    cars.lo <- loess(dist ~ speed, cars)
    resids <- residuals(cars.lo)
    write.csv(resids, "loRes.csv")
    

    This example has no row names, hence is a single column, with a column variable name ("x").

    You should have no trouble reading that into Excel (other spreadsheet software is available).