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

Bert Gunter gunter.berton at gene.com
Mon May 6 22:07:46 CEST 2013


Camille:

1. Your English is way better than my French!

2. Please re-read the Help file for predict.smooth.spline. Does not
the x argument allow you to do exactly what you want? If not, please
explain why not.

-- Bert

On Mon, May 6, 2013 at 12:27 PM, camille rérolle
<camille.rerolle at gmail.com> wrote:
> 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,
>>>
>>> Rui Barradas
>>>
>>> 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:
>> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list