You need to specify on what variable you are subsetting. Easiest thing is replacing your sub.data <- data
line with: sub.data <- data[(X>xinf & X<xsup),]
, so that you just have
FitWeibull <- function(data, xinf, xsup){
sub.data <- data[(data$X > xinf & data$X < xsup),]
my.lm <- lm(Y~X, data = sub.data)
return(my.lm)
}
You can then do whatever plotting/summarizing you want with the returned object.