character vector to text with returns

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

character vector to text with returns

Ben quant
Hello,

Does anyone know how to convert this:
> msg
 [1] "a"
 [2] "b"
 [3] "c"


To:

> msg
"a
 b
 c"

In other words, I need to convert a character vector to a single string with
carriage returns for each row.

Functionally, I'm attempting to send an email of a character vector in a way
that is readable in the email body. I can only input one string as the
message body parameter. I'm using rJython to send the email because I need
authentication.

Thanks!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Henrique Dallazuanna
Try:

paste(c("a", "b", "c"), collapse = "\n")

On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:

> Hello,
>
> Does anyone know how to convert this:
> > msg
>  [1] "a"
>  [2] "b"
>  [3] "c"
>
>
> To:
>
> > msg
> "a
>  b
>  c"
>
> In other words, I need to convert a character vector to a single string
> with
> carriage returns for each row.
>
> Functionally, I'm attempting to send an email of a character vector in a
> way
> that is readable in the email body. I can only input one string as the
> message body parameter. I'm using rJython to send the email because I need
> authentication.
>
> Thanks!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> 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.
>


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Ben quant
Unfortunately that didn't work. I just says the text is an invalid argument.
I also tried saving it in a variable name and passed that in, but that
didn't work. I get:

Error in ls(envir = envir, all.names = private) :
  invalid 'envir' argument

...when I try to send the message.

Any other ideas?

Thanks,
Ben

On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]>wrote:

> Try:
>
> paste(c("a", "b", "c"), collapse = "\n")
>
> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>
>> Hello,
>>
>> Does anyone know how to convert this:
>> > msg
>>  [1] "a"
>>  [2] "b"
>>  [3] "c"
>>
>>
>> To:
>>
>> > msg
>> "a
>>  b
>>  c"
>>
>> In other words, I need to convert a character vector to a single string
>> with
>> carriage returns for each row.
>>
>> Functionally, I'm attempting to send an email of a character vector in a
>> way
>> that is readable in the email body. I can only input one string as the
>> message body parameter. I'm using rJython to send the email because I need
>> authentication.
>>
>> Thanks!
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> 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.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Jeff Newmiller
Perhaps you need to conform to the conventions mandated by RFC 2822 section 2.1 for record separators. Most libraries automatically handle this for you, but perhaps your rJython library does not.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<[hidden email]> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

Ben qant <[hidden email]> wrote:

Unfortunately that didn't work. I just says the text is an invalid argument.
I also tried saving it in a variable name and passed that in, but that
didn't work. I get:

Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument

...when I try to send the message.

Any other ideas?

Thanks,
Ben

On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]>wrote:

> Try:
>
> paste(c("a", "b", "c"), collapse = "\n")
>
> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>
>> Hello,
>>
>> Does anyone know how to convert this:
>> > msg
>> [1] "a"
>> [2] "b"
>> [3] "c"
>>
>>
>> To:
>>
>> > msg
>> "a
>> b
>> c"
>>
>> In other words, I need to convert a character vector to a single string
>> with
>> carriage returns for each row.
>>
>> Functionally, I'm attempting to send an email of a character vector in a
>> way
>> that is readable in the email body. I can only input one string as the
>> message body parameter. I'm using rJython to send the email because I need
>> authentication.
>>
>> Thanks!
>>
>> [[alternative HTML version deleted]]
>>
>>_____________________________________________

>> [hidden email] mailing list
>> 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.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paran�-Brasil
> 25� 25' 40" S 49� 16' 22" O
>
        [[alternative HTML version deleted]]

_____________________________________________

[hidden email] mailing list
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.


        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Bert Gunter
In reply to this post by Ben quant
Is something like this what you want?

x <- letters[1:4]
x
y <-do.call(paste,c( paste('"',x[1]), as.list(x[2:3]),
paste(x[4],'"'),sep="\n"))
y
cat(y,"\n")

-- Bert


On Mon, Aug 29, 2011 at 6:59 PM, Ben qant <[hidden email]> wrote:

> Unfortunately that didn't work. I just says the text is an invalid argument.
> I also tried saving it in a variable name and passed that in, but that
> didn't work. I get:
>
> Error in ls(envir = envir, all.names = private) :
>  invalid 'envir' argument
>
> ...when I try to send the message.
>
> Any other ideas?
>
> Thanks,
> Ben
>
> On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]>wrote:
>
>> Try:
>>
>> paste(c("a", "b", "c"), collapse = "\n")
>>
>> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>>
>>> Hello,
>>>
>>> Does anyone know how to convert this:
>>> > msg
>>>  [1] "a"
>>>  [2] "b"
>>>  [3] "c"
>>>
>>>
>>> To:
>>>
>>> > msg
>>> "a
>>>  b
>>>  c"
>>>
>>> In other words, I need to convert a character vector to a single string
>>> with
>>> carriage returns for each row.
>>>
>>> Functionally, I'm attempting to send an email of a character vector in a
>>> way
>>> that is readable in the email body. I can only input one string as the
>>> message body parameter. I'm using rJython to send the email because I need
>>> authentication.
>>>
>>> Thanks!
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> 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.
>>>
>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> [hidden email] mailing list
> 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.
>
>



