library(splines)
pwidth_ns <- ns(iris$Petal.Width[1:100], df = 2)
tail(pwidth_ns)
##                1           2
##  [95,] 0.5385619  0.13258303
##  [96,] 0.5629247  0.02595812
##  [97,] 0.5385619  0.13258303
##  [98,] 0.5385619  0.13258303
##  [99,] 0.5768393 -0.06624522
## [100,] 0.5385619  0.13258303