[R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
I'm interested in using a data frame as if it were a hash table.  For
instance if I had the following,

> (d <- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))
  keyvalue
1 0.5 -1.118665122
2 1.0  0.465122921
3 1.5 -0.529239211
4 2.0 -0.147324638
5 2.5 -1.531503795
6 3.0 -0.002720434

Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
to get -0.53.  How would one go about doing this?

Yours,
Alan Lue

__
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] Data Frame as Hash Table

2010-05-30 Thread Barry Rowlingson
On Sun, May 30, 2010 at 9:03 AM, Alan Lue  wrote:
> I'm interested in using a data frame as if it were a hash table.  For
> instance if I had the following,
>
>> (d <- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))
>  key        value
> 1 0.5 -1.118665122
> 2 1.0  0.465122921
> 3 1.5 -0.529239211
> 4 2.0 -0.147324638
> 5 2.5 -1.531503795
> 6 3.0 -0.002720434
>
> Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
> to get -0.53.  How would one go about doing this?

Assign the key to the rownames:

> row.names(d)=d$key
> d
key  value
0.5 0.5 -0.1023732
1   1.0 -0.2005591
1.5 1.5  0.1204866

but note they are character strings:

> d["0.5",]
key  value
0.5 0.5 -0.1023732

 I'm not sure if R uses a fast hashing algorithm for lookups or a
simple sequential search. Looking at the source code, testing, or
waiting for someone else to answer that on here will tell.

 Or you could do it with a list, but again the keys are always
character strings.

Barry

__
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] Data Frame as Hash Table

2010-05-30 Thread Patrick Burns

You might want to investigate the 'data.table'
package.

On 30/05/2010 09:03, Alan Lue wrote:

I'm interested in using a data frame as if it were a hash table.  For
instance if I had the following,


(d<- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))

   keyvalue
1 0.5 -1.118665122
2 1.0  0.465122921
3 1.5 -0.529239211
4 2.0 -0.147324638
5 2.5 -1.531503795
6 3.0 -0.002720434

Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
to get -0.53.  How would one go about doing this?

Yours,
Alan Lue

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



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question about package coin

2010-05-30 Thread Achim Zeileis

On Sat, 29 May 2010, Bryan Keller wrote:

Anyone know if coin can run a permutation test based on a (user-defined) 
statistic other than the mean difference?  The function 
independence_test does the permutation t-test via difference in means.


...by default, that is.

I'm wondering if it's possible to use independence_test to run a 
permutation test for some other statistic than the difference in means.


Yes.

For example, I'd like to run a permutation test using Welch's t instead 
of the difference in means.


No.

The help for independence_test reveals that "teststat" is an argument 
which allows for specification of standardized scalar test statistic, a 
maximum type statistic, or a quadratic form.  I cannot, however, figure 
out if it is possible to specify how the statistic should be calculated 
by, for example, supplying a function.


Have you considered reading the references mentioned in the documentation.
I suggest you start with
  vignette("LegoCondInf", package = "coin")
which essentially is the "The American Statistician" paper mentioned in 
the help pages.


The general framework is that the user can specify data transformations 
for which an independence test is computed. Depending on the data 
transformation, this can be a t test, chi-squared test, Wilcoxon test, 
Kruskal-Wallis test, and many many more.


Furthermore, note that the null hypothesis is always permutation 
invariance. Hence, the Welch test does not fit into this framework because 
under the null it assumes same means but with potentially different 
variances, which is not invariant with respect to permutations.


Therefore, the default t statistic in independence_test() computes a mean 
difference standardized by the one-sample standard deviation (with only a 
single mean!). This is neither the pooled two-sample standard deviation 
(with two means) that t.test(..., var.equal = TRUE) uses nor the 
two-sample standard deviation (with two means and two standard deviations) 
of the Welch test.


hth,
Z

__
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] adding statistical output to a plot

2010-05-30 Thread Jim Lemon

On 05/29/2010 10:11 PM, dunner wrote:

... Perhaps "apply" simply doesn't deal with the colname and I have
to try a completely different method? Or will apply pass enough information
to the included function (mtab.norm) to allow me to annotate the plot?


It doesn't seem to, as I tried this on a different problem last night. I 
couldn't get the names to the called function with a matrix or a data 
frame. Finally just wrote a different (and probably much slower) apply 
function that would take different argument(s) for each vector.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?

2010-05-30 Thread Sherrie Jin
Hi,

I want to fit a linear model (without any random effect) with method "ml". I
tried to use "glm"  I found that there is no option for "ml" or "reml" and
the default one is "reml". THen I tried to use "lme" but it requires a
random effect. How can I fix this problem?

Of course, it's not necessary to be "glm" or "lme", I am just looking for
commands which allow me to fit a linear model (without any random effect)
with "ml" method. And later I may also need to fit generalized linear models
(probit, gamma and negtive binomial) with method "ml". Any suggestions?

Thanks.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?

2010-05-30 Thread Achim Zeileis

On Sun, 30 May 2010, Sherrie Jin wrote:


Hi,

I want to fit a linear model (without any random effect) with method "ml". I
tried to use "glm"  I found that there is no option for "ml" or "reml" and
the default one is "reml". THen I tried to use "lme" but it requires a
random effect. How can I fix this problem?

Of course, it's not necessary to be "glm" or "lme", I am just looking for
commands which allow me to fit a linear model (without any random effect)
with "ml" method. And later I may also need to fit generalized linear models
(probit, gamma and negtive binomial) with method "ml". Any suggestions?


glm() always performs Maximum Likelihood estimation and thus has no 
method="ml" argument.

Z


Thanks.

[[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] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?

2010-05-30 Thread Doran, Harold
Why are you not using the lm() function? OLS is ML with no random effects

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Sherrie Jin [jingo...@gmail.com]
Sent: Sunday, May 30, 2010 5:05 AM
To: r-help@r-project.org
Subject: [R] How can I fit a fixed-effect linear model or generalized linear
model with method="ml"?

Hi,

I want to fit a linear model (without any random effect) with method "ml". I
tried to use "glm"  I found that there is no option for "ml" or "reml" and
the default one is "reml". THen I tried to use "lme" but it requires a
random effect. How can I fix this problem?

Of course, it's not necessary to be "glm" or "lme", I am just looking for
commands which allow me to fit a linear model (without any random effect)
with "ml" method. And later I may also need to fit generalized linear models
(probit, gamma and negtive binomial) with method "ml". Any suggestions?

Thanks.

[[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] Vector docs

2010-05-30 Thread Duncan Murdoch

i...@whywouldwe.com wrote:

Hi

The docs for R are very practical, which is quite refreshing compared to 
other languages, however I can't find any details about all the things I 
can do with a vector. I'm expecting methods like vector.contains('foo') 
and vector.remove('foo'), maybe those methods don't exist but I'd love 
to find a page that details the ones that do.


I'd also like to find some docs about foreach loops (unless there's a 
better way to iterate through a vector), I've only found mailing list posts.


  


There may be such a page somewhere, but it is probably incomplete.  The 
object model in R has methods owned by generics, not by classes.  So 
even if someone wrote a list of all methods that worked on vectors, 
someone else could add a new one without modifying the vector class.


You can ask R what methods are currently visible, e.g.

library(methods)
showMethods(classes="vector")

but it won't show methods in unattached packages.

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.


Re: [R] Selecting first 7 elements

2010-05-30 Thread David Winsemius


On May 29, 2010, at 11:37 PM, Kang Min wrote:


What if I want to select the 8th to 14th element of the list? I tried
to use "[" again, but it doesn't work.


x[8:14]

(And I could not get Iverson's earlier method to work properly on a  
long list. It just returned the whole list. Did it work properly for  
you? )


--
David.





"[" is a function, and you want to use it on each element of the  
list,

so...



lapply(x, "[", c(1:7))


and the call to c() is of course not necessary, since ":" will  
generate a vector.



__
r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/ 
listinfo/r-help

PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
You received this message because you are subscribed to the Google  
Groups "R-help-archive" group.
To post to this group, send email to r-help- 
arch...@googlegroups.com.
To unsubscribe from this group, send email to r-help-archive+unsubscr...@googlegroups.com 
.
For more options, visit this group athttp://groups.google.com/group/r-help-archive?hl=en 
.


__
r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/ 
listinfo/r-help

PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

--
You received this message because you are subscribed to the Google  
Groups "R-help-archive" group.

To post to this group, send email to r-help-arch...@googlegroups.com.
To unsubscribe from this group, send email to r-help-archive+unsubscr...@googlegroups.com 
.
For more options, visit this group athttp://groups.google.com/group/r-help-archive?hl=en 
.


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


David Winsemius, MD
West Hartford, CT

__
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] Vector docs

2010-05-30 Thread David Winsemius


On May 30, 2010, at 1:43 AM, i...@whywouldwe.com wrote:


Hi

The docs for R are very practical, which is quite refreshing  
compared to other languages, however I can't find any details about  
all the things I can do with a vector. I'm expecting methods like  
vector.contains('foo') and vector.remove('foo'), maybe those methods  
don't exist but I'd love to find a page that details the ones that do.


Since vectors may contain named elements, your request is ambiguous. I  
cannot tell whether "foo" is a name or a value. It's also ambiguous  
because it's not clear what vector.contains() is supposed to return.  
If you read the introductory material, you should find that the  
function "[" is fairly fundamental to R operations.


?"["
?which
?grep

> x <- c(foo=3,bar=4)
> x
foo bar
  3   4
> x["foo"]
foo
  3
> x[-"foo"]
Error in -"foo" : invalid argument to unary operator
# the negation operation on indices only works with numeric arguments
# grep and which provide numeric resutls that can be used for "removal".
> x[grep("foo", names(x))]
foo
  3
> x[-grep("foo", names(x))]
bar
  4
> x[which(names(x)=="foo")]
foo
  3