--
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Ben quant
Hello,

I need to clarify, Henrique's suggestion worked great for getting the text
that I needed via cat(), but I haven't sorted out how to get cat() like
output into a variable so I can pass it into the message body variable I am
using.

Here is what I mean:
 x
[1] "a" "b" "c" "d"
 paste(x,collapse='\n')
[1] "a\nb\nc\nd"
 y = paste(x,collapse='\n')
 cat(y)
a
b
c
d

This is the problem with 'y' has the msg body:

paste("msg = MIMEText('",y,"')",sep="")
[1] "msg = MIMEText('a\nb\nc\nd')"

This is what I am after (I think!):

paste("msg = MIMEText('",y,"')",sep="")
[1] "msg = MIMEText('a
b
c
d')"


Here is how I am actually using it (with sensitive items generalized):

 require(rJython)
 rJython <- rJython()
 rJython$exec( "import smtplib" )
 rJython$exec("from email.MIMEText import MIMEText")
 rJython$exec("import email.utils")

 mail<-c(
 #Email settings
 "fromaddr = '[hidden email]'",
 "toaddrs  = '[hidden email]'",
 #"msg = MIMEText('test message from R')",
 paste("msg = MIMEText('",y,"')",sep=""),    # my message in this example is
'y'
 "msg['From'] = email.utils.formataddr(('gmail acct', fromaddr))",
 "msg['To'] = email.utils.formataddr(('cc email!', toaddrs))",
 "msg['Subject'] = 'test with y'",

 #SMTP server credentials
 "username = '[hidden email]'",
 "password = 'a password here'",

 #Set SMTP server and send email, e.g., google mail SMTP server
 "server = smtplib.SMTP('smtp.gmail.com:587')",
 "server.ehlo()",
 "server.starttls()",
 "server.ehlo()",
 "server.login(username,password)",
 "server.sendmail(fromaddr, toaddrs, msg.as_string())",
 "server.quit()")

jython.exec(rJython,mail)  # and here is the error I get.
Error in ls(envir = envir, all.names = private) :
  invalid 'envir' argument


Just in case someone asks, I can do this:

y = "a test"

...and the above email sends fine with 'a test' as the msg body.

Any ideas?

PS - I received lots of suggestions. Thank you very much for your
effort/input.

Ben

On Mon, Aug 29, 2011 at 9:29 PM, Bert Gunter <[hidden email]> wrote:

> Is something like this what you want?
>
> x <- letters[1:4]
> x
> y <-do.call(paste,c( paste('"',x[1]), as.list(x[2:3]),
> paste(x[4],'"'),sep="\n"))
> y
> cat(y,"\n")
>
> -- Bert
>
>
> On Mon, Aug 29, 2011 at 6:59 PM, Ben qant <[hidden email]> wrote:
> > Unfortunately that didn't work. I just says the text is an invalid
> argument.
> > I also tried saving it in a variable name and passed that in, but that
> > didn't work. I get:
> >
> > Error in ls(envir = envir, all.names = private) :
> >  invalid 'envir' argument
> >
> > ...when I try to send the message.
> >
> > Any other ideas?
> >
> > Thanks,
> > Ben
> >
> > On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]
> >wrote:
> >
> >> Try:
> >>
> >> paste(c("a", "b", "c"), collapse = "\n")
> >>
> >> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
> >>
> >>> Hello,
> >>>
> >>> Does anyone know how to convert this:
> >>> > msg
> >>>  [1] "a"
> >>>  [2] "b"
> >>>  [3] "c"
> >>>
> >>>
> >>> To:
> >>>
> >>> > msg
> >>> "a
> >>>  b
> >>>  c"
> >>>
> >>> In other words, I need to convert a character vector to a single string
> >>> with
> >>> carriage returns for each row.
> >>>
> >>> Functionally, I'm attempting to send an email of a character vector in
> a
> >>> way
> >>> that is readable in the email body. I can only input one string as the
> >>> message body parameter. I'm using rJython to send the email because I
> need
> >>> authentication.
> >>>
> >>> Thanks!
> >>>
> >>>        [[alternative HTML version deleted]]
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list
> >>> 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.
> >>>
> >>
> >>
> >>
> >> --
> >> Henrique Dallazuanna
> >> Curitiba-Paraná-Brasil
> >> 25° 25' 40" S 49° 16' 22" O
> >>
> >
> >        [[alternative HTML version deleted]]
> >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > 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.
> >
> >
>
>
>
> --
> "Men by nature long to get on to the ultimate truths, and will often
> be impatient with elementary studies or fight shy of them. If it were
> possible to reach the ultimate truths without the elementary studies
> usually prefixed to them, these would not be preparatory studies but
> superfluous diversions."
>
> -- Maimonides (1135-1204)
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Ben quant
In reply to this post by Henrique Dallazuanna
Hello,

