在R中,如何通过不能接受双精度的函数循环字符向量

在R中,如何通过不能接受双精度的函数循环字符向量,r,R,在R中,我尝试创建一个loop/lappy函数,通过一个处理和测试字符的函数来运行字符列表。我目前正在尝试使用预定义变量运行函数,但是我希望函数在列表中重复 Data_F = ABC #this references a row in the Data1 Matrix. Data_Fs is the Columns. Variable="item" ttestFunc <-function(x){ #Make a matrix one tall to turn into a numeric

在R中,我尝试创建一个loop/lappy函数,通过一个处理和测试字符的函数来运行字符列表。我目前正在尝试使用预定义变量运行函数,但是我希望函数在列表中重复

Data_F = ABC #this references a row in the Data1 Matrix. Data_Fs is the Columns.
Variable="item"
ttestFunc <-function(x){
#Make a matrix one tall to turn into a numeric vector
Data1[Data_F, Data_Fs]-> "ttesttest"
as.numeric-> "ttestvect"
t.test(ttestvect, ttestvect)

你是说像这样的事吗?您可以循环遍历目标向量的长度,并在遇到每个项目时使用它:

> targets <- c("ABC", "ABB", "XYZ")
> for (i in 1:length(targets)) { write(paste0("value is: ",targets[i]), stdout()) }
value is: ABC
value is: ABB
value is: XYZ
>目标为(i in 1:length(targets)){write(paste0(“值为:”,目标[i]),stdout())
价值是:ABC
价值为:ABB
值为:XYZ

在寻求帮助时,您应该提供一个简单的示例输入和所需输出,用于测试和验证可能的解决方案。
> targets <- c("ABC", "ABB", "XYZ")
> for (i in 1:length(targets)) { write(paste0("value is: ",targets[i]), stdout()) }
value is: ABC
value is: ABB
value is: XYZ