Skip to main content
added 98 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" in scan which is a special filename to read from stdinstandard input (that means from pipes or redirections).

Now you can redirect your data over stdin to the R script:

$ cat datafile 1 2 4 $ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafiledatafile2 1.1 2.2 4.4 $ ./mmmm.r < datafiledatafile2 1.1 4.4 2.2 2.566667 

If you don't want to write an R script file you can invoke a true one-liner (with linebreak only for readability) in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE)' \ -e 'cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Now you can redirect your data over stdin to the R script:

$ cat datafile 1 2 4 $ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an R script file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE)' \ -e 'cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" in scan which is a special filename to read from standard input (that means from pipes or redirections).

Now you can redirect your data over stdin to the R script:

$ cat datafile 1 2 4 $ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile2 1.1 2.2 4.4 $ ./mmmm.r < datafile2 1.1 4.4 2.2 2.566667 

If you don't want to write an R script file you can invoke a true one-liner (with linebreak only for readability) in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE)' \ -e 'cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 
deleted 44 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Suppose theNow you can redirect your data is in a file named datafileover stdin to the R script:

$ cat datafile 1 2 4 

Now you can redirect the datafile to the R script:

$ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an RscriptR script file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE);' \   -e cat'cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Suppose the data is in a file named datafile:

$ cat datafile 1 2 4 

Now you can redirect the datafile to the R script:

$ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an Rscript file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE); \   cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Now you can redirect your data over stdin to the R script:

$ cat datafile 1 2 4 $ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an R script file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE)' \ -e 'cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 
added 74 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Suppose the data is in a file named datafile:

$ cat datafile 1 2 4 

Now you can redirect the datafile to the R script:

$ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an Rscript file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE); \ cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Suppose the data is in a file named datafile:

$ cat datafile 1 2 4 

Now you can redirect the datafile to the R script:

$ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an Rscript file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE); \ cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.

You can use the R programming language.

Here is a quick and dirty R script:

#! /usr/bin/env Rscript d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep="\n") 

Note the "stdin" which is a special filename to read from stdin.

Suppose the data is in a file named datafile:

$ cat datafile 1 2 4 

Now you can redirect the datafile to the R script:

$ ./mmmm.r < datafile 1 4 2 2.333333 

Also works for floating points:

$ cat datafile 1.1 2.2 4.4 $ ./mmmm.r < datafile 1.1 4.4 2.2 2.566667 

If you don't want to write an Rscript file you can invoke a true one-liner in the command line using Rscript:

$ Rscript -e 'd<-scan("stdin", quiet=TRUE); \ cat(min(d), max(d), median(d), mean(d), sep="\n")' < datafile 1 4 2 2.333333 

Read the fine R manuals at http://cran.r-project.org/manuals.html.

Unfortunately the full reference is only available in PDF. Another way to read the reference is by typing ?topicname in the prompt of an interactive R session.


For completeness: there is an R command which outputs all the values you want, and more. Unfortunately in a human friendly format which is hard to parse programmatically.

> summary(c(1,2,4)) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 1.500 2.000 2.333 3.000 4.000 
added 74 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87
Loading
deleted 247 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87
Loading
added 349 characters in body
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87
Loading
Source Link
Lesmana
  • 28.1k
  • 20
  • 85
  • 87
Loading