title: Error in gam function in R
body: <p>I have a problem with my R code about a multiple linear regression. 
  First, I try to use the gam function but this gives me an error. 
  Here is the code:</p>
  
  <pre><code>install.packages("nlme")
  library("mgcv")
  library("ggplot2")
  #Import dataset
  setwd("/Users/Sarah/Documents/Master T&amp;O/Master 1/Statistics IV/Assignment 2 ")
  weight_data = read.csv("WeightLossGroup190.csv", sep = "", dec = ".", header = TRUE)
  
  #Name of used data
  weight &lt;- weight_data$weight  
  date &lt;- weight_data$date 
  dayNr &lt;- weight_data$dayNumber 
  time &lt;- weight_data$time 
  #Check linearity 
  gam1 &lt;- gam(as.numeric(weight_data$weight) ~ s(as.numeric(weight_data$dayNumber)) + s(as.numeric(weight_data$time)))
  summary(gam1)
  plot.gam(gam1, se = FALSE, rug = TRUE, all.terms = TRUE)
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <pre><code>Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) : 
    A term has fewer unique covariate combinations than specified maximum degrees of freedom
  </code></pre>
  
  <p>Does anyone have an idea of what I'm doing wrong? </p>