Kavitha Venkatesan
2009-Jun-28 05:03 UTC
[R] applying a function to a pair of components for each row of a list
Hi, I have a set of (x,y) coordinate pairs that are stored as a list> my_list$x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 $y [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466 [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085 [13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694 [19] -1.6357864 -1.3478118 -1.0228402 -0.6708884 -0.2973863 0.0922034 [25] 0.4935457 I would like to plot each of these points onto an existing plot. ie., For each (x,y) pair, I would like to do:>points(x,y)How can I do this in a vectorized manner? Thanks! Kavitha [[alternative HTML version deleted]]
milton ruser
2009-Jun-28 05:11 UTC
[R] applying a function to a pair of components for each row of a list
Hi Kavitha, I must confess you that I not understood well what you are looking for. But.. mylist<-list(x=1:25, y=runif(n=25)) plot(mylist, type="n") points(mylist, type="p", col=mylist$x) Hth, miltinho On Sun, Jun 28, 2009 at 1:03 AM, Kavitha Venkatesan < kavitha.venkatesan@gmail.com> wrote:> Hi, > > I have a set of (x,y) coordinate pairs that are stored as a list > > > my_list > $x > [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 > 24 > 25 > > $y > [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466 > [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085 > [13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694 > [19] -1.6357864 -1.3478118 -1.0228402 -0.6708884 -0.2973863 0.0922034 > [25] 0.4935457 > > I would like to plot each of these points onto an existing plot. ie., For > each (x,y) pair, I would like to do: > > >points(x,y) > > How can I do this in a vectorized manner? > > Thanks! > Kavitha > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Maybe Matching Threads
- Obtaining the value of x at a given value of y in a smooth.spline object
- split-apply question
- Converting a character string into a data frame name and performing assignments to that data frame
- CentOS 7.2 rootfs for i386
- tapply with multiple arguments that are not part of the same data frame