Minus operations on numeric indices perform removal, at least to the  
extent of what is returned, but indexing does not do destructive  
removal unless accompanied by "<-" . In fact "[<-" is a function in  
its own right.




I'd also like to find some docs about foreach loops (unless there's  
a better way to iterate through a vector), I've only found mailing  
list posts.


Indexed solution are preferred, so see above, but if you want to find  
the help page for the "for" function


?"Control"





--

David Winsemius, MD
West Hartford, CT

__
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] geom_ribbon removes missing values

2010-05-30 Thread Karsten Loesing
Hi everyone,

it looks like geom_ribbon removes missing values and plots a single
ribbon over the whole interval of x values. However, I'd rather want it
to act like geom_line, that is, interrupt the ribbon for the interval of
missing values and continue once there are new values. Here's an example:

library(ggplot2)
df <- data.frame(
  date = seq(from = as.Date("2010-05-15"),
 to = as.Date("2010-05-24"),
 by = "1 day"),
  low = c(4, 5, 4, 5, NA, NA, 4, 5, 4, 5),
  mid = c(8, 9, 8, 9, NA, NA, 8, 9, 8, 9),
  high = c(12, 13, 12, 13, NA, NA, 12, 13, 12, 13))
ggplot(df, aes(x = date, y = mid, ymin = low, ymax = high)) +
  geom_line() +
  geom_ribbon(fill = alpha("blue", 0.5))

When running this code, R tells me:

Warning message:
Removed 2 rows containing missing values (geom_ribbon).

When you look at the graph, you can see that the line stops at May 18
and starts again on May 21. But the ribbon reaches from May 15 to 24,
even though there are no values on May 19 and 20.

Is there an option that I could set? Or a geom/stat that I should use
instead? In my pre-ggplot2 times I used polygon(), but I figured there
must be something better in ggplot2 (as there has always been so far).

Thanks,
--Karsten

__
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] Data Frame as Hash Table

2010-05-30 Thread Marshall Feldman
Besides data.table, there's the hash package. It does not use data.frame 
type structures but is a bit more flexible.


Marsh Feldman

On 5/30/10 [May 30, 10] 6:00 AM, r-help-requ...@r-project.org wrote:

Message: 40
Date: Sun, 30 May 2010 09:24:22 +0100
From: Patrick Burns
To:r-help@r-project.org,alan@gmail.com
Subject: Re: [R] Data Frame as Hash Table
Message-ID:<4c0220b6.7090...@pburns.seanet.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

You might want to investigate the 'data.table'
package.

On 30/05/2010 09:03, Alan Lue wrote:
   

>  I'm interested in using a data frame as if it were a hash table.  For
>  instance if I had the following,
>
 

>>  (d<- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))
   

>  keyvalue
>  1 0.5 -1.118665122
>  2 1.0  0.465122921
>  3 1.5 -0.529239211
>  4 2.0 -0.147324638
>  5 2.5 -1.531503795
>  6 3.0 -0.002720434
>
>  Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
>  to get -0.53.  How would one go about doing this?
>
>  Yours,
>  Alan Lue
>
>  __
>  R-help@r-project.org  mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>
 
-- Patrick Burns pbu...@pburns.seanet.com http://www.burns-stat.com 
(home of 'Some hints for the R beginner' and 'The R Inferno')


__
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] create new variable: percentile value of variable in data frame

2010-05-30 Thread Jonathan Beard
Hi Stephan, thanks for your response.

It looks like the ecdf() works like it should.

I have a quick follow-up:

I didn't notice any discussion in the help documents of the methods
behind ecdf() and quantile(type=3) being equivalent.

It looks like the results produced by each method are consistent.

Any thoughts?

Again, thanks so much,

-Jon




On Fri, May 28, 2010 at 4:06 PM, Stephan Kolassa  wrote:
> Hi Jon,
>
> does the empirical cumulative distribution function do what you want?
>
> dat$q.score <- ecdf(dat$score)(dat$score)
> ?ecdf
>
> HTH
> Stephan
>
>
> Jonathan Beard schrieb:
>>
>> Hello all,
>>
>> Thanks in advance for you attention.
>> I would like to generate a third value that represents the quantile
>> value of a variable in a data frame.
>>
>>
>> # generating data
>>
>> x <- as.matrix(seq(1:30))
>> y <- as.matrix(rnorm(30, 20, 7))
>> tmp1 <- cbind(x,y)
>> dat <- as.data.frame(tmp1)
>> colnames(dat) <- c("id", "score")
>> dat
>>
>> #  finding percentiles of "score"
>>
>> qs <- as.matrix(quantile(dat$score, type=3, probs = seq(0,1,.1)))
>> colnames(qs) <- c( "score")
>> qs
>>
>> #  is there a way to put the quantile value for a value of 'score'
>> into a new variable,
>> #  such that the new data frame would have three variables: id, score
>> and q.score?
>>
>> ##  running R version 2.8.1 (2008-12-22) on Vista
>>
>>
>> Thanks so much!
>>
>> -Jon
>>
>> __
>> 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] Selecting first 7 elements

2010-05-30 Thread Kang Min
Hmm x[8:14] didn't work. Yes Iverson's method worked, I wanted the
whole list, with 7 elements in each vector.

Now I want the whole list as well, but with the 8th to 14th element.


On May 30, 7:47 pm, David Winsemius  wrote:
> On May 29, 2010, at 11:37 PM, Kang Min wrote:
>
> > What if I want to select the 8th to 14th element of the list? I tried
> > to use "[" again, but it doesn't work.
>
> x[8:14]
>
> (And I could not get Iverson's earlier method to work properly on a  
> long list. It just returned the whole list. Did it work properly for  
> you? )
>
> --
> David.
>
>
>
>
>
>
>
>  "[" is a function, and you want to use it on each element of the  
>  list,
>  so...
>
>  lapply(x, "[", c(1:7))
>
> >>> and the call to c() is of course not necessary, since ":" will  
> >>> generate a vector.
>
> >>> __
> >>> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> >>> listinfo/r-help
> >>> PLEASE do read the posting 
> >>> guidehttp://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
>
> >>> --
> >>> You received this message because you are subscribed to the Google  
> >>> Groups "R-help-archive" group.
> >>> To post to this group, send email to r-help-
> >>> arch...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> r-help-archive+unsubscr...@googlegroups.com
> >>> .
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/r-help-archive?hl=en
> >>> .
>
> >> __
> >> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> >> listinfo/r-help
> >> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
> >> --
> >> You received this message because you are subscribed to the Google  
> >> Groups "R-help-archive" group.
> >> To post to this group, send email to r-help-arch...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> r-help-archive+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/r-help-archive?hl=en
> >> .
>
> > __
> > r-h...@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] Vector docs

2010-05-30 Thread i...@whywouldwe.com
Thanks for this, and all the other responses - I have a better 
understanding now.




David Winsemius wrote:


On May 30, 2010, at 1:43 AM, i...@whywouldwe.com wrote:


Hi

The docs for R are very practical, which is quite refreshing compared 
to other languages, however I can't find any details about all the 
things I can do with a vector. I'm expecting methods like 
vector.contains('foo') and vector.remove('foo'), maybe those methods 
don't exist but I'd love to find a page that details the ones that do.


Since vectors may contain named elements, your request is ambiguous. I 
cannot tell whether "foo" is a name or a value. It's also ambiguous 
because it's not clear what vector.contains() is supposed to return. 
If you read the introductory material, you should find that the 
function "[" is fairly fundamental to R operations.


?"["
?which
?grep

> x <- c(foo=3,bar=4)
> x
foo bar
  3   4
> x["foo"]
foo
  3
> x[-"foo"]
Error in -"foo" : invalid argument to unary operator
# the negation operation on indices only works with numeric arguments
# grep and which provide numeric resutls that can be used for "removal".
> x[grep("foo", names(x))]
foo
  3
> x[-grep("foo", names(x))]
bar
  4
> x[which(names(x)=="foo")]
foo
  3

Minus operations on numeric indices perform removal, at least to the 
extent of what is returned, but indexing does not do destructive 
removal unless accompanied by "<-" . In fact "[<-" is a function in 
its own right.




I'd also like to find some docs about foreach loops (unless there's a 
better way to iterate through a vector), I've only found mailing list 
posts.


Indexed solution are preferred, so see above, but if you want to find 
the help page for the "for" function


?"Control"





--

David Winsemius, MD
West Hartford, CT




__
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] Selecting first 7 elements

2010-05-30 Thread David Winsemius


On May 30, 2010, at 9:44 AM, Kang Min wrote:


Hmm x[8:14] didn't work. Yes Iverson's method worked, I wanted the
whole list, with 7 elements in each vector.

Now I want the whole list as well, but with the 8th to 14th element.


Oh, ... then in what sense did the lapply method not work? What code  
did you use? Did you get an error message? (It seems to be working  
fine for that purpose on my machine.)


--
David.




On May 30, 7:47 pm, David Winsemius  wrote:

On May 29, 2010, at 11:37 PM, Kang Min wrote:

What if I want to select the 8th to 14th element of the list? I  
tried

to use "[" again, but it doesn't work.


x[8:14]

(And I could not get Iverson's earlier method to work properly on a
long list. It just returned the whole list. Did it work properly for
you? )

--
David.








"[" is a function, and you want to use it on each element of the
list,
so...



lapply(x, "[", c(1:7))



and the call to c() is of course not necessary, since ":" will
generate a vector.


David Winsemius, MD
West Hartford, CT

__
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] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-30 Thread Uwe Ligges



On 26.05.2010 08:52, Alan Lue wrote:

Come to think of it, we can't save the output of each invocation and
concatenate it later, since we need the output as input for the next
iteration.



Yes, but you can do it a bit cleverer than before by initializing to the 
fill length as in:


r.seq <- numeric(nrow(d))
r.seq[1] <- 2 * (1 / d$Dt[1] - 1)
for (i in 2:nrow(d)) {
  r.seq[i] <- uniroot(bdt.deviation, interval = c(0, 1),
D.T = d$Dt[i], r.prior = r.seq[i-1])$root
}

