Function 尝试将col.name附加到向量
我在R(studio)中尝试实现几个函数。我将展示最简单的一个。我试图将名称附加到向量上,以便以后用作列名称Function 尝试将col.name附加到向量,function,r,Function,R,我在R(studio)中尝试实现几个函数。我将展示最简单的一个。我试图将名称附加到向量上,以便以后用作列名称 # Initialize headerA <- vector(mode="character",length=20) headerA[1]="source";headerA[2]="matches" # Function - add on new name h <- function(df, compareA, compareB) { new_header <-
# Initialize
headerA <- vector(mode="character",length=20)
headerA[1]="source";headerA[2]="matches"
# Function - add on new name
h <- function(df, compareA, compareB) {
new_header <- paste(compareA,"Vs",compareB,sep="_")
data.frame(df,new_header)
}
# Comparison 1:
compareA <-"AA"
compareB <-"BB"
headers <- (headerA, compareA, compareB)
#初始化
headerA看起来您错过了对函数h
的调用,而只是打开了一个(
:
headers <- h(headerA, compareA, compareB)
@oax-发生在我们当中最好的人身上:)。祝你好运
df new_header
1 source AA_Vs_BB
2 matches AA_Vs_BB
3 AA_Vs_BB
4 AA_Vs_BB
...