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

Rui Barradas ruipbarradas at sapo.pt
Mon May 6 17:26:50 CEST 2013


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.
>



More information about the R-help mailing list