Uwe Ligges




Alan


On Tue, May 25, 2010 at 11:43 PM, Alan Lue  wrote:

Since `for' loops are slow in R, and since `apply' functions are
faster, I was wondering whether there were a way to use an apply
function—or to otherwise avoid using a loop—when iterating over a
statement that updates its input.

For example, here's some such code:

r.seq<- 2 * (1 / d$Dt[1] - 1)
for (i in 2:nrow(d)) {
  rf<- uniroot(bdt.deviation, interval=c(0, 1), D.T=d$Dt[i], r.prior=r.seq)
  r.seq<- append(r.seq, rf$root)
}

The call to `uniroot()' both updates `r.seq' and reads it as input.
We could save the output of each invocation of `uniroot()' and
concatenate it later, but is there a better way to write this (i.e.,
to execute more quickly) while updating `r.seq' in each iteration?

Alan







__
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] Selecting first 7 elements

2010-05-30 Thread Jorge Ivan Velez
Hi Kang,

Try either

lapply(x, "[", 8:14)   # Erik Iverson's method

or

lapply(x, function(x) x[8:14])

HTH,
Jorge


On Sun, May 30, 2010 at 9:44 AM, Kang Min <> wrote:

> Hmm x[8:14] didn't work. Yes Iverson's method worked, I wanted the
> whole list, with 7 elements in each vector.
>
> Now I want the whole list as well, but with the 8th to 14th element.
>
>
> On May 30, 7:47 pm, David Winsemius  wrote:
> > On May 29, 2010, at 11:37 PM, Kang Min wrote:
> >
> > > What if I want to select the 8th to 14th element of the list? I tried
> > > to use "[" again, but it doesn't work.
> >
> > x[8:14]
> >
> > (And I could not get Iverson's earlier method to work properly on a
> > long list. It just returned the whole list. Did it work properly for
> > you? )
> >
> > --
> > David.
> >
> >
> >
> >
> >
> >
> >
> >  "[" is a function, and you want to use it on each element of the
> >  list,
> >  so...
> >
> >  lapply(x, "[", c(1:7))
> >
> > >>> and the call to c() is of course not necessary, since ":" will
> > >>> generate a vector.
> >
> > >>> __
> > >>> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> > >>> listinfo/r-help
> > >>> PLEASE do read the posting guidehttp://
> www.R-project.org/posting-guide.html
> > >>> and provide commented, minimal, self-contained, reproducible code.
> >
> > >>> --
> > >>> You received this message because you are subscribed to the Google
> > >>> Groups "R-help-archive" group.
> > >>> To post to this group, send email to r-help-
> > >>> arch...@googlegroups.com.
> > >>> To unsubscribe from this group, send email to
> r-help-archive+unsubscr...@googlegroups.com
> > >>> .
> > >>> For more options, visit this group athttp://
> groups.google.com/group/r-help-archive?hl=en
> > >>> .
> >
> > >> __
> > >> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> > >> listinfo/r-help
> > >> PLEASE do read the posting guidehttp://
> www.R-project.org/posting-guide.html
> > >> and provide commented, minimal, self-contained, reproducible code.
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> > >> Groups "R-help-archive" group.
> > >> To post to this group, send email to r-help-arch...@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> r-help-archive+unsubscr...@googlegroups.com
> > >> .
> > >> For more options, visit this group athttp://
> groups.google.com/group/r-help-archive?hl=en
> > >> .
> >
> > > __
> > > r-h...@r-project.org mailing list
> > >https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guidehttp://
> www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> > __
> > r-h...@r-project.org mailing listhttps://
> stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guidehttp://
> 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.
>

[[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] subsetting

2010-05-30 Thread ANJAN PURKAYASTHA
Hi,
I have a data-frame,  r (column names below), that needs subsetting:
date, time, strain, gene, deltact

When I try to subset r by applying selection criteria on two columns I get
an empty data frame. For example I would like to extract all rows that have
time == 0h and strain == ROC.
So, t <- subset(r, (r$time == "0h" && r$strain == "ROC"), select= c(time,
strain, gene, deltact)) returns an empty data-frame.
Is it not possible to subset based on two criteria?
TIA
Anjan

-- 
===
anjan purkayastha, phd.
research associate
fas center for systems biology,
harvard university
52 oxford street
cambridge ma
phone-703.740.6939
===

[[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] solve_TSP ignores control data, or I'm reading the help doc incorrectly.

2010-05-30 Thread Steven Lembark

I read the documentation below to mean that:

solve_TSP( tsp_input, '2-opt', rep=99 )

will use the 2-opt method on the tsp_input variable 
99 times.

Catch: I get an "unused input" error.

Q: Am I reading the docs (Item 1, below) correctly or 
   is this a problem with solve_TSP ignoring its inputs
   (Item 2, below).



Item 1: solve_TSP doc:

> library(TSP)
> ?sove_TSP

Description:

 Common interface to all TSP solvers in this package.

Usage:

 solve_TSP(x, method, control)

Arguments:

   x: the TSP given as an object of class 'TSP' or 'ATSP'.

  method: method to solve the TSP (default: nearest insertion
  algorithm; see details).

 control: a list of arguments passed on to the TSP solver selected by
  'method'.




'"2-opt"' Two edge exchange improvement procedure (Croes 1958).

  This procedure systematically exchanges two edges in the
  graph represented by the distance matrix till no improvements
  are possible. Exchanging two edges is equal to reversing part
  of the tour. The resulting tour is called _2-optimal._

  By default, improvement starts with a random tour.

  Additional control options:

  'tour' an existing tour which should be improved.  If no tour
  is given, a random tour is used.

  'rep' number of times to try 2-opt with a different initial
  random tour (default: 1).



Item 2: Failed execution

>  solve_TSP(tsp, method = '2-opt' )
object of class 'TOUR'
result of method '2-opt' for 56 cities
tour length: 5.681276

>  solve_TSP(tsp, method = '2-opt', rep=56 )
Error in solve_TSP(tsp, method = "2-opt", rep = 56) :
unused argument(s) (rep = 56)

this isn't an artifact of the debugger since I get
the same result without debug() setups.
 


-- 
Steven Lembark  85-09 90th St.
Workhorse Computing   Woodhaven, NY, 11421
lemb...@wrkhors.com+1 888 359 3508

__
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 sort order linux/Windows (R.2.11.0)

2010-05-30 Thread Steven Lembark
On Fri, 28 May 2010 01:17:49 -0700 (PDT)
carslaw  wrote:

>  [4] "HGV-D-Euro-III" "HGV-D-Euro-IV EGR"  "HGV-D-Euro-IV SCR" 
>  [4] "HGV-D-Euro-III" "HGV-D-Euro-IV EGR"  "HGV-D-Euro-IV SCR"

>  [7] "HGV-D-Euro-IV SCRb" "HGV-D-Euro-V EGR"   "HGV-D-Euro-VI" 
>  [7] "HGV-D-Euro-IV SCRb" "HGV-D-Euro-V EGR"   "HGV-D-Euro-V SCR" 

This is a lexical sort. Depending on the locale the
items may not sort in ASCII order. For example, a 
European-latin locale may have some letters in 
different places than ASCII. You have to check 
what is being sorted (e.g., map the stuff to UTF8
binary).

You might also find that input generated on windog
has "smart spaces" in it from the generating program
(e.g., Excell) that are something like \xA0 instead
of \x20 (32d) used in ASCII spaces.

Suggestion: Validate the data with something like
"od -cx" on linux so you know what you are sorting.
Then dump it out as hex in R [sorry, I have no idea
how to do that] and see if what you are sorting 
matches. After that validate the LOCALE setting
on both sides. If all of those turn up the same 
raw data then you've found a bug in R -- or at least
need to read some fine print in the lexical sort
docs.

-- 
Steven Lembark  85-09 90th St.
Workhorse Computing   Woodhaven, NY, 11421
lemb...@wrkhors.com+1 888 359 3508

__
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] create new variable: percentile value of variable in data frame

2010-05-30 Thread David Winsemius


On May 30, 2010, at 9:03 AM, Jonathan Beard wrote:


Hi Stephan, thanks for your response.

It looks like the ecdf() works like it should.

I have a quick follow-up:

I didn't notice any discussion in the help documents of the methods
behind ecdf() and quantile(type=3) being equivalent.

It looks like the results produced by each method are consistent.


If you want a method that uses what you know to be type 3 quantile  
based consider:


> dat$q.score <- findInterval(dat$score, qs)
> dat

You can adjust the parameters of findInterval to resolve to your  
specifications issues relating to which end of the interval is open.


--
David.


Any thoughts?

Again, thanks so much,

-Jon




On Fri, May 28, 2010 at 4:06 PM, Stephan Kolassa > wrote:

Hi Jon,

does the empirical cumulative distribution function do what you want?

dat$q.score <- ecdf(dat$score)(dat$score)
?ecdf

HTH
Stephan


Jonathan Beard schrieb:


Hello all,

Thanks in advance for you attention.
I would like to generate a third value that represents the quantile
value of a variable in a data frame.


# generating data

x <- as.matrix(seq(1:30))
y <- as.matrix(rnorm(30, 20, 7))
tmp1 <- cbind(x,y)
dat <- as.data.frame(tmp1)
colnames(dat) <- c("id", "score")
dat

#  finding percentiles of "score"

qs <- as.matrix(quantile(dat$score, type=3, probs = seq(0,1,.1)))
colnames(qs) <- c( "score")
qs

#  is there a way to put the quantile value for a value of 'score'
into a new variable,
#  such that the new data frame would have three variables: id,  
score

and q.score?

##  running R version 2.8.1 (2008-12-22) on Vista


Thanks so much!

-Jon

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


David Winsemius, MD
West Hartford, CT

__
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] simpleError in storage.mode(y)

