Dear Tim, Actually, I am replacing a big for loop by the lapply() function, and report the progress:
lapply(TP, function(i) { BODY; print(i)}) Can you please adjust your solution in this light? THanking you, Yours sincerely, AKSHAY M KULKARNI ________________________________ From: Ebert,Timothy Aaron <teb...@ufl.edu> Sent: Monday, November 7, 2022 11:07 PM To: Andrew Simmons <akwsi...@gmail.com>; akshay kulkarni <akshay...@hotmail.com> Cc: R help Mailing list <r-help@r-project.org> Subject: RE: [R] print and lapply.... Another option is use paste() within print() lapply(TP,function(x){print(paste("x= ",x, " x^2 = ", x^2))}) Tim -----Original Message----- From: R-help <r-help-boun...@r-project.org> On Behalf Of Andrew Simmons Sent: Monday, November 7, 2022 12:21 PM To: akshay kulkarni <akshay...@hotmail.com> Cc: R help Mailing list <r-help@r-project.org> Subject: Re: [R] print and lapply.... [External Email] put print() around x^2 On Mon, Nov 7, 2022, 12:18 akshay kulkarni <akshay...@hotmail.com> wrote: > Dear members, > I have the following code and output: > > > TP <- 1:4 > > lapply(TP,function(x){print(x);x^2}) > [1] 1 > [1] 2 > [1] 3 > [1] 4 > [[1]] > [1] 1 > > [[2]] > [1] 4 > > [[3]] > [1] 9 > > [[4]] > [1] 16 > > How do I make the print function output x along with x^2, i.e not at > the beginning but before each of x^2? > > Many thanks in advance.... > > THanking you, > Yours sincerely > AKSHAY M KULKARNI > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat > .ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7Ctebert%40ufl > .edu%7C28ae59febb2d43ce03b108dac0e46e79%7C0d4da0f84a314d76ace60a62331e > 1b84%7C0%7C0%7C638034384601744085%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w > LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C > &sdata=1D8FQ07q2NcYL8PaJW84PqdUAte3pZJy8XJuJXENbJ4%3D&reserved > =0 > PLEASE do read the posting guide > https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r > -project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu% > 7C28ae59febb2d43ce03b108dac0e46e79%7C0d4da0f84a314d76ace60a62331e1b84% > 7C0%7C0%7C638034384601744085%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM > DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C& > sdata=aEeZJ8FHVKGX%2BqOJaKskC1onjqKcON2Ux5cj3MimTGw%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7Ctebert%40ufl.edu%7C28ae59febb2d43ce03b108dac0e46e79%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638034384601744085%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1D8FQ07q2NcYL8PaJW84PqdUAte3pZJy8XJuJXENbJ4%3D&reserved=0 PLEASE do read the posting guide https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu%7C28ae59febb2d43ce03b108dac0e46e79%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638034384601744085%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=aEeZJ8FHVKGX%2BqOJaKskC1onjqKcON2Ux5cj3MimTGw%3D&reserved=0 and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.