2. There are some different functions in different library with the same name. You can call one in a library, and you can call another in another library by calling the library name where it is before calling the function. For example,
library(epicalc)
summ(xxx)
# Calling summ() in epicalc library.
library(ice)
summ(xxx)
# Calling summ() in ice library.
3. There are at least two ways to work with a vector in a data frame, first by using $ and the second by using transform() function. See example below.
dat$var2 <- as.numeric(dat$var1 != 0)
# Forcing 0 in var1 being 0 and others being 1
dat <- transform(dat, var2 = as.numeric(var1 != 0))
# Remember this function transforms a data frame, not a variable in a data frame.
No comments:
Post a Comment