Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Liviu Andronic
On 6/12/09, Graham Smith graham.sm...@myotis.co.uk wrote:
  Its now working. BUT the code still runs off the edge of the page and doesn't
 wrap with a continuation symbol. Anyone have any suggestions for fixing this
 one?

\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu


Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Graham Smith



Liviu Andronic wrote:

On 6/12/09, Graham Smith graham.sm...@myotis.co.uk wrote:
  

 Its now working. BUT the code still runs off the edge of the page and doesn't
wrap with a continuation symbol. Anyone have any suggestions for fixing this
one?



\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu
  

Thanks. I will have a look at using ERT.

Graham



Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Liviu Andronic
On 6/12/09, Graham Smith graham.sm...@myotis.co.uk wrote:
  Its now working. BUT the code still runs off the edge of the page and doesn't
 wrap with a continuation symbol. Anyone have any suggestions for fixing this
 one?

\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu


Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Graham Smith



Liviu Andronic wrote:

On 6/12/09, Graham Smith graham.sm...@myotis.co.uk wrote:
  

 Its now working. BUT the code still runs off the edge of the page and doesn't
wrap with a continuation symbol. Anyone have any suggestions for fixing this
one?



\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu
  

Thanks. I will have a look at using ERT.

Graham



Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Liviu Andronic
On 6/12/09, Graham Smith  wrote:
>  Its now working. BUT the code still runs off the edge of the page and doesn't
> wrap with a continuation symbol. Anyone have any suggestions for fixing this
> one?
>
\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu


Re: Sweave code full of escape codes when printed?

2009-06-19 Thread Graham Smith



Liviu Andronic wrote:

On 6/12/09, Graham Smith  wrote:
  

 Its now working. BUT the code still runs off the edge of the page and doesn't
wrap with a continuation symbol. Anyone have any suggestions for fixing this
one?



\SweaveOpts{keep.source=TRUE} can help with this issue. See
?RweaveLatex for details. The option allows you to fully control the
way echoed code is displayed and avoid unexpected results. I prefer
using this option in combination with ERT environments (instead of
Scrap ones).
Liviu
  

Thanks. I will have a look at using ERT.

Graham



Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Phillippe.

I have already replied directly to you on this (in error) but to keep 
the help within the list  I have repeated my answers here and added  
some information:


If I convert the SWeave Scrap environment to Lyx Code,  it  compiles (as 
a bit of text) to PDF as expected, no strange escape codes.


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;X2004=2004;etc
@

So it seems to be definitely connected with the Sweave part of the process

The rest of my reply is below

Philippe Grosjean wrote:

1) Have you placed your code in an ERT (Tex code)?
No,  I have now got a twelve chunks of Sweave code in the document 
(which all work) and none are in ERT


2) Did you enclose it with the required tags for noweb (INSIDE de 
ERT), i.e.,


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 


etc
@
Yes,  the full code copied from Lyx is (its in the Scrap environment and 
I have added the +'s to make it fit the email):


=library(car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;X2004=2004; 

+X2005=2005;X2006=2006;X2007=2007;X2008=2008;X2009=2009;X2010=2010; 


+X2011=2011;X2012=2012')
@


3) Did you run Sweave on the Noweb version produced?
Not manually in any way, I have just compiled to PDF from Lyx as I have 
been doing successfully with all the other SWeave chunks, up until this 
one.


But I haven't called an R package before, or used the recode function.  
Which are functioning in R OK, as I try the code in R first before 
copying into Lyx.


Strangely of course, it is compiling OK and giving me a PDF. With the 
other chunks of code, if I made a mistake, it refused to compile and I 
got an Rcmd error.


Not sure if that gives any more of a clue.

Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith
I wonder if its worth mentioning I am using a Mac, as it seems to be 
character code issue and maybe its something peculiar to the Mac.


Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 08.59, Graham Smith wrote:

I wonder if its worth mentioning I am using a Mac, as it seems to be  
character code issue and maybe its something peculiar to the Mac.


Graham


You can always try to change the encoding, e.g. using TextWrangler and  
see if that changes anything.


/Anders



Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler and 
see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into Lyx. 
I'm afraid I am  over my threshold of understanding here.


However, if I type the commands into an Emacs buffer I get some strange 
syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including the 
X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but so is 
the = sign. The X2002 and 2002 are now black, which is the pattern that 
persists for the rest of the code.



Graham






Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

I have now tried reversing the single quotes and double quotes as here:

cabbages$Year-recode(cabbages$Year,'X2001'='2001';'X2002'='2002';'X2003'='2003'; 
etc


This is now compiling verbatim (so no spurious slashes) when it appears 
in the PDF , but it is running off the edge of the page and not actually 
running in R.


My next command

=
head(cabbages, n=10)
@


is showing no recoding has taken place.

Graham


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler  
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit  
of code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into  
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save  
as... and click option to specify the encoding you want (there are  
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some  
strange syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including  
the X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but  
so is the = sign. The X2002 and 2002 are now black, which is the  
pattern that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders,

Thanks again.

I have now been sent some trial code that works with Lyx/SWeave/R on 
Linux, but it is doing nothing on my Mac (with a fresh file). So I 
suspect there may be a real issue here rather than it me.



The strange syntax thing seems to have gone away now, so not sure what 
was going on there.


I think I am stuck now :-(

Graham



Anders Ekberg wrote:

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler 
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into 
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save 
as... and click option to specify the encoding you want (there are 
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some 
strange syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including 
the X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but so 
is the = sign. The X2002 and 2002 are now black, which is the pattern 
that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

With help from Anders and Jay, part of this problem seems to be solved.

Some sample code from Jay, refused to run until the document settings 
were changed to use utf8 encoding.


This worked for the sample code, but didn't help with my code.

However, I notice that with my code in the latex code window, the code 
is highlighted between the $ signs at the start of the code


cabbages$Year-recode(cabbages$Year,'.

I wonder if this suggests that the $ sign is being interpreted in some 
odd way.


Graham

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Well this is a bit embarrassing , it seems I had two problems, one
was that the recode command seems to need utf8 coding rather than the
Lyx default (which is fine), plus I had typing error in the data set,
which is not fine :-(

I rewrote my code using the with command which allowed it to run, but
it then became obvious that the recoded results were not what I had
expected. The typing error then being obvious.

The first entry in my code was 'X2001'='2001' but the first level in
the data set was X20001 and this was enough to cause recode to fail
in my original code, but run using the with command.

Its now working. BUT the code still runs off the edge of the page and 
doesn't wrap with a continuation symbol. Anyone have any suggestions for 
fixing this one?


Thanks to everyone for there help.

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Phillippe.

I have already replied directly to you on this (in error) but to keep 
the help within the list  I have repeated my answers here and added  
some information:


If I convert the SWeave Scrap environment to Lyx Code,  it  compiles (as 
a bit of text) to PDF as expected, no strange escape codes.


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;X2004=2004;etc
@

So it seems to be definitely connected with the Sweave part of the process

The rest of my reply is below

Philippe Grosjean wrote:

1) Have you placed your code in an ERT (Tex code)?
No,  I have now got a twelve chunks of Sweave code in the document 
(which all work) and none are in ERT


2) Did you enclose it with the required tags for noweb (INSIDE de 
ERT), i.e.,


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 


etc
@
Yes,  the full code copied from Lyx is (its in the Scrap environment and 
I have added the +'s to make it fit the email):


=library(car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;X2004=2004; 

+X2005=2005;X2006=2006;X2007=2007;X2008=2008;X2009=2009;X2010=2010; 


+X2011=2011;X2012=2012')
@


3) Did you run Sweave on the Noweb version produced?
Not manually in any way, I have just compiled to PDF from Lyx as I have 
been doing successfully with all the other SWeave chunks, up until this 
one.


But I haven't called an R package before, or used the recode function.  
Which are functioning in R OK, as I try the code in R first before 
copying into Lyx.


Strangely of course, it is compiling OK and giving me a PDF. With the 
other chunks of code, if I made a mistake, it refused to compile and I 
got an Rcmd error.


Not sure if that gives any more of a clue.

Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith
I wonder if its worth mentioning I am using a Mac, as it seems to be 
character code issue and maybe its something peculiar to the Mac.


Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 08.59, Graham Smith wrote:

I wonder if its worth mentioning I am using a Mac, as it seems to be  
character code issue and maybe its something peculiar to the Mac.


Graham


You can always try to change the encoding, e.g. using TextWrangler and  
see if that changes anything.


/Anders



Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler and 
see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into Lyx. 
I'm afraid I am  over my threshold of understanding here.


However, if I type the commands into an Emacs buffer I get some strange 
syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including the 
X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but so is 
the = sign. The X2002 and 2002 are now black, which is the pattern that 
persists for the rest of the code.



Graham






Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

I have now tried reversing the single quotes and double quotes as here:

cabbages$Year-recode(cabbages$Year,'X2001'='2001';'X2002'='2002';'X2003'='2003'; 
etc


This is now compiling verbatim (so no spurious slashes) when it appears 
in the PDF , but it is running off the edge of the page and not actually 
running in R.


My next command

=
head(cabbages, n=10)
@


is showing no recoding has taken place.

Graham


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler  
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit  
of code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into  
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save  
as... and click option to specify the encoding you want (there are  
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some  
strange syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including  
the X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but  
so is the = sign. The X2002 and 2002 are now black, which is the  
pattern that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders,

Thanks again.

I have now been sent some trial code that works with Lyx/SWeave/R on 
Linux, but it is doing nothing on my Mac (with a fresh file). So I 
suspect there may be a real issue here rather than it me.



The strange syntax thing seems to have gone away now, so not sure what 
was going on there.


I think I am stuck now :-(

Graham



Anders Ekberg wrote:

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler 
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into 
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save 
as... and click option to specify the encoding you want (there are 
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some 
strange syntax handling


cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002; etc

With  the X2001=2001  the   and the numbers are pink (including 
the X) and the = is black the ; is also pink and the ' is black


but in the

X2002=2002 this is reversed the  and the ; are still pink but so 
is the = sign. The X2002 and 2002 are now black, which is the pattern 
that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

With help from Anders and Jay, part of this problem seems to be solved.

Some sample code from Jay, refused to run until the document settings 
were changed to use utf8 encoding.


This worked for the sample code, but didn't help with my code.

However, I notice that with my code in the latex code window, the code 
is highlighted between the $ signs at the start of the code


cabbages$Year-recode(cabbages$Year,'.

I wonder if this suggests that the $ sign is being interpreted in some 
odd way.


Graham

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Well this is a bit embarrassing , it seems I had two problems, one
was that the recode command seems to need utf8 coding rather than the
Lyx default (which is fine), plus I had typing error in the data set,
which is not fine :-(

I rewrote my code using the with command which allowed it to run, but
it then became obvious that the recoded results were not what I had
expected. The typing error then being obvious.

The first entry in my code was 'X2001'='2001' but the first level in
the data set was X20001 and this was enough to cause recode to fail
in my original code, but run using the with command.

Its now working. BUT the code still runs off the edge of the page and 
doesn't wrap with a continuation symbol. Anyone have any suggestions for 
fixing this one?


Thanks to everyone for there help.

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Phillippe.

I have already replied directly to you on this (in error) but to keep 
the help within the list  I have repeated my answers here and added  
some information:


If I convert the SWeave Scrap environment to Lyx Code,  it  compiles (as 
a bit of text) to PDF as expected, no strange escape codes.


<<>>=
library (car)
cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003";"X2004"="2004";etc
@

So it seems to be definitely connected with the Sweave part of the process

The rest of my reply is below

Philippe Grosjean wrote:

1) Have you placed your code in an ERT (Tex code)?
No,  I have now got a twelve chunks of Sweave code in the document 
(which all work) and none are in ERT


2) Did you enclose it with the required tags for noweb (INSIDE de 
ERT), i.e.,


<<>>=
library (car)
cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003"; 


etc
@
Yes,  the full code copied from Lyx is (its in the Scrap environment and 
I have added the +'s to make it fit the email):


<<>>=library(car)
cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003";"X2004"="2004"; 

+"X2005"="2005";"X2006"="2006";"X2007"="2007";"X2008"="2008";"X2009"="2009";"X2010"="2010"; 


+"X2011"="2011";"X2012"="2012"')
@


3) Did you run Sweave on the Noweb version produced?
Not manually in any way, I have just compiled to PDF from Lyx as I have 
been doing successfully with all the other SWeave chunks, up until this 
one.


But I haven't called an R package before, or used the recode function.  
Which are functioning in R OK, as I try the code in R first before 
copying into Lyx.


Strangely of course, it is compiling OK and giving me a PDF. With the 
other chunks of code, if I made a mistake, it refused to compile and I 
got an Rcmd error.


Not sure if that gives any more of a clue.

Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith
I wonder if its worth mentioning I am using a Mac, as it seems to be 
character code issue and maybe its something peculiar to the Mac.


Graham




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 08.59, Graham Smith wrote:

I wonder if its worth mentioning I am using a Mac, as it seems to be  
character code issue and maybe its something peculiar to the Mac.


Graham


You can always try to change the encoding, e.g. using TextWrangler and  
see if that changes anything.


/Anders



Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler and 
see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into Lyx. 
I'm afraid I am  over my threshold of understanding here.


However, if I type the commands into an Emacs buffer I get some strange 
syntax handling


cabbages$Year<-recode(cabbages$Year,'"X2001"="2001;"X2002"="2002"; etc

With  the "X2001"="2001"  the  " and the numbers are pink (including the 
X) and the = is black the ; is also pink and the ' is black


but in the

"X2002"="2002" this is reversed the " and the ; are still pink but so is 
the = sign. The X2002 and 2002 are now black, which is the pattern that 
persists for the rest of the code.



Graham






Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

I have now tried reversing the single quotes and double quotes as here:

cabbages$Year<-recode(cabbages$Year,"'X2001'='2001';'X2002'='2002';'X2003'='2003'; 
etc


This is now compiling verbatim (so no spurious slashes) when it appears 
in the PDF , but it is running off the edge of the page and not actually 
running in R.


My next command

<<>>=
head(cabbages, n=10)
@


is showing no recoding has taken place.

Graham


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Anders Ekberg

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler  
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit  
of code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into  
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save  
as... and click option to specify the encoding you want (there are  
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some  
strange syntax handling


cabbages$Year<-recode(cabbages$Year,'"X2001"="2001;"X2002"="2002"; etc

With  the "X2001"="2001"  the  " and the numbers are pink (including  
the X) and the = is black the ; is also pink and the ' is black


but in the

"X2002"="2002" this is reversed the " and the ; are still pink but  
so is the = sign. The X2002 and 2002 are now black, which is the  
pattern that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Anders,

Thanks again.

I have now been sent some trial code that works with Lyx/SWeave/R on 
Linux, but it is doing nothing on my Mac (with a fresh file). So I 
suspect there may be a real issue here rather than it me.



The strange syntax thing seems to have gone away now, so not sure what 
was going on there.


I think I am stuck now :-(

Graham



Anders Ekberg wrote:

On 12 jun 2009, at 11.06, Graham Smith wrote:


Anders

Anders Ekberg wrote:
You can always try to change the encoding, e.g. using TextWrangler 
and see if that changes anything.
I'm sorry to say I don't how to do this. Do you mean my little bit of 
code giving me problems or do you mean the entire Lyx file.


If its the former do I change the encoding and paste it back into 
Lyx. I'm afraid I am  over my threshold of understanding here.


Yes, that was the quick-and-dirty idea. Open in TextWrangler, use save 
as... and click option to specify the encoding you want (there are 
probably much fancier ways of doing it).


However, if I type the commands into an Emacs buffer I get some 
strange syntax handling


cabbages$Year<-recode(cabbages$Year,'"X2001"="2001;"X2002"="2002"; etc

With  the "X2001"="2001"  the  " and the numbers are pink (including 
the X) and the = is black the ; is also pink and the ' is black


but in the

"X2002"="2002" this is reversed the " and the ; are still pink but so 
is the = sign. The X2002 and 2002 are now black, which is the pattern 
that persists for the rest of the code.


This is defenitely far over my (very low) threshold of understanding ;-)

/Anders


--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

With help from Anders and Jay, part of this problem seems to be solved.

Some sample code from Jay, refused to run until the document settings 
were changed to use utf8 encoding.


This worked for the sample code, but didn't help with my code.

However, I notice that with my code in the latex code window, the code 
is highlighted between the $ signs at the start of the code


cabbages$Year<-recode(cabbages$Year,"'.

I wonder if this suggests that the $ sign is being interpreted in some 
odd way.


Graham

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003"; 
etc


But its appearing in the PDF as


> cabbages$Year <- recode(cabbages$Year, 
"\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Re: Sweave code full of escape codes when printed?

2009-06-12 Thread Graham Smith

Well this is a bit embarrassing , it seems I had two problems, one
was that the recode command seems to need utf8 coding rather than the
Lyx default (which is fine), plus I had typing error in the data set,
which is not fine :-(

I rewrote my code using the "with" command which allowed it to run, but
it then became obvious that the recoded results were not what I had
expected. The typing error then being obvious.

The first entry in my code was 'X2001'='2001' but the first level in
the data set was "X20001" and this was enough to cause recode to fail
in my original code, but run using the with command.

Its now working. BUT the code still runs off the edge of the page and 
doesn't wrap with a continuation symbol. Anyone have any suggestions for 
fixing this one?


Thanks to everyone for there help.

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003"; 
etc


But its appearing in the PDF as


> cabbages$Year <- recode(cabbages$Year, 
"\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



--
Graham M Smith
graham.sm...@myotis.co.uk

Station Cottage, Station Road
Binegar, Somerset
BA3 4UQ




Sweave code full of escape codes when printed?

2009-06-11 Thread Graham Smith

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



Re: Sweave code full of escape codes when printed?

2009-06-11 Thread Philippe Grosjean

1) Have you placed your code in an ERT (Tex code)?

2) Did you enclose it with the required tags for noweb (INSIDE de ERT), 
i.e.,


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;
etc
@

3) Did you run Sweave on the Noweb version produced?

Best,

Philippe Grosjean

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


  cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham





Sweave code full of escape codes when printed?

2009-06-11 Thread Graham Smith

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


 cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



Re: Sweave code full of escape codes when printed?

2009-06-11 Thread Philippe Grosjean

1) Have you placed your code in an ERT (Tex code)?

2) Did you enclose it with the required tags for noweb (INSIDE de ERT), 
i.e.,


=
library (car)
cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003;
etc
@

3) Did you run Sweave on the Noweb version produced?

Best,

Philippe Grosjean

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year-recode(cabbages$Year,'X2001=2001;X2002=2002;X2003=2003; 
etc


But its appearing in the PDF as


  cabbages$Year - recode(cabbages$Year, 
\X2001\=\2001\;\X2002\=\2002\;\X2003\=\2003\;\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham





Sweave code full of escape codes when printed?

2009-06-11 Thread Graham Smith

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003"; 
etc


But its appearing in the PDF as


> cabbages$Year <- recode(cabbages$Year, 
"\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham



Re: Sweave code full of escape codes when printed?

2009-06-11 Thread Philippe Grosjean

1) Have you placed your code in an ERT (Tex code)?

2) Did you enclose it with the required tags for noweb (INSIDE de ERT), 
i.e.,


<<>>=
library (car)
cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003";
etc
@

3) Did you run Sweave on the Noweb version produced?

Best,

Philippe Grosjean

Graham Smith wrote:

I've started using Sweave and having a problem

The code in Lyx is

library (car)

cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003"; 
etc


But its appearing in the PDF as


 > cabbages$Year <- recode(cabbages$Year, 
"\"X2001\"=\"2001\";\"X2002\"=\"2002\";\"X2003\"=\"2003\";\ etc


And obviously isn't working as printing out incorrectly.

Can anyone suggest what is happening here.

Many thanks,

Graham