Re: [R] ggplot2: geom_segment does not produce the color I desire?

2016-09-17 Thread Erich Neuwirth
Here are 2 solutions to you problem:

If you only want to use one color (for possibly many arrows),
this will work:

ggplot()+geom_segment(mapping = aes(x = as.Date(test[,"date"]),
y =y1,
xend = as.Date(test[,"date"]),
yend = y2), color="green", data=testdf,
  arrow=arrow())


if you use a variable to colors different items differently,
you are using a mapping.
If you want to override ggplot’s default mapping, you set the palette 
explicitly:

ggplot()+geom_segment(mapping = aes(x = as.Date(test[,"date"]),
y =y1,
xend = as.Date(test[,"date"]),
yend = y2, color=co), data=testdf,
arrow=arrow()) +
  scale_color_manual(values=list(green="green"))


> On Sep 17, 2016, at 00:43, John  wrote:
> 
>> 
>> test
>dateco   y1   y2
> 5 2011-11-28 green 196.6559 1.600267
>> dput(test)
> structure(list(date = structure(15306, class = "Date"), co = "green",
>y1 = 196.655872, y2 = 1.600267), .Names = c("date", "co",
> "y1", "y2"), class = "data.frame", row.names = 5L)
>> ggplot()+geom_segment(mapping = aes(x = as.Date(test[,"date"]), y =
> y1, xend = as.Date(test[,"date"]), yend = y2, color=co), data=test,
> arrow=arrow())
> 



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] gene name problem in Excel, and an R analogue

2016-09-14 Thread Erich Neuwirth
Since many people commenting on the gene name problem in Excel essentially tell 
us
This could never have happened with R
I want to show you a somewhat related issue:


ff1 <- tempfile()
cat(file = ff1, "12345", "1E002", sep = "\n")
xdf1 <- read.fwf(ff1, widths = 5, stringsAsFactors=FALSE)

ff2 <- tempfile()
cat(file = ff2, "12345", "1E002","1A010", sep = "\n")
xdf2 <- read.fwf(ff2, widths = 5, stringsAsFactors=FALSE)

in xdf1, the variable is numeric, in xdf2, it is a character variable.
Of course, in hindsight this makes sense. But the problem is similar to the
Excel problem where something which could be a date is interpreted as a date.

A possible solution with my read.fwf problem would be to have a parameter
forcing variables to be read as strings.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] workflow getting UTF-8 csv in and out of R on Mac (spreadsheet editor)

2016-09-02 Thread Erich Neuwirth
read_excel in Hadley’s readxl package
should handle your encoding problems.
Writing Excel files on a Mac, however, still is somewhat messy.

And you probably should post this kind of question on r-sig-mac



On 02 Sep 2016, at 13:03, Kai Mx  wrote:
> 
> Hi all,
> 
> I am hoping for some advice on how to handle UTF-8 spreadsheet files in a
> Mac environment - sort of off-topic, but still relevant for hopefully a
> bunch of people.
> 
> I am using R on Mac OS 10.10. Sometimes I have the urge to actually look at
> a large spreadsheet on the big screen or make some changes to the tables.
> Since most of my colleagues live in the M$ Excel - world I tend to use
> Excel 2011 as well. However, Excel does not handle UTF-8 (which I like
> because of different system locales).
> So I actually do a write.csv with file-encoding in macroman, but even then
> Excel won't just open it and I will have to work my way through the
> import-dialogue.
> 
> The other way around, it's even worse. I save the spreadsheet as macroman,
> iconv it to utf-8 and then read.csv it to R.
> 
> It works, but it's just really messy. Is there a (preferably light-weight)
> csv-spreadsheet Editor for Mac OS that you use? Open-Office? I would like
> NOT to actually buy another Excel version. However, for collaboration, a
> xls-export would be phenomenal.
> 
> Thanks!
> 
> Kai
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Install on Xenial

2016-05-04 Thread Erich Neuwirth
I am trying to install R-3.3.0 on Xenial.
I followed the instructions on the corresponding CRAN page, and I added the GPG 
key.
But after adding
deb https://cran.at.r-project.org//bin/linux/ubuntu xenial/
to /etc/apt/sources.list
and
sudo apt-get update
I get the following error:

Err:7 https://cran.at.r-project.org//bin/linux/ubuntu xenial/ Packages
  SSL: certificate subject name (*.r-project.org) does not match target host 
name 'cran.at.r-project.org’

What do I need to do to get rid of this error




signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Compute the Gini coefficient

2016-03-30 Thread Erich Neuwirth

> On 30 Mar 2016, at 02:53, Marine Regis  wrote:
> 
> Hello,
> 
> I would like to build a Lorenz curve and calculate a Gini coefficient in 
> order to find how much parasites does the top 20% most infected hosts support.
> 
> Here is my data set:
> 
> Number of parasites per host:
> parasites = c(0,1,2,3,4,5,6,7,8,9,10)
> 
> Number of hosts associated with each number of parasites given above:
> hosts = c(18,20,28,19,16,10,3,1,0,0,0)
> 
> To represent the Lorenz curve:
> I manually calculated the cumulative percentage of parasites and hosts:
> 
> cumul_parasites <- cumsum(parasites)/max(cumsum(parasites))
> cumul_hosts <- cumsum(hosts)/max(cumsum(hosts))
> plot(cumul_hosts, cumul_parasites, type= "l”)


Your values in hosts are frequencies. So you need to calculate

cumul_hosts = cumsum(hosts)/sum(hosts)
cumul_parasites = cumsum(hosts*parasites)/sum(parasites)

The Lorenz curves starts at (0,0), so to draw it, you need to extend these 
vectors

cumul_hosts = c(0,cumul_hosts)
cumul_parasites = c(0,cumul_parasites)

plot(cumul_hosts,cum9l_parasites,type=“l”)


The Gini coefficient can be calculated as
library(reldist)
gini(parasites,hosts)


If you want to check, you can “recreate” the original data (number of parasited 
for each host) with

num_parasites = rep(parasites,hosts)

and
gini(num_parasites)

will also give you the Gini coefficient you want.



> 

>> From this Lorenz curve, how can I calculate the Gini coefficient with the 
>> function "gini" in R (package reldist) given that the vector "hosts" is not 
>> a vector of weights ?
> 
> Thank you very much for your help.
> Have a nice day
> Marine
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Persistent state in a function?

2016-03-19 Thread Erich Neuwirth
package memoise
might help you

> On 19 Mar 2016, at 17:45, Boris Steipe  wrote:
> 
> Dear all -
> 
> I need to have a function maintain a persistent lookup table of results for 
> an expensive calculation, a named vector or hash. I know that I can just keep 
> the table in the global environment. One problem with this approach is that 
> the function should be able to delete/recalculate the table and I don't like 
> side-effects in the global environment. This table really should be private. 
> What I don't know is:
> -A- how can I keep the table in an environment that is private to the 
> function but persistent for the session?
> -B- how can I store and reload such table?
> -C- most importantly: is that the right strategy to initialize and maintain 
> state in a function in the first place?
> 
> 
> For illustration ...
> 
> ---
> 
> myDist <- function(a, b) {
># retrieve or calculate distances
>if (!exists("Vals")) {
>Vals <<- numeric() # the lookup table for distance values
>   # here, created in the global env.
>}
>key <- sprintf("X%d.%d", a, b)
>thisDist <- Vals[key]
>if (is.na(thisDist)) {  # Hasn't been calculated yet ...
>cat("Calculating ... ")
>thisDist <- sqrt(a^2 + b^2) # calculate with some expensive function 
> ...
>Vals[key] <<- thisDist  # store in global table
>}
>return(thisDist)
> }
> 
> 
> # run this
> set.seed(112358)
> 
> for (i in 1:10) {
>x <- sample(1:3, 2)
>print(sprintf("d(%d, %d) = %f", x[1], x[2], myDist(x[1], x[2])))
> }
> 
> 
> Thanks!
> Boris
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] FUNCTION ctree

2016-03-10 Thread Erich Neuwirth
If you do
??ctree
and the package partykit is installed, you will see that this function is 
defined in this package.
So, you should run
library(partykit)
before running your function call

If partykit is not installed, you need to install it.





> On Mar 10, 2016, at 15:58, CHIRIBOGA Xavier  wrote:
> 
> Dear all,
> 
> 
> I am using Rstudio. What to do when you get this message?
> 
> Error in plot(ctree(Surv(hours, state) ~ soil + volatile, data = data)) :
>  could not find function "ctree"
> 
> Thank you,
> 
> 
> Xavier
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] .Call works in R 2 not in R 3

2016-03-08 Thread Erich Neuwirth
cutree is a function available in stats.
So it might be worth a try to just replace

.Call("R_cutree", tree$merge, k, PACKAGE = "stats”)

by

cutree(tree$merge,k)

and see what happens.

checking the source of cutree shows the following call

ans <- .Call(C_cutree, tree$merge, k)

so replacing R_cutree by C_cutree also might be an option.
But, of course as Uwe recommended,
using a plain R call and not using .Call is the preferred solution.


> On Mar 8, 2016, at 14:55, Sebastien Moretti  wrote:
> 
>>> Hi
>>> 
>>> I inherited a R package done in 2004 that works perfectly in R 2.15.1
>>> and before, but not in R 3.2.2 ( >= 3).
>>> 
>>> I have already fixed issues with namespace for functions in R 3 but
>>> maybe not all of them.
>>> 
>>> Here is the error message:
>>> Error in .Call("R_cutree", tree$merge, k, PACKAGE = "stats")
>>> "R_cutree" not available for .Call() for package "stats"
>> 
>> Why do you .Call() into another package? Rather use the API.
> 
> Let's say that I am far from a R master.
> I never use .Call() myself.
> 
> I want the code works again in R >= 3 because R support for R 2 will soon be 
> stopped in my institute.
> When the code will work again, I could change internals by comparing results 
> with R 2 and R 3.
> 
>> Best,
>> Uwe Ligges
>> 
>>> 
>>> Thanks for your help
> 
> --
> Sébastien Moretti
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] readRDS problem

2016-02-24 Thread Erich Neuwirth
?data
will show you that data is a reserved word!


> On 24 Feb 2016, at 11:02, Sigbert Klinke  wrote:
> 
> Hi,
> 
> thanks, using
> 
> test <<- readRDS (name)
> 
> it worked. But why?
> 
> Best Sigbert
> 
> Am 24.02.2016 um 10:39 schrieb Michael Dewey:
>> Try calling it something other than data.
>> 
>> On 24/02/2016 09:26, Sigbert Klinke wrote:
>>> Hi,
>>> 
>>> I have two scripts, one creates a data structure (a list of data frames
>>> + some attributes) and saves it via saveRDS.
>>> 
>>> The second script reads the RDS file (outside of any function) and
>>> 
>>> data <- readRDS (name)
>>> 
>>> works, but
>>> 
>>> data <<- readRDS (name)
>>> 
>>> creates the error
>>> 
>>> Error: cannot change value of locked binding for 'data'
>>> 
>>> Any idea what goes wrong?
>>> 
>>> Thanks Sigbert
>>> 
>> 
> 
> 
> --
> http://u.hu-berlin.de/sk 
> __
> R-help@r-project.org  mailing list -- To 
> UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] choropleth packages (US)

2015-12-07 Thread Erich Neuwirth
ggplot2 also can do this with
fortify
geom_polygon

Von meinem iPad gesendet

> Am 06.12.2015 um 21:03 schrieb Benjamin Tyner :
> 
> Hi
> 
> I wish to draw a basic choropleth (US, by state) and am wondering if anyone 
> has any recommendations? I've tried the following thus far:
> 
> 1. choroplethr: this works, but required installation of 30+ dependencies. I 
> would prefer something with fewer dependencies.
> 2. tmap: this also seems promising, but most of the examples I saw were 
> specific to European maps. Can it be adapted for US?
> 3. statebins: doesn't draw true choropleths, but I liked that it doesn't have 
> many dependencies.
> 
> Regards
> Ben
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Can we use all the functions of R in visual studio? The Rmath.dll and R.dll seems only contain a part of R functions

2015-12-04 Thread Erich Neuwirth
There is statconnDCOM, whoch gives full R as a COM server which can be used 
from all he Visual languages.
It is not free. There are cost free licenses for student and home use, but 
essentially it is a commercial product.

Mor information can be found at
www.statconn.com 



> On 04 Dec 2015, at 13:38, 李琥 <081024...@fudan.edu.cn> wrote:
> 
> Can we use all the functions of R in visual studio? The Rmath.dll and R.dll 
> seems only contain a part of R functions



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] is.na behavior

2015-11-19 Thread Erich Neuwirth
I am not sure I undestand the issue.
But if the question is to decidedif an expression evaluates to NA,
using eval should solve the problem.
In fact, I do not really understand what an NA expression, and not an 
expression evaluating to NA,
means.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Creating new variables in R

2015-10-26 Thread Erich Neuwirth
data <- within(data,variable3=pmax(variable1,variable2))
also should work if your variables are numeric.

using dplyr and magrittr (which I recommend to all my students)
it could be

library(dplyr)
library(magrittr)
data %<>% mutate(variable3=pmax(variable1,variable2))



> On 26 Oct 2015, at 12:53, PIKAL Petr  wrote:
> 
> Hi
> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org 
>> ] On Behalf Of Duncan
>> Murdoch
>> Sent: Monday, October 26, 2015 11:58 AM
>> To: Lorenz, Jennifer; r-help@r-project.org 
>> Subject: Re: [R] Creating new variables in R
>> 
>> On 26/10/2015 6:24 AM, Lorenz, Jennifer wrote:
>>> Hi,
>>> 
>>> I  have a question regarding the creation of new variables on the
>> basis of existing ones in R.
>>> 
>>> I have two variables containing information on parents' educational
>> degree (e.g. 1 'high school degree', 2 'college degree', etc.). I would
>> like to create a new variable for 'parents' highest educational
>> degree', i.e. if variable1 (father's degree) is higher than variable2
>> (mother's degree) than the new variable (variable3) should take on the
>> value of variable1, if not, than variable3 should take on the value of
>> variable2.
>>> 
>>> I usually use SPSS for data manipulation, there I would code
>> variable3 as follows:
>>> COMPUTE variable3= 0.
>>> IF variable1 > variable2 variable3= variable1.
>>> IF variable1 <= variable2 variable3= variable2.
>>> 
>>> The closest I came to that in R was with this code:
>>> data$variable3 <- 0
>>> data$variable3[data$variable1 > data$variable2]<-data$variable1
>>> data$variable3[data$variable1 <= data$variable2]<-data$variable2
>>> 
>>> I also tried:
>>> data$variable3 <- ifelse(data$variable1 > data$variable2),
>>> data$variable1, data$variable2)
>>> 
>>> Both didn't work.
> 
> The ifelse version should work. Are you sure that variable 1 and 2 are 
> numeric?.
> 
> What is a result of str(data)?
> 
> Cheers
> Petr
> 
>>> 
>>> I am not sure if my post is at all understandable (this is my first
>> time posting on R-help), but I am really hoping for some advice!
>> 
>> This is a good place to use the ifelse() function:
>> 
>> data$variable3 <- ifelse(data$variable1 > data$variable2,
>> data$variable1, data$variable2)
>> 
>> Duncan Murdoch
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
> 
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou 
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
> jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
> svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
> zpožděním přenosu e-mailu.
> 
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, 
> a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany 
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
> dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
> žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
> pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu 
> případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je 
> adresátovi či osobě jím zastoupené známá.
> 
> This e-mail and any documents attached to it may be confidential and are 
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its sender. 
> Delete the contents of this e-mail with all attachments and its copies from 
> your system.
> If you are not the intended recipient of this e-mail, you are not authorized 
> to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage caused 
> by modifications of the e-mail or by delay with transfer of the email.
> 
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a 
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an 