2010-05-30 Thread Uwe Ligges
Please tell us the code you used and we may be able to help you 
interpreting the error message.


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Uwe Ligges


On 29.05.2010 23:05, anzid wrote:


hello,
I am working with multiple source software method, I got this error message:
simpleError in storage.mode (y) - "double": invalid to change the mode of a
storage factor
searching the net is a universal message
please, what does mean this message?

thank you for your interest
anzid


__
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] simpleError in storage.mode(y)

2010-05-30 Thread anzid

Thank you Uve ligges

  The SimpleError is solved ( 1 data abscent )
  thank you  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/simpleError-in-storage-mode-y-tp2235745p2236367.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to use the function "glht" of multcomp package to test interaction?

2010-05-30 Thread RICHARD M. HEIBERGER
Usually you will want to look at simple effects of the factors when there is
interaction.  Please look at the WoodEnergy demos in the HH package.
These examples use glht.

install.packages("HH")  ## if you don't currently have HH
library(HH)
demo("MMC.WoodEnergy-aov")
demo("MMC.WoodEnergy")

Rich

[[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] library location and error messages when loading packages

2010-05-30 Thread Uwe Ligges



On 24.05.2010 03:59, Daisy Englert Duursma wrote:

Hello,

I am running R on a server that several people share. Previously we
all had separate libraries for R.
I have set up R so everyone on the server shares the same library and
I downloaded the latest version of R and installed it on the
main drive of our server in the  "Program Files" folder (obvious
enough).

I changed the Environmental Variables in the advanced system setting
so R_LIBS  is C:\\RLIBRARY and restarted the server.

The commands :

.libPaths()

[1] "C:\\RLIBRARY""C:/PROGRA~1/R/R-211~1.0/library"



1. So this is a Terminal Server, not a network drive, right?



.Library

[1] "C:/PROGRA~1/R/R-211~1.0/library"


  When I try to run several packages it says It can not load them
(although many packages do work). So I tried
to install the  packages again (I deleted the old ones, downloaded a zip file
of the new ones  and this is what happened :


library(Hmisc)

Error in library.dynam(lib, package, package.lib) :
  shared library 'cluster' not found
Error: package/namespace load failed for 'Hmisc'



Strange, since cluster is a recommended package. Have you inspected the 
permissions in the directory of your R installation?





utils:::menuInstallPkgs()
trying URL 
'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.11/cluster_1.12.3.zip'
Content type 'application/zip' length 340188 bytes (332 Kb)
opened URL
downloaded 332 Kb
package 'cluster' successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\Users\Daisy
Englert\AppData\Local\Temp\2\RtmpWGZV31\downloaded_packages



library(cluster)

Error in get(Info[i, 1], envir = env) :
  internal error -3 in R_decompress1
Error: package/namespace load failed for 'cluster'


**But, I can fix this by setting the lib.loc


library(cluster, lib.loc =  "C:/PROGRA~1/R/R-211~1.0/library" )


**Unfortunately this is not where the updated packages went, the
updated package went to  "C:\\RLIBRARY" . I have messed something up
and I do not know how to fix it.


At first, look at write / read permissions in both libraries.

Uwe Ligges




Any advice would be welcome.


Thanks,
Daisy



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to use the function "glht" of multcomp package to test interaction?

2010-05-30 Thread Ivan Allaman

It's been a few weeks I'm racking my brains on how to use the function glht
the package multcomp to test interactions. Unfortunately, the creator of the
package forgot to put a sample in pdf package how to do it. I have looked in
several places, but found nothing. If someone for the love of God can help
me I'll be extremely grateful. The model is glm.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-the-function-glht-of-multcomp-package-to-test-interaction-tp2236315p2236315.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] subsetting

2010-05-30 Thread Patrick Burns

'&&' is scalar 'and' you want to use
the vector 'and' which is '&'.

On 30/05/2010 16:14, ANJAN PURKAYASTHA wrote:

Hi,
I have a data-frame,  r (column names below), that needs subsetting:
date, time, strain, gene, deltact

When I try to subset r by applying selection criteria on two columns I get
an empty data frame. For example I would like to extract all rows that have
time == 0h and strain == ROC.
So, t<- subset(r, (r$time == "0h"&&  r$strain == "ROC"), select= c(time,
strain, gene, deltact)) returns an empty data-frame.
Is it not possible to subset based on two criteria?
TIA
Anjan



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

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

2010-05-30 Thread David Winsemius


On May 30, 2010, at 11:14 AM, ANJAN PURKAYASTHA wrote:


Hi,
I have a data-frame,  r (column names below), that needs subsetting:
date, time, strain, gene, deltact

When I try to subset r by applying selection criteria on two columns  
I get
an empty data frame. For example I would like to extract all rows  
that have

time == 0h and strain == ROC.
So, t <- subset(r, (r$time == "0h" && r$strain == "ROC"),


At least one error is the use of && instead of &. "&&" will only  
return a single value whereas "&" is the correct operator to use when  
working with vectors.



select= c(time,
strain, gene, deltact)) returns an empty data-frame.
Is it not possible to subset based on two criteria?
TIA
Anjan

--
===
anjan purkayastha, phd.
research associate
fas center for systems biology,
harvard university
52 oxford street
cambridge ma
phone-703.740.6939
===

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


David Winsemius, MD
West Hartford, CT

__
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] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
Thanks, guys!

Alan


On Sun, May 30, 2010 at 5:35 AM, Marshall Feldman  wrote:
> Besides data.table, there's the hash package. It does not use data.frame
> type structures but is a bit more flexible.
>
> Marsh Feldman
>
> On 5/30/10 [May 30, 10] 6:00 AM, r-help-requ...@r-project.org wrote:
>>
>> Message: 40
>> Date: Sun, 30 May 2010 09:24:22 +0100
>> From: Patrick Burns
>> To:r-help@r-project.org,alan@gmail.com
>> Subject: Re: [R] Data Frame as Hash Table
>> Message-ID:<4c0220b6.7090...@pburns.seanet.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> You might want to investigate the 'data.table'
>> package.
>>
>> On 30/05/2010 09:03, Alan Lue wrote:
>>
>>>
>>> >  I'm interested in using a data frame as if it were a hash table.  For
>>> >  instance if I had the following,
>>> >
>>>

 >>  (d<- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))

>>>
>>> >      key        value
>>> >  1 0.5 -1.118665122
>>> >  2 1.0  0.465122921
>>> >  3 1.5 -0.529239211
>>> >  4 2.0 -0.147324638
>>> >  5 2.5 -1.531503795
>>> >  6 3.0 -0.002720434
>>> >
>>> >  Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
>>> >  to get -0.53.  How would one go about doing this?
>>> >
>>> >  Yours,
>>> >  Alan Lue
>>> >
>>> >  __
>>> >  r-h...@r-project.org  mailing list
>>> >  https://stat.ethz.ch/mailman/listinfo/r-help
>>> >  PLEASE do read the posting
>>> > guidehttp://www.R-project.org/posting-guide.html
>>> >  and provide commented, minimal, self-contained, reproducible code.
>>> >
>>>
>>
>> -- Patrick Burns pbu...@pburns.seanet.com http://www.burns-stat.com (home
>> of 'Some hints for the R beginner' and 'The R Inferno')
>
>



-- 
Alan Lue
Master of Financial Engineering
UCLA Anderson School of Management

__
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] extracat , JGR, iWidgets install problems

2010-05-30 Thread Uwe Ligges



On 26.05.2010 15:28, Michael Friendly wrote:

[Environment: Win XP, R 2.10.1]

I'm trying to install the packages JGR and iWidgets required by the
extracat package to make the interactive plots
in the package work. I've tried various things, but nothing seems to
work. Here is my most recent attempt,
followed by my sessionInfo().

Does anyone have any suggestions how to make this work?

 >
 > library(extracat)
Loading required package: reshape
Loading required package: plyr
Loading required package: grid
Loading required package: MASS
 > ?irmb
starting httpd help server ... done
 > data(housing)
 > # example 1
 > irmb(~Type+Infl+Cont+Sat,dset=housing,expected = TRUE,
+ eqwidth=FALSE,base=0.2,mult=2,lab.tv=TRUE,abbr=TRUE)
iWidgets requires 'JGR' in order to run correctly.
Please visit
http://www.rosuda.org/software/
to download it.>
 > utils:::menuInstallPkgs()
trying URL
'http://probability.ca/cran/bin/windows/contrib/2.10/JGR_1.7-1.zip'
Content type 'application/zip' length 483687 bytes (472 Kb)
opened URL
downloaded 472 Kb

package 'JGR' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\default\Local
Settings\Temp\RtmpNbWm3Y\downloaded_packages
 > data(housing)
 > # example 1
 > irmb(~Type+Infl+Cont+Sat,dset=housing,expected = TRUE,
+ eqwidth=FALSE,base=0.2,mult=2,lab.tv=TRUE,abbr=TRUE)
iWidgets requires 'JGR' in order to run correctly.
Please visit
http://www.rosuda.org/software/
to download it.>



You need some JGR.exe from that URL, the package alone does not help. 
Hence just do what the authors of that package wrote in their message:


Please visit
http://www.rosuda.org/software/
to download it.

Best wishes,
Uwe






 > sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32

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] grid stats graphics grDevices utils datasets methods [8] base
other attached packages:
[1] extracat_1.0-1 MASS_7.3-6 reshape_0.8.3 plyr_0.1.9
loaded via a namespace (and not attached):
[1] tools_2.10.1
 >



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-30 Thread Alan Lue
Is there a performance advantage to doing this, as opposed to growing
the vector within the loop?  I suppose R could have to dynamically
reallocate memory at some point?

Alan


