[R] how to loop or lapply over a XMLNodeSet object with condition (if else)

2015-05-23 Thread Omar André Gonzáles Díaz
Hi, R-Help members, I'm doing some webscraping. This time i need the image (url) of the products of an ecommerce. I can get the nodes where the urls are, but when trying to extract the URL, i need to take 1 additional step: src vs data-original: in the source code, some urls are in the src

[R] a for loop to lapply

2011-03-30 Thread Alaios
Dear all, I am trying to learn lapply. I would like, as a test case, to try the lapply alternative for the Shadowlist-array(data=NA,dim=c(dimx,dimy,dimmaps)) for (i in c(1:dimx)){ Shadowlist[,,i]-i } ---so I wrote the following--- returni -function(i,ShadowMatrix) {ShadowMatrix-i}

Re: [R] a for loop to lapply

2011-03-30 Thread Andreas Borg
Hi Alaios, there are some problems with your code: 1. In the expression Shadowlist[,,i]-i, i corresponds to dimmaps, not dimx. The for loop should be either for (i in c(1:dimmaps)){ Shadowlist[,,i]-i } or for (i in c(1:dimx)){ Shadowlist[i,,]-i } 2. in lapply, the function must be

Re: [R] a for loop to lapply

2011-03-30 Thread Nick Sabbe
: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: woensdag 30 maart 2011 8:31 To: R-help@r-project.org Subject: [R] a for loop to lapply Dear

Re: [R] a for loop to lapply

2011-03-30 Thread Kenn Konstabel
Hi Alex, lapply is not a substitute for for, so it not only does things differenly, it does a different thing. Shadowlist-array(data=NA,dim=c(dimx,dimy,dimmaps)) for (i in c(1:dimx)){    Shadowlist[,,i]-i } Note that your test case is not reproducible as you haven't defined dimx, dimy,

Re: [R] a for loop to lapply

2011-03-30 Thread Dieter Menne
alaios wrote: I am trying to learn lapply. I would like, as a test case, to try the lapply alternative for the Shadowlistlt;-array(data=NA,dim=c(dimx,dimy,dimmaps)) for (i in c(1:dimx)){ Shadowlist[,,i]lt;-i } ---so I wrote the following--- returni lt;-function(i,ShadowMatrix)