Access to column name of dataframe with *apply function
问题 I need to make tutorial for beginner using the R *apply function (without using reshape or plyr package in a first time) I try to lapply (because i read apply is not good for dataframe) a simple function to this dataframe, and i want to use named column to access data : fDist <- function(x1,x2,y1,y2) { return (0.1*((x1 - x2)^2 + (y1-y2)^2)^0.5) } data <- read.table(textConnection("X1 Y1 X2 Y2 1 3.5 2.1 4.1 2.9 2 3.1 1.2 0.8 4.3 ")) data$dist <- lapply(data,function(df) {fDist(df$X1 , df$X2 ,