Re: [R] Confusing concept of vector and matrix in R

2010-03-30 Thread lith
> Reframe the problem. Rethink why you need to keep dimensions. I never ever 
> had to use drop.

The problem is that the type of the return value changes if you happen
to forget to use drop = FALSE, which can easily turn into a nightmare:

m <- matrix(1:20, ncol=4)
for (i in seq(3, 1, -1)) {
print(class(m[1:i, ]))
}
[1] "matrix"
[1] "matrix"
[1] "integer"

__
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] R output to Rich Text Format

2010-03-18 Thread lith
> Hi,  Does anyone know of an existing package that will output to rtf?  
> Something along the lines of pdf(ds,'file.pdf') or write.csv(ds,'file.csv').

You could use odfWeave and then use OpenOffice to generate an RTF
file.

Regards,
Tom

__
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] odfWeave Error

2010-03-17 Thread lith
> I am following an example from online and am getting the following error:
> ."Error unizipping fileunzip not found".

Are zip and unzip in your path? If not you could use odfWeaveControl.

Example:

odfctrl <- odfWeaveControl(
zipCmd = c("h:/bin/zip.exe -r $$file$$ .", "h:/bin/unzip.exe -o $
$file$$"),
)
odfWeave(template, outfile, control = odfctrl)

__
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] dot-dot-dot as an actual argument

2010-02-19 Thread lith
> I could not find any documentation of how dot-dot-dot works when used
> as an argument in a function call (rather than as a formal argument in
> a definition).

You might also be interested in other thread regarding this problem:
http://groups.google.com/group/r-help-archive/msg/5c6ea5eb593337b4

Regards
Tom

__
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] ellipsis-related error: used in an incorrect context, no ... to look in

2010-02-19 Thread lith
Does nobody have an advice concerning that problem? If it is a FAQ,
I'd appreciate a pointer to a discussion of this issue. With the docs
accessible to me, I wasn't able to solve that problem.

>     require(lattice)
>     f.barchart <- function(...) {
>         barchart(...,
>             panel = function(x, y, ...) {
>                 panel.barchart(x, y, ...)
>             }
>         )
>     }
>
>     x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
>     f.barchart(a ~ b, data = x, groups = c)
>
> Which results in the following error being thrown:
>
>     ..3 used in an incorrect context, no ... to look in

Regards,
Tom

__
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] ellipsis-related error: used in an incorrect context, no ... to look in

2010-02-16 Thread lith
Hi,

I have the following code snippet:

require(lattice)
f.barchart <- function(...) {
barchart(...,
panel = function(x, y, ...) {
panel.barchart(x, y, ...)
}
)
}

x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1))
f.barchart(a ~ b, data = x, groups = c)

Which results in the following error being thrown:

..3 used in an incorrect context, no ... to look in

When I use the following definition:

f.barchart <- function(...) {
substitute(barchart(...,
panel = function(x, y, ...) {
panel.barchart(x, y, ...)
}
))
}

I get:

barchart(a ~ b, data = x, groups = c,
panel = function(x, y, ...) {
panel.barchart(x, y, a ~ b, data = x, groups = c)
})

I'm not sure if this is the cause of above error but this would mean
that the ellipsis in panel.barchart gets wrongly expanded with the
contents of the arguments given to f.barchart and not the panel
function.

Is there a way to avoid this problem? How can I make the function
work?

I use R 2.10.1 @ win32.

Regards,
Tom

__
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] question on sqldf syntax

2010-01-25 Thread lith
On 25 Jan., 20:26, GL  wrote:
> Actually, better sql would likely be:
>
> dbs.final <- sqldf("select * from dbs.possible.combos left join
> dbs.aggregate using (Date,Place)")
>
> but this still doesn't work

I'd suspect name mangling to cause the problem:
http://code.google.com/p/sqldf/#2._Why_does_sqldf_seem_to_mangle_certain_variable_names?

Try to quote the table names with backticks (`).

__
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] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-30 Thread lith
> Yes. You can get back the tick marks with scaless$col:

Thanks for the hint. May I kindly ask what would be the easiest way to
draw a line on the left side?

Thanks,
Tom

__
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] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-18 Thread lith
> 1.) How do I make lattice (e.g. barchart) to not draw a box but only a
> y-axis on the left hand side so that the plot looks like barplot with
> default settings?

Does nobody have an idea? Or is the solution that obvious?

__
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] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-16 Thread lith
Hi,

I have two somewhat embarassing questions about the lattice-related
plot functions:

1.) How do I make lattice (e.g. barchart) to not draw a box but only a
y-axis on the left hand side so that the plot looks like barplot with
default settings? So that the following two code snippets look more
alike:

barplot(VADeaths)

library(reshape)
vad <- melt(data.frame(VADeaths, Age=rownames(VADeaths)), id="Age")
barchart(value ~ variable, groups=Age, horizontal=FALSE, stack=TRUE,
data=vad)

2.) What is the proper way to make lines in xyplots thicker? When I
set lwd=2, I get thicker lines but in conjunction with lty=1:n they
also look somewhat ugly which makes me wonder if I'm doing something
wrong.

I guess both questions are newbie questions and the information should
be easily available somewhere. Unfortunately I wasn't able to find the
answer to these questions myself.

Regards,
Tom

__
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.