Re: [R] ggplot: combining geom's in function

2015-10-23 Thread Erich Neuwirth
I often look for examples in
http://www.cookbook-r.com/Graphs/ 

> On 23 Oct 2015, at 18:27, Jeff Newmiller  wrote:
> 
> Have you looked at the qplot function in the ggplot2 package?
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live Go...
>  Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
> 
> On October 23, 2015 3:12:41 PM GMT+02:00, sbihorel 
>  wrote:
>> Hi,
>> 
>> Next adventure into my journey from lattice to ggplot: I would like to
>> create a custom generic function that combines multiple existing geom's
>> 
>> in order to reproduce what the lattice panel.xyplot function does based
>> 
>> on the type argument (ie, plotting points only for type='p', plotting
>> lines for type 'l', etc).
>> 
>> My current naive attempt is:
>> 
>> library(lattice)
>> library(ggplot2)
>> 
>> geom_xyplot <- function (mapping = NULL, data = NULL, stat =
>> "identity",
>> position = "identity", na.rm = FALSE, type =
>> 'p', ...) {
>> 
>>  if (any(type=='p')){
>>geom_point(mapping = mapping, data = data, stat = stat,
>>   position = position, na.rm = na.rm, ...)
>>  }
>>  if (any(type=='l')){
>>geom_path(mapping = mapping, data = data, stat = stat,
>>  position = position, na.rm = na.rm, ...)
>>  }
>>  if (any(type%in%c('b','o'))){
>>geom_point(mapping = mapping, data = data, stat = stat,
>>   position = position, na.rm = na.rm, ...) +
>>  geom_path(mapping = mapping, data = data, stat = stat,
>>position = position, na.rm = na.rm, ...)
>>  }
>> }
>> 
>> data <- data.frame(x = rep(1:4, each = 25),
>>   y = rep(1:25, times = 4),
>>   g = rep(1:4, each = 25))
>> data$x <- data$x + 0.005*(data$y)^2-0.1*data$y+1
>> 
>> ggplot(data2, aes(x, y, group = g, colour = factor(g))) +
>> geom_xyplot(type = 'l')
>> 
>> I get:
>>> Error: No layers in plot
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
> 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Spreadsheet math problem (exponentiation)

2015-09-18 Thread Erich Neuwirth
Let me add a little bit here:

When using math formulas, one should know about the parsing rules form complex 
expression
which do not have all the necessary parenthesis.

Different systems do have different parings rules.
In the case of a^b^c, the expression is ambiguus because
(as mentioned in a previous mail) in general
(a^b)^c != a^(b^c)
To avoid unintended consequences, just us parentheses and you will get
the right result.
in the case of -a^b
The question is the order of precedence of unary - and binary ^.

In Excel, -2^2=4, but 0-2^2=-4

Reason: For Excel, unary - is stronger than the power operator, but binary 
minus is weaker.

My feeling is that too many people are bashing spreadsheets for the wrong 
reason.
Spreadsheets ca do things R cannot do: Automatic recalculation when input 
changes,
and visual point and click modelling of dependencies.
The calculation engine of Excel admittedly has some weak points.

That is the reason why I wrote RExcel which gives you all the advantages of the 
spreadsheet interface
and allows you to use the R calculation within this interface whenever needed.




signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Spreadsheet math problem (exponentiation)

2015-09-18 Thread Erich Neuwirth
Methinks that any math teaching should make learners aware of the fact that
math conventions are not laws of nature, and that ambiguous expressions may
produce different values in different systems.

I think -2^2=4 is perfectly reasonable.

In my experience, most people after high school math do not know that
binary - und unary - are very different operations.
And that is the fault of the current way of teaching math!



> On Sep 18, 2015, at 18:00, John Kane  wrote:
> 
> A very good point re RExcel   for sophisticated users.  The majority of 
> spreadsheet users, will never have heard of RExcel (or R for that matter) and 
> very likely will no  have the sophistication of knowing that they need to use 
> brackets.  Plus RExcel  is not available in  flavours for Apache OpenOffice 
> or gnumeric as far as I am aware.
> 
> If one actually learned the formal mathematical order of operations and still 
> remembers  them the expectation is that -2^2 will return -2.  In a  20 sheet 
> spreadsheet the error is likely to go completely undetected and may or may 
> not have significant effect on final results.
> 
> I, recently, was reading an education blog where the author was bemoaning the 
> fact that shiny new math teachers were teaching that -2^2 = 4. Presumably 
> they are putting their faith in Excel, etc., rather than the actual math 
> conventions.
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: erich.neuwi...@univie.ac.at
>> Sent: Fri, 18 Sep 2015 17:13:44 +0200
>> To: r-help@r-project.org
>> Subject: Re: [R] Spreadsheet math problem (exponentiation)
>> 
>> Let me add a little bit here:
>> 
>> When using math formulas, one should know about the parsing rules form
>> complex expression
>> which do not have all the necessary parenthesis.
>> 
>> Different systems do have different parings rules.
>> In the case of a^b^c, the expression is ambiguus because
>> (as mentioned in a previous mail) in general
>> (a^b)^c != a^(b^c)
>> To avoid unintended consequences, just us parentheses and you will get
>> the right result.
>> in the case of -a^b
>> The question is the order of precedence of unary - and binary ^.
>> 
>> In Excel, -2^2=4, but 0-2^2=-4
>> 
>> Reason: For Excel, unary - is stronger than the power operator, but
>> binary minus is weaker.
>> 
>> My feeling is that too many people are bashing spreadsheets for the wrong
>> reason.
>> Spreadsheets ca do things R cannot do: Automatic recalculation when input
>> changes,
>> and visual point and click modelling of dependencies.
>> The calculation engine of Excel admittedly has some weak points.
>> 
>> That is the reason why I wrote RExcel which gives you all the advantages
>> of the spreadsheet interface
>> and allows you to use the R calculation within this interface whenever
>> needed.
> 
> 
> Send any screenshot to your friends in seconds...
> Works in all emails, instant messengers, blogs, forums and social networks.
> TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE
> 
> 



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] data format

2015-08-19 Thread Erich Neuwirth
This is the kind of problem the package tidyR has been designed for.

 On 19 Aug 2015, at 16:29, minikg min...@cmfri.org.in wrote:
 
 Hi,
 
 I have a dataset consisting of landmarks of each sample's  coordinates as
 given below.
 
 landmark  X   Y   X   Y   X   Y
 P1   534  7   26  7   32
 P2 46 45  48  42  44  48
 P3 73 45  72  44  71  46
 P4 92 43  90  43  89  42
 
 
 please help me to change my data format to
 
 samplep1x1p1y1p2x2p2y2p3x3p3y3p4x4p4y4
 1534  46  45  73  45  92  43
 2726  48  42  72  44  90  43
 3732  44  48  71  46  89  42
 
 Thanks
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/data-format-tp4711278.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] about R 3.2.0

2015-07-25 Thread Erich Neuwirth
If you are running R on Windows,
there is the package installr which will help you with the process
of upgrading.

And item 2.8 in the R for Windows FAQ has some information about upgrading also.
 On 25 Jul 2015, at 06:41, Waqas Shafqat waqas1...@gmail.com wrote:
 
 Dear sir,
 
 I am using currently R 3.1.3. But i wnat to upgrade this version to R 3.2.0
 but i am feared that the libraries which i have installed may be remove?
 please guide me.
 
 thanks
 --
 Waqas Shafqat Chattha
 Ph. D Scholar
 Department of Plant Breeding and Genetics
 University of Agriculture, Faisalabad
 Pakistan
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] interactive Map: Popups

2015-07-23 Thread Erich Neuwirth
Some shapefiles for Germany can be found here

http://www.statsilk.com/maps/download-free-shapefile-maps 
http://www.statsilk.com/maps/download-free-shapefile-maps

 On Jul 23, 2015, at 21:36, Erin Hodgess erinm.hodg...@gmail.com wrote:
 
 Hello Erich:
 
 I just looked at your leaflet package and its examples.  It is awesome!
 
 Thanks,
 Erin
 
 
 On Thu, Jul 23, 2015 at 6:28 AM, Erich Neuwirth erich.neuwi...@univie.ac.at 
 mailto:erich.neuwi...@univie.ac.at wrote:
 I am quite happy with that package leaflet which is not yet on CRAN
 but available on Githib.
 
 https://github.com/rstudio/leaflet https://github.com/rstudio/leaflet 
 https://github.com/rstudio/leaflet https://github.com/rstudio/leaflet
 
 
 __
 R-help@r-project.org mailto:R-help@r-project.org mailing list -- To 
 UNSUBSCRIBE and more, see
 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.
 
 
 
 --
 Erin Hodgess
 Associate Professor
 Department of Mathematical and Statistics
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com mailto:erinm.hodg...@gmail.com


signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] interactive Map: Popups

2015-07-23 Thread Erich Neuwirth
I am quite happy with that package leaflet which is not yet on CRAN
but available on Githib.

https://github.com/rstudio/leaflet https://github.com/rstudio/leaflet



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] tcltk problem

2015-03-12 Thread Erich Neuwirth
Thesw are demos for
tclscrollbar
I copied them from the help file to the console manually
as the help file suggested.
 On 12 Mar 2015, at 09:04, peter dalgaard pda...@gmail.com wrote:
 
 
 On 11 Mar 2015, at 23:41 , Erich Neuwirth erich.neuwi...@univie.ac.at 
 mailto:erich.neuwi...@univie.ac.at wrote:
 
 OSX 10.10.2
 R 3.1.3
 XQuartz installed.
 
 I am trying to run one of the tcltk demos
 
 Which demos? Doesn't look like any the ones in the package.
 



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] tcltk problem

2015-03-12 Thread Erich Neuwirth
Sorry,
I get at these demo when I do
?tkscrollbar
Then the help file for many of the UI widgets appears, titled
TkWidgets {tcltk}
On the bottom of this file are the 2 examples I mentioned.
Excuse the incomplete description in the first and the incorrect description in 
the second message.





 On 12 Mar 2015, at 09:04, peter dalgaard pda...@gmail.com wrote:
 
 
 On 11 Mar 2015, at 23:41 , Erich Neuwirth erich.neuwi...@univie.ac.at 
 mailto:erich.neuwi...@univie.ac.at wrote:
 
 OSX 10.10.2
 R 3.1.3
 XQuartz installed.
 
 I am trying to run one of the tcltk demos
 
 Which demos? Doesn't look like any the ones in the package.
 
 (Please at least be specific when you imply that someone is publishing bad 
 code.)
 
 This one works:
 
 tt - tktoplevel()
 label.widget - tklabel(tt, text = Hello, World!)
 button.widget - tkbutton(tt, text = Push,
 command = function()cat(OW!\n))
 tkpack(label.widget, button.widget) # geometry manager
   # see Tk-commands
 
 
 But the next one breaks:
 if(as.character(tcl(info, tclversion)) = 8.5) {
 +   # make use of themed widgets
 +   # list themes
 +   as.character(tcl(ttk::style, theme, names))
 +   # select a theme -- here pre-XP windows
 +   tcl(ttk::style, theme use, winnative)
 + } else {
 +   # use Tk 8.0 widgets
 + }
 Error in structure(.External(.C_dotTclObjv, objv), class = tclObj) :
 [tcl] bad command theme use: must be configure, map, lookup, layout, 
 theme, or element.
 
 What is going wrong here?
 
 Presumably theme use wants to be theme, use.
 
 (Many moons ago, tcl() just pasted words together and executed the result as 
 a Tcl command via .Tcl. Looks like the author expected .Tcl(ttk::style theme 
 use winnative), but nowadays it uses .Tcl.objv() which expects a vector of 
 Tcl words so there is a difference between two words and one word with a 
 space in the middle. The puzzling bit is that I'd have thunk Tcl 8.5 to be 
 considerably later than the change to tcl()?)
 
 
 --
 Peter Dalgaard, Professor,
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk mailto:pd@cbs.dk  Priv: pda...@gmail.com 
 mailto:pda...@gmail.com


signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] tcltk problem

2015-03-11 Thread Erich Neuwirth
OSX 10.10.2
R 3.1.3
XQuartz installed.

I am trying to run one of the tcltk demos
This one works:

tt - tktoplevel()
label.widget - tklabel(tt, text = Hello, World!)
button.widget - tkbutton(tt, text = Push,
  command = function()cat(OW!\n))
tkpack(label.widget, button.widget) # geometry manager
# see Tk-commands


But the next one breaks:
 if(as.character(tcl(info, tclversion)) = 8.5) {
+   # make use of themed widgets
+   # list themes
+   as.character(tcl(ttk::style, theme, names))
+   # select a theme -- here pre-XP windows
+   tcl(ttk::style, theme use, winnative)
+ } else {
+   # use Tk 8.0 widgets
+ }
Error in structure(.External(.C_dotTclObjv, objv), class = tclObj) :
  [tcl] bad command theme use: must be configure, map, lookup, layout, theme, 
or element.

What is going wrong here?



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] %%

2015-02-17 Thread Erich Neuwirth
AFAIK dplyr imports magrtittr.
So dplyr ses %% from migrittr, it does not have its own version.


 On Feb 17, 2015, at 22:19, Ben Bolker bbol...@gmail.com wrote:
 
 David Barron dnbarron at gmail.com writes:
 
 
 It's in the magrittr package.
 
 David
 
  It also exists in dplyr.
 
  (I would guess that it's imported/exported from magrittr.)
  Although I think the documentation in magrittr is a little better.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] transpose a data frame according to a specific variable

2015-02-09 Thread Erich Neuwirth

library(tidyr)
spread(DF,Year,Day)




 On 09 Feb 2015, at 16:47, jeff6868 geoffrey_kl...@etu.u-bourgogne.fr wrote:
 
 finalDF -
 data.frame(id=c(A,B,C),2000=c(NA,NA,164),2001=c(120,NA,99),
 2002=c(90,18,48),2003=c(54,217,NA),2004=c(NA,68,NA))



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Generate random numbers under constrain

2014-11-27 Thread Erich Neuwirth
You want random numbers within the n-dimensional simplex (sum xi =1)
The easiest solution of course would be creating n-dimensions vectors
with iid uniform components on [0,1) and throwing away those
violating the inequality.
Since the volume of the n-dimensional simplex is 1/n! (factorial)
this becomes very wasteful even for low dimensions.