2010/5/30 Uwe Ligges :
>
>
> On 26.05.2010 08:52, Alan Lue wrote:
>>
>> Come to think of it, we can't save the output of each invocation and
>> concatenate it later, since we need the output as input for the next
>> iteration.
>
>
> Yes, but you can do it a bit cleverer than before by initializing to the
> fill length as in:
>
> r.seq <- numeric(nrow(d))
> r.seq[1] <- 2 * (1 / d$Dt[1] - 1)
> for (i in 2:nrow(d)) {
>  r.seq[i] <- uniroot(bdt.deviation, interval = c(0, 1),
>                D.T = d$Dt[i], r.prior = r.seq[i-1])$root
> }
>
> Uwe Ligges
>
>
>
>> Alan
>>
>>
>> On Tue, May 25, 2010 at 11:43 PM, Alan Lue  wrote:
>>>
>>> Since `for' loops are slow in R, and since `apply' functions are
>>> faster, I was wondering whether there were a way to use an apply
>>> function—or to otherwise avoid using a loop—when iterating over a
>>> statement that updates its input.
>>>
>>> For example, here's some such code:
>>>
>>> r.seq<- 2 * (1 / d$Dt[1] - 1)
>>> for (i in 2:nrow(d)) {
>>>  rf<- uniroot(bdt.deviation, interval=c(0, 1), D.T=d$Dt[i],
>>> r.prior=r.seq)
>>>  r.seq<- append(r.seq, rf$root)
>>> }
>>>
>>> The call to `uniroot()' both updates `r.seq' and reads it as input.
>>> We could save the output of each invocation of `uniroot()' and
>>> concatenate it later, but is there a better way to write this (i.e.,
>>> to execute more quickly) while updating `r.seq' in each iteration?
>>>
>>> Alan
>>>
>>
>>
>>
>



-- 
Alan Lue
Master of Financial Engineering
UCLA Anderson School of Management

__
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 on the iPhone/iPad? Not so much....a GPL violation

2010-05-30 Thread Tal Galili
Android + rattle:
http://www.r-bloggers.com/data-mining-through-the-android/

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sat, May 29, 2010 at 10:25 PM, Lanre Okusanya
wrote:

> Android FTW?
>
> On Sat, May 29, 2010 at 11:12 AM, Marc Schwartz 
> wrote:
> > Hi all,
> >
> > There have been posts in the past about R being made available for the
> iPhone and perhaps more logically now, on the iPad. My recollection is that
> the hurdle discussed in the past was primarily a lack of access to a CLI on
> the iPhone's variant of OSX, compelling the development of a GUI interface
> for R specifically for these devices. R itself, can be successfully compiled
> with the iPhone development tools.
> >
> > Well, now there is another, clearly more profound reason.
> >
> > The FSF has recently communicated with Apple on the presence of a GPL
> application (GNU Go) in the iTunes store because the iTunes TOS infringes
> upon the GPL. Apple, given a choice, elected to remove the application,
> rather than amending their TOS.
> >
> > The FSF also informed the developers of the iPhone port of GNU Go that
> their distribution is in violation of the GPL. R Core and any others
> considering an iPhone/iPad port of R, if you are not already aware, take
> note...
> >
> > More information is here:
> >
> >  http://www.fsf.org/news/2010-05-app-store-compliance/
> >
> > with an update here:
> >
> >
> http://www.fsf.org/news/blogs/licensing/more-about-the-app-store-gpl-enforcement
> >
> > So, until Apple amends their TOS agreement, it looks like there will be
> no GPL apps available for the iPhone/iPad, since the only way to make
> applications available for these platforms is via the iTunes store (unless
> you unlock the device). Hence, no R for these devices in the foreseeable
> future.
> >
> > BTW, I am posting this as an FYI, not as a catalyst for a discussion on
> the political aspects of this situation. So please, let's not go there...
>  :-)
> >
> > Regards,
> >
> > Marc Schwartz
> >
> > __
> > 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.
>

[[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] Calling fft from C

2010-05-30 Thread Gunnar Hellmund
Hi

I have made a R function 'convolve2' for convolution of two real
valued vectors based on Rs 'convolve' with option type="open" - see
below.
(exp.length and irf.length are variables set in another part of the program)

I wish to implement the function convolve2 in C and use it in a
function used from R with .Call - e.g. I need to call fft in C.
All I can find in the source code is do_fft in Internals.h - but how
do I use do_fft? Or should I call another C routine (and how)?

How do I solve the problem in the most appropriate way?

convolve2=function2(x,y)
{
x<- c(rep.int(0,exp.length-1),x)
n <- length(y<-c(y, rep.int(0, irf.length -1)))
x <- fft(fft(x) * Conj(fft(y)), inverse=TRUE)
return(Re(x)/n)
}

-- 
Best wishes/bedste hilsner

Gunnar Hellmund

cand. scient., PhD
http://staff.pubhealth.ku.dk/~guhe/

---
“If everyone is thinking alike, then somebody isn't thinking.”

__
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 fft from C

2010-05-30 Thread Gabor Grothendieck
The Writing R Extensions manual specifically uses convolve as an
example of calling C from R.

On Sun, May 30, 2010 at 2:08 PM, Gunnar Hellmund  wrote:
> Hi
>
> I have made a R function 'convolve2' for convolution of two real
> valued vectors based on Rs 'convolve' with option type="open" - see
> below.
> (exp.length and irf.length are variables set in another part of the program)
>
> I wish to implement the function convolve2 in C and use it in a
> function used from R with .Call - e.g. I need to call fft in C.
> All I can find in the source code is do_fft in Internals.h - but how
> do I use do_fft? Or should I call another C routine (and how)?
>
> How do I solve the problem in the most appropriate way?
>
> convolve2=function2(x,y)
> {
> x<- c(rep.int(0,exp.length-1),x)
> n <- length(y<-c(y, rep.int(0, irf.length -1)))
> x <- fft(fft(x) * Conj(fft(y)), inverse=TRUE)
> return(Re(x)/n)
> }
>
> --
> Best wishes/bedste hilsner
>
> Gunnar Hellmund
>
> cand. scient., PhD
> http://staff.pubhealth.ku.dk/~guhe/
>
> ---
> “If everyone is thinking alike, then somebody isn't thinking.”
>
> __
> 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] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-30 Thread Uwe Ligges



On 30.05.2010 19:23, Alan Lue wrote:

Is there a performance advantage to doing this, as opposed to growing
the vector within the loop?  I suppose R could have to dynamically
reallocate memory at some point?


Right, but that takes time since memory management is always expensive 
(and this way you need memory management in each iteration rather than 
once) and your objects may be copied around all the time.


Uwe Ligges





Alan


2010/5/30 Uwe Ligges:



On 26.05.2010 08:52, Alan Lue wrote:


Come to think of it, we can't save the output of each invocation and
concatenate it later, since we need the output as input for the next
iteration.



Yes, but you can do it a bit cleverer than before by initializing to the
fill length as in:

r.seq<- numeric(nrow(d))
r.seq[1]<- 2 * (1 / d$Dt[1] - 1)
for (i in 2:nrow(d)) {
  r.seq[i]<- uniroot(bdt.deviation, interval = c(0, 1),
D.T = d$Dt[i], r.prior = r.seq[i-1])$root
}

Uwe Ligges




Alan


On Tue, May 25, 2010 at 11:43 PM, Alan Luewrote:


Since `for' loops are slow in R, and since `apply' functions are
faster, I was wondering whether there were a way to use an apply
function—or to otherwise avoid using a loop—when iterating over a
statement that updates its input.

For example, here's some such code:

r.seq<- 2 * (1 / d$Dt[1] - 1)
for (i in 2:nrow(d)) {
  rf<- uniroot(bdt.deviation, interval=c(0, 1), D.T=d$Dt[i],
r.prior=r.seq)
  r.seq<- append(r.seq, rf$root)
}

The call to `uniroot()' both updates `r.seq' and reads it as input.
We could save the output of each invocation of `uniroot()' and
concatenate it later, but is there a better way to write this (i.e.,
to execute more quickly) while updating `r.seq' in each iteration?

Alan













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

2010-05-30 Thread sayan dasgupta

try
 t <- subset(r, (r$time == "0h" & r$strain == "ROC"), select= c(time,strain,
gene, deltact)) 
Do ?"&" to understand the difference between  & and && . 



