This may seem menial, but it affects my productivity. I am using R in terminal mode on Linux. Unlike the Windows IDE, Linux limits the number of columns to 80, thus making harder the inspection of data sets. Is there a way to set the max number of columns?
The ncol() function in R programming That is, ncol() function returns the total number of columns present in the object.
The most easiest way to drop columns is by using subset() function. In the code below, we are telling R to drop variables x and z. The '-' sign indicates dropping variables. Make sure the variable names would NOT be specified in quotes when using subset() function.
To add a new column to a dataframe in R you can use the $-operator. For example, to add the column “NewColumn”, you can do like this: dataf$NewColumn <- Values . Now, this will effectively add your new variable to your dataset.
Here is a function I have in my ~/.Rprofile
file:
wideScreen <- function(howWide=Sys.getenv("COLUMNS")) { options(width=as.integer(howWide)) }
Calling the function without the howWide
argument sets the column to be the width of your terminal. You can optionally pass in the argument to set the width to an arbitrary number of your choosing.
Almost like Josh's suggestion, but less magic :-)
Set it with something like
options("width"=200)
which is in fact what I have in ~/.Rprofile. See help(options) for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With