Updated: 2023-06-09 Things that I find it useful during my work: Debuging warnings Sometimes it’s nice to know where in the code that generate warnings especially when it’s related to NA introduced by coercion. To do this we can change the options to make warning as error.
Read MoreYesNo question
Different ways to make your R session interactive for asking question and receive the answer as an input. readline You can find some example in StackOverflow or Geeksforgeeks. Basically is just like this: cp <- as.integer(readline(prompt = "Vil du kopiere filen?
Read MoreEnvironment
Updated: 2022-04-12 Several nice blogs and references on the net to read on this stuff. Among those: Environments in R How R Searches and Finds Stuff This discussion from StackOverflow and here explains nicely with example on the difference between parent.
Read Morenames attribute
Sometime an object has attribute names for identification of the value with names instead of index. There are time you need to extract the names of a vector or object. The easiest way is to do: library(data.table) dt <- cars[1,] setDT(dt) str(dt) dt[, dist := as.
Read MoreClean attributes
When reading data from SPSS or Stata into R, the metadata will also be inherited to the dataset. Sometimes it can be useful for extra information, but most of the time it’s not needed. To get rid of these metadata then do this:
Read More