How do I test $H_0 : \beta_1\leq 2$ in R? How do I test $H_0 : \beta_1\leq 2$ in R?
The data is as follows:
x<-c(1,2,3,3,4,5,5)
y<-c(3,7,5,8,11,14,12)


The general idea of t-testing a regression coefficient $\beta_k$ is that the following follows a t-distribution.
$$
\dfrac{
\hat\beta_k-\beta_{k0}
}{
\widehat{SE}(\hat\beta_k)
}
$$
We typically want to test if the coefficient is nonzero, so we take $\beta_{k0}=0$, but nothing stops us from testing with $\beta_{k0}=2$. We then would do only a one-sided t-test for your exact null hypothesis, though a two-sided test could be performed for an alternative hypothesis of $\beta_k\ne2$.
In software, we get the observed coefficient and standard error from the regression summary. We then calculate the test statistic from the fraction above and calculate the one-side do-value as usual.
Here is an example of how you could implement this in R.
set.seed(2022)
N <- 51
k <- 1 # which variable to test
x <- rnorm(N)
y <- 2*x +rnorm(N)
L <- lm(y~x)
s <- summary(L)$coef
tstat <- (s[k+1,1] - 2)/s[k+1, 2]
dof <- summary(L)$df[2] # degrees of freedom
p.value <- 1 - pt(tstat, dof) 

