How to use the removed function

I would like to use prescindMeta in package tm, but I cannot find the function in the lastest downloaded version of tm. Therefore I checked the older version of the package and find that this function has been removed. My question is how could I us...
more »

2017-07-16 05:07 (0) Answers

R : use of uniroot

I have this R code mean.test <- function(x, y, B=10000, alternative=c("two.sided","less","greater")) { p.value <- 0 alternative <- match.arg(alternative) z <- c(x,y) T <- replicate(B, (mean(sample(z, B, TRUE))-mean(sample(z, B, TRUE))...
more »

2017-07-16 00:07 (0) Answers

How to create similar python function in R?

I'm new to R and trying to learn how to make a simple function. Could anyone advise me how to replicate this same python addition function in R please? def add(self,x,y): number_types = (int, long, float, complex) if isinstance(x, n...
more »

2017-07-14 16:07 (2) Answers

Getting arguments of S3 method in R

I get see the argument of any R function with args function, like args(cor) function (x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman")) NULL However, not able to see the arguments of cor.test. See MWE. Any help w...
more »

2017-07-13 16:07 (1) Answers

Return closest date to a given date in R

My data frame consists of individual observations of individual animals. Each animal has a birthdate, that I would like to associate to the closest field season date from a date vector. Here is a very basic reproducible example: ID <- c("a", "b"...
more »

2017-07-13 15:07 (5) Answers

apply function for a list of data frames

I wrote a function that split my data frame to 7 Different data frames. so far everything OK. but I'm trying to apply this function on a list of dataframes this is the list I made: m =list(X2016_kvish_1_10t, X2015_kvish_1_10t, X2014_kvish_1_10t, ...
more »

2017-07-12 16:07 (1) Answers

Function to return modified matrix in R

The following code adds vector XTS1$XTSSum2 to xts object XTS1: library(xts) XTS1 <- structure(c(12, 7, 7, 22, 24, 30, 26, 23, 27, 30), .indexCLASS = c("POSIXct", "POSIXt"), .indexTZ = "", tclass = c("POSIXct", "POSIXt"), tzone = "", class = c("x...
more »

2017-07-10 23:07 (1) Answers

how to vectorize the args of a function in R?

I have a list in R and I'm trying to rename the list members from a character array. For instance: mylist <- list(c('a','b','c'),c('d','e'),'f') headers <- c('heading1','heading2','heading3') And I can rename the list members like this: nam...
more »

2017-07-08 05:07 (2) Answers

Modify complicated character vector automatically

I have a complicated character vector, whereby each element of the vector consists of numbers and letters. I want to simplify this vector, so that sequences of numbers and/or letters are put into ranges. Here is an example, how the input and output v...
more »

2017-07-06 16:07 (1) Answers

Get highest value of X rows

I'm looking for a function to calculate the highest value for the prior X periods on an XTS object. The function would return a vector with such values. I would believe there are multiple ways to calculate this. Surprisingly I could not find this c...
more »

2017-07-06 09:07 (1) Answers

Fill matrix with function output R

I'm trying to fill a matrix with the outputs of a function at each instance of the matrix. I either get the error "replacement has length zero" or "number of items to replace is not a multiple of replacement length". Please help! setPoint <- fun...
more »

2017-07-04 19:07 (1) Answers

R write function to bind column to dataframe

I wrote a function which creates a vector of values via a substring operation on a column of an existing data frame: fetchParent <- function(column){ substr(column,1,regexpr(":", column)-1) } An example run of this function is: fetchParent(t...
more »

2017-07-04 05:07 (1) Answers

Mac: Removing compilers and starting from scratch

I have been coding with Rcpp and RcppArmadillo for the last 3 years. At some point I had installed additional compilers (gcc / gfortran) over the Xcode Command Line tools. Since then I haven't been able to install RcppArmadillo without compiling R fr...
more »

2017-07-01 12:07 (1) Answers

getting either 1 or -1

I want to get from the user either -1 or 1, but the attached function allows the user to input any value. How can it be modified? readB.Y<-function(){ #B.Y is a storage variable that will be used later B.Y<-readline(prompt = "ENTER THE NUMBE...
more »

2017-06-30 13:06 (1) Answers

Coercing GLMs into list

I'm writing a function that produces 3 different models as output and want the function to return all three models so the user can see the output. Currently I am using something like: return(FinalLM,LMReduced1,FullLM) and lets say I do the cal...
more »

2017-06-29 19:06 (1) Answers