A possible  answer is to use the Dirichlet distribution from package lca)
since the uniform distribution on the simplex is a special case
of the Dirichlet distribution.


 On Nov 27, 2014, at 14:57, Jue Lin-Ye jl.i...@gmail.com wrote:
 
 Hello! I am relatively new using R, but this is my contribution to the
 answer. How about using a Monte-Carlo method. Generate m numbers in the
 support [0,1], where mn. Then constrain by constructing a loop that takes
 every one of the elements in the m sized vector and select the ones that
 sum up to one. If it is very uncommon to sum up to one, given the
 distribution that you use to generate the random numbers, you can construct
 a loop that generates as many random numbers as you need and then follow
 the steps
 1.generate
 2.select
 
 until you find a total of n number.
 
 Dear all,
 I use R 3.1.1 for Windows.
 kindly how can I generate n number of random numbers with probability
 from [0,1]
 and their sum must not be more than one
 thanks in advance
 Ragia
 
 ​Best regards,​
 
 -- 
 Jue Lin-Ye
 
 ---
 Civil Engineering phD candidate
 Maritime Engineering Laboratory (LIM)
 Universitat Politècnica de Catalunya (UPC)
 C/Jordi Girona 1-3, Barcelona 08034 (Spain)
 -
 
   [[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] Slight misinformation in OSX version of R

2013-09-25 Thread Erich Neuwirth
I just installed R on a Mac without any traces of earlier versions.
It exhibited a well know problem:

WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will 
work.
Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system 
preferences accordingly.

The information needed is in section 7, not in section 9.

__
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] transform variables

2013-08-26 Thread Erich Neuwirth
Have a look at the packages reshape and reshape2
They were written with this type of problems in mind.

On Aug 26, 2013, at 1:04 PM, catalin roibu catalinro...@gmail.com wrote:

 Dear all!
 
 I have a data frame composed by 13 columns (year, and 12 months). I want to
 transform this data base in another like this
 year month values
 1901 1
 1901 2
 1901 3
 .
 1901 12
 1902  1
 1902  2
 
 1902  12
 
 Is there a possibility to succeed that in R?
 
 Thank you!
 
 best regards!
 CR
 
 -- 
 ---
 Catalin-Constantin ROIBU
 Lecturer PhD, Forestry engineer
 Forestry Faculty of Suceava
 Str. Universitatii no. 13, Suceava, 720229, Romania
 office phone +4 0230 52 29 78, ext. 531
 mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
 FAX:+4 0230 52 16 64
 silvic.usv.ro
 
   [[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] Rexcel

2013-08-22 Thread Erich Neuwirth
Free support for RExcel is available by subscribing to the mailing list at
rcom.univie.ac.at
and posting questions to the list.

On Aug 22, 2013, at 7:04 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:

 This is not on topic for this mailing list. See the Statconn website for 
 support for RExcel.

__
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] problems with constrained optimization

2013-08-19 Thread Erich Neuwirth
Bad starting value.
Try 
c(3/5,4/5)

On Aug 19, 2013, at 1:33 PM, il...@gertner.health.gov.il wrote:

 I tried ti run a simple example with function solnp() from Rsolnp: find
 max(x+y) on a unit circle x*x+y*y=1. The answer should be x=y=1/sqrt(2)
 with max=sqrt(2).
 
 Here are my code and results
 
 
 
 # test Rsolnp
 
 library(Rsolnp)
 
 fn1 - function(x)
 
 + {
 
 +   x[1] + x[2]
 
 + }
 
 cond - function(x)
 
 + {
 
 +  z- x[1]*x[1] + x[2]*x[2]
 
 + }
 
 x0 - c(0,1)
 
 cval - c(1)
 
 optim -solnp(x0,fun=fn1,eqfun=cond,eqB=cval)
 
 
 
 Iter: 1 fn: 1.   Pars:  -3.053e-11  1.000e+00
 
 solnp-- Completed in 1 iterations
 
 optim
 
 $pars
 
 [1] -3.053113e-11  1.00e+00
 
 
 
 $convergence
 
 [1] 0
 
 
 
 $values
 
 [1] 1 1
 
 
 
 $lagrange
 
 [,1]
 
 [1,]  0.5
 
 
 
 $hessian
 
  [,1] [,2]
 
 [1,] 2e+100
 
 [2,] 0e+001
 
 
 
 $ineqx0
 
 NULL
 
 
 
 $nfuneval
 
 [1] 13
 
 
 
 $outer.iter
 
 [1] 1
 
 
 
 $elapsed
 
 Time difference of 0.00500083 secs
 
 
 
 
 
 #
 
 SOMETHING IS WRONG BUT I DO NOT SEE ANY MY MISTAKE. 
 
 
   [[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] RScript.exe and map directory issue

2012-06-01 Thread Erich Neuwirth
To put double quotes in a string in VBA one has to use double double quotes

str = a string with a quoted word



On Jun 1, 2012, at 12:26 AM, Duncan Murdoch wrote:

 On 12-05-31 4:40 PM, Bert Jacobs wrote:
 Hi,
 I'm trying to run on Windows 7 a scriptfile with Rscript.exe from within
 Excel 2010 with the following code:
 Call Shell(rPath  \Rscript.exe C:\Work\Latest\_Test.R, vbHide)
 
 The good news is: the above code works perfectly, but ...
 
 If I add white spaces to my map directory, like:
 Call Shell(rPath  \Rscript.exe C:\Work\Latest 1\_Test.R, vbHide)
 
 In the above case or the RScript.exe doesn't run the file anymore.
 Could someone explain to me how this comes and how I can deal with it?
 
 Probably you'll need to put the file path in quotes.  I suspect either single 
 or double quotes will work.
 
 I don't know how to put quotes in a quoted string in Excel, but I imagine 
 there's a way.
 
 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] Interactive Plot in R?

2012-05-19 Thread Erich Neuwirth
You might want to give the packages animation a try.
On May 19, 2012, at 11:47 AM, c...@mail.tu-berlin.de wrote:

 Hi,
 I want to do an interactive plot in R:
 I have a time series and I can plot it in the normal way:
 
 plot(modifieddate,timeseries,type=l,xlab=Date,ylab=values, main=title)
 
 (modifieddate is the values for the date on the x axis)
 
 The aim now is, that I want to do a Latex Presentation, where if it comes to 
 the slide where the plot is, the plot not just appears/shows up, but it is 
 drawn, that means, as if an human would draw it with a pencle. So I googled 
 and I thougth it would be the best if I generate png for every point and 
 match these to one gif an implement this. But the problem ist, I do not know, 
 how to do these png in r? Could you help me?
 1. Step I think is, to do a loop to draw every single point, but how can I do 
 this?
 This does not work:
 for (i in 1: length(timeseries){
 plot(modifieddate,timeseries[i],type=l,xlab=Date,ylab=values, 
 main=title,add=1)
 }
 
 2. save every single drawing as a png, how can I do this?
 
 Thanks a lot for your help!
 
 __
 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] R report generator (for Word)?

2012-01-02 Thread Erich Neuwirth
A little bit more information about SWord:
It is similar to SWeave in the sense that one writes text and R code in one 
document,
and the toolchain then replaces the R code by the results produced by running 
the R code.
In SWeave, this produces a new file which then can processed by TeX.
In SWord, the R output is integrated into the Word document, but the original R 
code is kept also.
Therefore, in SWord, if two people are cooperating, the R person can produce a 
report in Word
(using Sword) and send the document including the R results to the second 
person who does not 
need to have R.
The second person then can edit the text in the Word document and send it back 
to the first person
and changes to the R code (or the data) can be made in the Word file.
In the SWeave workflow, the results are only contained in the TeX file.
Any changes in the text made in the TeX file
then have to be backported to the SWeave source file (.Rnw).


http://rcom.univie.ac.at has more information on SWord.

__
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] Problem with RCOM package

2011-12-23 Thread Erich Neuwirth
All questions related to rcom, statconnDCOM, and RExcel
should be posted on the mailing list of the statconnDCOM project.
You can subscribe at
http://rcom.univie.ac.at


On 12/23/2011 11:02 AM, KUMAR wrote:
 Hi,
 
 I am using R version 2.14.0 on windows 7. Trying to use RCOM
 package and followed example provided at
 (http://cran.r-project.org/web/packages/rcom/rcom.pdf) .
 
  
 
 I am able to load the com object as seen in screenshot
 2.png.  however I am unable to invoke/get/set property to the object.
 
  
 
  
 
 Please guide me on the same,
 
  
 
 Regards;
 
 Kumar Anand
 
 
 
 
 __
 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] List of user installed packages

2011-11-05 Thread Erich Neuwirth
Running
rownames(installed.packages())
will tell you the names of all packages of the version of R in which you are 
running the command.
http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages
tells you the names of the packages which were installed with R itself.




On Nov 5, 2011, at 2:37 PM, Cem Girit wrote:

 Hello,
 
 
 
I am going to install the new version of R 2.14.1. After the
 installation, I want to copy my installed packages to the new library. But
 since over time I forgot which ones I installed I want to get a list of all
 the packages I installed among the packages installed initially by the
 R-installer. Is this possible? 
 
 
 
 Cem
 
 
 
 Cem Girit, PhD
 
 
 
 Biopticon Corporation
 
 182 Nassau Street, Suite 204
 
 Princeton, NJ 08542
 
 Tel: (609)-853-0231
 
 Email:gi...@biopticon.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.



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
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] Size of windows graphics device

2011-11-02 Thread Erich Neuwirth
R for Windows 2.14.0

Is there a function reporting the size of the current windows device
after it has been resized manually?

__
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] extracting p-values in scientific notation

2011-10-03 Thread Erich Neuwirth
format.pval is documented and accessible from outside of base.
So you do not have to qualify it as base::format.pval

On 10/3/2011 11:24 AM, Liviu Andronic wrote:
 Thanks all for your pointers. The following does trick:
 base::format.pval(x$p.value)  ##Hmisc also has such a function
 [1] 2e-16
 
 
 On Mon, Oct 3, 2011 at 10:25 AM, Rolf Turner rolf.tur...@xtra.co.nz wrote:
 Isn't it true that 0  2.2e-16?

 
 Yes, but it doesn't mean that the p-value actually hits absolute zero.
 And cor.test, as Ted noticed, returns
 identical(x$p.value, 0)
 [1] TRUE
 
 Not that this makes a great practical difference in my case, but I
 would still prefer to print 2e-16 in my Sweave document.
 
 Regards
 Liviu
 
 __
 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] Namespace in packages

2011-09-01 Thread Erich Neuwirth

On 9/1/2011 1:04 PM, Eran Eidinger wrote:


 Hello,

 I wonder how I might create a package that only reveals some of the
 function
 in the package to the user.

 I've tried creating an R package using the following:
 f- function(x,y) x+y
 g- function(x,y) x-y
 h- function(x,y) f(x,y)*g(x,y)

 package.skeleton(list=c(f,**g,h), name=mypkg)

 ^ what is the meaning of ** here?
 such an object seems not to be
defined.

__
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] Build a package - check error

2011-08-21 Thread Erich Neuwirth
On 8/20/2011 3:37 PM, Uwe Ligges wrote:
 ?.First.lib has an example:
 
 ## Suppose a package needs to call a DLL named 'fooEXT',
 ## where 'EXT' is the system-specific extension.  Then you should use
 .First.lib - function(lib, pkg)
   library.dynam(foo, pkg, lib)
 

Shouldn't the first line here be

 ## Suppose a package needs to call a DLL named 'foo.EXT',
 ^

__
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] Elegant way to subtract matrix from array

2011-07-27 Thread Erich Neuwirth
A-kronecker(rep(1,10),S)

kronecker(m1,m2) creates a tiled matrix
each element of m1 in replaced by m2 multiplied with the element of m1

m1 = (1 2)
 (3 4)

m2 = (11 12)
 (13 14)

kronecker(m1,m2) therefore is


   1 * (11 12)2 * (11 12)
   (13 14)(13 14)

   3 * (11 12)3 * (11 12)
   (13 14)(13 14)


   11   13   22   26
   12   14   24   28
   33   39   44   52
   36   42   48   56

If m1 has 1 everywhere, the tiles are all identical.



On 7/27/2011 11:31 AM, steven mosher wrote:
 Cool,
 
  I looked at sweep but didnt consider it as I thought it was restricted to
 certain functions.
 So thanks for that solution.
 
   yes the data is very large and the future work will increase 10 fold,
 
 as for the matrix one I'm not too keen on replicating the smaller matrix,
 I've had one guy using the package who has hit the memory limits.. I have
 one more thing to try
 
 Thanks!
 
 Steve
 
 On Wed, Jul 27, 2011 at 1:42 AM, Gavin Simpson gavin.simp...@ucl.ac.ukwrote:
 
 On Wed, 2011-07-27 at 01:06 -0700, steven mosher wrote:
 there are really two related problems here

 I have a 2D matrix


 A - matrix(1:100,nrow=20,ncol =5)


 S - matrix(1:10,nrow=2,ncol =5)


 #I want to subtract S from A. so that S would be subtracted from the
 first 2 rows of

 #A, then the next two rows and so on.

 For this one, I have used the following trick to replication a matrix

do.call(rbind, rep(list(mat), N)

 where we convert the matrix, `mat`, to a list and repeat that list `N`
 times, and arrange for the resulting list to be rbind-ed. For your
 example matrices, the following does what you want:

A - do.call(rbind, rep(list(S), nrow(A)/nrow(S)))

 Whether this is useful will depend on the dimension of A and S - from
 your posts on R-Bloggers, I can well imagine you are dealing with large
 matrices.

 #I have a the same problem with a 3D array

 # where I want to subtract Q for every layer (1-10) in Z

 # I thought I solved this one with  array(mapply(-,Z,Q),dim=dim(Z))

 # but got the wrong answers


 Z - array(1:100,dim=c(2,5,10))

 Q - matrix(1:10,nrow=2,ncol =5)

 For this one, consider the often overlooked function `sweep()`:

sweep(Z, c(1,2), Q, -)

 does what you wanted. c(1,2) is the `MARGIN` argument over the
 dimensions that Q will be swept from.

 HTH

 G

 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Dr. Gavin Simpson [t] +44 (0)20 7679 0522
  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


 
   [[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] [RExcel] please help me to set up RExcel via a remote server

2011-06-20 Thread Erich Neuwirth
statconnDCOM and RExcel have their own mailing list.
Please subscribe at rcom.univie.ac.at and post you question there.

On Jun 17, 2011, at 7:55 AM, Takatsugu Kobayashi wrote:

 Hi RUsers,
 
 I am currently tying to use RExcel via R installed in my remote server
 (CentOS 5.5).
 Could you please help me set up a R remote server?
 
 All I know about the server is its IPAddress.
 Apologies for my fundamental question.
 
 Thank you so much!
 
 
 Taka
 
 __
 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] computer name

2011-06-13 Thread Erich Neuwirth
This depends on your OS.

on Windows,
Sys.getenv('computername')
should work.

Sys.info()['nodename']
should work on all systems.



On 6/13/2011 7:38 AM, David Scott wrote:
  On 13/06/11 15:19, pdb wrote:
 Is there an r function that will be able to identify the computer the
 code is
 running on?

 I have some common code that I run on several computers and each has a
 database with a different server name - although the content is
 identical.

 I need to set thisServer depending on which machine the code is running
 on...

 something like...

 if(pcname = pc1) thisServer = 'SERVER1'
 if(pcname = pc2) thisServer = 'SERVER2'


 conn- odbcDriverConnect(driver=SQL
 Server;database=x;server=thisServer;)

 ...rest of code will now run OK.

 I know I could set the DSN names the same and use...

 conn- odbcConnect(commonDSNname)

   but I was wondering if there was another way


 -- 
 View this message in context:
 http://r.789695.n4.nabble.com/computer-name-tp3593120p3593120.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.
 Does
 
 Sys.info()[nodename]
 
 give you what you want?
 
 David Scott


__
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] summing array elements

