Skip to the posts
Buffalo's neighborhood journals since 2003 🍀 Patrick Spicy Devil Logan🌭 Sahlen🥨 Weber Spank🥟 Pierogi🐸 Scaj🍺 Labatt Utica Pink Cherio❄️ Snow Murder

tinypliny’s journal

🏷️ r statistics

3 posts

Where is R installed on Linux?

·

Simple yet frustrating question for those who want to view the code behind the base functions.

whereis R



Turns out R on linux is installed in the following directory structures:
  • /usr/bin/R : this is the executable binary
  • /usr/lib64/R

ls


bin COPYING etc include lib library modules NEWS NEWS.pdf SVN-REVISION
  • /usr/include/R

ls


Rconfig.h Rembedded.h R.h Rinternals.h Rversion.h
Rdefines.h R_ext Rinterface.h Rmath.h S.h
  • /usr/share/R

ls


encodings java library licenses locale make R sh texmf
  • /usr/share/man/man1/R.1.gz : possibly the manual pages

Writing Functions in R: Part 2

·

I skipped all the in-between bits of writing functions. Maybe I will return to them in the future.

But for now, I think it's super important to know how to apply a function once I have written it using what else but...
APPLY!!!

  • The output of Apply can be a vector or array or list of values
  • The input of Apply is always a matrix. So make sure to insert a "as.matrix" before anything you want to apply your function on.


Basic syntax:

apply(as.matrix(some object which is not a matrix already), Starting Row, function)

For eg.
Out <- apply(as.matrix(list of element), 1, function)

Writing Functions in R: Part I

·

I have been learning how to write functions in R. They are core to learning the language instead of just using what other people have written for their purposes. They make tailored manipulations in R easier. I am going to document the function writing system here, step by step so I can progressively write better functions and yet not forget the basics

Basic Syntax

NewFunction <- function (input){
answer <- some manipulation with the input
answer
}

  • NewFunction is the name of the new function.
  • function is the R function that creates functions.
  • input is the "argument" of a function
  • { delimits the beginning of the function
  • } delimits the end of the function
  • the last statement (in this case, just "answer", returns the answer as the output of the function. I could also have said return(answer).