Dear Tim,
                   I think the recent replies from you, Bert and Rui cleared 
everything ...
THanks a lot..

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
________________________________
From: Ebert,Timothy Aaron <teb...@ufl.edu>
Sent: Tuesday, November 8, 2022 2:15 AM
To: akshay kulkarni <akshay...@hotmail.com>; Bert Gunter 
<bgunter.4...@gmail.com>; Andrew Simmons <akwsi...@gmail.com>
Cc: R help Mailing list <r-help@r-project.org>
Subject: RE: [R] print and lapply....

Dear Akshay,
    I think we have provided several solutions to the question asked. Can you 
please adjust your question to more closely align with what you need. It would 
be nice if you can provide sufficient detail so that we can see how you have 
adapted our solutions and how these have not quite addressed this problem.

Tim

-----Original Message-----
From: R-help <r-help-boun...@r-project.org> On Behalf Of akshay kulkarni
Sent: Monday, November 7, 2022 1:10 PM
To: Bert Gunter <bgunter.4...@gmail.com>; Andrew Simmons <akwsi...@gmail.com>
Cc: R help Mailing list <r-help@r-project.org>
Subject: Re: [R] print and lapply....

[External Email]

Dear Bert,
                   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: Bert Gunter <bgunter.4...@gmail.com>
Sent: Monday, November 7, 2022 11:16 PM
To: Andrew Simmons <akwsi...@gmail.com>
Cc: akshay kulkarni <akshay...@hotmail.com>; R help Mailing list 
<r-help@r-project.org>
Subject: Re: [R] print and lapply....

Well... yes, of course. But assuming the sole purpose is to print the results 
and not to save them for further processing, the OP's approach seems rather 
painful. My preference would be to vectorize:

> print(cbind(TP, TPsq =TP^2), print.gap = 3)
       TP   TPsq
[1,]    1      1
[2,]    2      4
[3,]    3      9
[4,]    4     16

See ?print.default for details

-- Bert


On Mon, Nov 7, 2022 at 9:20 AM Andrew Simmons <akwsi...@gmail.com> wrote:
>
> 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%2Fst
> > at.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&amp;data=05%7C01%7Ctebert%4
> > 0ufl.edu%7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a
> > 62331e1b84%7C0%7C0%7C638034414365456384%7CUnknown%7CTWFpbGZsb3d8eyJW
> > IjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C300
> > 0%7C%7C%7C&amp;sdata=dQk1JPxWI4D0D6%2FSoC8LWw56749ulaFrGQc6affgBeM%3
> > D&amp;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&amp;data=05%7C01%7Ctebert%40ufl.
> > edu%7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a62331
> > e1b84%7C0%7C0%7C638034414365456384%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM
> > C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%
> > 7C%7C&amp;sdata=KDskHBxmxe0DV9XO7GvkESemUNTq2w%2BT%2Fro%2Bgb4DS2w%3D
> > &amp;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&amp;data=05%7C01%7Ctebert%40ufl
> .edu%7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a62331e
> 1b84%7C0%7C0%7C638034414365456384%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w
> LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> &amp;sdata=dQk1JPxWI4D0D6%2FSoC8LWw56749ulaFrGQc6affgBeM%3D&amp;reserv
> ed=0 PLEASE do read the posting guide
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r
> -project.org%2Fposting-guide.html&amp;data=05%7C01%7Ctebert%40ufl.edu%
> 7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a62331e1b84%
> 7C0%7C0%7C638034414365612626%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM
> DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;
> sdata=OxZmpA4ORbfUq0gqM8ebZvK5bQTaiCwo0Y1ekn%2F3zBE%3D&amp;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&amp;data=05%7C01%7Ctebert%40ufl.edu%7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638034414365612626%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=OCyLwP3YBC3kfih9kaX6vEbPdzvAq1a48LeDRyqlYd0%3D&amp;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&amp;data=05%7C01%7Ctebert%40ufl.edu%7Cb726a89349ed4860265708dac0eb5d0a%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638034414365612626%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=OxZmpA4ORbfUq0gqM8ebZvK5bQTaiCwo0Y1ekn%2F3zBE%3D&amp;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.

Reply via email to