I\'m trying to filter some data, with functions in R relatives to data frames. But in the second function, it gives me the following error: cannot change the value of locked bin
You should be avoiding <<-
. That creates function with side-effects which run contrary to the spirit of functional languages. Try
load.data <- function(x,dir = ".") {
read.csv(paste(dir,x,sep="/"), header = FALSE, sep = "\t", dec = ".", col.names = c("Seq","Allele","Peptide","Identity","Pos","Core","Core-Rel", "Um-log50k(aff)","Affinity(nM)","Rank","Exp_Bind","Binding Level"))
}
filter.data <- function(x, dir = ".") {
load.data(x, dir)[,c(1,2,3,4,9,10,12)]
}
df <- filter.data("mypath.csv")