2011-05-26 Thread Erich Neuwirth
 arr-1:72
 dim(arr)-c(2,4,3,3)
 apply(arr,1:2,sum)
 [,1] [,2] [,3] [,4]
[1,]  297  315  333  351
[2,]  306  324  342  360
 apply(arr,3:4,sum)
 [,1] [,2] [,3]
[1,]   36  228  420
[2,]  100  292  484
[3,]  164  356  548


apply(arr,1:2,sum)
will sum all elements arr(i1,i2,..)
for each single combination of the first and the second index
over all possible combinations of the third and fourth index.




On 5/27/2011 12:06 AM, marco milella wrote:
 Hi to everybody
 I have an array with dimensions 2,4,3,3.
 Wanting to sum the matrices in the first two dimensions, I'm trying to use
 the apply function, but with no results. Have to say I'm quite new with R
 syntax.
 tx in advance
 
 marco
 
   [[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] Writing Macros for RExcel

2011-04-27 Thread Erich Neuwirth
RExcel has its own mailing list (the included documentation says so!)
Please subscribe at rcom.univie.ac.at and post your question on that list.



On 4/27/2011 8:00 PM, wwreith wrote:
 I have columns of data in Excel 2007, A2:A196, B2:B196...ET2:ET196 that I
 would like to place into arrays in R. I have been trying to write a macro
 that would automatically create all of my arrays for me with a array names
 coming from the cells A1, B1, etc.
 
 I can manually create an array using RExcelPut R Var Array, but I don't
 want to manually create all 150 arrays this way. 
 
 Thanks for the help.
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Writing-Macros-for-RExcel-tp3478981p3478981.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.


__
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] Hook into Coercion Framework for data.frame

2011-04-26 Thread Erich Neuwirth
statconnDCOM, availagble from rcom.univie.ac.at
is a (D)COM server accessing R.
rcom (available from CRAN) is an R package
which can turn R into a COM server or into a COM client.

These tools have their own mailing list which can
be subscribed at rcom.univie.ac.at.




On 4/26/2011 6:20 PM, Von Der Hirschheydt, Juergen wrote:
 Hi,
 
 I am looking into a way to hook into the R coercion framework to allow
 me to convert table-like data stored within a COM object into a
 data.frame.
 
 Some of our COM objects have their own table-like data storage, and from
 R's point of view it's an object (EXTPTRSXP) decoarated with a sepcial
 symbol so we can easily identify it.
 
   COM_Table - a_method_that_creates_the_object()
   class(COM_TABLE)
QS.IpdgRelation
 
 In addition, we have a method that transforms this object into a
 data.frame:
 
   relation.to.data.frame - function(obj) { ... }
 
 A user can easily transform the above object into a data.frame by
 calling:
 
   myDataFrame - relation.to.data.frame(COM_Table)
 
 That all works nice and well, but we'd like to take it a step further
 and be able to call
 
   data.frame(COM_Table)   and/or
   as.data.frame(COM_Table)
 
 To achieve the same coercion. I've tried to hook into the coercion by
 using setAs :
 
   setOldClass ( QS.IpdgRelation )
   setAs ( QS.IpdgRelation, data.frame, function(from)
 relation.to.data.frame(from) )
 
 Which allows me to do
 
   as ( COM_Table, data.frame )
 
 But I can't seem to get the last step to hook this coercion into the
 data.frame() or as.data.frame() call. Is there a way to achieve this, or
 am I chasing a red hering here ?
 
 Any help appreciated,
 Thanks a lot,
 
 Juergen
 
 ===
  
 Please access the attached hyperlink for an important el...{{dropped:4}}
 
 __
 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] Fibonacci

2011-04-20 Thread Erich Neuwirth
The easy solution to compute the Fibonacci numbers is
 
fibo - function(n,a=1,b=1){
 if (n == 1) return(a)
 if (n == 2) return(b)
 return(fibo(n-1,b,a+b)) 
}

It avoids double recursion.
It is, however, not as resource efficient as a loop since R does not do
tail recursion elimination.




On Apr 20, 2011, at 11:42 AM, Georgina Imberger wrote:

 Hi!
 
 I am trying to work out the code to get a Fibonacci sequence, using the
 while() loop and only one variable. And I can't figure it out.
 
 Fibonacci-c(1,1)
 while (max(Fibonacci)500){
 Fibonacci-c(Fibonacci, (max(Fibonacci) + ?(Fibanacci)))
 }
 
 
 How can I tell R to take the value one before the max value? (Without
 defining another variable)
 
 (Probably super easy... I am a beginner...)
 
 Thanks,
 Georgie
 
   [[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] RExcel

2011-04-12 Thread Erich Neuwirth
rcom has its own mailing list.
Please subscribe at rcom.univie.ac.at
and post all questions there.

On 4/12/2011 1:04 AM, array chip wrote:
 Yes, I did, and no error message. And comRegisterRegistry() returns NULL, not 
 sure if that matters
 
 John
 
 
 
 
 
 
 From: Jonathan P Daily jda...@usgs.gov
 
 Cc: r-help r-help@r-project.org; r-help-boun...@r-project.org
 Sent: Mon, April 11, 2011 11:39:12 AM
 Subject: Re: [R] RExcel
 
 It is asking the obvious, but did you run the commands from the rcom 
 package after installation (see inline ***s)?
 --
 Jonathan P. Daily
 Technician - USGS Leetown Science Center
 11649 Leetown Road
 Kearneysville WV, 25430
 (304) 724-4480
 Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it.
  - Jubal Early, Firefly
 
 r-help-boun...@r-project.org wrote on 04/11/2011 02:08:02 PM:
 
 [image removed] 

 [R] RExcel

 array chip 

 to:

 r-help

 04/11/2011 02:12 PM

 Sent by:

 r-help-boun...@r-project.org

 Hi, I am installing Excel using package RExcelInstaller. When I 
 tried to run 

 installRExcel()

 I got this error message:

 You don not have the R package rcom installed.
 The (D)COM server installed which will aloow you to use the 
 background server in 
 RExcel.
 Since rcom is not installed, foreground mode will be unavailable.

 You may continue with the installation, but in most circumstances 
 you probably 
 should cancel current installation, install the package rcom properly 
 (do not 
 forget to run the commands
 
   library(rcom)
   comRegisterRegistry()
 
 immediately after installation)
 and after that run this installer once again


 But rcom package was installed without any problem, somehow the 
 installer keeps 
 saying that rcom is not installed.

 Any suggestions?

 Thanks

 John

 sessionInfo()
 R version 2.12.2 (2011-02-25)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=English_United States.1252 
 [2] LC_CTYPE=English_United States.1252 
 [3] LC_MONETARY=English_United States.1252
 [4] LC_NUMERIC=C 
 [5] LC_TIME=English_United States.1252 

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base 

 other attached packages:
 [1] RExcelInstaller_3.1-13 rcom_2.2-3.1   rscproxy_1.3-1 

 loaded via a namespace (and not attached):
 [1] tools_2.12.2
[[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.
   [[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] fonts in mosaic

2011-04-02 Thread Erich Neuwirth
The problem of changing the default font used fpr the windows graphics
device seems to be quite complicated.
As I wrote already

windowsFonts(myfont=Consolas)
par(family=myfont)

will make the windows graphics device use Consolas as the
defaut font for labels.

Therefore, a function call like
plot(1:10,main=Title)
will use Consolas for labeling.
It will, however, not change the default for

mosaic(UCBAdmissions)

The mosaic plot will still use the original default font
for the device, which in a standard configuration
seems to be Arial.

par(family=NULL)
will reset the current default font to the original default font,
so after this command
plot(1:10,main=Title)
will use Arial again.

The the font family used in graphics from package grid is set by
explicitly using gpar paramenter in calls to functions from that package.
gpar has default values, but there seems to be no way
of changing the default values of the gpar object.

Does anybody on the list know if there is a way of changing the default
values of gpar objects?

__
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] fonts in mosaic

2011-03-31 Thread Erich Neuwirth
The easiest way of changing the font used for labels by the windows
graphics device (opened by a call to windows()) seems to be the following:

Let us assume we want to use the font Consolas for all labels:

windowsFonts(myfont=Consolas)
par(family=myfont)

If one later on wants to change the default font for graphics,
one has to run both commands again. Just issueing a new windowsFonts
command will not change the font used by the graphics device.

__
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] fonts in mosaic

2011-03-30 Thread Erich Neuwirth
I need to change the font(s) used in mosaic from package vcd.
The help file and the vignette do not give very explicit examples for
doing that.
The easiest solution would be changing the font for everything
on the graph: var labels, var names, title, subtitle, and cell labels.
What is the easiest way of accomplishing this?

__
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] fonts in mosaic

2011-03-30 Thread Erich Neuwirth
Achim
I simply want to replace the font R uses on mosaic (whatever it is)
by a font of my choice (say Calibri or Arial)
because I need to embed the R charts in a PowerPoint
presentation and want the fonts to match.
And I want the most simple way of accomplishing this.
I worked my way through the strucplot vignette,
but I could not extract enough information there.
Is there some information about the proper font names
to use in R?


 Personally, I simply change the size of the device I'm plotting on. When
 I plot on a large device, the fonts will be relatively smaller, and vice
  versa. This is what I do when including graphics in PDF files (papers,
  slides, reports, etc.).
 
  For fine control, you can set the arguments of the labeling function
  employed. ?strucplot shows that the default is ?labeling_border which
  has several arguments. For example you can set the graphical parameters
  of the labels (gp_labels) or the graphical parameters of the variable
  names (gp_varnames). Both arguments take ?gpar lists (grid graphical
  parameters). For example you may do
 

__
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] fonts in mosaic

2011-03-30 Thread Erich Neuwirth
Here is a more complete solution to my problem.
The fact that the parameters are called gp_varnames,
gp_labels, and gp_text on one hand, but main_gp and
and sub_gp on the other hand comes as a surprise
when one tries to find a solution.

windowsFonts(calibri = windowsFont(Calibri))

mosaic(UCBAdmissions, labeling_args = list(
  gp_labels = gpar(fontsize = 12, fontfamily = calibri),
  gp_varnames = gpar(fontsize = 16, fontfamily = calibri)),
  main = Main title, main_gp = gpar(fontfamily = calibri),
  sub = Subtitle, sub_gp = gpar(fontfamily = calibri),
  pop=FALSE)
labeling_cells(text = UCBAdmissions, clip = TRUE,
  gp_text = gpar(fontfamily = calibri))(UCBAdmissions)


On 3/30/2011 8:42 PM, Henrique Dallazuanna wrote:
 Try this:
 
 windowsFonts(calibri = windowsFont(Calibri))
 
 mosaic(UCBAdmissions, labeling_args = list(
   gp_labels = gpar(fontsize = 12, fontfamily = calibri),
   gp_varnames = gpar(fontsize = 16, fontfamily = calibri)
 ))


__
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] ks and contour plot labels

2011-03-22 Thread Erich Neuwirth
Is there an easy way to control the font size for the contour lines
in plots of kde objects in package ks?
The label size seems not obey the cex parameter (which probably
would be the R way of doing it).

__
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] One to One Matching multiple vectors

2011-03-16 Thread Erich Neuwirth
y[which(x %in% z)]

On 3/16/2011 10:42 AM, Vincy Pyne wrote:
 Dear R helpers
 
 Suppose,
 
 x = c(0,  1,  2,  3)
 
 y = c(A, B, C, D)
 
 z = c(1, 3)
 
 For given values of z, I need to the values of y. So I should get B and 
 D. 
 
 I tried doing 
 
 y[x][z] but it gives 
 
 y[x][z]
 [1] A C
 
 Kindly guide.
 
 Regards
 
 Vincy
 
 
 
   [[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] Reg : Using R in Web

2011-03-13 Thread Erich Neuwirth
Assuming you are using a Windows based server have a look at
statconnWS at rcom.univie.ac.at
Warning: statconnWS is NOT open source.
It is under development, and it also will work under Linux in the future.
The statconnDCOM server also might be an option for you.
It is available from the same web site.


On 3/13/2011 6:12 AM, Vikram wrote:
 Hi everyone .
 
 I would like to integrate R with Microsoft Silverlight . I would like to
 know whether we can connect R through any other software . If possible how ?
 Could anyone help me with this
 
 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] Difference in numeric Dates between Excel and R

2011-03-02 Thread Erich Neuwirth
A detailed description of the Excel problem as seen through the eyes of
MS can be found at

http://support.microsoft.com/kb/214326

On 3/2/2011 8:15 AM, Prof Brian Ripley wrote:
 
  ## Excel is said to use 1900-01-01 as day 1 (Windows default) or
  ## 1904-01-01 as day 0 (Mac default), but this is complicated by Excel
  ## thinking 1900 was a leap year.
  ## So for recent dates from Windows Excel
  as.Date(35981, origin=1899-12-30) # 1998-07-05
  ## and Mac Excel
  as.Date(34519, origin=1904-01-01) # 1998-07-05
 
 So the origin you used is off by 2 days: one for the origin being day 1
 and one for Windows Excel's ignorance of the calendar.
 
 Note too that these are *default*: they can be changed in Excel.
 
 Thank you
 Felipe Parra

 [[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.
 
 PLEASE do try to do your own homework (and not send HTML), as we
 requested there.  It is galling that you ask here about bugs in Excel,
 bugs that are even documented in R's help.  In future, please use the
 Microsoft help you paid for with Excel if it disagrees with R.


__
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] Generating uniformly distributed correlated data.

2011-02-22 Thread Erich Neuwirth
You do not need the regions with the double densities near the center
(1/2,1/2), you can use just the parallel 45 degree borders in that
region also.

 x-x
 |/*\\\|
 |---/***\\|
 |--/*\|
 |-/**/|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |/**/-|
 |\*/--|
 |\\***/---|
 |/|
 \-x



The problem with this range is that (for a = half width of the diagonal
stripe) you have r = 1-2*a+a^3 which does not have a nice inverse
function, therefore computing the data for given r is not
straightforward. Furthermore, creating the y's is harder because
the simple trick using %% for uniform random numbers does not allow
to create random numbers with 2 differerent nonzero densities in
two different intervals.




 There is the same number of stars in each horizontal row and each
 vertical column.
 
 I love it! I plotted the data that your method generated and got a plot
 with points in the regions you displayed. After pondering its curious
 pathology (three disjoint regions), I thought I could cure that
 pathology by flipping quadrants. I proceeded to do so but discovered
 that the pathology wasn't really cured but only concentrated at the ends
 and middle. Using your ASCII art, my version  wuld look like this where
 the \\\ regions are double dense.
 
 y[x0.5  y 0.5] = 0.5 +abs(0.5-y[x0.5  y 0.5])
 y[x0.5  y 0.5] = 0.5 -abs(0.5-y[x0.5  y 0.5])
 plot(x,y)
 
 x-x
 |/*\\\|
 |---/***\\|
 |--/*\|
 |-/**/|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |-|\\***/-|
 |-|\\\*/--|
 |-|---|
 |-*---|
 |/|
 |---/**\\\|
 |--/\\|
 |-/**\|
 |/**/-|
 |---/**/--|
 |--/**/---|
 |-/**/|
 |/**/-|
 |\*/--|
 |\\***/---|
 |/|
 \-x
 
 So it not only created a still slightly less pathological counterpart,
 but the correlation jumped from 0.5 to 0.95. It looks to be a promising
 basis for homework problems in probability courses, an experience I have
 never has the ?pleasure? to experience except during self-study to
 repair my (many) mathematical deficiencies.
 
 cor(x,y)
 [1] 0.9449256


__
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] Generating uniformly distributed correlated data.

