[R] how can i add Qtr1 Qtr2 Qtr3 Qtr4 on the x axis?

2013-12-15 Thread ????????
> x<-ts(sales,frequency=4,start=c(2010,1))
> x
 Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0
> plot.ts(x)__
R-help@r-project.org 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.


[R] [Probable spam] RE: how can i add Qtr1 Qtr2 Qtr3 Qtr4 on the x axis?

2013-12-15 Thread Dániel Kehl
Hi,

try

?axis.Date

works similar to the axis function.

I hope that helps!
daniel

Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; 
meghatalmazó: 水静流深 [1248283...@qq.com]
Küldve: 2013. december 15. 9:17
To: r-help
Tárgy: [R] how can i add Qtr1 Qtr2 Qtr3 Qtr4  on the x axis?

> x<-ts(sales,frequency=4,start=c(2010,1))
> x
 Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0
> plot.ts(x)
__
R-help@r-project.org 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.


[R] why there is no quarters?

2013-12-15 Thread ????????
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"years")
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"weeks")
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"days")

why there is no 
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"quarters")  ?
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] why as.vector can't make x to be a vector?

2013-12-15 Thread ????????
> x=read.table(text="
+   Qtr1 Qtr2 Qtr3 Qtr4
+ 2010  1.8  8.0  6.0  3.0
+ 2011  2.0 11.0  7.0  3.5
+ 2012  2.5 14.0  8.0  4.2
+ 2013  3.0 15.2  9.5  5.0",sep="",header=TRUE)
> x
 Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0
> as.vector(x)
 Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0
> class(as.vector(x))
[1] "data.frame"
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] why there is no quarters?

2013-12-15 Thread Duncan Murdoch

On 13-12-15 6:43 AM, 水静流深 wrote:

seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"years")
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"weeks")
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"days")

why there is no
seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"quarters")  ?


There's no need for it.  Just use months, and take every 3rd one:

x <- seq(as.Date("2001/1/1"),as.Date("2010/1/1"),"months")
x[seq_along(x) %% 3 == 1]

__
R-help@r-project.org 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.


Re: [R] why as.vector can't make x to be a vector?

2013-12-15 Thread Duncan Murdoch

On 13-12-15 6:48 AM, 水静流深 wrote:

x=read.table(text="

+   Qtr1 Qtr2 Qtr3 Qtr4
+ 2010  1.8  8.0  6.0  3.0
+ 2011  2.0 11.0  7.0  3.5
+ 2012  2.5 14.0  8.0  4.2
+ 2013  3.0 15.2  9.5  5.0",sep="",header=TRUE)

x

  Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0

as.vector(x)

  Qtr1 Qtr2 Qtr3 Qtr4
2010  1.8  8.0  6.0  3.0
2011  2.0 11.0  7.0  3.5
2012  2.5 14.0  8.0  4.2
2013  3.0 15.2  9.5  5.0

class(as.vector(x))

[1] "data.frame"


Data frames are lists, which are already vectors.

Duncan Murdoch

__
R-help@r-project.org 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.


[R] how to add a line in the graph?

2013-12-15 Thread ????????
t<--4:4
y<-c(5,7,10,13,15,16,14,12,11)
plot(t,y,type="l")

how can i add a curve  y=0.83*t-0.44*t^2  in the graph?
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] [Probable spam]RE: how to add a line in the graph?

2013-12-15 Thread Dániel Kehl
t<- -4:4
y<-c(5,7,10,13,15,16,14,12,11)
plot(t,y,type="l", ylim=c(-20,20))

curve(0.83*x-0.44*x^2, add=TRUE)

I added ylim to plot so that your curve is on the graph. Maybe you wanted to 
use different parameters.

Try going through a basic manual of R!

daniel

Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; 
meghatalmazó: 水静流深 [1248283...@qq.com]
Küldve: 2013. december 15. 13:46
To: r-help
Tárgy: [R] how to  add a line in the graph?

t<--4:4
y<-c(5,7,10,13,15,16,14,12,11)
plot(t,y,type="l")

how can i add a curve  y=0.83*t-0.44*t^2  in the graph?
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.
__
R-help@r-project.org 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.


[R] RSM

2013-12-15 Thread IZHAK shabsogh
kindly help find out why the following code is given me error 