ANJAN PURKAYASTHA wrote:
> 
> Hi,
> I have a data-frame,  r (column names below), that needs subsetting:
> date, time, strain, gene, deltact
> 
> When I try to subset r by applying selection criteria on two columns I get
> an empty data frame. For example I would like to extract all rows that
> have
> time == 0h and strain == ROC.
> So, t <- subset(r, (r$time == "0h" && r$strain == "ROC"), select= c(time,
> strain, gene, deltact)) returns an empty data-frame.
> Is it not possible to subset based on two criteria?
> TIA
> Anjan
> 
> -- 
> ===
> anjan purkayastha, phd.
> research associate
> fas center for systems biology,
> harvard university
> 52 oxford street
> cambridge ma
> phone-703.740.6939
> ===
> 
>   [[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.
> 
> 

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How can I fit a fixed-effect linear model or generalized linear model with method="ml"?

2010-05-30 Thread Sherrie Jin
Thanks for your reply.
I should have made my question clearer. Yes, I want to estimate standard
errors with the method "ml" rather than "reml". According to your
suggestion, I looked at the source code for "summary.glm". Now I know it's
"summary.glm" rather than "glm"  itself estimates the standard errors. So it
must be "summary.glm" that uses "reml" as a default to compute standard
errors.

But when I read the source code for "summary.glm", I'm still confused. How
can I modify the code to re-compute the standard errors with method "reml"?
I'm pretty new to R and haven't write any code by myself. Thanks.

On Sun, May 30, 2010 at 8:01 AM, Prof Brian Ripley wrote:

> On Sun, 30 May 2010, Achim Zeileis wrote:
>
>  On Sun, 30 May 2010, Sherrie Jin wrote:
>>
>>  Hi,
>>>
>>> I want to fit a linear model (without any random effect) with method
>>> "ml". I
>>> tried to use "glm"  I found that there is no option for "ml" or "reml"
>>> and
>>> the default one is "reml". THen I tried to use "lme" but it requires a
>>> random effect. How can I fix this problem?
>>>
>>> Of course, it's not necessary to be "glm" or "lme", I am just looking for
>>> commands which allow me to fit a linear model (without any random effect)
>>> with "ml" method. And later I may also need to fit generalized linear
>>> models
>>> (probit, gamma and negtive binomial) with method "ml". Any suggestions?
>>>
>>
>> glm() always performs Maximum Likelihood estimation and thus has no
>> method="ml" argument.
>>
>
> ML of what?  For the coefficients, yes.  However, for parameters in the
> distribution estimated via the dispersion, not usually and not in the case
> of sigma^2 for the gaussian.
>
> Strictly, neither lm() not glm() estimate the dispersion, but their
> summary() methods do.  However, you can use your own estimate of dispersion
> and supply it to summary.glm (but not summary.lm): you can also use gls()
> from package nlme.  MASS (the book) discusses how to get MLE for a gamma
> glm, for example, and MASS::glm.nb fits a negative binomial glm with
> parameters estimated by ML.
>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>

[[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] Calling fft from C

2010-05-30 Thread Gunnar Hellmund
Thanks for the reply, but ...

No, I am not interested in the convolution function defined in the
R-extensions manual.
I want to use a fast fourier transform version implemented in C
returning values to another C function.
So the question is: How do I call the fft supplied by R in C? (just
like it is possible to use other R functions in C using #include
 etc)

Best,
Gunnar

On Sun, May 30, 2010 at 8:12 PM, Gabor Grothendieck
 wrote:
> The Writing R Extensions manual specifically uses convolve as an
> example of calling C from R.
>
> On Sun, May 30, 2010 at 2:08 PM, Gunnar Hellmund  wrote:
>> Hi
>>
>> I have made a R function 'convolve2' for convolution of two real
>> valued vectors based on Rs 'convolve' with option type="open" - see
>> below.
>> (exp.length and irf.length are variables set in another part of the program)
>>
>> I wish to implement the function convolve2 in C and use it in a
>> function used from R with .Call - e.g. I need to call fft in C.
>> All I can find in the source code is do_fft in Internals.h - but how
>> do I use do_fft? Or should I call another C routine (and how)?
>>
>> How do I solve the problem in the most appropriate way?
>>
>> convolve2=function2(x,y)
>> {
>> x<- c(rep.int(0,exp.length-1),x)
>> n <- length(y<-c(y, rep.int(0, irf.length -1)))
>> x <- fft(fft(x) * Conj(fft(y)), inverse=TRUE)
>> return(Re(x)/n)
>> }
>>
>> --
>> Best wishes/bedste hilsner
>>
>> Gunnar Hellmund
>>
>> cand. scient., PhD
>> http://staff.pubhealth.ku.dk/~guhe/
>>
>> ---
>> “If everyone is thinking alike, then somebody isn't thinking.”
>>
>> __
>> 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.
>>
>



-- 
Best wishes/bedste hilsner

Gunnar Hellmund

PhD, Scientific Assistant
http://staff.pubhealth.ku.dk/~guhe/

---
“If everyone is thinking alike, then somebody isn't thinking.”

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question about package coin

2010-05-30 Thread Bryan Keller
Thanks for the reply, that answers my question.  

I'm actually interested in using the Welch t in a randomization model framework 
where the variance heterogeneity is introduced by the treatment effect and is 
not present under the null hypothesis of no differential treatment effect.  In 
other words, the test would be valid because exchangeability is satisfied by 
random assignment of experimental units to treatments.

Much thanks to you and your colleagues for providing and maintaining this 
fantastic package.

Bryan

On 05/30/10, Achim Zeileis   wrote:

> On Sat, 29 May 2010, Bryan Keller wrote:
> 
> >Anyone know if coin can run a permutation test based on a (user-defined) 
> >statistic other than the mean difference?  The function independence_test 
> >does the permutation t-test via difference in means.
> 
> ...by default, that is.
> 
> >I'm wondering if it's possible to use independence_test to run a permutation 
> >test for some other statistic than the difference in means.
> 
> Yes.
> 
> >For example, I'd like to run a permutation test using Welch's t instead of 
> >the difference in means.
> 
> No.
> 
> >The help for independence_test reveals that "teststat" is an argument which 
> >allows for specification of standardized scalar test statistic, a maximum 
> >type statistic, or a quadratic form.  I cannot, however, figure out if it is 
> >possible to specify how the statistic should be calculated by, for example, 
> >supplying a function.
> 
> Have you considered reading the references mentioned in the documentation.
> I suggest you start with
>   vignette("LegoCondInf", package = "coin")
> which essentially is the "The American Statistician" paper mentioned in the 
> help pages.
> 
> The general framework is that the user can specify data transformations for 
> which an independence test is computed. Depending on the data transformation, 
> this can be a t test, chi-squared test, Wilcoxon test, Kruskal-Wallis test, 
> and many many more.
> 
> Furthermore, note that the null hypothesis is always permutation invariance. 
> Hence, the Welch test does not fit into this framework because under the null 
> it assumes same means but with potentially different variances, which is not 
> invariant with respect to permutations.
> 
> Therefore, the default t statistic in independence_test() computes a mean 
> difference standardized by the one-sample standard deviation (with only a 
> single mean!). This is neither the pooled two-sample standard deviation (with 
> two means) that t.test(..., var.equal = TRUE) uses nor the two-sample 
> standard deviation (with two means and two standard deviations) of the Welch 
> test.
> 
> hth,
> Z
-- 
---
Bryan Keller, Doctoral Student/Project Assistant
Educational Psychology - Quantitative Methods
The University of Wisconsin - Madison

__
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] Gamma regression doesn't converge

2010-05-30 Thread Sherrie Jin
When I ran a Gamma regression in SAS, the algorithm converged. When I ran it
in R, it keeps uncoverged even if I used 1 iterations. What was wrong?
I used the following code in R:
glm(y ~ x1 x2 x3, control=glm.control(maxit=1), data,
family=Gamma(link="log"))

[[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] [R-pkgs] New package RSQLite.extfuns and minor upgrade for RSQLite

2010-05-30 Thread Seth Falcon
RSQLite.extfuns provides SQLite extension functions for use with
RSQLite.  The package is a wrapper of extension functions written by
Liam Healy and made available through the SQLite website
(http://www.sqlite.org/contrib).

You can make the extension functions available on a per db connection
basis like this:

library("RSQLite.extfuns")
db <- dbConnect(SQLite(), dbname = ":memory:")
init_extensions(db)


The extension functions provided by the package include:

Math: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference,
degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp,
log, log10, power, sign, sqrt, square, ceil, floor, pi.

String: replicate, charindex, leftstr, rightstr, ltrim, rtrim, trim,
replace, reverse, proper, padl, padr, padc, strfilter.

Aggregate: stdev, variance, mode, median, lower_quartile, upper_quartile.


RSQLite has been modified to provide the SQLite header files in the
installed include directory so that RSQLite.extfuns (and other
packages wishing to provide SQLite extension functions) can use
LinkingTo.  The default value of loadable.extensions is now TRUE.

+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/

___
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] Calling fft from C

2010-05-30 Thread biostatmatt
The fft in R has the following C call chain

file  purpose
src/main/names.c  links R function "fft" to do_fft
src/main/fourier.cdo_fft calls fft_factor, fft_work
src/appl/fft.chome of fft_factor, fft_work

If you want to use the fft at a low level, you should use fft_factor and
fft_work. You can read about these functions in the fft.c file. In order
to use these functions in an R package, you must use the definitions in
the R/R_ext/Applic.h header. 

However, I believe the time limiting factor in an fft call is the work
performed by the fft_factor and fft_work functions. Hence, you are not
likely to save much time by calling them directly.

BTW, I think this sort of question is better suited for the R-devel
mailing list.

Matt Shotwell
Graduate Student
Division of Biostatistics and Bioinformatics 
Medical University of South Carolina

On Sun, 2010-05-30 at 21:35 +0200, Gunnar Hellmund wrote:
> Thanks for the reply, but ...
> 
> No, I am not interested in the convolution function defined in the
> R-extensions manual.
> I want to use a fast fourier transform version implemented in C
> returning values to another C function.
> So the question is: How do I call the fft supplied by R in C? (just
> like it is possible to use other R functions in C using #include
>  etc)
> 
> Best,
> Gunnar
> 
> On Sun, May 30, 2010 at 8:12 PM, Gabor Grothendieck
>  wrote:
> > The Writing R Extensions manual specifically uses convolve as an
> > example of calling C from R.
> >
> > On Sun, May 30, 2010 at 2:08 PM, Gunnar Hellmund  
> > wrote:
> >> Hi
> >>
> >> I have made a R function 'convolve2' for convolution of two real
> >> valued vectors based on Rs 'convolve' with option type="open" - see
> >> below.
> >> (exp.length and irf.length are variables set in another part of the 
> >> program)
> >>
> >> I wish to implement the function convolve2 in C and use it in a
> >> function used from R with .Call - e.g. I need to call fft in C.
> >> All I can find in the source code is do_fft in Internals.h - but how
> >> do I use do_fft? Or should I call another C routine (and how)?
> >>
> >> How do I solve the problem in the most appropriate way?
> >>
> >> convolve2=function2(x,y)
> >> {
> >> x<- c(rep.int(0,exp.length-1),x)
> >> n <- length(y<-c(y, rep.int(0, irf.length -1)))
> >> x <- fft(fft(x) * Conj(fft(y)), inverse=TRUE)
> >> return(Re(x)/n)
> >> }
> >>
> >> --
> >> Best wishes/bedste hilsner
> >>
> >> Gunnar Hellmund
> >>
> >> cand. scient., PhD
> >> http://staff.pubhealth.ku.dk/~guhe/
> >>
> >> ---
> >> “If everyone is thinking alike, then somebody isn't thinking.”
> >>
> >> __
> >> 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] Gamma regression doesn't converge

2010-05-30 Thread Joshua Wiley
On Sun, May 30, 2010 at 12:16 PM, Sherrie Jin  wrote:
> When I ran a Gamma regression in SAS, the algorithm converged. When I ran it
> in R, it keeps uncoverged even if I used 1 iterations. What was wrong?
> I used the following code in R:
> glm(y ~ x1 x2 x3, control=glm.control(maxit=1), data,
> family=Gamma(link="log"))

What is the actual glm expression you tried to run?  Does it not
converge for just one formula or when you try different formulas/data?

Josh

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



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.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] Building a list

2010-05-30 Thread Noah Silverman
Hello,

I need to build a "list of lists"

We have 20 groups we are generating MCMC samples for.  There are 10
coefficients, and 1 MCMC iterations.

I would like to store each iteration by-group in a list.  My problem is
with the first iteration.

Here is a toy example:

Chain <- list()
for (j in 1:1){
coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
Chain[[j]] <- rbind(Chain[[j]], coef)
}

This returns an error, UNLESS I  initialize the first row of Chain[[j]]
with something.

The idea is that for any group, I can quickly extract, plot, average,
etc the values for each coefficient.

for example:

Chain[[5]][,3] will give me all 10,000 values of coefficient 3 for group
5. 

Again, this seems to work, but I can't initialize the chain with a
random value as it will cause problems with the data summary later.
(Each row in Chain[[j]] will be out of sync by 1, subsequently all
summary and plotting work will have to account for this - it can get
messy in a large program.)

Is there an easier way to do this?  Am I missing something?

__
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] Building a list

