R Error - cannot change value of locked binding for 'df'

前端 未结 4 1251
日久生厌
日久生厌 2021-02-14 06:00

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

4条回答
  •  心在旅途
    2021-02-14 06:48

    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")
    

提交回复
热议问题