time<-c(80,80,90,90,85,85,85,85,85,85,92,77,85,85)
> tem<-c(170,180,170,180,175,175,175,175,175,175,175,175,182.07,167.93)
> yield<-c(80.5,81.5,82,83.5,83.9,84.3,84,79.7,79.8,79.5,78.4,75.6,78.6,77)
> Block<-c("B1","B1","B1","B1","B1","B1","B1","B2","B2","B2","B2","B2","B2","B2")
> chem<-data.frame(time,tem,Block,yield)
> ggg<-coded.data(chem, x1 ~ (time - 85)/5, x2 ~ (tem - 175)/5)
> gg1=rsm(yield~ FO(x1,x2),data=chem,subset = (Block == "B1"))
Error in lapply(X = X, FUN = FUN, ...) : object 'x1' not found
> gg1=rsm(yield~ SO(x1,x2),data=chem,subset = (Block == "B1"))
Error in lapply(X = X, FUN = FUN, ...) : object 'x1' not found

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] RSM

2013-12-15 Thread Dániel Kehl
There is no variable called x1 in the chem dataframe.
Did you mean 

gg1=rsm(yield~ FO(x1,x2),data=ggg,subset = (Block == "B1"))

hth.
daniel

Feladó: r-help-boun...@r-project.org [r-help-boun...@r-project.org] ; 
meghatalmazó: IZHAK shabsogh [ishaqb...@yahoo.com]
Küldve: 2013. december 15. 15:53
To: r-help@r-project.org
Tárgy: [R] RSM

kindly help find out why the following code is given me error


time<-c(80,80,90,90,85,85,85,85,85,85,92,77,85,85)
> tem<-c(170,180,170,180,175,175,175,175,175,175,175,175,182.07,167.93)
> yield<-c(80.5,81.5,82,83.5,83.9,84.3,84,79.7,79.8,79.5,78.4,75.6,78.6,77)
> Block<-c("B1","B1","B1","B1","B1","B1","B1","B2","B2","B2","B2","B2","B2","B2")
> chem<-data.frame(time,tem,Block,yield)
> ggg<-coded.data(chem, x1 ~ (time - 85)/5, x2 ~ (tem - 175)/5)
> gg1=rsm(yield~ FO(x1,x2),data=chem,subset = (Block == "B1"))
Error in lapply(X = X, FUN = FUN, ...) : object 'x1' not found
> gg1=rsm(yield~ SO(x1,x2),data=chem,subset = (Block == "B1"))
Error in lapply(X = X, FUN = FUN, ...) : object 'x1' not found

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.

__
R-help@r-project.org 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.


[R] Simple way to define a function to be used in a formula object inside another function

2013-12-15 Thread Frank Harrell

I would like to do this:

f <- function(formula, data=NULL) {
 gg <- sqrt
 model.frame(formula, data=data)
 }
x <- y <- 1:10
f(y ~ gg(x))
Error in eval(expr, envir, enclos) : could not find function "gg"

Is there a simple way to get access to gg from within the model.frame 
invocation inside f?


Thanks
Frank

__
R-help@r-project.org 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.


Re: [R] Simple way to define a function to be used in a formula object inside another function

2013-12-15 Thread William Dunlap
The following works because model.frame looks for things in environment(formula)
and ancestral environments thereof.  It puts the new things in a child 
environment
of the original environment(formula) so it does not alter the original 
environment.

f2 <- function (formula, data = NULL) 
{
environment(formula) <- new.env(parent = environment(formula))
assign(envir = environment(formula), "gg", sqrt)
model.frame(formula, data = data)
}

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Frank Harrell
> Sent: Sunday, December 15, 2013 10:09 AM
> To: RHELP
> Subject: [R] Simple way to define a function to be used in a formula object 
> inside another
> function
> 
> I would like to do this:
> 
> f <- function(formula, data=NULL) {
>   gg <- sqrt
>   model.frame(formula, data=data)
>   }
> x <- y <- 1:10
> f(y ~ gg(x))
> Error in eval(expr, envir, enclos) : could not find function "gg"
> 
> Is there a simple way to get access to gg from within the model.frame
> invocation inside f?
> 
> Thanks
> Frank
> 
> __
> R-help@r-project.org 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.

__
R-help@r-project.org 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.


Re: [R] Invalid connection error message when trying to write a file

2013-12-15 Thread John Karon

The response below asks what I actually did.

I defined a function (details omitted; it computes the data frame 
LRtest.out); arguments include "path\\filename.csv" to which I want to write 
a data frame using write.csv(  ).  Repeated executions of the function 
(without the file(  ) and close(  ) instructions) were successful until 2 
days ago, when I received the error message below.  I simplified the code to 
write a file and received the error message below (same message as before) 
in response to the commands


zz<-file(description="c:\\LRtest.txt","w")
write.table(LRtest.out, file="c:\\LRtest.txt", sep="\t")
close(zz)

Error in file(description = "c:\\LRtest.txt", "w") :
 cannot open the connection