2010-05-30 Thread Joshua Wiley
Hello Noah,

Does this work for you?

Chain <- vector("list", 1)
for (j in 1:1){
   coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
   Chain[[j]] <- rbind(Chain[[j]], coef)

If it does, this has the additional advantage that it tends to be
faster to initialize the list at size rather than expanding it as
needed.

HTH,

Josh

On Sun, May 30, 2010 at 2:52 PM, Noah Silverman  wrote:
> Hello,
>
> I need to build a "list of lists"
>
> We have 20 groups we are generating MCMC samples for.  There are 10
> coefficients, and 1 MCMC iterations.
>
> I would like to store each iteration by-group in a list.  My problem is
> with the first iteration.
>
> Here is a toy example:
>
> Chain <- list()
> for (j in 1:1){
>    coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>    Chain[[j]] <- rbind(Chain[[j]], coef)
> }
>
> This returns an error, UNLESS I  initialize the first row of Chain[[j]]
> with something.
>
> The idea is that for any group, I can quickly extract, plot, average,
> etc the values for each coefficient.
>
> for example:
>
> Chain[[5]][,3] will give me all 10,000 values of coefficient 3 for group
> 5.
>
> Again, this seems to work, but I can't initialize the chain with a
> random value as it will cause problems with the data summary later.
> (Each row in Chain[[j]] will be out of sync by 1, subsequently all
> summary and plotting work will have to account for this - it can get
> messy in a large program.)
>
> Is there an easier way to do this?  Am I missing something?
>
> __
> 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.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Building a list

2010-05-30 Thread Noah Silverman
That would be great, except I just realized I made a typo when sending
my code. 

I'm tracking 20 coefficents for 10 groups.  So I need a "top" list of 10
groups.  Then each of the 10,000 samples for each of the 20 coefficients.

It should be more like this:

for(j in 1:1){
for(g in groups){
coef <- c(1,2,3,4,5,6,7,8,9,10) #would be actual MCMC samples
Chain[[g]] <- rbind(Chain[[g]], coef)
}
}

So, there are 10 lists in "Chain"  (One for each group.)  Each list is
then a matrix/data.frame of values for each coef.  (Hence the "rbind" in
my code.)

R gives me an error about the subscript, as Chain[[g]] is empty for the
first iteration.




On 5/30/10 3:00 PM, Joshua Wiley wrote:
> Hello Noah,
>
> Does this work for you?
>
> Chain <- vector("list", 1)
> for (j in 1:1){
>coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>Chain[[j]] <- rbind(Chain[[j]], coef)
>
> If it does, this has the additional advantage that it tends to be
> faster to initialize the list at size rather than expanding it as
> needed.
>
> HTH,
>
> Josh
>
> On Sun, May 30, 2010 at 2:52 PM, Noah Silverman  
> wrote:
>   
>> Hello,
>>
>> I need to build a "list of lists"
>>
>> We have 20 groups we are generating MCMC samples for.  There are 10
>> coefficients, and 1 MCMC iterations.
>>
>> I would like to store each iteration by-group in a list.  My problem is
>> with the first iteration.
>>
>> Here is a toy example:
>>
>> Chain <- list()
>> for (j in 1:1){
>>coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>>Chain[[j]] <- rbind(Chain[[j]], coef)
>> }
>>
>> This returns an error, UNLESS I  initialize the first row of Chain[[j]]
>> with something.
>>
>> The idea is that for any group, I can quickly extract, plot, average,
>> etc the values for each coefficient.
>>
>> for example:
>>
>> Chain[[5]][,3] will give me all 10,000 values of coefficient 3 for group
>> 5.
>>
>> Again, this seems to work, but I can't initialize the chain with a
>> random value as it will cause problems with the data summary later.
>> (Each row in Chain[[j]] will be out of sync by 1, subsequently all
>> summary and plotting work will have to account for this - it can get
>> messy in a large program.)
>>
>> Is there an easier way to do this?  Am I missing something?
>>
>> __
>> 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] Building a list

2010-05-30 Thread jim holtman
Let initialize Chain:

Chain <- vector('list', 5)
groups <- 1:5
for(j in 1:1){

   for(g in groups){

   coef <- c(1,2,3,4,5,6,7,8,9,10) #would be actual MCMC samples

   Chain[[g]] <- rbind(Chain[[g]], coef)
   }
}


On Sun, May 30, 2010 at 6:05 PM, Noah Silverman  wrote:
> That would be great, except I just realized I made a typo when sending
> my code.
>
> I'm tracking 20 coefficents for 10 groups.  So I need a "top" list of 10
> groups.  Then each of the 10,000 samples for each of the 20 coefficients.
>
> It should be more like this:
>
> for(j in 1:1){
>    for(g in groups){
>        coef <- c(1,2,3,4,5,6,7,8,9,10) #would be actual MCMC samples
>        Chain[[g]] <- rbind(Chain[[g]], coef)
>    }
> }
>
> So, there are 10 lists in "Chain"  (One for each group.)  Each list is
> then a matrix/data.frame of values for each coef.  (Hence the "rbind" in
> my code.)
>
> R gives me an error about the subscript, as Chain[[g]] is empty for the
> first iteration.
>
>
>
>
> On 5/30/10 3:00 PM, Joshua Wiley wrote:
>> Hello Noah,
>>
>> Does this work for you?
>>
>> Chain <- vector("list", 1)
>> for (j in 1:1){
>>    coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>>    Chain[[j]] <- rbind(Chain[[j]], coef)
>>
>> If it does, this has the additional advantage that it tends to be
>> faster to initialize the list at size rather than expanding it as
>> needed.
>>
>> HTH,
>>
>> Josh
>>
>> On Sun, May 30, 2010 at 2:52 PM, Noah Silverman  
>> wrote:
>>
>>> Hello,
>>>
>>> I need to build a "list of lists"
>>>
>>> We have 20 groups we are generating MCMC samples for.  There are 10
>>> coefficients, and 1 MCMC iterations.
>>>
>>> I would like to store each iteration by-group in a list.  My problem is
>>> with the first iteration.
>>>
>>> Here is a toy example:
>>>
>>> Chain <- list()
>>> for (j in 1:1){
>>>    coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>>>    Chain[[j]] <- rbind(Chain[[j]], coef)
>>> }
>>>
>>> This returns an error, UNLESS I  initialize the first row of Chain[[j]]
>>> with something.
>>>
>>> The idea is that for any group, I can quickly extract, plot, average,
>>> etc the values for each coefficient.
>>>
>>> for example:
>>>
>>> Chain[[5]][,3] will give me all 10,000 values of coefficient 3 for group
>>> 5.
>>>
>>> Again, this seems to work, but I can't initialize the chain with a
>>> random value as it will cause problems with the data summary later.
>>> (Each row in Chain[[j]] will be out of sync by 1, subsequently all
>>> summary and plotting work will have to account for this - it can get
>>> messy in a large program.)
>>>
>>> Is there an easier way to do this?  Am I missing something?
>>>
>>> __
>>> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] sanity-checking plans for glmer

2010-05-30 Thread Mitchell Maltenfort
Having briefly fallen for the notion that the negative.binomial family
in MASS could be used in glmer, I want to use these lists for a sanity
check on my final (?) plans.

I want to use glmer for logistic regression and for poisson regression
on a data set of 10,000 items.  There will be two crossed random
effects.

For the logistic regression, I want odds ratios with confidence
intervals.For the poisson regression, I'd want multiplying factors,
again with confidence intervals. Either way, my co-authors will want
p-values.  I'd also like to examine whether the two random effects
have comparable variation, and whether any of them are provide odds
ratios or multipliers that are are statistically distinct from 1.0 .

Can I use the s.e's and p-values (from z-statistics) provided by
glmer?  Or should I use the pvals.fnc function from the language R
package?

Are there any holes in my plans I'm not seeing?

Thanks in advance.

__
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] Selecting first 7 elements

2010-05-30 Thread Kang Min
Sorry I made a mistake in my code, lapply(x, "[", 8:14) works fine
now. Thanks.

