I often find myself with a file that has one number per line. I end up importing it in excel to view things like median, standard deviation and so forth.
Is there a command line utility in linux to do the same? I usually need to find the average, median, min, max and std deviation.
This is a breeze with R. For a file that looks like this:
Use this:
To get this:
-qflag squelches R’s startup licensing and help output-eflag tells R you’ll be passing an expression from the terminalxis adata.frame– a table, basically. It’s a structure that accommodates multiple vectors/columns of data, which is a little peculiar if you’re just reading in a single vector. This has an impact on which functions you can use.summary(), naturally accommodatedata.frames. Ifxhad multiple fields,summary()would provide the above descriptive stats for each.sd()can only take one vector at a time, which is why I indexxfor that command (x[ , 1]returns the first column ofx). You could useapply(x, MARGIN = 2, FUN = sd)to get the SDs for all columns.