R语言自定义函数-命名规则注意

Python013

R语言自定义函数-命名规则注意,第1张

udf_async_rbind <- function(path= "D:/R/oper_key_index/data/d_data/",

name= "移网线上单" ,

Date_temp = format(Date_stemp,"%Y%m%d"), # 直接引用变量不执行,需加函数转为常量

Date_last_month_day = ymd("2021-08-31") , # 函数内变量名不要与外部变量名重复

Date_last_month_day1= ymd("2021-07-31") ,

cols=190 ){

x <- udf_DT(paste0(path,name,Date_temp,".xlsx") , 1 ,0)

y <- udf_DT(paste0(path,name,format(Date_last_month_day,"%Y%m%d"),".xlsx"),1,0)

z <- udf_DT(paste0(path,name,format(Date_last_month_day1,"%Y%m%d"),".xlsx"),1,0)

if(ncol(x)>70){

x <- x[,1:cols]

y <- y[,1:cols]

z <- z[,1:cols]}else{print("全列导入")}

setnames(y,names(x))

table <- rbind(x, y)

return(table)

}

mob_dev_2ilist <- udf_async_rbind( name = "移网线上单" )

#include<stdio.h>

#include<math.h>

void add(float x,float y) //函数定义

{

printf("%5.2f\n",x+y)//计算a+b

}

main()

{float a=0.0,b=0.0

double s

scanf("%f,%f",&a,&b)//输入a b

add(a,b)//直接调用函数

s=sqrt(a)

printf("跟号a=%f\n",s)

s=sqrt(b)

printf("跟号b=%f\n",s)

}

问题补充:

你的想法很好,可以的话去学下C++吧,能学到你所想的

你想调用函数的话,把这函数做成一个C文件,以后需要时就合并用吧