On May 30, 10:55 pm, Jorge Ivan Velez 
wrote:
> HiKang,
>
> Try either
>
> lapply(x, "[", 8:14)   # Erik Iverson's method
>
> or
>
> lapply(x, function(x) x[8:14])
>
> HTH,
> Jorge
>
>
>
>
>
> On Sun, May 30, 2010 at 9:44 AM,KangMin<> wrote:
> > Hmm x[8:14] didn't work. Yes Iverson's method worked, I wanted the
> > whole list, with 7 elements in each vector.
>
> > Now I want the whole list as well, but with the 8th to 14th element.
>
> > On May 30, 7:47 pm, David Winsemius  wrote:
> > > On May 29, 2010, at 11:37 PM,KangMinwrote:
>
> > > > What if I want to select the 8th to 14th element of the list? I tried
> > > > to use "[" again, but it doesn't work.
>
> > > x[8:14]
>
> > > (And I could not get Iverson's earlier method to work properly on a
> > > long list. It just returned the whole list. Did it work properly for
> > > you? )
>
> > > --
> > > David.
>
> > >  "[" is a function, and you want to use it on each element of the
> > >  list,
> > >  so...
>
> > >  lapply(x, "[", c(1:7))
>
> > > >>> and the call to c() is of course not necessary, since ":" will
> > > >>> generate a vector.
>
> > > >>> __
> > > >>> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> > > >>> listinfo/r-help
> > > >>> PLEASE do read the posting guidehttp://
> >www.R-project.org/posting-guide.html
> > > >>> and provide commented, minimal, self-contained, reproducible code.
>
> > > >>> --
> > > >>> You received this message because you are subscribed to the Google
> > > >>> Groups "R-help-archive" group.
> > > >>> To post to this group, send email to r-help-
> > > >>> arch...@googlegroups.com.
> > > >>> To unsubscribe from this group, send email to
> > r-help-archive+unsubscr...@googlegroups.com > oglegroups.com>
> > > >>> .
> > > >>> For more options, visit this group athttp://
> > groups.google.com/group/r-help-archive?hl=en
> > > >>> .
>
> > > >> __
> > > >> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/
> > > >> listinfo/r-help
> > > >> PLEASE do read the posting guidehttp://
> >www.R-project.org/posting-guide.html
> > > >> and provide commented, minimal, self-contained, reproducible code.
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > > >> Groups "R-help-archive" group.
> > > >> To post to this group, send email to r-help-arch...@googlegroups.com.
> > > >> To unsubscribe from this group, send email to
> > r-help-archive+unsubscr...@googlegroups.com > oglegroups.com>
> > > >> .
> > > >> For more options, visit this group athttp://
> > groups.google.com/group/r-help-archive?hl=en
> > > >> .
>
> > > > __
> > > > r-h...@r-project.org mailing list
> > > >https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guidehttp://
> >www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
>
> > > David Winsemius, MD
> > > West Hartford, CT
>
> > > __
> > > r-h...@r-project.org mailing listhttps://
> > stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guidehttp://
> >www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
>
> > __
> > r-h...@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-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] Building a list

2010-05-30 Thread Noah Silverman
Nice.

Thanks!

-N


On 5/30/10 3:16 PM, jim holtman wrote:
> Let initialize Chain:
>
> Chain <- vector('list', 5)
> groups <- 1:5
> for(j in 1:1){
>
>for(g in groups){
>
>coef <- c(1,2,3,4,5,6,7,8,9,10) #would be actual MCMC samples
>
>Chain[[g]] <- rbind(Chain[[g]], coef)
>}
> }
>
>
> On Sun, May 30, 2010 at 6:05 PM, Noah Silverman  
> wrote:
>   
>> That would be great, except I just realized I made a typo when sending
>> my code.
>>
>> I'm tracking 20 coefficents for 10 groups.  So I need a "top" list of 10
>> groups.  Then each of the 10,000 samples for each of the 20 coefficients.
>>
>> It should be more like this:
>>
>> for(j in 1:1){
>>for(g in groups){
>>coef <- c(1,2,3,4,5,6,7,8,9,10) #would be actual MCMC samples
>>Chain[[g]] <- rbind(Chain[[g]], coef)
>>}
>> }
>>
>> So, there are 10 lists in "Chain"  (One for each group.)  Each list is
>> then a matrix/data.frame of values for each coef.  (Hence the "rbind" in
>> my code.)
>>
>> R gives me an error about the subscript, as Chain[[g]] is empty for the
>> first iteration.
>>
>>
>>
>>
>> On 5/30/10 3:00 PM, Joshua Wiley wrote:
>> 
>>> Hello Noah,
>>>
>>> Does this work for you?
>>>
>>> Chain <- vector("list", 1)
>>> for (j in 1:1){
>>>coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
>>>Chain[[j]] <- rbind(Chain[[j]], coef)
>>>
>>> If it does, this has the additional advantage that it tends to be
>>> faster to initialize the list at size rather than expanding it as
>>> needed.
>>>
>>> HTH,
>>>
>>> Josh
>>>
>>> On Sun, May 30, 2010 at 2:52 PM, Noah Silverman  
>>> wrote:
>>>
>>>   
 Hello,

 I need to build a "list of lists"

 We have 20 groups we are generating MCMC samples for.  There are 10
 coefficients, and 1 MCMC iterations.

 I would like to store each iteration by-group in a list.  My problem is
 with the first iteration.

 Here is a toy example:

 Chain <- list()
 for (j in 1:1){
coef <- c(1,2,3,4,5,6,7,8,9,10)  #would be actual MCMC samples
Chain[[j]] <- rbind(Chain[[j]], coef)
 }

 This returns an error, UNLESS I  initialize the first row of Chain[[j]]
 with something.

 The idea is that for any group, I can quickly extract, plot, average,
 etc the values for each coefficient.

 for example:

 Chain[[5]][,3] will give me all 10,000 values of coefficient 3 for group
 5.

 Again, this seems to work, but I can't initialize the chain with a
 random value as it will cause problems with the data summary later.
 (Each row in Chain[[j]] will be out of sync by 1, subsequently all
 summary and plotting work will have to account for this - it can get
 messy in a large program.)

 Is there an easier way to do this?  Am I missing something?

 __
 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] Data Frame as Hash Table

2010-05-30 Thread Don MacQueen
If you only need a single variable (in this case value), and just 
want to refer to it by the "key", there are other options.


   value <- rnorm(6)
   names(value) <- format(seq(0.5,3,0.5))

value['1.5']

But do watch out for numerical precision in the output of seq() if 
your vector of values is long.


Or, given the dataframe version, it's not essential to assign key to 
the row names


  d[ d$key==1.5 , ]
or
  subset(d , key==1.5)

(again with some potential for numerical precision issues)

If you want your psuedo-hash-table to reference more complex 
structures, use a list.


  myhash <- vector('list',6)   ## initialize a list of six elements
  names(myhash) <- letters[1:6] ## name the six elements
  myhash$a <- data.frame(x=1:4, y=c('a','b','d','f'))   ## assign 
something to the first element

  myhash$b <- rnorm(10)   ## assign something to the second element
and so on for $c, $d, $e, and $f
 the elements don't even have to have the same structure

-Don

At 1:03 AM -0700 5/30/10, Alan Lue wrote:

I'm interested in using a data frame as if it were a hash table.  For
instance if I had the following,


 (d <- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))

  keyvalue
1 0.5 -1.118665122
2 1.0  0.465122921
3 1.5 -0.529239211
4 2.0 -0.147324638
5 2.5 -1.531503795
6 3.0 -0.002720434

Then I'd like to be able to quickly retrieve the "value" of "key" 1.5
to get -0.53.  How would one go about doing this?

Yours,
Alan Lue

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



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

__
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] geepack installation problem?

2010-05-30 Thread Denis B

Hello R Forum members.

I have installed for my statistician user, apparently without error, both
the concord and geepack packages.   The target system is R 2.10.1 on a
64-bit RedHat Enterprise Linux platform.

However when she attempts to invoke a function in geepack, for example...

geeglm((abuse_total ~ case),id=mother, family="poisson")

the resultant error is

Error: could not find function "geeglm"

Neither she as a user, nor myself as administrator, can get even help to
work for geepack.  It is almost as though the package is not installed,
regardless that the installation process appeared to complete without error.

I would be grateful of some guidance for her.   I have tried this (R +
geepack) on another Linux-based system (SuSE Enterprise Linux, also 64-bit)
with identical results and I do not see any references to similar issues in
amongst R Forum articles.

Kind regards,
Denis

-- 
View this message in context: 
http://r.789695.n4.nabble.com/geepack-installation-problem-tp2236893p2236893.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] Creating dropout time from longitudinal data with missing data

2010-05-30 Thread john james
Dear R users,
 
Please assist me with the following problem. I have a dataset that looks like 
the following:
 
dat<-data.frame(
  'id'=rep(c(1,2,3),each=3),
  'time'=rep(c(1,2,3),3),
  'y'= c(2,2,NA,2,NA,NA,2,5,7)
) 

 
I wish to create a variable for dropout time in dataframe 'dat' such that the 
dropout time is the time to drop out by the subject as follows:
 
 
dat<-data.frame(
  'id'=rep(c(1,2,3),each=3),
  'time'=rep(c(1,2,3),3),
  'y'= c(2,2,NA,2,NA,NA,2,5,7),
  'dropout time'=c(2,2,2,1,1,1,3,3,3)
) 

Any help will be appreciated. Many thanks in advance.
 
james


  
[[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] Kalman Filter

2010-05-30 Thread Johann Hibschman
Greigiano Jose Alves  writes:

> I am working on an article forecasting, which use the dynamic linear model,
> a model state space. I am wondering all the commands in R, to represent the
> linear dynamic model and Kalman filter.
> I am available for any questions.

There are a few libraries out there, available on CRAN:

  - dlm
  - dse
  - sspir

I tend to use dlm, myself.

Best of luck,
Johann

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