(Sorry if this is a dup post...)

I need to clarify, Henrique's suggestion worked great for getting the text
that I needed via cat(), but I haven't sorted out how to get cat() like
output into a variable so I can pass it into the message body variable I am
using.

Here is what I mean:
 x
[1] "a" "b" "c" "d"
 paste(x,collapse='\n')
[1] "a\nb\nc\nd"
 y = paste(x,collapse='\n')
 cat(y)
a
b
c
d

This is the problem with 'y' has the msg body:

paste("msg = MIMEText('",y,"')",sep="")
[1] "msg = MIMEText('a\nb\nc\nd')"

This is what I am after (I think!):

paste("msg = MIMEText('",y,"')",sep="")
[1] "msg = MIMEText('a
b
c
d')"


Here is how I am actually using it (with sensitive items generalized):

 require(rJython)
 rJython <- rJython()
 rJython$exec( "import smtplib" )
 rJython$exec("from email.MIMEText import MIMEText")
 rJython$exec("import email.utils")

 mail<-c(
 #Email settings
 "fromaddr = '[hidden email]'",
 "toaddrs  = '[hidden email]'"
- Show quoted text -
jython.exec(rJython,mail)  # and here is the error I get.

Error in ls(envir = envir, all.names = private) :
  invalid 'envir' argument


Just in case someone asks, I can do this:

y = "a test"

...and the above email sends fine with 'a test' as the msg body.

Any ideas?

PS - I received lots of suggestions. Thank you very much for your
effort/input.

Ben


On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]>wrote:

> Try:
>
> paste(c("a", "b", "c"), collapse = "\n")
>
> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>
>> Hello,
>>
>> Does anyone know how to convert this:
>> > msg
>>  [1] "a"
>>  [2] "b"
>>  [3] "c"
>>
>>
>> To:
>>
>> > msg
>> "a
>>  b
>>  c"
>>
>> In other words, I need to convert a character vector to a single string
>> with
>> carriage returns for each row.
>>
>> Functionally, I'm attempting to send an email of a character vector in a
>> way
>> that is readable in the email body. I can only input one string as the
>> message body parameter. I'm using rJython to send the email because I need
>> authentication.
>>
>> Thanks!
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> 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.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

David Winsemius

On Aug 30, 2011, at 1:09 PM, Ben qant wrote:

> Hello,
>
> (Sorry if this is a dup post...)
>
> I need to clarify, Henrique's suggestion worked great for getting  
> the text
> that I needed via cat(), but I haven't sorted out how to get cat()  
> like
> output into a variable so I can pass it into the message body  
> variable I am
> using.

cat() is not the right function to get text assgned to an object. It's  
entire purpose is to have a side-effect and _not_ return anything into  
R's workspace. Why are you not assigning the result of that paste  
operation to the variable?