In addition: Warning message:
In file(description = "c:\\LRtest.txt", "w") :
 cannot open file 'c:\LRtest.txt': Permission denied

This happens whether there is no previous file with that name or an 
essentially empty file with that name.  In previous executions of code with 
a path to a folder, executing the file(  )  command would create an empty 
file.  Now no empty file is created.  The problem persists after rebooting 
the computer.


I also tried writing to the clipboard (description ="clipboard" in the 
file(  ) command); that was unsuccessful, with file="clipboard" or no file 
statement in the write.table(  ) command (Word showed there was something to 
paste, but pasting into an empty Word document did not put text into the 
document; with no file statement, the data frame was written to the 
console).


I question whether there is a setting that forbids writing to a file. 
Information on putting the data frame on the clipboard would also help. 
Thanks for any help.  John Karon


-Original Message- 
From: Uwe Ligges

Sent: Saturday, December 14, 2013 10:05 AM
To: J Karon ; r-help@r-project.org
Subject: Re: [R] Invalid connection error message when trying to write a 
file




On 13.12.2013 20:11, J Karon wrote:

I get an invalid connection method error message when trying to write an R
object from a user-defined function to my hard drive (running Windows 7)
using write.csv.  I have previously not had this problem with the same
user-defined function.  The error message is

Error in isOpen(file, "w") : invalid connection
In addition: Warning message:
In if (file == "") file <- stdout() else if (is.character(file)) { :
   the condition has length > 1 and only the first element will be used

Using
zz<-file(description="path","w")
write.csv(  )
close(zz)

creates an empty file but yields the same error message when I execute
write.csv.



Please tell us what you actually did.

This works for me:

zz <- file(description="path", "w")
write.csv(iris, zz)
close(zz)

Best,
Uwe Ligges

__
R-help@r-project.org 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.


Re: [R] Invalid connection error message when trying to write a file

2013-12-15 Thread Uwe Ligges



On 15.12.2013 20:13, John Karon wrote:

The response below asks what I actually did.

I defined a function (details omitted; it computes the data frame
LRtest.out); arguments include "path\\filename.csv" to which I want to
write a data frame using write.csv(  ).  Repeated executions of the
function (without the file(  ) and close(  ) instructions) were
successful until 2 days ago, when I received the error message below.  I
simplified the code to write a file and received the error message below
(same message as before) in response to the commands

zz<-file(description="c:\\LRtest.txt","w")
write.table(LRtest.out, file="c:\\LRtest.txt", sep="\t")
close(zz)


Wrong, *either* use

write.table(LRtest.out, file="c:\\LRtest.txt", sep="\t")

or

zz <- file(description="c:\\LRtest.txt","w")
write.table(LRtest.out, file=zz, sep="\t")
close(zz)

Best,
Uwe Ligges









Error in file(description = "c:\\LRtest.txt", "w") :
  cannot open the connection
In addition: Warning message:
In file(description = "c:\\LRtest.txt", "w") :
  cannot open file 'c:\LRtest.txt': Permission denied

This happens whether there is no previous file with that name or an
essentially empty file with that name.  In previous executions of code
with a path to a folder, executing the file(  )  command would create an
empty file.  Now no empty file is created.  The problem persists after
rebooting the computer.

I also tried writing to the clipboard (description ="clipboard" in the
file(  ) command); that was unsuccessful, with file="clipboard" or no
file statement in the write.table(  ) command (Word showed there was
something to paste, but pasting into an empty Word document did not put
text into the document; with no file statement, the data frame was
written to the console).

I question whether there is a setting that forbids writing to a file.
Information on putting the data frame on the clipboard would also help.
Thanks for any help.  John Karon

-Original Message- From: Uwe Ligges
Sent: Saturday, December 14, 2013 10:05 AM
To: J Karon ; r-help@r-project.org
Subject: Re: [R] Invalid connection error message when trying to write a
file



On 13.12.2013 20:11, J Karon wrote:

I get an invalid connection method error message when trying to write
an R
object from a user-defined function to my hard drive (running Windows 7)
using write.csv.  I have previously not had this problem with the same
user-defined function.  The error message is

Error in isOpen(file, "w") : invalid connection
In addition: Warning message:
In if (file == "") file <- stdout() else if (is.character(file)) { :
   the condition has length > 1 and only the first element will be used

Using
zz<-file(description="path","w")
write.csv(  )
close(zz)

creates an empty file but yields the same error message when I execute
write.csv.



Please tell us what you actually did.

This works for me:

zz <- file(description="path", "w")
write.csv(iris, zz)
close(zz)

Best,
Uwe Ligges

__
R-help@r-project.org 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.


__
R-help@r-project.org 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.


Re: [R] why as.vector can't make x to be a vector?

2013-12-15 Thread David Carlson
According to the documentation (?as.vector), "All attributes are removed from 
the result if it is of an atomic mode, but not in general for a list result."

data.frames are lists so

> is.vector(as.vector(x))
[1] FALSE

However if you convert using unlist() or as.matrix(), you will get a vector:

> is.vector(unlist(x))
[1] TRUE
> is.vector(as.vector(as.matrix(x)))
[1] TRUE


-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Duncan Murdoch
Sent: Sunday, December 15, 2013 6:12 AM
To: 水静流深; r-help
Subject: Re: [R] why as.vector can't make x to be a vector?

On 13-12-15 6:48 AM, 水静流深 wrote:
>> x=read.table(text="
> +   Qtr1 Qtr2 Qtr3 Qtr4
> + 2010  1.8  8.0  6.0  3.0
> + 2011  2.0 11.0  7.0  3.5
> + 2012  2.5 14.0  8.0  4.2
> + 2013  3.0 15.2  9.5  5.0",sep="",header=TRUE)
>> x
>   Qtr1 Qtr2 Qtr3 Qtr4
> 2010  1.8  8.0  6.0  3.0
> 2011  2.0 11.0  7.0  3.5
> 2012  2.5 14.0  8.0  4.2
> 2013  3.0 15.2  9.5  5.0
>> as.vector(x)
>   Qtr1 Qtr2 Qtr3 Qtr4
> 2010  1.8  8.0  6.0  3.0
> 2011  2.0 11.0  7.0  3.5
> 2012  2.5 14.0  8.0  4.2
> 2013  3.0 15.2  9.5  5.0
>> class(as.vector(x))
> [1] "data.frame"

Data frames are lists, which are already vectors.

Duncan Murdoch

__
R-help@r-project.org 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.

__
R-help@r-project.org 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.


Re: [R] Simple way to define a function to be used in a formula object inside another function

2013-12-15 Thread Frank Harrell

Thank you Bill, that worked perfectly.
Frank

__
R-help@r-project.org 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.


[R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread david hamer
Hello,

My x-y scatterplot produces a very ragged best-fit line when imported into
Word.



* >plot (data.file$x, data.file$y, type = "p", las=1, pch=20,ylab =
expression("Cover of Species y" ~ (m^{2}~ha^{-1} )),xlab =
expression("Cover of Species x" ~ (m^{2}~ha^{-1}))  )>lines  (
data.file$x,   fitted ( model.x )  )*

 A suggestion from the internet is to use .png at high (1200) resolution.
   * >dev.print  ( device = png,  file = "R.graph.png",  width = 1200,
height = 700)*
This gives a high–quality graph, but the titles and tick–mark labels become
very tiny when exported into Word.

I therefore increased the size of the titles and tick–mark labels with cex.
   * >plot (..cex =1.8, cex.lab = 1.8, cex.axis = 1.25,)*
But this causes the x–axis title to lie on top of the tick–mark labels.
(This problem does not occur with the y–axis, where the title lies well
away from the y–axis tick–mark labels.)
Changing margins * >par ( mai = c ( 1.3, 1.35, 1, .75 ) )*does not
seem to have any effect on this.

A suggestion from the internet is to delete the titles from plot, and use
mtext with line=4 to drop the title lower on the graph.

* >plot (...  ylab = " ", xlab = " ".)>mtext(side = 1, "Cover
of Species x (superscripts??)", line = 4)*
This works, but with mtext I have now lost the ability to have the
superscripts in the axis title.

And I am back full circle, having to lower the resolution of the graph to
keep the x–axis title away from the axis, and thus reverting to a ragged,
segmented “line” when exported to Word..

Final note:  The R graphics window version of the graph becomes very
distorted, even though the graph may be of high quality (other than the
problem of the x-axis title overlaying the x-axis tick-mark labels) once in
Word.  I guess this is because of using “tricks” to try to get a desired
end-product in Word

Thanks for any suggestions,
 David.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Henrik Bengtsson
See ?png and argument 'pointsize'.  You can increase that as you
increase the dimensions of the output image.

/Henrik

On Sun, Dec 15, 2013 at 3:00 PM, david hamer  wrote:
> Hello,
>
> My x-y scatterplot produces a very ragged best-fit line when imported into
> Word.
>
>
>
> * >plot (data.file$x, data.file$y, type = "p", las=1, pch=20,ylab =
> expression("Cover of Species y" ~ (m^{2}~ha^{-1} )),xlab =
> expression("Cover of Species x" ~ (m^{2}~ha^{-1}))  )>lines  (
> data.file$x,   fitted ( model.x )  )*
>
>  A suggestion from the internet is to use .png at high (1200) resolution.
>* >dev.print  ( device = png,  file = "R.graph.png",  width = 1200,
> height = 700)*
> This gives a high–quality graph, but the titles and tick–mark labels become
> very tiny when exported into Word.
>
> I therefore increased the size of the titles and tick–mark labels with cex.
>* >plot (..cex =1.8, cex.lab = 1.8, cex.axis = 1.25,)*
> But this causes the x–axis title to lie on top of the tick–mark labels.
> (This problem does not occur with the y–axis, where the title lies well
> away from the y–axis tick–mark labels.)
> Changing margins * >par ( mai = c ( 1.3, 1.35, 1, .75 ) )*does not
> seem to have any effect on this.
>
> A suggestion from the internet is to delete the titles from plot, and use
> mtext with line=4 to drop the title lower on the graph.
>
> * >plot (...  ylab = " ", xlab = " ".)>mtext(side = 1, "Cover
> of Species x (superscripts??)", line = 4)*
> This works, but with mtext I have now lost the ability to have the
> superscripts in the axis title.
>
> And I am back full circle, having to lower the resolution of the graph to
> keep the x–axis title away from the axis, and thus reverting to a ragged,
> segmented “line” when exported to Word..
>
> Final note:  The R graphics window version of the graph becomes very
> distorted, even though the graph may be of high quality (other than the
> problem of the x-axis title overlaying the x-axis tick-mark labels) once in
> Word.  I guess this is because of using “tricks” to try to get a desired
> end-product in Word
>
> Thanks for any suggestions,
>  David.
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org 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.
>

__
R-help@r-project.org 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.


Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Henrik Bengtsson
And possibly better, argument 'res', e.g.

png("R.graph.png",  width=1200, height = 700, res=144)
plot(...)
dev.off()

Default corresponds to res=72.

/Henrik

On Sun, Dec 15, 2013 at 3:13 PM, Henrik Bengtsson  wrote:
> See ?png and argument 'pointsize'.  You can increase that as you
> increase the dimensions of the output image.
>
> /Henrik
>
> On Sun, Dec 15, 2013 at 3:00 PM, david hamer  wrote:
>> Hello,
>>
>> My x-y scatterplot produces a very ragged best-fit line when imported into
>> Word.
>>
>>
>>
>> * >plot (data.file$x, data.file$y, type = "p", las=1, pch=20,ylab =
>> expression("Cover of Species y" ~ (m^{2}~ha^{-1} )),xlab =
>> expression("Cover of Species x" ~ (m^{2}~ha^{-1}))  )>lines  (
>> data.file$x,   fitted ( model.x )  )*
>>
>>  A suggestion from the internet is to use .png at high (1200) resolution.
>>* >dev.print  ( device = png,  file = "R.graph.png",  width = 1200,
>> height = 700)*
>> This gives a high–quality graph, but the titles and tick–mark labels become
>> very tiny when exported into Word.
>>
>> I therefore increased the size of the titles and tick–mark labels with cex.
>>* >plot (..cex =1.8, cex.lab = 1.8, cex.axis = 1.25,)*
>> But this causes the x–axis title to lie on top of the tick–mark labels.
>> (This problem does not occur with the y–axis, where the title lies well
>> away from the y–axis tick–mark labels.)
>> Changing margins * >par ( mai = c ( 1.3, 1.35, 1, .75 ) )*does not
>> seem to have any effect on this.
>>
>> A suggestion from the internet is to delete the titles from plot, and use
>> mtext with line=4 to drop the title lower on the graph.
>>
>> * >plot (...  ylab = " ", xlab = " ".)>mtext(side = 1, "Cover
>> of Species x (superscripts??)", line = 4)*
>> This works, but with mtext I have now lost the ability to have the
>> superscripts in the axis title.
>>
>> And I am back full circle, having to lower the resolution of the graph to
>> keep the x–axis title away from the axis, and thus reverting to a ragged,
>> segmented “line” when exported to Word..
>>
>> Final note:  The R graphics window version of the graph becomes very
>> distorted, even though the graph may be of high quality (other than the
>> problem of the x-axis title overlaying the x-axis tick-mark labels) once in
>> Word.  I guess this is because of using “tricks” to try to get a desired
>> end-product in Word
>>
>> Thanks for any suggestions,
>>  David.
>>
>> [[alternative HTML version deleted]]
>>
>>
>> __
>> R-help@r-project.org 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.
>>

__
R-help@r-project.org 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.


Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Duncan Murdoch

On 13-12-15 6:00 PM, david hamer wrote:

Hello,

My x-y scatterplot produces a very ragged best-fit line when imported into
Word.


Don't use a bitmap format (png).

Don't produce your graph in one format (screen display), then convert to 
another (png).  Open the device in the format you want for the final file.


Use a vector format for output.  I don't know what kinds Word supports, 
but EPS or PDF would likely be best; if it can't read those, then 
Windows metafile (via windows() to open the device) would be best. 
(Don't trust the preview to tell you the quality of the graph, try 
printing the document.  Word isn't quite as bad as it appears.)


Don't use Word.

Duncan Murdoch





* >plot (data.file$x, data.file$y, type = "p", las=1, pch=20,ylab =
expression("Cover of Species y" ~ (m^{2}~ha^{-1} )),xlab =
expression("Cover of Species x" ~ (m^{2}~ha^{-1}))  )>lines  (
data.file$x,   fitted ( model.x )  )*

  A suggestion from the internet is to use .png at high (1200) resolution.
* >dev.print  ( device = png,  file = "R.graph.png",  width = 1200,
height = 700)*
This gives a high–quality graph, but the titles and tick–mark labels become
very tiny when exported into Word.

I therefore increased the size of the titles and tick–mark labels with cex.
* >plot (..cex =1.8, cex.lab = 1.8, cex.axis = 1.25,)*
But this causes the x–axis title to lie on top of the tick–mark labels.
(This problem does not occur with the y–axis, where the title lies well
away from the y–axis tick–mark labels.)
Changing margins * >par ( mai = c ( 1.3, 1.35, 1, .75 ) )*does not
seem to have any effect on this.

A suggestion from the internet is to delete the titles from plot, and use
mtext with line=4 to drop the title lower on the graph.

* >plot (...  ylab = " ", xlab = " ".)>mtext(side = 1, "Cover
of Species x (superscripts??)", line = 4)*
This works, but with mtext I have now lost the ability to have the
superscripts in the axis title.

And I am back full circle, having to lower the resolution of the graph to
keep the x–axis title away from the axis, and thus reverting to a ragged,
segmented “line” when exported to Word..

Final note:  The R graphics window version of the graph becomes very
distorted, even though the graph may be of high quality (other than the
problem of the x-axis title overlaying the x-axis tick-mark labels) once in
Word.  I guess this is because of using “tricks” to try to get a desired
end-product in Word

Thanks for any suggestions,
  David.

[[alternative HTML version deleted]]



__
R-help@r-project.org 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.



__
R-help@r-project.org 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.


Re: [R] Exporting R graphics into Word without losing graph quality

2013-12-15 Thread Rolf Turner

On 16/12/13 12:23, Duncan Murdoch wrote:



[After a number of other "Don'ts"]
Don't trust the preview to tell you the quality of the graph, try 
printing the document.

Word isn't quite as bad as it appears.

Don't use Word. 


Fortune?

cheers,

Rolf Turner

__
R-help@r-project.org 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.


[R] possible overflow/underflow error causing NaN in .trval when invoking trmat with degree 4

2013-12-15 Thread Nerd of Darkness
Hello all,
I have two copies of the same data; I want to compare trend matrices for
degrees 3 and 4, so I name the copies "triplo" and "quatro".
> triploSurface<-surf.ls(3,triplo)
> triploMat<-trmat(triploSurface,-150.,150.,-150.,150., 300)

[This produces the expected triploSurface and triploMat results and can
be graphed.]


> quatroSurface<-surf.ls(4,quatro)
> quatroMat<-trmat(quatroSurface, -150,150,-150,150, 300)
Error in .trval(object, x, y) :
  NA/NaN/Inf in foreign function call (arg 5)

[This produces an apparently correct quatroSurface result but does not
produce any quatroMat result, just an error message.]

I think this is an overflow or underflow - i.e. I think I'm demanding
too much precision from the numbers.

The tail of the quatroSurface looks like this:
0.0238192479364594, NaN, -0.785397268575074,
0.258979557395067, 0.416633191734089, 0.48818709354019, 0.303158973109538,
0.0976576257799269, 0.0203250815697912, -0.24213596942919,
-0.0892132957309183,
0.975147904903443, 0.176878824295857, 0.0452657395908427,
0.0635179944972253,
NaN, NaN), beta = c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
NaN, NaN, NaN, NaN, NaN, NaN), wz = c(NaN, NaN, NaN, NaN, NaN,
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN), rx = c(-126.5463, 108.6537
), ry = c(-128.3801, 135.6199), call = quote(surf.ls(np = 4,
x = quatro))), .Names = c("x", "y", "z", "np", "f", "r",
"beta", "wz", "rx", "ry", "call"), class = "trls")


The tail of the triploSurface looks similar, but all its values are
well-behaved without any NaN problems

 0.0351979976095227, -1.36626369439296, -0.280695994275675,
0.40206378062954, 0.0633634395824397, 0.00569741981675165,
-0.513420054181769
), beta = c(106.769396311982, -2.24615036637542, 0.156526774285082,
1.80159305847556, -3.09710659318204, -0.524195072882179, 2.70901190859632,
-1.02836821322134, 4.80130168312262, 2.37977833647081), wz =
c(-0.0728849622348235,
-0.186585406288444, 0.415603707564799, 0.233806471348331,
0.330715976834796,
-0.0613265591678669, -0.242396311982404, -1.18446693543041,
-0.0285404338742694,
1.01075743539955, -0.210496969514736, -0.0515734891310018,
0.0473874764761177
), rx = c(-126.5463, 108.6537), ry = c(-128.3801, 135.6199),
call = quote(surf.ls(np = 3, x = triplo))), .Names = c("x",
"y", "z", "np", "f", "r", "beta", "wz", "rx", "ry", "call"), class = "trls")


There seem to be two obvious possibilities:

A - I could get a well-behaved result with degree 4 if only I could
manage to use the correct commands.

B - This data doesn't have the right characteristics to support a degree
4 trend and thus I should limit myself to degree 3.

Any comments are welcome. Thanks.

__
R-help@r-project.org 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.


Re: [R] how to add a line in the graph?

2013-12-15 Thread Frans Marcelissen
Hi,
On itself one way of doing this is:
lines(seq(-4,4,0.1),sapply(seq(-4,4,0.1),function(t)0.83*t-0.44*t^2))

The curve does not fit in the scale, however. Are you sure the formula is
correct? Then you have to adapt the scale:

plot.new()
plot.window(xlim=c(-4,4), ylim=c(-10,16))
axis(1)
axis(2)
t<--4:4
y<-c(5,7,10,13,15,16,14,12,11)
lines(t,y,type="l")

lines(seq(-4,4,0.1),sapply(seq(-4,4,0.1),function(t)0.83*t-0.44*t^2))
)



2013/12/15 水静流深 <1248283...@qq.com>

> t<--4:4
> y<-c(5,7,10,13,15,16,14,12,11)
> plot(t,y,type="l")
>
> how can i add a curve  y=0.83*t-0.44*t^2  in the graph?
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org 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.
>



-- 


---
dr F.H.G. (Frans) Marcelissen
DigiPsy (www.DigiPsy.nl )
Pomperschans 26
5595 AV Leende
tel: 040 2065030/06 2325 06 53
skype adres: frans.marcelissen
email: frans.marcelis...@digipsy.nl

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] Rows to Column