2011-02-21 Thread Erich Neuwirth
hw-function(r){
(3-sqrt(1+8*r))/4
}


x-runif(1000)
y-(x+runif(1000,-hw(0.5),hw(0.5))) %% 1


x and y will have correlation 0.5 and will be uniformly distributed
on the unit interval.
Replacing 0.5 by any nonnegative number r between 0 and 1 will
create correlated uniformly distributed random numbers with correlation r.

plot(x,y) will show the construction of the joint distribution of these
random numbers.
The rest is simple algebra.






On 2/20/2011 3:17 AM, Søren Faurby wrote:
 I wish to generate a vector of uniformly distributed data with a defined
 correlation to another vector
 
 The only function I have been able to find doing something similar is
 corgen from the library ecodist.
 
 The following code generates data with the desired correlation to the
 vector x but the resulting vector y is normal and not uniform distributed
 
 library(ecodist)
 x - runif(10^5)
 y - corgen(x=x, r=.5)$y
 
 Do anyone know a similar function generating uniform distributed data or
 a way of transforming y to the desired distribution while keeping the
 correlation between x and y
 
 Kind regards, Soren
 
 __
 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] Generating uniformly distributed correlated data.

2011-02-21 Thread Erich Neuwirth
We want to generate a distribution on the unit square with the following
properties
* It is concentrated on a reasonable subset of the square,
  and the restricted distribution is uniform on this subset.
* Both marginal distributions are uniform on the unit interval.
* All horizontal and all vertical cross sections are sets of lines
  segments with the same total length

If we find a geometric figure with these properties, we have solved the
problem.

So we define the distribution to be uniform on the following area:
(it is distorted but should give the idea)