>
> Here is what I mean:
> x
> [1] "a" "b" "c" "d"
> paste(x,collapse='\n')
> [1] "a\nb\nc\nd"
> y = paste(x,collapse='\n')
> cat(y)
> a
> b
> c
> d
>
> This is the problem with 'y' has the msg body:
>
> paste("msg = MIMEText('",y,"')",sep="")
> [1] "msg = MIMEText('a\nb\nc\nd')"
>
> This is what I am after (I think!):
>
> paste("msg = MIMEText('",y,"')",sep="")
> [1] "msg = MIMEText('a
> b
> c
> d')"
>
>
> Here is how I am actually using it (with sensitive items generalized):
>
> require(rJython)
> rJython <- rJython()
> rJython$exec( "import smtplib" )
> rJython$exec("from email.MIMEText import MIMEText")
> rJython$exec("import email.utils")
>
> mail<-c(
> #Email settings
> "fromaddr = '[hidden email]'",
> "toaddrs  = '[hidden email]'"
> - Show quoted text -
> jython.exec(rJython,mail)  # and here is the error I get.
>
> Error in ls(envir = envir, all.names = private) :
>  invalid 'envir' argument
>
>
> Just in case someone asks, I can do this:
>
> y = "a test"
>
> ...and the above email sends fine with 'a test' as the msg body.
>
> Any ideas?
>
> PS - I received lots of suggestions. Thank you very much for your
> effort/input.
>
> Ben
>
>
> On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]
> >wrote:
>
>> Try:
>>
>> paste(c("a", "b", "c"), collapse = "\n")
>>
>> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>>
>>> Hello,
>>>
>>> Does anyone know how to convert this:
>>>> msg
>>> [1] "a"
>>> [2] "b"
>>> [3] "c"
>>>
>>>
>>> To:
>>>
>>>> msg
>>> "a
>>> b
>>> c"
>>>
>>> In other words, I need to convert a character vector to a single  
>>> string
>>> with
>>> carriage returns for each row.
>>>
>>> Functionally, I'm attempting to send an email of a character  
>>> vector in a
>>> way
>>> that is readable in the email body. I can only input one string as  
>>> the
>>> message body parameter. I'm using rJython to send the email  
>>> because I need
>>> authentication.
>>>
>>> Thanks!
>>>
>>>       [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> 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.
>>>
>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
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 | Threaded
Open this post in threaded view
|

Re: character vector to text with returns

Ben quant
David,

Yes, I understand that cat() won't do what I want, but that is the only way
I can illustrate what I am after. Note the phrasing in my question:
'...cat() like...'

Regarding assigning the paste  to a variable: it produces the same error.
I've already tried that.

Thanks for your suggestion!

Ben

On Tue, Aug 30, 2011 at 11:24 AM, David Winsemius <[hidden email]>wrote:

>
> On Aug 30, 2011, at 1:09 PM, Ben qant wrote:
>
>  Hello,
>>
>> (Sorry if this is a dup post...)
>>
>> I need to clarify, Henrique's suggestion worked great for getting the text
>> that I needed via cat(), but I haven't sorted out how to get cat() like
>> output into a variable so I can pass it into the message body variable I
>> am
>> using.
>>
>
> cat() is not the right function to get text assgned to an object. It's
> entire purpose is to have a side-effect and _not_ return anything into R's
> workspace. Why are you not assigning the result of that paste operation to
> the variable?
>
>
>
>
>> Here is what I mean:
>> x
>> [1] "a" "b" "c" "d"
>> paste(x,collapse='\n')
>> [1] "a\nb\nc\nd"
>> y = paste(x,collapse='\n')
>> cat(y)
>> a
>> b
>> c
>> d
>>
>> This is the problem with 'y' has the msg body:
>>
>> paste("msg = MIMEText('",y,"')",sep="")
>> [1] "msg = MIMEText('a\nb\nc\nd')"
>>
>> This is what I am after (I think!):
>>
>> paste("msg = MIMEText('",y,"')",sep="")
>> [1] "msg = MIMEText('a
>> b
>> c
>> d')"
>>
>>
>> Here is how I am actually using it (with sensitive items generalized):
>>
>> require(rJython)
>> rJython <- rJython()
>> rJython$exec( "import smtplib" )
>> rJython$exec("from email.MIMEText import MIMEText")
>> rJython$exec("import email.utils")
>>
>> mail<-c(
>> #Email settings
>> "fromaddr = '[hidden email]'",
>> "toaddrs  = '[hidden email]'"
>> - Show quoted text -
>> jython.exec(rJython,mail)  # and here is the error I get.
>>
>> Error in ls(envir = envir, all.names = private) :
>>  invalid 'envir' argument
>>
>>
>> Just in case someone asks, I can do this:
>>
>> y = "a test"
>>
>> ...and the above email sends fine with 'a test' as the msg body.
>>
>> Any ideas?
>>
>> PS - I received lots of suggestions. Thank you very much for your
>> effort/input.
>>
>> Ben
>>
>>
>> On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <[hidden email]
>> >wrote:
>>
>>  Try:
>>>
>>> paste(c("a", "b", "c"), collapse = "\n")
>>>
>>> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <[hidden email]> wrote:
>>>
>>>  Hello,
>>>>
>>>> Does anyone know how to convert this:
>>>>
>>>>> msg
>>>>>
>>>> [1] "a"
>>>> [2] "b"
>>>> [3] "c"
>>>>
>>>>
>>>> To:
>>>>
>>>>  msg
>>>>>
>>>> "a
>>>> b
>>>> c"
>>>>
>>>> In other words, I need to convert a character vector to a single string
>>>> with
>>>> carriage returns for each row.
>>>>
>>>> Functionally, I'm attempting to send an email of a character vector in a
>>>> way
>>>> that is readable in the email body. I can only input one string as the
>>>> message body parameter. I'm using rJython to send the email because I
>>>> need
>>>> authentication.
>>>>
>>>> Thanks!
>>>>
>>>>      [[alternative HTML version deleted]]
>>>>
>>>> ______________________________**________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<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.
>>>>
>>>>
>>>
>>>
>>> --
>>> Henrique Dallazuanna
>>> Curitiba-Paraná-Brasil
>>> 25° 25' 40" S 49° 16' 22" O
>>>
>>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<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.
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
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.