2013-12-15 Thread marcos.takahashi
Hi all,
I'm kinda new in R programming and I need some help preparing a database to
run logistic regression.

I have data in a tuple form:

*id cat val*
1   A   2
1   C   4
3   B   1
5   A   2
6   A   3
6   B   5
6   C   2
8   B   5
8   D   2
9   D   3

and would like to have it like:

*id catAcatBcatCcatD*
120  4  0
301  0  0
520  0  0
635  2  0
805  0  2
900  0  3

Could someone help me?
I have already tried table function, but it doesn't return row and column
names.



--
View this message in context: 
http://r.789695.n4.nabble.com/Rows-to-Column-tp4682245.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] The Stoppa distribution

2013-12-15 Thread andrewH
Thanks enormously, Bill!  I'll run with this for a while, and let you know
how it works for me.

 Yours,  andrewH



--
View this message in context: 
http://r.789695.n4.nabble.com/The-Stoppa-distribution-tp4682171p4682254.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] How can I find nonstandard or control characters in a large file?

2013-12-15 Thread Andrew Hoerner
Thanks, Enrico! I did this, and if I did it right, there are no nonstandard
characters. So now I am suspecting a size limit internal to the filehash
package, and trying to chase that down. Your help is much appreciated.


On Mon, Dec 9, 2013 at 11:11 PM, Enrico Schumann wrote:

> On Mon, 09 Dec 2013, andrewH  writes:
>
> > I have a humongous csv file containing census data, far too big to read
> into
> > RAM. I have been trying to extract individual columns from this file
> using
> > the colbycol package. This works for certain subsets of the columns, but
> not
> > for others. I have not yet been able to precisely identify the problem
> > columns, as there are 731 columns and running colbycol on the file on my
> old
> > slow machine takes about 6 hours.
> >
> > However, my suspicion is that there are some funky characters, either
> > control characters or characters with some non-standard encoding,
> somewhere
> > in this 14 gig file. Moreover, I am concerned that these characters may
> > cause me trouble down the road even if I use a different approach to
> getting
> > columns out of the file.
> >
> > Is there an r utility will search through my file without trying to read
> it
> > all into memory at one time and find non-standard characters or misplaced
> > (non-end-of-line) control characters? Or some R code to the same end?
>  Even
> > if the real problem ultimately proves top be different, it would be
> helpful
> > to eliminate this possibility. And this is also something I would
> routinely
> > run on files from external sources if I had it.
> >
> >  I am working in a windows XP environment, in case that makes a
> difference.
> >
> > Any help anyone could offer would be greatly appreciated.
> >
> > Sincerely, andrewH
>
> You could process your file in chunks:
>
>   f <- file("myfile.csv", open = "r")
>   lines <- readLines(f, n = 1)
>   ## do something with lines
>   lines <- readLines(f, n = 1)
>   ## do something with lines
>   ## 
>
> To find 'non-standard characters' you will need to define what
> 'non-standard characters' are.  But perhaps ?tools:::showNonASCII, which
> uses ?iconv, can help you.  (Please note the warnings and caveats on the
> functions' help pages.)
>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>



-- 
J. Andrew Hoerner
Director, Sustainable Economics Program
Redefining Progress
(510) 507-4820

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] How can I find nonstandard or control characters in a large file?

