# [R] Retrieve specific y for a list of x on a ploted line

camille rérolle camille.rerolle at gmail.com
Mon May 6 21:27:13 CEST 2013

```Sorry for my bad explanation (french people don't speak english well ,
it is known). I  tried predict.smooth.spline and it's working.
The aim of this work was to extract the y for x=1, x=2, x=3 etc on the
ploted line.

Thank you for your time.
Best Regards

Camille REROLLE

2013/5/6 Bert Gunter <gunter.berton at gene.com>:
> With the same possibility of misunderstanding as Rui, this sort of
> question is generally answered by predict() methods, in this case:
>
> ?predict.smooth.spline
>
>
> -- Bert
>
> On Mon, May 6, 2013 at 8:26 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
>> Hello,
>>
>> I'm not sure I understand. If you assign the value of smooth.spline, you'll
>> have a list with elements x and y:
>>
>> dat <- read.table(text = "
>>  X     Y
>> 1    0    137.659166666667
>> 2    2.502    152.623333333333
>> 3    4.998    162.391333333333
>> 4    7.501    170.753666666667
>> 5    9.997    174.877
>> 6    12.499    178.4275
>> 7    15.002 184.565
>> 8    17.498    189.8985
>> 9    20    192.6885
>> ", header = TRUE)
>> dat
>>
>> sp <- smooth.spline(dat)
>> plot(sp\$x, sp\$y, type="l")
>>
>>
>> Aren't the values of y you want in sp\$y?
>>
>> Hope this helps,
>>
>>
>> Em 06-05-2013 14:36, camille rérolle escreveu:
>>>
>>> Dear list,
>>>
>>> I'm trying to retrieve specific y for a list of x on a drawn line in the
>>> plot area.
>>> The line is plot with an other list of xy coordinates,which only serve to
>>> plot the line.
>>> Here is an example of the beginning of a table of initial coordinates
>>> which
>>> permit to draw the line:
>>>          X     Y
>>> "1"    0    137.659166666667
>>> "2"    2.502    152.623333333333
>>> "3"    4.998    162.391333333333
>>> "4"    7.501    170.753666666667
>>> "5"    9.997    174.877
>>> "6"    12.499    178.4275
>>> "7"    15.002 184.565
>>> "8"    17.498    189.8985
>>> "9"    20    192.6885
>>> [...]
>>>
>>> Here is what I want to do:
>>>
>>>          dossier<-  ### path of the table to read
>>>          table <- read.table(dossier)
>>>          curv<-plot(smooth.spline(table),
>>> type="l",xlim=c(0,100),ylim=c(0,255))
>>>
>>>          # Now the line is drawn
>>>
>>>          #For x in 1:100 on  curv, I want to retrieve each
>>> corresponding y and sort coordinates in a table.
>>>
>>> I search on the forum, the RSiteSearch, the R-intro.pdf, and I read the
>>> book
>>> of the most common graph packages...
>>> But I don't find the specific answer for my problem.
>>> Can you help me, please.
>>> Kind regards
>>>
>>> Camille
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website: