Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to unix "less" command within R console

Tags:

Is there an equivalent to the unix less command that can be used within the R console?

like image 448
fmark Avatar asked May 16 '10 04:05

fmark


People also ask

How do I run a command in R console?

To run an R command, put the cursor on the line of the command and then click the Run button at the top of the file window. Or just press CTRL-Enter.

What is the command line in R?

In RStudio, this command line interaction occurs in the command console. R is an interpreted programming language. This means that R will interpret each line of code as it is entered and, if it is valid, R will execute it, returning the result in the command console.

What does less do in Unix?

less is a terminal pager program on Unix, Windows, and Unix-like systems used to view (but not change) the contents of a text file one screen at a time. It is similar to more, but has the extended capability of allowing both forward and backward navigation through the file.

Is R in Unix?

The UNIX “r” commands enable users to issue commands on their local machines that run on the remote host. These commands include the following: rcp.


2 Answers

There is also page() which displays a representation of an object in a pager, like less.

dat <- data.frame(matrix(rnorm(1000), ncol = 10)) page(dat, method = "print") 
like image 127
Gavin Simpson Avatar answered Sep 24 '22 19:09

Gavin Simpson


Not really. There are the commands

  • head() and tail() for showing the beginning and end of objects
  • print() for explicitly showing an object, and just its name followed by return does the same
  • summary() for concise summary that depends on the object
  • str() for its structure

and more. An equivalent for less would be a little orthogonal to the language and system. Where the Unix shell offers you less to view the content of a file (which is presumed to be ascii-encoded), it cannot know about all types.

R is different in that it knows about the object types which is why summary() -- as well as the whole modeling framework -- are more appropriate.

Follow-up edit: Another possibility is provided by edit() as well as edit.data.frame().

like image 42
Dirk Eddelbuettel Avatar answered Sep 25 '22 19:09

Dirk Eddelbuettel