2013-12-15 Thread andrewH
Thanks, Earl. Your utility ran like a charm, and confirmed that my effort
to adapt Enrico's code to this purpose had not gone astray, which is to
say, I found no funky characters. Your help is greatly appreciated.
Sincerely, andrewH


On Tue, Dec 10, 2013 at 7:35 AM, Earl F Glynn [via R] <
ml-node+s789695n4681952...@n4.nabble.com> wrote:

> andrewH wrote:
>
> > However, my suspicion is that there are some funky characters, either
> > control characters or characters with some non-standard encoding,
> somewhere
> > in this 14 gig file. Moreover, I am concerned that these characters may
> > cause me trouble down the road even if I use a different approach to
> getting
> > columns out of the file.
>
> This is not an R solution, but here's a Windows utility I wrote to
> produce a table of frequency counts for all hex characters x00 to xFF in
> a file.
>
> http://www.efg2.com/Lab/OtherProjects/CharCount.ZIP
>
> Normally, you'll want to scrutinize anything below x20 or above x7F,
> since ASCII printable characters are in the range x20 to x7E. You can
> see how many tab (x09) characters are in the file, and whether the line
> endings are from Linux (x0A) or Windows (paired x0A and x0D).
>
>
> The ZIP includes Delphi source code, but provides a Windows executable.
>   I made a change several months ago to allow drag-and-drop, so you can
> just drop the file on the application to have the characters counted.
> Just run the EXE after unzipping.  No installation is needed.
>
> Once you find problems characters in the file, you can read the file as
> character data and use sub/gsub or other tools to remove or alter
> problem characters.
>
> efg
> Earl F Glynn
> UMKC School of Medicine
> Center for Health Insights
>
> __
> [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.
>
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/How-can-I-find-nonstandard-or-control-characters-in-a-large-file-tp4681896p4681952.html
>  To unsubscribe from How can I find nonstandard or control characters in a
> large file?, click 
> here
> .
> NAML
>



-- 
J. Andrew Hoerner
Director, Sustainable Economics Program
Redefining Progress
(510) 507-4820




--
View this message in context: 
http://r.789695.n4.nabble.com/How-can-I-find-nonstandard-or-control-characters-in-a-large-file-tp4681896p4682257.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] How to choose data from two sets of data to ensure that the choosed data has a better normal feature?

2013-12-15 Thread Marino David
Hi R mailing listers:

Assume that there are two sets of data  (denoted as A and B) with the same
size, say 100X1. And I try to select a new set of data (100X1) that has a
 better normal feature  from these two sets. Better normal feature means
that the histogram shape of the constructed set of data is more normal
bell-shaped.  The choose rule is that the i-th element of new set is from
i-th element of A or B.

Any suggest is greatly appreciated.

Thank you!

David

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] how to fit exponential curve such as a*b^t in r?

2013-12-15 Thread ????????
input <- "
  ty
 1  5.3
 2  7.2
 3  9.6
 4 12.9
 5 17.1
 6 23.2" 
dat<-read.table(textConnection(input),header=TRUE,sep="")
t<-dat[,1]
y<-dat[,2]   

`y=3.975*(1.341^t)` is the resule of fit,how can i use `nls` function to get it?
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.