x***/-/***x
|**/-/|
|*/-/*|
|/-/**|
|-/**/|
|/**/-|
|---/**/--|
|--/**/---|
|-/**/|
|/**/-|
|---/**/--|
|--/**/---|
|-/**/|
|/**/-|
|---/**/--|
|--/**/---|
|-/**/|
|/**/-|
|---/**/--|
|--/**/---|
|-/**/|
|/**/-|
|**/-/|
|*/-/*|
|/-/**|
x***/-/***x

There is the same number of stars in each horizontal row and each
vertical column.


So we define
g(x1,x2)= 1 abs(x1-x2) = a or
abs(x1-x2+1) = a or
abs(x1-x2-1) = a
  0 elsewhere

The total area of the shape is 2*a.
The admissible range for a is 0,1/2
therefore
f(x1,x2)=g(x1,x2)/(2*a)
is a density functions.
This is where simple algebra comes in.
This distribution has
expected value 1/2 and variance 1/12 for both margins
(uniform distribution), and it has
covariance = (1-3*a+2*a2)/12
and correlation = 1 - 3*a + 2*a2

The inverse function of 1 - 3*2 + 2*a2 is
(3-sqrt(1+8*r))/4

Therefore we can compute that our distribution with
a=(3-sqrt(1+8*r))/4
will produce a given r.


Ho do we create random numbers from this distribution?
By using conditional densities.
x1 is sampled from the uniform distribution, and for a give x1
we produce x2 by a uniform distribution on the along the vertical cross
cut of the geometrical shape (which is either 1 or 2 intervals).
And which is most easily implemented by using the modulo operator %%.

This mechanism is NOT a convolution. Applying module after the addition
makes it a nonconvolution. Adding independent random variables
without doing anything further is a convolution, by applying a trimming
operation, the convolution property gets lost.

__
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] monitor variable change

2011-02-16 Thread Erich Neuwirth
You could use any of the gui toolkits (tcltk, gWidgets ...)
and create a watch window which displays the changing value of your
variable in a popup widged.

On 2/16/2011 10:54 AM, Rainer M Krug wrote:
 On 02/16/2011 10:38 AM, Alaios wrote:
 Dear all I would like to ask you if there is a way in R to monitor in R when 
 a value changes. 
 
 Right now I use the sprintf('my variables is %d \n, j) to print the value of 
 the variable. 
 
 Is it possible when a 'big' for loop executes to open in a new window to 
 dynamically check only the variable I want to.
 
 I don't think that this functionality is implemented.
 
 But I guess you can implement it - would it be possible to re-define th
 - to check if a certain variable is to be changed, and then print it?
 
 Might be tricky and would slow everything considerably down.
 
 Just a thought,
 
 Rainer
 
 
 If I put all the sprintf statements inside my loop then I get flooded with 
 so many messages that makes it useless.  
 
 Best Regards
 Alex
 
 __
 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-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] Writing do and resample functions

2011-01-04 Thread Erich Neuwirth
It seems that the textbook workspace you are using as a method
definition for * for class repeater. Load the workspace and try
methods(`*`)
If you get something like '*.repeater' this suspicion is confirmed


On 1/4/2011 11:36 AM, Ben Ward wrote:
 Hi,
 
 I'm trying to take a function from a workspace download provided in a
 stats textbook book, so I have it in my workspace to use all the time.
 
 I opened the workspace and typed the names of the two functions to get
 the code that makes them up:
 -
 
 resample
 function(d, size, replace=TRUE,prob=NULL,within=NULL) {
   if (!is.null(within)) return( resample.within(d,
 within,replace=replace) )
   if (is.null(dim(d))) {
  # it's just a vector
  if (missing(size)) size=length(d)
 return( d[ sample(1:length(d),size, replace=replace, prob=prob)])
   }
   else {
  if (missing(size)) size = dim(d)[1];
  inds = sample(1:(dim(d))[1], size, replace=replace, prob=prob)
  if (is.data.frame(d) | is.matrix(d)) {
 return(d[inds,]);
  } else {
 return(d[inds]);
  }
   }
 }
 -
 
 do
 function(n=10){
   as.repeater(n)
 }
 -
 
 as.repeater
 function(n=5){
   foo = list(n=n)
   class(foo) = 'repeater'
   return(foo)
 }
 
 Then I made the functions in my workspace by choosing the name (same
 name), and then = and then copied and pasted the function, beginning
 with function( and ending with the final }'s.
 
 But when I try to do the following in my workspace afterwards:
 
 samps = do(500)* coef(lm(MIC.~1+Challenge+Cleaner+Replicate,
 data=resample(ecoli)))
 sd(samps)
 
 I get an error:
 Error in do(500) * coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,  :
 non-numeric argument to binary operator.
 
 But in the workspace that comes with that book, I get a decent output:
 
 sd(samps)
 (Intercept)   Challenge   CleanerGarlic  ReplicateFirst
 ReplicateFourth
   3.9455401   0.7178385   1.6830641   5.4564926  
 5.4320998
 ReplicateSecond  ReplicateThird
   5.3895562   5.5422622
 
 Is there anybody out there who know a lot more about programming
 functions in R than I do, that might know why this is giving me the
 error? I don't understand why one workspace would accept the model
 formula, when the other give me the non-numeric argument to binary
 vector, the only vector that's not numerical is Replicate, but I don't
 that's what the error is talking about.
 
 Thanks,
 Ben Ward.
 
 __
 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] [R-pkgs] ENmisc_1.0

2011-01-04 Thread Erich Neuwirth
ENmisc contains two utility function

mtapply is a hybrid of mapply and tapply. It evaluates summary function
for each cell of data defined by a fixed set of factor values.
The reason I wrote it was to be able to compute weighted means
(using wtd.mean from Hmisc) to groups of data defined by factors,
but it accepts any multivariate function as the function argument

wtd.boxplot does what the name makes you expect, it computes and draws
boxplots for weighted data. It behaves like boxplot, but accepts an
additional argument, weights.

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Trying to extract an algorithm from a function

2011-01-01 Thread Erich Neuwirth
vars:::predict.vec2var
vars:::predict.varest

On 12/29/2010 9:31 PM, CALEF ALEJANDRO RODRIGUEZ CUEVAS wrote:
 Hi, I'm using package vars and I'm trying to extract the algorithm that
 function predict contained in that package in order to understand how does
 it work.
 
 When I type function VAR then all its algorithm appears in R, however if I
 try to do the same with predict nothing happens...Is there any possible
 way to extract the algorithm?
 
 Thanks a lot.
 
 Regards
 
   [[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] RExcel doesn't get active dataset

2011-01-01 Thread Erich Neuwirth
Please subscribe to the rcom mailing list at
rcom.univie.ac.at
RExcel questions are handled on that list.

On 12/20/2010 9:24 PM, jryan.dani...@gmail.com wrote:
 Hey everyone
 
 When I try to 'get active dataframe' from the context menu in excel using 
 Rcmdr menus in excel, only the header and first row of data gets copied to 
 the excel spread sheet. No clue why this is happening. I followed the 
 instructions from 'R through Excel' pg 25-26. I'm using excel 2010, Rcmdr v 
 1.6-0 and R 2.11.1. 
 
 Much appreciate any help
 
 
 Sent via my BlackBerry from Vodacom - let your email find you!
 
 __
 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] editor for MacOS

2010-12-16 Thread Erich Neuwirth
TextMate from www.macromates.com is a very nice editor, similar in power
to Emacs, but much more Macish. It has its own subculture with many
macro packages. It is NOT free, but not very expensive either.

redcar available from http://redcareditor.com/
open source sibling of TextMate running on different platforms
(Java and Ruby based).







On 12/16/2010 4:41 PM, Troels Ring wrote:
 Dear friends - I'm using Tinn-R in Windows and find it OK. My son is
 running MacOS and is just starting using R and I know nothing about
 MacOS and R but we seem to have difficulties in finding something
 similar to Tinn for MaC. What are your suggestions?
 Thanks a lot!
 Troels Ring, MD
 Aalborg, Denmark
 
 __
 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] how to divide each column in a matrix by its colSums?

2010-11-28 Thread Erich Neuwirth
sweep(m,1,rowSums(m),/)
sweep(m,2,colSums(m),/)




On 11/28/2010 9:55 PM, casperyc wrote:
 
 In that case, there are values 1,
 which is clearly not what I wanted.
 
 Thanks.
 
 I think I should use prop.table
 


__
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] Rexcel

2010-11-22 Thread Erich Neuwirth
a) RExcel has its own mailing list (as the documentation tell you).
Please post RExcel related questions to the mailing list
accessible at rcom.univie.ac.at
b) For running code at startup, you have to create a worksheet (not a
workbook) named RCode in your workbook.


On 11/22/2010 7:15 PM, csrabak wrote:
 Em 22/11/2010 10:11, Luis Felipe Parra escreveu:
 Hello I am new to RExcel and I would like to run a source code form the
 excel worksheet. I would like to run the following code

 source(C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r)

 from the excel wroksheet. Does anybody know how to do this?

 Thank you

 Felipe,
 
 Look at the section Startup in the RExcel help. In a nutshell, if you
 want the code to run immediately at the loading of the spreadsheet,
 create a workbook called RCode and put your source there.
 
 Other options are available. See the docs.
 
 -- 
 Cesar Rabak
 
 __
 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] Integrating functions / vector arithmetic

2010-11-19 Thread Erich Neuwirth
Some remarks:
Why are you using assignments to indicate the return values of functions?
This is R idiom:
 f-function(u){
  f-0
  for (j in 1:4){
f-f+coeff[j]*(zeta(j)(u))
  }
  f
 }
 

If you only want the inner product of 2 vector, outer probably is an overkill.

g - function(u){
 sum(coeff * zeta(1:4)(u))
}

should be enough.

And plot(g) does not work because g is not vectorized.

plot(Vectorize(g))

will work

On Nov 16, 2010, at 1:18 AM, Eduardo de Oliveira Horta wrote:

 Hello,
 
 I was trying to build some functions which I would like to integrate over an
 interval using the function 'integrate' from the 'stats' package. As an
 example, please consider the function
 
 h(u)=sin(pi*u) + sqrt(2)*sin(pi*2*u) + sqrt(3)*sin(pi*3*u) + 2*sin(pi*4*u)
 
 Two alternative ways to 'build' this function are as in f and g below:
 
 coeff-sqrt(1:4)
 
 zeta-function(i) {force(i); function(u){
  zeta-sqrt(2)+sin(pi*i*u)
 }}
 
 f-function(u){
  f-0
  for (j in 1:4){
f-f+coeff[j]*(zeta(j)(u))
  }
  f-f
 }
 
 g-function(u){
  g-crossprod(coeff,zeta(1:4)(u))
 }
 
 Obviously, f and g are equivalent, but in the actual code I am writing, g is
 much faster. However, I can't seem to integrate (neither to plot) g. In
 fact, these are the error messages I get:
 
 print(f(.1))
 [1] 4.443642
 print(g(.1))
 [,1]
 [1,] 4.443642
 
 Everything ok until here... but...
 
 When using plot(), I get this:
 
 plot(f) #plots, as expected.
 plot(g)
 Error in crossprod(coeff,zeta(1:4)(u)) : arguments not compatible
 Besides that: Warning message:
 In pi * i * u :
  longer object length is not a multiple of shorter object length
 
 When using integrate(), I get this:
 
 integrate(f,0,1)
 1.004172 with absolute error  2.5e-13
 integrate(g,0,1)
 Error in crossprod(coeff,zeta(1:4)(u)) : arguments not compatible
 Besides that: Warning message:
 In pi * i * u :
  longer object length is not a multiple of shorter object length
 
 
 I have already tried some simple 'solutions', for example to set
 g-function(u){
  vec1-drop(coeff)
  vec2-drop(zeta(1:4)(u))
  g-drop(crossprod(coeff,zeta(1:4)(u)))
 }
 
 as well as using the %*% operation, but these won't solve my problem.
 
 Any suggestions would be welcome. Thanks in advance,
 
 Eduardo Horta
 
   [[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.
 

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Center for Computer Science Didactics and Learning Research 
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39902 Fax: +43-1-4277-39459

__
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] Rserve alternative?

2010-11-08 Thread Erich Neuwirth
You might want to look at statconnWS (available from rcom.univie.ac.at).
Warning: This project is not open source.


On 11/8/2010 12:40 PM, Ralf B wrote:
 The Rserve documentation at
 
 http://rosuda.org/Rserve/doc.shtml#start
 
 states that even when making multiple connections to the Rserve,
 Windows won't separate workspaces physically and share environments,
 which will obviously cause problems and should therefore not be used.
 Are there any alternatives for the windows platform?
 
 Ralf
 
 __
 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] How to eliminate this for loop ?

2010-11-08 Thread Erich Neuwirth
Reduce(function(x1,x2)b*x1-x2,c,init=1,accum=TRUE)

might be what you are looking for.
This is not fully tested, so you should test it before
you want to use it.

__
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 save this result in a vector

2010-11-01 Thread Erich Neuwirth
My guess is that what you want probably is best done by using ecdf.
You might want to look it up in the docs.

1-ecdf(test)(x)
Will give you the percentage of values in test larger than x.


On 11/1/2010 2:24 AM, Changbin Du wrote:
 Thanks Joshua! Yes, i is not going up sequentially  by 1, as i here is the
 raw number of reads for each DNA base. Thanks so much for the great help!
 
 
 On Sun, Oct 31, 2010 at 6:03 PM, Joshua Wiley jwiley.ps...@gmail.comwrote:
 
 On Sun, Oct 31, 2010 at 5:44 PM, Joshua Wiley jwiley.ps...@gmail.com
 wrote:
 snip
 #cover is a vector
 cover_per - function(cover) {
  ## create a vector to store the results of your for loop
  output - vector(numeric, length(min(cover):max(cover)))
  for (i in min(cover):max(cover)) {
## rather than print()ing the output, assign it to an object
output[i] - 100*sum(ifelse(cover = i, 1, 0))/length(cover)
  }
  ## have the return value from the function be
  ## the object 'output'
  return(output)
 }

 I did not catch that i was not necessarily starting at 1 going
 sequentially up, so that would have to be done manually (or use cumsum
 per David rather than the function you wrote).

 cover_per2 - function(cover) {
   output - vector(numeric, length(min(cover):max(cover)))
   j - 1
   for (i in min(cover):max(cover)) {
 output[j] - 100*sum(ifelse(cover = i, 1, 0))/length(cover)
j - j + 1
  }
  return(output)
 }

 Josh

 
 


__
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-Excel Macro mode

2010-10-27 Thread Erich Neuwirth
RExcel has its own mailing list, rcom-l.
Please subscribe on rcom.unvie.ac.at and post your question on that list.


On 10/27/2010 1:29 PM, Puijman, R. wrote:
 I'm using R-Excel's macro mode to make an R based Excel tool for inventory 
 management. It's quite a lot of R-code which I made in R at first and now I 
 am trying to transform it into excel. The R code is a simulation of a random 
 path x times, put into matrices and then doing some transformations on it.
 
 I pasted the R code on a seperate sheet in my Excel file, which by means of 
 VBA I read with RInterface.RunRCodeFromRange Range(...). Before this, I put 
 Excel data to the required R variables with the RInterface.PutArray 
 ...,Range(...). After the code is run, I want to get the variables from the 
 code, which I want to do with GetArray.
 
 The model seems to work fine for small numbers of x, but with more than 5000 
 simulations, I get a VBA Run-time error '6', Overflow. The code works in R 
 itself so I assume there is no problem in the code itself, but there is 
 something wrong in the way VBA reads the code.
 
 Can someone help me? According to VBA, the error means that I am trying make 
 an assignment that exceeds the limitations of the target of the assignment. I 
 don't understand why there is a tipping point in the number of simulations 
 for which it works and for which it doesnt?
 
 Thanks!
 
 Roy
 
 __
 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] Extracting elements from a nested list

2010-10-19 Thread Erich Neuwirth
mapply(function(x1,x2)x1[[x2]],all.predicted.values,max.growth,SIMPLIFY=FALSE)

gives a list of factors.


On 10/18/2010 8:40 PM, Gregory Ryslik wrote:
 Hi Everyone,
 
 This is closer to what I need but this returns me a matrix where each
 element is a factor. Instead I would want a list of lists. The first
 entry of the list should equal the first column of the matrix that
 mapply makes, the second entry to the second column etc...
 
 I've attached the two files that have all.predicted.values and
 max.growth from dput to make for easy testing. Thanks again!
 
 
 
 
 Kind regards,
 Greg
 
 On Oct 18, 2010, at 1:33 PM, Erich Neuwirth wrote:
 
 You probably need mapply since you have 2 list of arguments which you
 want to use in sync

 mapply(function(x1,x2)x1[[x2]],all.predicted.values,max.growth)

 might be what you want.



 On Oct 18, 2010, at 5:17 PM, Gregory Ryslik wrote:

 Unfortunately, that gives me null everywhere. Here's the data I have
 for all.predicted.values and max.growth. Perhaps this will help. Thus
 I want all.predicted.values[[1]][[4]] then
 all.predicted.values[[2]][3]] and then all.predicted.values[[3]][[4]].

 I've attached what your statement outputs at the end.

 Thanks again!

 Browse[2] max.growth
 [[1]]
 [1] 4

 [[2]]
 [1] 3

 [[3]]
 [1] 4

 Browse[2] all.predicted.values
 [[1]]
 [[1]][[1]]
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [55] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 Levels: 0 1 2

 [[1]][[2]]
  [1] 2 2 2 0 2 0 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 0 0 2 2 2 2 0
 0 0 2 2 0 0 2 2 0 2 2 2 2 2 0 2 2 2 0 2 2 0
 [55] 0 0 2 0 2 0 0 0 0 2 2 2 2 0 2 2 2 0 2 2 0 0 2 2 2 2 2 2 2 0 0 0
 2 0 2 2 2 2 0 2 2 2 0 2 0 0
 Levels: 0 1 2

 [[1]][[3]]
  [1] 0 0 0 0 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 2 0 2 2 2 0 0 0 2 0 0 2 0
 0 0 0 0 0 0 2 0 0 0 0 0 2 2 0 0 0 2 0 0 0 0
 [55] 0 0 2 0 2 0 0 0 0 2 2 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 2 2 0 0 0 0 0 0 2 0 0
 Levels: 0 1 2

 [[1]][[4]]
  [1] 0 0 0 0 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 2 0 2 2 2 0 0 0 2 0 0 2 0
 0 0 0 0 0 0 2 0 0 0 0 0 2 2 0 0 0 2 0 0 0 0
 [55] 0 0 2 0 2 0 0 0 0 2 2 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 2 2 0 0 0 0 0 0 2 0 0
 Levels: 0 1 2


 [[2]]
 [[2]][[1]]
  [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 [55] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 Levels: 0 1 2

 [[2]][[2]]
  [1] 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2
 2 2 1 2 2 2 1 2 2 1 1 2 2 2 2 2 2 2 2 1 2 2
 [55] 2 2 2 2 1 2 2 2 2 1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1 2 2 2 1 1 2 2
 1 2 2 1 1 2 1 1 1 2 2 1 2 2
 Levels: 0 1 2

 [[2]][[3]]
  [1] 2 2 2 0 1 2 2 2 2 2 1 2 2 2 0 1 2 1 2 2 2 2 2 2 2 0 0 2 1 2 2 2
 0 0 1 2 0 0 1 2 0 1 1 2 2 2 0 2 2 2 0 1 2 2
 [55] 0 2 2 2 1 0 0 0 0 1 2 2 1 1 1 2 2 0 1 2 1 0 1 2 1 2 2 2 1 1 2 2
 1 2 2 1 1 2 1 1 1 2 2 1 0 2
 Levels: 0 1 2


 [[3]]
 [[3]][[1]]
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 [55] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 Levels: 0 1 2

 [[3]][[2]]
  [1] 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 2 2 2 2 2
 0 0 2 2 2 0 2 2 0 2 2 2 2 2 0 2 2 2 0 2 2 2
 [55] 0 2 2 2 2 2 0 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 Levels: 0 1 2

 [[3]][[3]]
  [1] 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0
 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0
 [55] 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0
 1 0 0 1 1 0 1 1 1 0 0 1 1 0
 Levels: 0 1 2

 [[3]][[4]]
  [1] 2 2 2 0 1 0 2 2 0 2 1 2 2 0 0 1 1 1 1 0 2 0 0 0 2 0 0 0 1 2 0 0
 0 0 1 2 0 0 1 2 0 1 1 2 0 0 0 2 2 0 0 1 2 0
 [55] 0 0 0 0 1 0 0 0 0 1 0 2 1 1 1 2 0 0 1 2 1 1 1 2 1 2 2 2 1 1 0 0
 1 0 2 1 1 2 1 1 1 2 0 1 1 0
 Levels: 0 1 2


 Browse[2]
 predicted.values.for.max.growth-diag(sapply(all.predicted.values,'[[','max.growth'))
 Browse[2] predicted.values.for.max.growth
 [[1]]
 NULL

 [[2]]
 [1] 0

 [[3]]
 [1] 0

 [[4]]
 [1] 0

 [[5]]
 NULL

 [[6]]
 [1] 0

 [[7]]
 [1] 0

 [[8]]
 [1] 0

 [[9]]
 NULL



 On Oct 18, 2010, at 11:08 AM, Henrique Dallazuanna wrote:

 Try this:

 diag(sapply(all.predicted.values, '[[', 'max.growth'))


 On Mon, Oct 18, 2010 at 12:59 PM, Gregory Ryslik rsa...@comcast.net
 mailto:rsa...@comcast.net wrote:
 Hi,

 I have a list of n items and the ith element has m_i elements within it.

 I want to do something like:

 predicted.values- lapply(all.predicted.values,'[[',max.growth[[i]])

 Where max.growth[[i]] is the element I want to extract from each of
 the ith predicted elements. Thus, for example, I want to extract the
 max.growth[[1]] element from  all.predicted.values[[1]] (which is
 itself a list). Then I want to extract max.growth[[2]] element from
 all.predicted.values[[2

Re: [R] Implementing R's recycling rule

2010-10-19 Thread Erich Neuwirth


On 10/19/2010 11:47 AM, Rainer M Krug wrote:
 x[n %% length(x)] gives you the same answer as rep(x, length.out=n)[n],
 without having to create the longer vector.



n %% length(x) may return 0 and in that case,
x[n %% length(x)] will not give the result you expect.

x[((n - 1)  %% length(x)) + 1]
might be what you want.

__
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] Extracting elements from a nested list

2010-10-18 Thread Erich Neuwirth
]]
 
 __
 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.

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] file.info returning NA

2010-10-07 Thread Erich Neuwirth
Windows 7, R-2.11.1 and R-2.12.0beta

When I do

file.info(list.files(getwd()))

I get what I expect, a dataframe with a lot of variables,
especially isdir, which tells me if the named object
is a file or a directory.

In the result of

file.info(list.files(paste(R.home(),library,sep=/)))

all variables have only NA values, even when I start R
in elevated mode.

__
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] rcom and safearray type of data

2010-09-22 Thread Erich Neuwirth
rcom has its own mailing list.
Please subscribe to this list at
rcom.univie.ac.at
and post your question there.

On 9/21/2010 2:53 PM, Alex Bird wrote:
 
 Hello there,
 
   I started to use rcom package and there were no problems until I tried to
 call some external function (method) which returns safearray type of data
 where either me or rcom or something else fails. Specifically I connected to
 a database and called a method doing something like this


__
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] Help!

2010-09-20 Thread Erich Neuwirth
If you assume that the variance is the same in all your subsets,
you can do an lm analysis with your subset classification as a factor.
You could also analyze the interaction between factors
and between factors and your numeric independent variable.
You also should consider repeated measurement methods since
you are taking 2 cores from the same individuals.

On 9/20/2010 11:46 PM, Oyomoare Osazuwa-Peters wrote:
 Please I need some help using R to 
 analyze my data. What I
 would like to do is to repeat the same basic process (e.g. linear regression
 between wood density and distance from pith) for at least 240 data 
 subsets
 within the main data-frame. Within the main data-frame, these data subsets 
 will be defined by three 
 variables
 namely, Â species, individual and core (i.e. 20 species, at least 6 
 individuals
 of each species, and 2 cores from each individual). Â Whereas I can write
 the code to carry out this process for each subset, I am unable to 
 successfully
 instruct R to automatically carry out the process for each of these 
 subsets (perhaps using loops). So to illustrate what I have done so far 
 with the codes
 below I was able to run a regression
  analysis for core ‘a’ of individual 1 in
 the species “Apeime�. But rather than do this 240 times, I would like to
  tell R
 to repeat the process automatically using loops or any method that 
 works.  
 
  Â  
 
 Code: 
 
  Â  
 
 RG2-BCI[BCI$Species == APEIME 
 
 BCI$Individual == 1  BCI$Core == a, ] 
 
 plot(x=RG2$DP..cm., 
 y=RG2$WD..g.cm3,
 xlab=Distance from pith cm, main=APEIME1a,
 ylab=Wood density g/cm3) 
 

 RG2lm-lm(RG2$WD..g.cm3~RG2$DP..cm.) 
 
 summary(RG2lm) 
 
  Â  
 
 Thanks 
 
  Â  
 
 Oyomoare
 
 
 
 
   
   [[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] easiest way to write an R dataframe to excel?

2010-08-23 Thread Erich Neuwirth
Search for an older message with the subject line

[R] export tables to excel files on multiple sheets with titles for each
table


On 8/23/2010 11:41 PM, Erik Iverson wrote:
 In addition to the Wiki already mentioned, the following may be
 useful:
 
 http://learnr.wordpress.com/2009/10/06/export-data-frames-to-multi-worksheet-excel-file/
 
 
 Eva Nordstrom wrote:

__
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] RExcel: Sctools not available

2010-08-09 Thread Erich Neuwirth
Please post any qeustions regarding RExcel to the rcom-l mailing list.
You can subscribe at rcom.univie.ac.at

On Aug 9, 2010, at 1:42 PM, Andreas Scherer wrote:

  I have a problem with RExcel which I have now installed on top of R 2.11.0. 
 The problem had been posted in 2009 on the forum by someone else, but no 
 (useful) response had been uploaded. 
 The issue is that 
 whenever I am trying to start R from excel, or by clicking the[ 
 RExcel2007 with 
 RCommander] icon., I get the following messages boxes : 
 SCTools not available  
 then: 
 there seems to be no R process connected 
 to excel 
 though both r and excel starts after I click the Icon!! 
 
 Could you please help me with this issue? 
 Thank you very much. 
 
 
 
 
   [[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.

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] reading dates in Excel into R

2010-08-02 Thread Erich Neuwirth
RExcel (available as an Excel Addin in Windows only) tries very hard
to transfer dates and times faithfully to R.
The package RExcelInstaller on CRAN will install it.


On Jul 29, 2010, at 7:32 PM, Hongying Li wrote:

 
 I am reading dates in Excel2007 into R.
 
 Here are the functions I used:
 
 library(RODBC)
 channel-odbcConnectExcel2007(myfile.xlsx)
 tmp-sqlFetch(channel,1,as.is=T)
 
 
 The dates in myfile.xlsx are all in this format: mm/dd/. But when I read 
 it to R, some columns look like -mm-dd 00:00:00, some columns look like 
 -mm-dd, and some columns are numbers. I do not know how I can control 
 this.
 
 
 
 Any help? Thanks!
 
 
 
 _
 Hotmail is redefining busy with tools for the New Busy. Get more from your 
 inbox.
 
 N:WL:en-US:WM_HMP:042010_2
   [[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.
 

--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Center for Computer Science Didactics and Learning Research 
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39902 Fax: +43-1-4277-39459

__
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] re. Mathematica and R

2010-07-18 Thread Erich Neuwirth
The wiki on rcom.univie.ac.at
in section
R(D)COM, rcom, and other software systems
has an example how to use R from within Mathematica on Windows.
You will need to install statconnDCOM and rcom
available from the same site.


On Jul 17, 2010, at 1:06 PM, Alan Kelly wrote:

 David - information on calling R from within Mathematica can be found at the
 following link:
 http://www.mofeel.net/1164-comp-soft-sys-math-mathematica/13022.aspx
 HTH,
 Alan Kelly
 
 __
 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.
 

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] re. Mathematica and R

2010-07-18 Thread Erich Neuwirth
The wiki on rcom.univie.ac.at
in section
R(D)COM, rcom, and other software systems
has an example how to use R from within Mathematica on Windows.
You will need to install statconnDCOM and rcom
available from the same site.
On Jul 17, 2010, at 1:06 PM, Alan Kelly wrote:

 David - information on calling R from within Mathematica can be found at the
 following link:
 http://www.mofeel.net/1164-comp-soft-sys-math-mathematica/13022.aspx
 HTH,
 Alan Kelly
 
 __
 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.
 

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] export tables to excel files on multiple sheets with titles for each table

2010-07-15 Thread Erich Neuwirth
If you are exporting your dataframes to Excel on Windows and
if you have Excel installed and 
if you are willing to make your hands dirty by programming VBA 
(the programming language built into Excel) and
if you are willing to install RExcel
(by way of the CRAN package RExcelInstaller or by visiting rcom.univie.ac.at)
then here is some code which transfers all dataframes in the
global environment in R into separate worksheets in the active workbook in 
Excel.
This version adds the name of the dataframe as a header on the sheet and also
uses it as the name of the worksheet.
It should be easy to adapt this to add headers and worksheet names of your 
choice.
If you want to use this code, you have to set a reference to RExcelVBALib in the
workbook with the VBA code below.
I you have never used RExcel before: There are many examples
demonstrating different techniques to connect R and Excel for
data transfer and computation.

-=-=-=-=-=-==

Option Explicit

Sub TransferToExcel(dfName As String, header As String)
Dim myWs As Worksheet
Set myWs = ActiveWorkbook.Worksheets.Add
myWs.Name = dfName
myWs.Cells(1, 1).Value = header
rinterface.GetDataframe dfName, myWs.Cells(2, 1)
End Sub

Sub DoIt()
Dim i As Integer
Dim dfNames As Variant
Dim myDfName As String
rinterface.StartRServer
dfNames = RDataFrameNames()
For i = LBound(dfNames) To UBound(dfNames)
myDfName = CStr(dfNames(i, LBound(dfNames, 2)))
TransferToExcel myDfName, myDfName
Next i
rinterface.StopRServer
End Sub

Function RDataFrameNames() As Variant
Dim cmdString As String
Dim myDfNames As Variant
rinterface.StartRServer
cmdString = dfpos-sapply(ls(),function(x)is.data.frame(eval(as.name(x
rinterface.RRun cmdString
cmdString = dfnames-ls()[dfpos]
rinterface.RRun cmdString
myDfNames = rinterface.GetRExpressionValueToVBA(dfnames)
RInterface.RRun rm(dfnames,dfpos)
RDataFrameNames = myDfNames
End Function

On Jul 15, 2010, at 3:29 AM, Whit Armstrong wrote:

 It isn't beautiful, but I use this package to write excel files from linux.
 
 http://github.com/armstrtw/Rexcelpoi

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] export tables to excel files on multiple sheets with titles for each table

2010-07-14 Thread Erich Neuwirth
You also could use RExcel and write some VBA macros doing this task for you.
You can essentially have the rcom R-centric solution or the
VBA-centric RExcel solution.


On Jul 14, 2010, at 12:19 AM, Marc Schwartz wrote:

 If I am correctly understanding what Eugen is trying to do, WriteXLS() won't 
 get him there. WriteXLS() will enable you to label/name the worksheets (tabs) 
 but not allow you to precede the actual data frame rows and columns on the 
 sheet with a title or label.
 
 I suspect that you may have to look at the RCom package tools for this. This 
 provides greater flexibility in writing to the worksheets and cells. 
 
 See http://rcom.univie.ac.at/ for more information.
 
 HTH,
 
 Marc Schwartz
 
 
 On Jul 13, 2010, at 4:09 PM, Felipe Carrillo wrote:
 
 Check the WriteXLS package, I think it does that and also saves
 each R object on a different excel sheet.
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 
 
 
 - Original Message 
 From: eugen pircalabelu eugen_pircalab...@yahoo.com
 To: R-help r-h...@stat.math.ethz.ch
 Sent: Tue, July 13, 2010 1:21:33 PM
 Subject: [R] export tables to excel files on multiple sheets with titles 
 for 
 each table
 
 Hello R-users,
 Checking the archives, I recently came across this topic: 
 export tables to Excel files 
 (http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679),
 ,
 and the following interesting references have been proposed:
 http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows
 http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/
 
 but my problem is somehow a small extension to what has been discussed, and 
 although i have a solution, i seek something more elegant. I want to export 
 multiple dataframes (on multiple sheets), but i also want each of them to 
 have 
 
 its own title that is to be written also in Excel. The packages/functions 
 that 
 i 
 
 have checked, cannot accommodate a title that is to be written on the 
 sheet, 
 along with the actual dataframe of interest.
 
 I can do something similar to what i need, but without writing the 
 dataframes 
 on 
 
 multiple sheets.
 
 #head(USArrests) and head(iris) written with accompanying title one under 
 each 
 
 other 
 
 write.excel-function (tab, ...){
 zz - file(example.dat, a+b) 
 cat(\TITLE extra line,file = zz, sep = \n)
 write.table(tab, file=zz, row.names=F,sep=\t)
 close(zz)}
 write.excel(head(USArrests))
 write.excel(head(iris))
 
 Any suggestion on how to export the same information on two separate 
 sheets, 
 and 
 
 keeping also a title for each of them, is highly appreciated, as i have 
 been 
 searching for some time for a good solution.
 
 Thank you very much and have a great day ahead!
 
 __
 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.
 

--
Erich Neuwirth
Didactic Center for Computer Science and Institute for Scientific Computing
University of Vienna





[[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] Problems installing data package on Windows

2010-06-02 Thread Erich Neuwirth
Did you try using the type=source parameter for install.packages?


On Jun 2, 2010, at 3:02 PM, Erick Rocha Fonseca wrote:

 Dear all,
 
 I'm having difficulties installing a package on Windows. It has only R
 data files, no code. I've built it on a Linux platform and installed it
 there without problems. When I tried installing the .tar.gz on Windows,
 via install.packages, I got the following errors:
 
 Error in gzfile(file, r) : unable to open connection 
 In addition: Warning message:
 1: In unzip(zipname, exdir = dest) :
  error 1 in extracting from zip file 
 2: In gzfile(file, r) :
  cannot open compressed file 'pkgname.tar.gz/DESCRIPTION', probable
 reason 'No such file or directory'
 
 
 After searching in the web, I tried installing the Rtools kit. The
 problem with install.packages remains, but I managed to install it with
 R CMD INSTALL. What could be wrong with install.packages? As far as I
 understood, installing a package without source code shouldn't need the
 resources in Rtools.
 
 Thanks, 
 
 Erick Fonseca
 
 __
 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] how to profile R interpreter?

2010-05-16 Thread Erich Neuwirth
Look for Rprof in the utils package.


On 5/12/2010 9:22 PM, xiaoming gu wrote:
 Hi, all. Does anyone know how to profile R interpreter? I've tried gprof but
 it doesn't work. Thanks.
 
 Xiaoming

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Center for Computer Science Didactics and Learning Research
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39902 Fax: +43-1-4277-39459

__
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] Image into Excel file from R

2010-04-25 Thread Erich Neuwirth
RExcel has a VBA command
InsertCurrentRPlot which will put the current R plot into an Excel file.
RExcel is an Excel addin and can be installed
through the package RExcelInstaller available on CRAN.



On 4/25/2010 8:11 PM, Hans-Peter Suter wrote:
 I am aware of the various packages (xlsReadWrite, RODBC) to get data
 frames into R, but I would like to copy images too.
 
 The xlsReadWritePro version could do it (see code below). It's a
 shareware package, but if people need/ask for a gratis license I send
 it (please download and check ?xls.lic first; www.swissr.org). I'm
 just finishing 'some' :-) RUnit tests and a new version will be
 released tomorrow or after tomorrow.
 
 Cheers,
 Hans-Peter
 
 rfile.img - sub(origData, origImage, rfile, fixed = TRUE)
 wfile.img - sub(tmpWriteData, tmpWriteImage, wfile, fixed = TRUE)
 pics - c(pic1.jpeg, pic2.png, pic3.bmp, pic4.emf, pic5.wmf,
 pic.jpg)
 fpics -  file.path(dirname(rfile), pics)
 
 
 ### test: image
 ### !!! tests have to be executed in sequencial order !!!
 
 test.proImage.1write - function() {
 exc - xls.open(rfile.img)
 xls.image(exc, set, fpics[1], Pic1)
 xls.image(exc, set, fpics[2], Pic2)
 xls.image(exc, set, fpics[3], Pic3)
 xls.image(exc, set, fpics[4], Pic4)
 xls.image(exc, set, fpics[5], Pic5)
 xls.image(exc, set, fpics[6], c(17, 7, 20, 8))
 xls.close( exc, file = wfile.img)
 
 res - xls.image(wfile.img, list)
 checkIdentical(res, c(Grafik 1, fpics))
 }
 
 __
 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.
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] loops and if statements

2010-04-18 Thread Erich Neuwirth
I would prefer version 1.
Version to creates a global variable R which you do not really need
since it contains the same values as d$r.
In option 2, you should probably remove the variable r itself
after it has been appended to d.


On 4/18/2010 5:23 PM, Laura Ferrero-Miliani wrote:
 Thanks for correcting my code Erich, do you think what I wrote is
 overcomplicating things? Considering what Juan wrote:
 
 # Option 1
 a - 1:4
 b - c(meep, foo, meep, foo)
 d - data.frame(a, b)
 d$r - with(d, ifelse(b == 'meep', 'oops', 'yay'))
 d
 
 # Option 2
 a - 1:4
 b - c(meep, foo, meep, foo)
 d - cbind(a, b)
 r - ifelse(d[,2] == 'meep', 'oops', 'yay')
 d - cbind(d, r)
 d
 
 
 On Sun, Apr 18, 2010 at 5:13 PM, Erich Neuwirth
 erich.neuwi...@univie.ac.at wrote:
 for(i in seq(along=d[,2])) {if (d[i,2]==meep) { print(oops)}
 else { print(yay)}
 }
 is probably what you want.
 But the way you are using cbind converts a into a vector of
 character. It is not numeric any more.
 Perhaps you want

 d-cbind(as.data.frame(a),b)

 And then you could do

 for (el in d$b) print(ifelse(el==meep,oops,yay))

 On 4/18/2010 2:46 PM, Laura Ferrero-Miliani wrote:
 for(i in seq(along=d[,2])) {if (d[i]==meep) { print(oops)}
 else { print(yay)}
 }

 --
 Erich Neuwirth, University of Vienna
 Faculty of Computer Science
 Computer Supported Didactics Working Group
 Visit our SunSITE at http://sunsite.univie.ac.at
 Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] run R script from Excel VBA

2010-04-18 Thread Erich Neuwirth
The site has a wiki and the wiki has a page
How to install
which should answer your question.

Furthermore, please subscribe to the rcom mailing list on our side
and post your questions regarding RExcel there.


On 4/16/2010 8:05 PM, KZ wrote:
 hmm, i could be a bit more computer savy. what do i suppose to do once i
 am on the site (http://rcom.univie.ac.at/.)? i thought maybe i should
 download rexcel 3.1.., which i did, then open the excel and make sure
 the rexcel add-ins is checked (i did it as well). it didn't work when i
 try to run rinterface.xyz.
  
 do you have a layman's version of instructions as to how to install
 rexcel and how to call a R file by an excel vba module? i am not
 interested in how to excute R functions interactively in excel, rather
 call from excel and excute a R file that i already wrote, and exit R the
 R file/code is done.
  
 thx
 
 On Fri, Apr 16, 2010 at 1:47 PM, Erich Neuwirth
 erich.neuwi...@univie.ac.at mailto:erich.neuwi...@univie.ac.at wrote:
 
 Sub Doit()
   RInterface.StartRServer
   RInterface.RRun whateveryoywanttodoinR
   RInterface.StopRServer
 End Sub
 
 You probably also want some results from R's computation transferred
 to R.
 RInterface.GetArray and
 RIntercace.GetDataframe will get arrays or dataframes from R
 and put them in Excel ranges.
 
 
 
 On 4/16/2010 6:34 PM, KZ wrote:
  not sure if this's what i had in mind. what i wanted is excel vba
 codes to:
  1. launch R,
  2. execute the R code (computeCovarMatrix.R), and
  3. exit R after the R code is done.
 
  thx
 
  On Fri, Apr 16, 2010 at 12:31 PM, Erich Neuwirth
  erich.neuwi...@univie.ac.at mailto:erich.neuwi...@univie.ac.at
 mailto:erich.neuwi...@univie.ac.at
 mailto:erich.neuwi...@univie.ac.at wrote:
 
  Have a look at rcom.univie.ac.at http://rcom.univie.ac.at/
 http://rcom.univie.ac.at/.
  We have an Excel addin which will allow you to do that.
  Disclaimer: I am the author of the addin.
 
 
 
  On 4/16/2010 4:57 PM, KZ wrote:
   I wrote a R script say called computeCovarMatrix.R and i want to
  call and
   run this piece from Excel visual basic. does anyone know how
 to do
  that?
  
   thanks,
   KZ
  
 [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailto:R-help@r-project.org
 mailto:R-help@r-project.org mailto: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
 http://www.r-project.org/posting-guide.html
  http://www.r-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible
 code.
  
  
 
  --
  Erich Neuwirth, University of Vienna
  Faculty of Computer Science
  Computer Supported Didactics Working Group
  Visit our SunSITE at http://sunsite.univie.ac.at
 http://sunsite.univie.ac.at/
  http://sunsite.univie.ac.at/
  Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
 
  __
  R-help@r-project.org mailto:R-help@r-project.org
 mailto:R-help@r-project.org mailto: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
 http://www.r-project.org/posting-guide.html
  http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 Erich Neuwirth, University of Vienna
 Faculty of Computer Science
 Computer Supported Didactics Working Group
 Visit our SunSITE at http://sunsite.univie.ac.at
 http://sunsite.univie.ac.at/
 Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] run R script from Excel VBA

2010-04-16 Thread Erich Neuwirth
Have a look at rcom.univie.ac.at.
We have an Excel addin which will allow you to do that.
Disclaimer: I am the author of the addin.



On 4/16/2010 4:57 PM, KZ wrote:
 I wrote a R script say called computeCovarMatrix.R and i want to call and
 run this piece from Excel visual basic. does anyone know how to do that?
 
 thanks,
 KZ
 
   [[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.
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] mantel.haenszel.test for trend in S-plus doesn't work i R

2010-04-04 Thread Erich Neuwirth
That is the problem
 c(,2,3)
Error: argument is missing, with no default


On 4/4/2010 12:51 PM, Fredrik Lundgren wrote:
 Dear R'ers,
 
 When I used S-plus i wrote a small program for a Mantel-Haenszel test  
 for trend (I think it worked). Unfortunately I can't get it working in  
 R.
 It appears as if my use of 'el' is the problem but I can't sort it out.
 
 Error in apply(array, c(, 2, 3), function(el) el * 1:s) :
argument is missing, with no default
 
 Further down in the program I use 'el' as well
 
 Can this be sorted out?
 
 Fredrik
 
 
 
 ###
 mantel.ext.test -
 function(array)
 {
 # Mantel-Extension Test  -- Testing for trend in the presence of
 # confounding ref. Rosner : Fundamentals of Biostatistics, 5th
 # ed, page 606-609
 # array is an 3-dim array with as many strata (last dimension)
 # you like case-control as second dimension and the dimension
 # for which a trend should be tested as the first dimension
 # Example:
 # snoring - array(c(196, 223, 103, 603, 486, 232, 188, 313,
 # 232, 348, 383, 206), c(3,2,2))
 # dimnames(snoring) - list(age = c('30-39', '40-49', '50-60'), #  
 status = c('Case', 'Control'), sex = c('Women', 'Men'))
 #
 # mantel.ext.test(snoring)
 #   Data: snoring
 # , , Women
 #   Case Control
 # 30-39  196 603
 # 40-49  223 486
 # 50-60  103 232
 # , , Men
 #   Case Control
 # 30-39  188 348
 # 40-49  313 383
 # 50-60  232 206
 # The trend of snoring with age , controlling for sex , has a
 # Mantel-Extension-test chi-square = 35.06 (df = 1 ) p-value = 0
 #  Effect is  increasing  with increasing age
  s - dim(array)[1]
  O - sum(apply(apply(array, c(, 2, 3), function(el) el * 1:s)[,  
 1,  ], 2, sum))
  tot - apply(array, c(3), sum)
  sum.case - apply(array, c(2, 3), sum)[1,  ]
  E - sum((apply(apply(apply(array, c(1, 3), sum), 2, function(
  el) el * 1:s), 2, sum) * sum.case)/tot)
  s1 - apply(apply(apply(array, c(1, 3), sum), 2, function(el)
  el * 1:s), 2, sum, simplify = F)
  s2 - apply(apply(apply(array, c(1, 3), sum), 2, function(el)
  el * (1:s)^2), 2, sum)
  V - sum((sum.case * (tot - sum.case) * (tot * s2 - s1^2))/(tot^
  2 * (tot - 1)))
  A - abs(O - E) - 0.5
  chi2 - (abs(O - E) - 0.5)^2/V
  p - 1 - pchisq(chi2, 1)
  incr - ifelse(A  0, increasing, decreasing)
  cat(\n, Data:, deparse(substitute(array)), \n)
  print(array)
  cat(\n, The trend of, deparse(substitute(array)), with,
  attr(dimnames(array), names)[1], , controlling for,
  attr(dimnames(array), names)[3], ,, has a, \n,
  Mantel-Extension-test chi-square =, round(chi2, 3),
  (df =, 1, ), p-value =, round(p, 6), \n,
  Effect is \, incr, \ with increasing, attr(
  dimnames(array), names)[1], \n)
 }
 
 ##
 
 
 
 
 Fredrik Lundgren
 fredrik.bg.lundg...@gmail.com
 
 Engelbrektsgatan 31
 582 21 Linköping
 tel   013 - 47 30 117
 mob   0706 - 86 39 29
 
 Sommarhus: Ljungnäs 158
 380 30 Rockneby
 0480 - 650 98
 
 
   [[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.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] RCOM Save

2010-04-01 Thread Erich Neuwirth
Please be more precise.
You seem not to use the rcom (note the lowercase name) package,
but the RDCOMClient package which is not available from CRAN
but as part of the Omegahat project.

rcom has a command comCreateObject and RDCOMClient has a command COMCreate.

The code you supplied will definitely not run in with rcom.
Furthermore, if your code had included the appropriate
library statement, things would have been much clearer.


On 4/1/2010 12:00 PM, koj wrote:
 
 Thank you. Unfortunately this recommendation does not solve my problem and I
 don't know why. Here is my test-code:
 
 
 pfad-paste(C:/...,xls,sep=.)
 xl - COMCreate(Excel.Application)  
 xl[[Visible]] - FALSE 
 wkbk - xl$Workbooks()$Open(pfad)   
 sh - xl$ActiveSheet()
 A3R - sh$Range(A28)
 A3R[[Formula]] - =Summe(A1:A27)
 A3RF - A3R$Font()
 A3RF[[Bold]] - TRUE
 wkbk$Close(pfad)
 system(taskkill /f /im Excel.exe)
 
 I tried a lot of possibilities (e. g. in the close statement) but without
 success. Excel always asks about the saving.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] Finding positions in array

2010-03-30 Thread Erich Neuwirth
which(y7)

z-which(y7)


On 3/30/2010 2:54 PM, Romildo Martins wrote:
 Hello,
 
 I need a function to check what positions of the array are greater than y
 and return to positions in another array z.
 
 x-array(E(gaux)$weight)
 x
 [1]  3  8 10  6
 
 If y = 7
 
 z
 [1] 2 3
 
 
 Thanks a lot!
 
 Romild
 
   [[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.
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] Calling R from c in Windows XP

2010-03-27 Thread Erich Neuwirth
If you want to call R from within VB.NET you might want to look at
the statconnDCOM server (available at rcom.univie.ac.at)
It wraps R into a (D)COM server and therefore allows any (D)COM client
to access R on windows. VB.NET is a (D)COM client.



On 3/27/2010 3:53 PM, dkStevens wrote:
 
 I'm searching for answers to four questions (I've been searching the net for
 hours...)
 
 In Windows XP, is it possible to call R functions from a c program? (I've
 found examples for Linux/Unix but not Windows)
 
 If so, is there a simple example to get started using gcc with R-2.10.0?
 
 If so, is it possible to write a simple interface using a c dll to call R
 functions from a Visual Basic.net program?
 
 If so, is there a simple example?
 
 Thanks to all

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] rpad ?

2010-03-24 Thread Erich Neuwirth
I found the repair by googling.
You have to get the source and buld the package.
The change needed is in HtmlTree.R

You have to add return(str) at the end of the function definition.
The reason is that for loops now return NULL,
they returned (I think) the value of the last interation
if the looped statement before.



HTMLargs - function(x) {
  # returns a string with the arguments as a=arg1, b=arg2, and so on
  names - names(x)
  if (length(x)  0) str -   else str - 
  for (i in seq(along = x))
str - paste(str, names[i], =, jsQuote(x[[i]]),  , sep = )
# next code line added by EN, necessary under under R 2.10
# due to changes how for works
  return(str)   
}


I found the solution here
http://code.google.com/p/rpad/issues/detail?id=5#c0

On 3/24/2010 4:18 PM, Bos, Roger wrote:
 Erich,
 
 I use Rpad actively so I am disappointed to hear it is no longer being
 updated.  Would you be willing to share your modifications with the
 list, or at least with me?
 
 Thanks,
 
 Roger
  
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Erich Neuwirth
 Sent: Tuesday, March 23, 2010 4:47 PM
 To: r-help@r-project.org
 Subject: Re: [R] rpad ?
 
 We are using RPad for a teaching application here.
 But we had to find many things the hard way, and additionally, it did
 not survive the latest R release change.
 There is a minimal repair, but the maintainer does not answer any email
 any more. We did the repair and are giving a modified version to our
 students, but we do not have enough resource to take over maintenance.
 
 
 
 On 3/23/2010 8:00 PM, sjaffe wrote:

 Is anyone using rpad? Is there any documentation or examples beyond 
 that in the 'man' directory of the source?

 
 --
 Erich Neuwirth, University of Vienna
 Faculty of Computer Science
 Computer Supported Didactics Working Group Visit our SunSITE at
 http://sunsite.univie.ac.at
 Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
 
 __
 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.
 ***
 
 This message is for the named person's use only. It may
 contain confidential, proprietary or legally privileged
 information. No right to confidential or privileged treatment
 of this message is waived or lost by an error in transmission.
 If you have received this message in error, please immediately
 notify the the sender by e-mail, delete the message and all 
 copies from your system and destroy any hard copies.  You must
 not, directly or indirectly, use, disclose, distribute, 
 print or copy any part of this message if you are not
 the intended recipient.
 
 
 
 
 
 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email 
 __
 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] rpad ?

2010-03-23 Thread Erich Neuwirth
We are using RPad for a teaching application here.
But we had to find many things the hard way,
and additionally, it did not survive the latest R release change.
There is a minimal repair, but the maintainer does not answer any email
any more. We did the repair and are giving a modified version to our
students, but we do not have enough resource to take over maintenance.



On 3/23/2010 8:00 PM, sjaffe wrote:
 
 Is anyone using rpad? Is there any documentation or examples beyond that in
 the 'man' directory of the source? 
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] Dataframe calculations

2010-03-19 Thread Erich Neuwirth
with the following code

newvars()$ARRIVALS and newvars()$DEPARTURES
will give you the new variables you need.


-=-=-=


addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(odds(newtimes))[-1]),
   arrives=evens(newtimes))
}

odds - function(inVec){
  indvec-0:(floor((length(inVec)-1)/2))
  inVec[2*indvec+1]
}

evens - function(inVec){
  odds(inVec[-1])
}


newvars - function(){
  DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
  starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
  waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
  travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
  list(DEPARTURES=

as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
ARRIVALS=

as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
}



-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
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] Dataframe calculations

2010-03-19 Thread Erich Neuwirth
Sorry,
Oddly I got the use of odds and evens the wrong way round.

addDelays - function(arriveTime,waitVec,travelVec){
  start-as.POSIXct(arriveTime,format=%H:%M:%S)
  delays-as.vector(t(cbind(waitVec,travelVec)))
  newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
  list(departs=c(arriveTime,(evens(newtimes))[-1]),
   arrives=odds(newtimes))
}

Using the new definition of addDelays above should do the trick.



On 3/19/2010 5:30 PM, Hosack, Michael wrote:
 Erich,
 
 Thank you so much for the effort you put into writing this code.
  I ran it and then assigned the two variables you created to the
 'ARRIVE' and 'DEPART' variables of my dataframe as you directed and
 the resultant calculations were incorrect. I am not sure why it did
 not work, I do not yet grasp the coding, I am still a novice.
 Perhaps you or someone else could rerun your code on my original
 dataframe and see why it did not yield the correct results.
 
 Thank you,
 
 Mike
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Erich Neuwirth
 Sent: Friday, March 19, 2010 11:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] Dataframe calculations
 
 with the following code
 
 newvars()$ARRIVALS and newvars()$DEPARTURES
 will give you the new variables you need.
 
 
 -=-=-=
 
 
 addDelays - function(arriveTime,waitVec,travelVec){
   start-as.POSIXct(arriveTime,format=%H:%M:%S)
   delays-as.vector(t(cbind(waitVec,travelVec)))
   newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S)
   list(departs=c(arriveTime,(odds(newtimes))[-1]),
arrives=evens(newtimes))
 }
 
 odds - function(inVec){
   indvec-0:(floor((length(inVec)-1)/2))
   inVec[2*indvec+1]
 }
 
 evens - function(inVec){
   odds(inVec[-1])
 }
 
 
 newvars - function(){
   DATE-with(SCHEDULE2,paste(YEAR,MM,DD,sep=))
   starts-as.list(with(SCHEDULE2,tapply(ARRIVE,DATE,function(x)x[1])))
   waits-with(SCHEDULE2,tapply(WAIT,DATE,function(x)x))
   travels-with(SCHEDULE2,tapply(TRAVEL,DATE,function(x)x))
   list(DEPARTURES=
 
 as.vector(mapply(function(...)addDelays(...)$departs,starts,waits,travels)),
 ARRIVALS=
 
 as.vector(mapply(function(...)addDelays(...)$arrives,starts,waits,travels)))
 }
 
 
 
 SCHEDULE2 -
 structure(list(MM = c(05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 05, 
 05, 05, 05, 05, 05, 05, 05, 05, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 06, 
 06, 06, 06, 06, 06, 06, 06, 06, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 07, 
 07, 07, 07, 07, 08, 08, 08, 08, 08,
 !
  08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 
 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 08, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 
 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 09, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10), DD = 
 c(02, 02, 02, 02, 03, 03, 03, 03, 
06!
  , 06, 06, 06, 09, 09, 09, 09, 10, 10, 10, 10, 
 14, 14, 14, 14, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 24, 24, 24, 24, 27, 27, 
 27, 27, 29, 29, 29, 29, 31, 31, 31, 31, 04, 04, 04, 
 04, 06, 06, 06, 06, 07, 07, 07, 07, 10, 10, 10, 10, 
 12, 12, 12, 12, 16, 16, 16, 16, 17, 17, 17, 17, 19, 
 19, 19, 19, 22, 22, 22, 22, 23, 23, 23, 23, 27, 27, 
 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 03, 03, 03, 
 03, 05, 05, 05, 05, 09, 09, 09, 09, 10, 10, 10, 10, 
 13, 13, 13, 13, 14, 14, 14, 14, 18, 18, 18, 18, 22, 
 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 27, 27, 
 27, 27, 28, 28, 28, 28, 01, 01, 01, 01, 04, 04, 04, 
 04, 06, 06, 06, 06, 07, 07, 07, 07, 12, 12, 12, 12, 
 13, 13, 13, 13, 14, 14, 14, 14, 16
, !
  16, 16, 16, 19, 19, 19, 19, 21, 21, 21, 21, 23, 
 23, 23, 23, 24, 24, 24, 24, 28, 28, 28, 28, 31, 31, 
 31, 31, 02, 02, 02, 02, 04, 04, 04, 04, 08, 08, 08, 
 08, 09, 09, 09, 09, 11, 11, 11, 11, 14, 14, 14, 14, 
 16, 16, 16, 16, 19, 19, 19, 19, 20, 20, 20, 20, 21, 
 21, 21, 21, 26, 26, 26, 26, 27, 27, 27, 27, 29, 29, 
 29, 29, 03, 03, 03, 03, 05, 05, 05, 05, 08, 08, 08, 
 08, 10, 10, 10, 10, 14, 14, 14, 14, 15, 15, 15, 15, 
 16, 16, 16, 16, 20, 20, 20, 20, 21, 21, 21, 21, 24, 
 24, 24, 24, 26, 26, 26, 26, 29, 29, 29, 29, 30, 30, 
 30, 30
 ), YEAR = c(2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 
 2010, 2010

Re: [R] How good is R at making publication quality tables?

2010-03-17 Thread Erich Neuwirth
If you are working in Windows and want Word output,
it might be worthwhile to have a look at SWord
available from the download section on rcom.univie.ac.at.

Warning: the program is free for noncommercial use,
but NOT licensed under GPL or LGPL.


On 3/17/2010 3:51 PM, Paul Miller wrote:
 Hello Everyone,
  
 I have just started learning R and am in the process of figuring out what it 
 can and can't do. I must say I am very impressed with R so far and am amazed 
 that something this good can actually be free. 
  
 Recently, I finished reading R for SAS and SPSS Users and have begun reading 
 SAS and R and Data Manipulation with R. Based on what I've read in these 
 books and elsewhere, I get the impression that R is very good at drawing high 
 quality graphs but maybe not so good at creating nice looking tables of the 
 sort I'm used to getting through SAS ODS.
  
 Am I right or wrong about this? If I am wrong, can anyone show me some 
 examples of how R can be used to create really nice looking tables? I often 
 make tables of adverse events in clinical trials that have n(%) values in the 
 cells. I'd love to see an example that does a nice job of making that sort of 
 table but would be happy to see any examples that someone might be willing to 
 send to me.
  
 Thanks,
  
 Paul
  
 
 
   __
 Looking for the perfect gift? Give the gift of Flickr! 
 
 
   [[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.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

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


  1   2   >