Hi
About your question, I not so clear what your specific context is. So I create a
general one for you, hope this can help.
a<-function(x,y)sum(x*(10^seq(0,(y-1))))
You type
a(2,4) then you have 2222
a(3,5) you have 555
If what you need here is only 2222,
you can use
a<-2222
and every time, type "a" is OK.
If only 2222...2222 is used, but the number of 2 is unknown,
you can say
a<-function(x)sum(2*10^seq(0,(x-1)))
a(4) can give you 4444
If you have further questions, feel free to inform me.
Best
Wolfgang Amadeus
Message: 112
Date: Tue, 19 Jan 2010 23:22:14 -0500
From: David Winsemius <dwinsemius@comcast.net>
To: Ron_M <>
Cc: r-help@r-project.org
Subject: Re: [R] A question
Message-ID: <AA19919E-4ABD-483D-85EE-4A60CD1AE703@comcast.net>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Jan 19, 2010, at 11:17 PM, Ron_M wrote:
>
> Hi all, I have a expression like that :
>
>> rep(2,4)
> [1] 2 2 2 2
> paste(rep(2,4), sep="", collapse="")
[1] "2222"
>
> Now I want to write it as "2222" through some automated way. Is
> there is
> function for doing that? I have tested with paste(), but count not
> get any
> desired result.
>
> Thanks,
> --
> View this message in context:
http://n4.nabble.com/A-question-tp1018144p1018144.html
> Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]