Re: [R] C module causing rounding errors?

2010-07-08 Thread Jeff Newmiller
Insufficient data. Please read the posting guide, particularly the part about 
reproducible code.

It might have something to do with "double" vs "float".

"Joseph N. Paulson"  wrote:

>Hi all!
>
>I am currently writing a C-module for a for loop in which I permute columns
>in a matrix (bootstrapping) and I send a couple of variables into C
>initially. All of it is working, except the initial values I send to R are
>rounded/truncated (I believe rounded).
>
>I am using a 32 bit machine to compile, I am using (I believe) 32 bit R
>
>While debugging I print the values I am sending to C, and then I print the
>same values using Rprintf and the number gets rounded to 10^-6, which is
>actually causing some errors for me. Is there any way to correct/prevent the
>error?
>
>
>sample output from R
>
> [1,]  1.000
> [2,]  1.0256242
> [3,]  1.1826277
> [4,] -0.6937246
> [5,]  1.3633604
>
>sample output from C
>1.00
>1.025624
>1.182628
>0.693725
>1.363360
>
>   [[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.

---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.

__
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] Histogram Principal component analysis in R

2010-07-08 Thread Tal Galili
Hello Dhiman ,

I have never tried doing it on such data, so I am not sure how this
methodology applies or what covets it may hold.

However, R wise, it sounds to me like simply reusing the code here:
http://www.statmethods.net/advstats/factor.html
Would do the trick.

p.s: you wrote "It would be great to know if there are any R functions that
can do this."
Reply: Please run the following code in your R session -

install.packages("fortunes")
require(fortunes)
fortune("R do")


Cheers,
Tal


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 Fri, Jul 9, 2010 at 1:16 AM, DHIMAN BHADRA wrote:

> Dhiman

[[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] Brewer.pal error

2010-07-08 Thread Tal Galili
Hi there,
For me the package is working.
Try to
install.packages("RColorBrewer")
It.

And then
 library("RColorBrewer")

Then something like:
brewer.pal(7,"Greens")

Write in the mailing list what errors you got (if any) at any of these
commands.

Tal


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 Fri, Jul 9, 2010 at 12:21 AM, Trying To learn again <
tryingtolearnag...@gmail.com> wrote:

> Hi all,
>
> I have 35 years, I have been working since I exit from University. I have
> returned to make a phd...I´m fortunatelly I´m working so unfortunatelly I
> have few time to study (I have also a baby with 16 months).
>
> I´m trying to use R but sometimes it gets very difficult.
>
> I´m trying to put this code in my polygon function
> colramp=colorRampPalette(brewer.pal(9,"YlOrRd")
>
> to use brever.pal I have installed this lybrary
>
> library(“RColorBrewer”)
>
> but when I try to run it appears this message:
>
> Error in col2rgb(colors) : cannot find function "brewer.pal"
>
> If you want I can attach the zip I use.
>
> Can anyone please guide me how to make this run?
>
> MAny thanks in advance.
>
> I really think I have never will get my phd but it wa a key I have in mind
> and years before I´m trying.
>
> My neurons are limited but I will fight to achieve...
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 10:33 PM, Erik Iverson wrote:




I have a data frame:
 id  
url urlType
1 1  www.yahoo.com www.yahoo.com>1
2 2  www.google.com/?search=  2
3 3  www.google.com www.google.com>   1
4 4  www.yahoo.com/?query=    2
5 5  www.gmail.com www.gmail.com> 1


This is not output from ?dput, which means more work to read it in.



Yeah it was kind of pain, but ...

dta <- read.table(textConnection(' id  
url urlType

1 1  "www.yahoo.com "  1
2 2  "www.google.com/?search= " 2

3 3  "www.google.com " 1
4 4  "www.yahoo.com/?query= "   2
5 5  "www.gmail.com " 1') )





Here is the definition for WHITELIST:-
WHITELIST = "[?]query=, [?]search="
WHITELIST <- unlist(trim(strsplit(trim(WHITELIST), ",")))


What is the 'trim' function?  I do not have that defined.

Perhaps David's answer will work for you...


Seems to ... after I fixed my incorrect cmd-V paste of the function  
name and guessing that trim was the one in gdata:


> require(gdata)
> checkBaseLine <- function(s){
+ for (listItem in WHITELIST){
+ if(regexpr(as.character(listItem), s)[1] > -1){
+ return(TRUE)
+ }
+ }
+ return(FALSE)
+ }
>
> #Here is the definition for WHITELIST:-
>
> WHITELIST = "[?]query=, [?]search="
> WHITELIST <- unlist(trim(strsplit(trim(WHITELIST), ",")))
> vcheck <- Vectorize(checkBaseLine)
>
> vcheck <- Vectorize(checkBaseLine)
>
> dta[ dta$urlType != 1 & vcheck(dta$url) , "url" ]
[1] www.google.com/?search=  www.yahoo.com/?query= 
 
5 Levels: www.gmail.com  www.google.com  ... www.yahoo.com/?query= 


--
David.

__
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 Manipulation using function

2010-07-08 Thread Erik Iverson



I have a data frame:

  id url 
urlType
1 1  www.yahoo.com    
 1
2 2  www.google.com/?search=    
  2
3 3  www.google.com  
  1
4 4  www.yahoo.com/?query=    
2
5 5  www.gmail.com    
  1




This is not output from ?dput, which means more work to read it in.




Here is the definition for WHITELIST:-

WHITELIST = "[?]query=, [?]search="
WHITELIST <- unlist(trim(strsplit(trim(WHITELIST), ",")))


What is the 'trim' function?  I do not have that defined.

Perhaps David's answer will work for you...

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


Re: [R] Data Frame Manipulation using function

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 10:09 PM, harsh yadav wrote:


Hi,

Here is a somewhat detailed explanation of what I want to achieve:

I have a data frame:

 id url
urlType
1 1  www.yahoo.com1
2 2  www.google.com/?search= 2
3 3  www.google.com   1
4 4  www.yahoo.com/?query=   2
5 5  www.gmail.com 1

I want to get all the URLs that are not of type `1` and satisfy the
condition defined by the following function:

checkBaseLine <- function(s){
for (listItem in WHITELIST){
if(regexpr(as.character(listItem), s)[1] > -1){
return(TRUE)
}
}
return(FALSE)
}

Here is the definition for WHITELIST:-

WHITELIST = "[?]query=, [?]search="
WHITELIST <- unlist(trim(strsplit(trim(WHITELIST), ",")))

Now, for the given data frame I want to apply the above function for
all row values for a given column:-

That is:

It works fine when I define a condition like:
data <- data[data$urlType != 1,]


Arrrgh. Why do people keep using "data" as an object name? Is there  
some water pump from which I can remove the handle?


Anyway ... try:

vcheck <- Vectorize(V)

data[ data$urlType != 1 & vcheck(data$url) , "url" ]

--
David


However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]

This would check whether the column `urlType` contains row values  
that !=

1, and the column `url` contains row values that satisfy the function
definition.

Any ideas how this can be done?

Thanks in advance.

Regards,
Harsh Yadav


On Thu, Jul 8, 2010 at 9:43 PM, Erik Iverson   
wrote:


It will be a lot easier to help you if you follow the posting guide  
and

PLEASE do read the posting guide and provide commented, minimal,
self-contained, reproducible code.

You gave your function definition, which is good.  Use ?dput to  
give us a

small data.frame that can accurately show what you want.


harsh yadav wrote:


Hi all,

I have a data frame for which I want to limit the output by checking
whether
row values for specific column meets particular conditions.

Here are the more specific details:

I have a function that checks whether an input string exists in a  
defined

list:-

checkBaseLine <- function(s){
for (listItem in WHITELIST){
if(regexpr(as.character(listItem), s)[1] > -1){
return(TRUE)
}
}
return(FALSE)
}

Now, I have a data frame for which I want to apply the above  
function for

all row values for a given column:-

This works fine when I define a condition like:
data <- data[data$urlType != 1,]

However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]

This would check whether the column `urlType` contains row values  
that !=

1,
and the column `url` contains row values that gets evaluated using  
the

defined function.

Any ideas how this can be done?

Thanks in advance.

Regards,
Harsh Yadav






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 Manipulation using function

2010-07-08 Thread harsh yadav
Hi,

Here is a somewhat detailed explanation of what I want to achieve:

I have a data frame:

  id url
urlType
1 1  www.yahoo.com1
2 2  www.google.com/?search= 2
3 3  www.google.com   1
4 4  www.yahoo.com/?query=   2
5 5  www.gmail.com 1

I want to get all the URLs that are not of type `1` and satisfy the
condition defined by the following function:

checkBaseLine <- function(s){
for (listItem in WHITELIST){
 if(regexpr(as.character(listItem), s)[1] > -1){
return(TRUE)
}
 }
return(FALSE)
}

Here is the definition for WHITELIST:-

WHITELIST = "[?]query=, [?]search="
WHITELIST <- unlist(trim(strsplit(trim(WHITELIST), ",")))

Now, for the given data frame I want to apply the above function for
all row values for a given column:-

That is:

It works fine when I define a condition like:
data <- data[data$urlType != 1,]

However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]

This would check whether the column `urlType` contains row values that !=
1, and the column `url` contains row values that satisfy the function
definition.

Any ideas how this can be done?

Thanks in advance.

Regards,
Harsh Yadav


On Thu, Jul 8, 2010 at 9:43 PM, Erik Iverson  wrote:

> It will be a lot easier to help you if you follow the posting guide and
> PLEASE do read the posting guide and provide commented, minimal,
> self-contained, reproducible code.
>
> You gave your function definition, which is good.  Use ?dput to give us a
> small data.frame that can accurately show what you want.
>
>
> harsh yadav wrote:
>
>> Hi all,
>>
>> I have a data frame for which I want to limit the output by checking
>> whether
>> row values for specific column meets particular conditions.
>>
>> Here are the more specific details:
>>
>> I have a function that checks whether an input string exists in a defined
>> list:-
>>
>> checkBaseLine <- function(s){
>>  for (listItem in WHITELIST){
>> if(regexpr(as.character(listItem), s)[1] > -1){
>>  return(TRUE)
>> }
>> }
>>  return(FALSE)
>> }
>>
>> Now, I have a data frame for which I want to apply the above function for
>> all row values for a given column:-
>>
>> This works fine when I define a condition like:
>> data <- data[data$urlType != 1,]
>>
>> However, I want to combine two logical conditions together like:
>> data <- data[data$urlType != 1 & checkBaseLine(data$url),]
>>
>> This would check whether the column `urlType` contains row values that !=
>> 1,
>> and the column `url` contains row values that gets evaluated using the
>> defined function.
>>
>> Any ideas how this can be done?
>>
>> Thanks in advance.
>>
>> Regards,
>> Harsh Yadav
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[alternative HTML version deleted]]

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


[R] C module causing rounding errors?

2010-07-08 Thread Joseph N. Paulson
Hi all!

I am currently writing a C-module for a for loop in which I permute columns
in a matrix (bootstrapping) and I send a couple of variables into C
initially. All of it is working, except the initial values I send to R are
rounded/truncated (I believe rounded).

I am using a 32 bit machine to compile, I am using (I believe) 32 bit R

While debugging I print the values I am sending to C, and then I print the
same values using Rprintf and the number gets rounded to 10^-6, which is
actually causing some errors for me. Is there any way to correct/prevent the
error?


sample output from R

 [1,]  1.000
 [2,]  1.0256242
 [3,]  1.1826277
 [4,] -0.6937246
 [5,]  1.3633604

sample output from C
1.00
1.025624
1.182628
0.693725
1.363360

[[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] Data Frame Manipulation using function

2010-07-08 Thread Erik Iverson
It will be a lot easier to help you if you follow the posting guide and PLEASE 
do read the posting guide and provide commented, minimal, self-contained, 
reproducible code.


You gave your function definition, which is good.  Use ?dput to give us a small 
data.frame that can accurately show what you want.



harsh yadav wrote:

Hi all,

I have a data frame for which I want to limit the output by checking whether
row values for specific column meets particular conditions.

Here are the more specific details:

I have a function that checks whether an input string exists in a defined
list:-

checkBaseLine <- function(s){
 for (listItem in WHITELIST){
if(regexpr(as.character(listItem), s)[1] > -1){
 return(TRUE)
}
}
 return(FALSE)
}

Now, I have a data frame for which I want to apply the above function for
all row values for a given column:-

This works fine when I define a condition like:
data <- data[data$urlType != 1,]

However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]

This would check whether the column `urlType` contains row values that !=
1,
and the column `url` contains row values that gets evaluated using the
defined function.

Any ideas how this can be done?

Thanks in advance.

Regards,
Harsh Yadav

[[alternative HTML version deleted]]

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


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


[R] Data Frame Manipulation using function

2010-07-08 Thread harsh yadav
Hi all,

I have a data frame for which I want to limit the output by checking whether
row values for specific column meets particular conditions.

Here are the more specific details:

I have a function that checks whether an input string exists in a defined
list:-

checkBaseLine <- function(s){
 for (listItem in WHITELIST){
if(regexpr(as.character(listItem), s)[1] > -1){
 return(TRUE)
}
}
 return(FALSE)
}

Now, I have a data frame for which I want to apply the above function for
all row values for a given column:-

This works fine when I define a condition like:
data <- data[data$urlType != 1,]

However, I want to combine two logical conditions together like:
data <- data[data$urlType != 1 & checkBaseLine(data$url),]

This would check whether the column `urlType` contains row values that !=
1,
and the column `url` contains row values that gets evaluated using the
defined function.

Any ideas how this can be done?

Thanks in advance.

Regards,
Harsh Yadav

[[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] Time value not sorting properly

2010-07-08 Thread Joshua Wiley
Jared,

I am not sure how you converted your 'time' variable from a factor to
numeric, but you probably actually want to convert it to one of the
'time' classes.  To learn more about them in R, see ?DateTimeClasses
Another nice feature of these special time classes is that they can
handle year, month, day, and time all in one column.  This means you
only need to sort by two columns (ID and time).  You can also look at
?strptime for details on converting character strings into time
variables.  An example using your data follows below.

Best regards,

Josh

samp.dat <- structure(list(ID = c(2836L, 2836L, 2836L, 2836L, 2836L, 2836L,
2836L, 2836L, 2836L, 2836L, 2836L, 2836L, 2836L, 2836L, 2836L,
2836L), year = c(2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L
), month = c(7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L), day = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), time = structure(c(12L, 13L, 14L,
15L, 16L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L), .Label = c("0:01:35",
"10:00:15", "11:00:44", "12:00:17", "13:00:38", "14:00:25", "15:00:53",
"16:00:11", "17:00:23", "18:00:47", "21:01:13", "3:00:50", "6:00:20",
"7:00:42", "8:00:42", "9:00:12"), class = "factor"), Lat = c(-1.2402597,
-1.2397508, -1.2431248, -1.2396636, -1.2304111, -1.2255532, -1.2248113,
-1.2251362, -1.2246384, -1.2245949, -1.2269631, -1.2264911, -1.2251153,
-1.2315372, -1.2578944, -1.242075), Long = c(35.5405911, 35.5406318,
35.5388285, 35.5285848, 35.5139149, 35.5162895, 35.5147305, 35.491731,
35.4918846, 35.4918647, 35.4880909, 35.4837137, 35.4817967, 35.4806165,
35.4670629, 35.5449559), test = c(77L, 120L, 214L, 300L, 345L,
436L, 528L, 585L, 665L, 727L, 813L, 846L, 928L, 1027L, 1093L,
1132L)), .Names = c("ID", "year", "month", "day", "time", "Lat",
"Long", "test"), class = "data.frame", row.names = c(NA, -16L
))

str(samp.dat)

#first combine all time columns using paste()
#then convert to POSIXlt
samp.dat$time2 <- strptime(x = paste(samp.dat$year, "-",
   samp.dat$month, "-",
   samp.dat$day, " ",
   samp.dat$time,
   sep=""),
 format = "%Y-%m-%d %H:%M:%S")

str(samp.dat) #note how 'time2' is actually a time class now

#ordering becomes easier
temp.or <- order(samp.dat$ID, samp.dat$time2, decreasing=FALSE)

samp.dat <- samp.dat[temp.or, ]

samp.dat #print to screen


On Thu, Jul 8, 2010 at 4:28 PM, Jared Stabach
 wrote:
> I have a dataframe of animal locations that I need to have in incremental
> order so that I can calculate the distance traveled between each time step.
> However, I have identified a few values that don't seem to sort properly.
> For instance, the last value in the table below should be the first value
> after sorting, since its time value is '00:01:35'.  But, for some reason, it
> seems to be recognized after the '21:01:13' value.  I also defined the time
> column as a numeric value (originally a factor) with the result shown in the
> 'test' column.  As the value is reported as '1132', it seems there is an
> issue with the time value listed.
>
>  ID      year    month  day  time          Lat
> Long            test
> 2836  2010   7         1      03:00:50     -1.2402597    35.5405911  77
> 2836  2010   7         1      06:00:20     -1.2397508    35.5406318  120
> 2836  2010   7         1      07:00:42     -1.2431248    35.5388285  214
> 2836  2010   7         1      08:00:42     -1.2396636    35.5285848  300
> 2836  2010   7         1      09:00:12     -1.2304111    35.5139149  345
> 2836  2010   7         1      10:00:15     -1.2255532    35.5162895  436
> 2836  2010   7         1      11:00:44     -1.2248113    35.5147305  528
> 2836  2010   7         1      12:00:17     -1.2251362    35.4917310  585
> 2836  2010   7         1      13:00:38     -1.2246384    35.4918846  665
> 2836  2010   7         1      14:00:25     -1.2245949    35.4918647  727
> 2836  2010   7         1      15:00:53     -1.2269631    35.4880909  813
> 2836  2010   7         1      16:00:11     -1.2264911    35.4837137  846
> 2836  2010   7         1      17:00:23     -1.2251153    35.4817967  928
> 2836  2010   7         1      18:00:47     -1.2315372    35.4806165  1027
> 2836  2010   7         1      21:01:13     -1.2578944    35.4670629  1093
> 2836  2010   7         1      00:01:35     -1.2420750    35.5449559  1132
>
> The code I used to sort the dataframe is:
>
> # Sort dataset so values are in incremental order
> temp.or
> <-order(wildebeest$ID,wildebeest$year,wildebeest$month,wildebeest$day,wildebeest$time,decreasing=FALSE)
> wildebeest <-wildebeest[temp.or,]
> Eventually, I will have around 400,000 records, so my script is designed at
> problem solving these errors.  Is there something that I am missing or is
> there something in this field that could possibly be hidden?  Any
> suggestions?
>
> Thanks in advance for any help.
>
> Jared
>
>        [[alternative HTML version deleted]]
>
> _

Re: [R] xyplot help

2010-07-08 Thread array chip
Thank you for pointing out panel.superpose. I got it working with panel.xyplot 
as below:

xyplot(y~x,groups=type,plotdata, auto.key=list(space='bottom',points=T)
, panel = function(x,y,subscripts, groups) { 
panel.xyplot(x,y, col=groups[subscripts])
x<-sort(x)
panel.lines(x,-1.324+0.1117*x-0.0006357*x*x) 

  }) 


type='b' doesn't give me a smooth line, so it didn't produce what I want.

Thanks

John



- Original Message 
From: Bert Gunter 
To: array chip ; r-help@r-project.org
Sent: Thu, July 8, 2010 4:25:51 PM
Subject: RE: [R] xyplot help

Read the "panel" part of ?xyplot carefully and note ?panel.superpose.
Typically, when you have a groups argument your panel function must be of
the form 

panel = function(x,y,...){
panel.superpose(x,y,...)
etc.
}

However, I think it might all happen automagically if you do the call as:

xyplot(y~x,groups=type,plotdata, type = "b", auto.key=T)

This is also referenced in the "panel" section of the xyplot help, where you
are referred to ?panel.xyplot for info on the type argument.

So, in brief, read the docs more carefully.

Bert Gunter
Genentech Nonclinical Statistics

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of array chip
> Sent: Thursday, July 08, 2010 3:58 PM
> To: r-help@r-project.org
> Subject: [R] xyplot help
> 
> Hi, I am learning xyplot. I have an example dataset attached.
> 
> plotdata<-read.table("plotdata.txt",sep='\t',header=T,row.names=1)
> 
> head(plotdata,n=4)
>   y  x type
> 1 -4.309601 -0.7448405A
> 2 -4.715421  0.7875994A
> 3 -2.310638  0.5455310A
> 4 -2.685803 10.4116868A
> 
> xyplot(y~x,groups=type,plotdata, auto.key=T)
> 
> This shows different colors for different levels of "type".
> 
> Now, I want to add a fitted line to the plot, the formula is
> -1.324+0.1117*x-0.0006357*x*x
> 
> I tried the following code to do this:
> 
> xyplot(y~x,groups=type,plotdata, auto.key=T
> , panel = function(x,y) {
> panel.xyplot(x,y, type='p')
> x<-sort(x)
> panel.lines(x,-1.324+0.1117*x-0.0006357*x*x)
> 
>   })
> 
> Now, it doesn't show different colors for different levels of "type". How
> can I
> restore that?
> 
> Also, is there anyway to put the legend at bottom of the plot (instead at
> the
> top right now)? And is there anyway to print legend horizontally, instead
> of
> vertically as shown right now?
> 
> Thanks
> 
> John
> 
> 
>

__
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] Multivariate Kalman Filter with inequality constraints

2010-07-08 Thread Pierre Lapointe
I'm trying to do a multivariate Kalman Filter with inequality constraints.

Specifically, I'm trying to force all betas to be positive in a y = beta * x
equation.

Any ideas?

Pierre Lapointe

[[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] Time value not sorting properly

2010-07-08 Thread Jared Stabach
I have a dataframe of animal locations that I need to have in incremental
order so that I can calculate the distance traveled between each time step.
However, I have identified a few values that don't seem to sort properly.
For instance, the last value in the table below should be the first value
after sorting, since its time value is '00:01:35'.  But, for some reason, it
seems to be recognized after the '21:01:13' value.  I also defined the time
column as a numeric value (originally a factor) with the result shown in the
'test' column.  As the value is reported as '1132', it seems there is an
issue with the time value listed.

 ID  yearmonth  day  time  Lat
Longtest
2836  2010   7 1  03:00:50 -1.240259735.5405911  77
2836  2010   7 1  06:00:20 -1.239750835.5406318  120
2836  2010   7 1  07:00:42 -1.243124835.5388285  214
2836  2010   7 1  08:00:42 -1.239663635.5285848  300
2836  2010   7 1  09:00:12 -1.230411135.5139149  345
2836  2010   7 1  10:00:15 -1.225553235.5162895  436
2836  2010   7 1  11:00:44 -1.224811335.5147305  528
2836  2010   7 1  12:00:17 -1.225136235.4917310  585
2836  2010   7 1  13:00:38 -1.224638435.4918846  665
2836  2010   7 1  14:00:25 -1.224594935.4918647  727
2836  2010   7 1  15:00:53 -1.226963135.4880909  813
2836  2010   7 1  16:00:11 -1.226491135.4837137  846
2836  2010   7 1  17:00:23 -1.225115335.4817967  928
2836  2010   7 1  18:00:47 -1.231537235.4806165  1027
2836  2010   7 1  21:01:13 -1.257894435.4670629  1093
2836  2010   7 1  00:01:35 -1.242075035.5449559  1132

The code I used to sort the dataframe is:

# Sort dataset so values are in incremental order
temp.or
<-order(wildebeest$ID,wildebeest$year,wildebeest$month,wildebeest$day,wildebeest$time,decreasing=FALSE)
wildebeest <-wildebeest[temp.or,]
Eventually, I will have around 400,000 records, so my script is designed at
problem solving these errors.  Is there something that I am missing or is
there something in this field that could possibly be hidden?  Any
suggestions?

Thanks in advance for any help.

Jared

[[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] xyplot help

2010-07-08 Thread Bert Gunter
Read the "panel" part of ?xyplot carefully and note ?panel.superpose.
Typically, when you have a groups argument your panel function must be of
the form 

panel = function(x,y,...){
panel.superpose(x,y,...)
etc.
}

However, I think it might all happen automagically if you do the call as:

xyplot(y~x,groups=type,plotdata, type = "b", auto.key=T)

This is also referenced in the "panel" section of the xyplot help, where you
are referred to ?panel.xyplot for info on the type argument.

So, in brief, read the docs more carefully.

Bert Gunter
Genentech Nonclinical Statistics

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of array chip
> Sent: Thursday, July 08, 2010 3:58 PM
> To: r-help@r-project.org
> Subject: [R] xyplot help
> 
> Hi, I am learning xyplot. I have an example dataset attached.
> 
> plotdata<-read.table("plotdata.txt",sep='\t',header=T,row.names=1)
> 
> head(plotdata,n=4)
>   y  x type
> 1 -4.309601 -0.7448405A
> 2 -4.715421  0.7875994A
> 3 -2.310638  0.5455310A
> 4 -2.685803 10.4116868A
> 
> xyplot(y~x,groups=type,plotdata, auto.key=T)
> 
> This shows different colors for different levels of "type".
> 
> Now, I want to add a fitted line to the plot, the formula is
> -1.324+0.1117*x-0.0006357*x*x
> 
> I tried the following code to do this:
> 
> xyplot(y~x,groups=type,plotdata, auto.key=T
> , panel = function(x,y) {
> panel.xyplot(x,y, type='p')
> x<-sort(x)
> panel.lines(x,-1.324+0.1117*x-0.0006357*x*x)
> 
>   })
> 
> Now, it doesn't show different colors for different levels of "type". How
> can I
> restore that?
> 
> Also, is there anyway to put the legend at bottom of the plot (instead at
> the
> top right now)? And is there anyway to print legend horizontally, instead
> of
> vertically as shown right now?
> 
> Thanks
> 
> John
> 
> 
>

__
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] Producing residual plots by time for lme object

2010-07-08 Thread Anne York
The plot also works if you replace "na.exclude" with 
"na.omit". 

On Wed, 7 Jul 2010, Deepayan Sarkar wrote:

DS > On Fri, Jul 2, 2010 at 11:40 AM, Gregory Gentlemen
DS >  wrote:
DS > > Fellow R-users,
DS > >
DS > > I have a longitudinal data set with missing values in it. I would like 
to produce a residual plot for each time using panel.xyplot function but I get 
an error message. Here's a simple example,
DS > >
DS > > library(nlme)
DS > > set.seed(1544)
DS > > longdata <- data.frame(ID=gl(10,1,50), y=rnorm(50), time = 
as.numeric(gl(5,10,50)), x = rnorm(50))
DS > > longdata$y[5] <- NA
DS > > longdata$x[35] <- NA
DS > >
DS > > modlme<- lme(fixed=y ~ time + x,
DS > >     random= ~ 1 | ID,
DS > >     na.action=na.exclude, data=longdata)
DS > >
DS > >
DS > > plot( modlme, abs( resid(., type = 'p')) ~ fitted(.) | time,
DS > >   panel = function(x, y, ...) {
DS > >     panel.xyplot( x, y, ...)
DS > >     panel.loess( x, y,...)
DS > >   })
DS > >
DS > > where the last call produces the error message
DS > > Error in `[[<-.data.frame`(`*tmp*`, j, value = c(1, 1, 1, 1, 1, 1, 1,  :
DS > >   replacement has 48 rows, data has 50
DS > >
DS > >
DS > > How do I fix this?
DS > 
DS > NA-handling is not working right, it seems. Would it make any real
DS > difference to your analysis to do
DS > 
DS > modlme<- lme(fixed=y ~ time + x,
DS > random= ~ 1 | ID, data = na.omit(longdata))
DS > 
DS > (in which case the subsequent plot call works)?
DS > 
DS > -Deepayan
DS > 
DS > __
DS > R-help@r-project.org mailing list
DS > https://stat.ethz.ch/mailman/listinfo/r-help
DS > PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
DS > and provide commented, minimal, self-contained, reproducible code.
DS > __
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] xyplot help

2010-07-08 Thread array chip
Hi, I am learning xyplot. I have an example dataset attached.

plotdata<-read.table("plotdata.txt",sep='\t',header=T,row.names=1)

head(plotdata,n=4)
  y  x type
1 -4.309601 -0.7448405A
2 -4.715421  0.7875994A
3 -2.310638  0.5455310A
4 -2.685803 10.4116868A

xyplot(y~x,groups=type,plotdata, auto.key=T)

This shows different colors for different levels of "type".

Now, I want to add a fitted line to the plot, the formula is 
-1.324+0.1117*x-0.0006357*x*x

I tried the following code to do this:

xyplot(y~x,groups=type,plotdata, auto.key=T
, panel = function(x,y) { 
panel.xyplot(x,y, type='p')
x<-sort(x)
panel.lines(x,-1.324+0.1117*x-0.0006357*x*x) 

  }) 

Now, it doesn't show different colors for different levels of "type". How can I 
restore that?

Also, is there anyway to put the legend at bottom of the plot (instead at the 
top right now)? And is there anyway to print legend horizontally, instead of 
vertically as shown right now?

Thanks

John


  y   x   type
1   -4.30960132841301   -0.744840518760792  A
2   -4.71542109959628   0.787599395527709   A
3   -2.31063823031730   0.545530976094587   A
4   -2.68580284811662   10.4116867886136A
5   0.857277739439742   45.8678415780720A
6   2.4572713553700584.8497464051184A
7   2.13169532824448103.133586922502A
8   1.28410512992259105.748839904875A
9   -1.03955702898241   -0.899013850822378  A
10  0.829280624483265   2.98715094752831A
11  -0.50214940111739   1.72294341018182A
12  3.1178629464421320.4231486028650A
13  3.3424685053647269.3541875183234A
14  2.70345650675251111.307639403626A
15  4.00616663408449124.004258887019A
16  5.1806910416212 128.613638097411A
17  -6.26534533776664   -0.944438526313875  A
18  -3.78598472716979   2.03694726901381A
19  -4.21383059434262.33837780519899A
20  1.8936558564966421.6366580986433A
21  4.5840279115829167.5861096660383A
22  2.05571359621679107.949510371836A
23  4.05242444227599112.126993688471A
24  4.34316209268166116.153400981747A
25  -2.12763929077743   -1.08663195011827   A
26  -2.10662282720267   -0.426141043811507  A
27  -3.01995286978557   -1.10752325011792   A
28  -1.64834644316891   7.78787375907454A
29  1.2440114496483745.3160993898581A
30  4.0353582382757787.1430284366417A
31  1.29543626134492105.003743707372A
32  3.84919041637386108.601951968250A
33  -3.2442183465   -0.382454625559666  A
34  -1.37712133953019   0.300186521658450   A
35  -2.12844632825254   -0.814335902708673  A
36  1.373118028256679.791747074437  A
37  -0.393168361803423  52.1011610030969A
38  2.66057348869074101.966194385881A
39  1.91384920016281112.592562878277A
40  2.06188667920977117.376424285145A
41  -3.05678162571978   -0.483215996703479  A
42  -0.184239995971267  1.23596224758922A
43  -1.42855399915072   0.248774451716021   A
44  1.4984400060720517.8847352593804A
45  2.5354258682307960.0336036447702A
46  2.95329003854665102.482588510080A
47  5.0685809676014 110.619630044398A
48  4.06642471090290120.486184775892A
49  -0.503130553392357  0.702688068466441   A
50  -0.860471679766733  1.43490186430460A
51  -0.17788663078253   3.11150418059122A
52  0.986266958945663   17.0902837098301A
53  2.1938933814974557.8826565905442A
54  3.9258915764087198.2558014383485A
55  2.53121102711589108.302821306135A
56  2.34432932634521111.053272678522A
97  -3.42191838986702   -0.885224809610779  A
98  -1.59014967363784   0.109987040681714   A
99  -1.58111592784537   3.78759624156396A
100 0.975980130414523   21.9589171041898A
101 2.6572303639741463.3950961679038A
102 3.3921352446590793.1009307560951A
103 4.2956847168814499.8712158796281A
104 4.84074935161124100.052602454596A
121 -1.68332987752984   0.227299766484946   A
122 0.468472823690819   1.87223738102554A
123 -0.547570024002551  4.37927291184889A
124 0.224584723010114   28.1273391056646A
125 1.9501827239534178.8401126239

[R] New R-SIG for Discrete Choice Modelling

2010-07-08 Thread John Williams

Hello all,

I'd like to announce the availability of a mailing list for a
newly-formed SIG (Special Interest Group) dedicated to using R for
Discrete Choice Modelling.

This list is intended for discussion of issues revolving around the
design and analysis of Discrete Choice (aka Stated Choice, Stated
Preference or Choice-Based Conjoint) experiments.

While R has good infrastructure for experimental design in the
traditional sense (i.e. generation and evaluation of fractional
factorials and balanced incomplete blocks) the use of packages can be
daunting for the novice. This list can be a source of help for applied
DC/SP/CBC researchers who may not necessarily be R experts.

If you'd like to join the SIG (or just subscribe to the list), please
visit this URI:

https://stat.ethz.ch/mailman/listinfo/r-sig-dcm

The SIG has not done anything apart from setting up this list (yet), and
at present consists of four people.  Check out the Web page to see more
detail on our views and aims, and jump in!


--
Department of Marketing
University of Otago

+64 03 479 5040
http://marketing.otago.ac.nz/staff/williamsj.asp

__
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] Column header strategy

2010-07-08 Thread RICHARD M. HEIBERGER
On Thu, Jul 8, 2010 at 3:14 PM, Addi Wei  wrote:

>
> Hopefully simple question:  What is the best way to name, and treat factor
> columns for data that has lots of columns?
>
> This is my column list:
> id pID50 D.1 D.2 D.3 D.4 D.5 , etc. all the way to D.185
>
It would be much better to use a factor and let R itself generate the set of
dummy variables.
Choose a useful name.  For example if D stands for Dose, then use something
like

micetitletest$Dose <- factor(micetitletest$dose.values)

miceD <- plsr(pID50 ~ Dose, ncomp=10, data = micetitletest)

Read about factors in the online An Introduction to R distributed as part of
R.

[[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] Column header strategy

2010-07-08 Thread Peter Ehlers

On 2010-07-08 13:14, Addi Wei wrote:


Hopefully simple question:  What is the best way to name, and treat factor
columns for data that has lots of columns?

This is my column list:
id pID50 D.1 D.2 D.3 D.4 D.5 , etc. all the way to D.185

I was under the impression from several R examples in pls that if you name
your columns like above, you should be able to simply call all the D factors
with "D", instead of going in and putting a plus sign between each column.
miceD<- plsr(pID50~D, ncomp=10,data = micetitletest)
Error in model.frame.default(formula = pID50 ~ D, data = micetitletest) :
   invalid type (closure) for variable 'D'

VS.

miceD<- plsr(pID50 ~ D.1 + D.2 + D.3 + D.4 etc. to D.185 , ncomp=10, data =
micetitletest)

What am I missing above that's causing that error message in bold?  Is there
a better strategy for naming my columns in order to make R use easier?


From the help page for plsr():

"The formula argument should be a symbolic formula of the
form response ~ terms, where response is the name of the
response vector or matrix (for multi-response models) and
terms is the name of one or more predictor _matrices_
(emphasis added), usually separated by +, e.g.,
water ~ FTIR or y ~ X + Z."

Note the word _matrices_; you may not have set up
your data correctly. Compare the 'yarn' dataset

 str(yarn)

with your data

 str(micetitletest)

And, as David says, don't use D for the name of your
predictor matrix (although it will probably work).

  -Peter Ehlers

__
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] Column header strategy

2010-07-08 Thread Joshua Wiley
On Thu, Jul 8, 2010 at 12:14 PM, Addi Wei  wrote:
>
> Hopefully simple question:  What is the best way to name, and treat factor
> columns for data that has lots of columns?
>
> This is my column list:
> id pID50 D.1 D.2 D.3 D.4 D.5 , etc. all the way to D.185
>
> I was under the impression from several R examples in pls that if you name
> your columns like above, you should be able to simply call all the D factors
> with "D", instead of going in and putting a plus sign between each column.

Hmm, I did not see this in the documentation (which does not mean it is not so).

If you want to have every column in the model except id, you could use
'.' all you would have to do is specifically remove the id column.
This becomes messier if you had another k set of E.1 to k factors.
See ?formula for how '.' works.

miceD <- plsr(pID50 ~ . -id, ncomp = 10, data = micetitletest)

> miceD <- plsr(pID50~D, ncomp=10,data = micetitletest)
> Error in model.frame.default(formula = pID50 ~ D, data = micetitletest) :
>  invalid type (closure) for variable 'D'
>
> VS.
>
> miceD <- plsr(pID50 ~ D.1 + D.2 + D.3 + D.4 etc. to D.185 , ncomp=10, data =
> micetitletest)
>
> What am I missing above that's causing that error message in bold?  Is there
> a better strategy for naming my columns in order to make R use easier?
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Column-header-strategy-tp2282740p2282740.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
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] Loading .Rdata within an R function

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 6:21 PM, Duncan Murdoch wrote:

On 08/07/2010 3:21 PM, Giles Crane wrote:
  

Colleagues:

I am having trouble loading data from within .Rdata file
within the environment of a function.  That is,
the following always loads to the global environment:

   f1 <- function(){

   load("mydata.Rdata")

   #  compute with objects from mydata.Rdata.

   }

I wish to load mydata.Rdata only within the function f1.
Perhaps I have misunderstood the capabilities of load(),
or the environment concepts.




You didn't specify where you wanted it loaded.  Just add 
envir=environment() to the call to load.



Sorry, my reply is misleading:  what you did will give the same result 
as what I suggested.


What makes you think it didn't work?

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] Loading .Rdata within an R function

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 3:21 PM, Giles Crane wrote:

Colleagues:

I am having trouble loading data from within .Rdata file
within the environment of a function.  That is,
the following always loads to the global environment:

   f1 <- function(){

   load("mydata.Rdata")

   #  compute with objects from mydata.Rdata.

   }

I wish to load mydata.Rdata only within the function f1.
Perhaps I have misunderstood the capabilities of load(),
or the environment concepts.



You didn't specify where you wanted it loaded.  Just add 
envir=environment() to the call to load.


Duncan Murdoch

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


[R] Histogram Principal component analysis in R

2010-07-08 Thread DHIMAN BHADRA
Hi,

I am trying to do a Principal component analysis on histogram data.
Basically, I have a group of subjects and for each of them, I have a column
of bin-counts (vis-a-vis intervals) and a corresponding column of
frequencies (or normalized frequencies). The bin counts are the same for all
the subjects. I also have a group-averaged histogram (with the same bin
counts and a column of frequencies) reflecting the overall group behavior.

I would like to apply PCA on these histograms (specifically the group
averaged one) to come up with the first few eigenvectors/PC scores that
would summarize the information contained in the histograms. Some medical
papers have done this (Dehmeshki J, Ruto AC, Arridge S...(2001) : Analysis
Of MTR histograms in multiple sclerosis using PC and muliple LDA") maybe
using some medical softwares. However, It would be great to know if there
are any R functions that can do this.
Thanks and regards,
Dhiman Bhadra



Dhiman Bhadra
Graduate Assistant.
Department of Statistics.
University of Florida.
Gainesville, Florida : 32611

[[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] Loading .Rdata within an R function

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 3:21 PM, Giles Crane wrote:


Colleagues:

I am having trouble loading data from within .Rdata file
within the environment of a function.  That is,
the following always loads to the global environment:

  f1 <- function(){
  load("mydata.Rdata")
  #  compute with objects from mydata.Rdata.
  }

I wish to load mydata.Rdata only within the function f1.
Perhaps I have misunderstood the capabilities of load(),
or the environment concepts.


How do you know that you are having troubles? I don't see any error  
messages.






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] Column header strategy

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 3:14 PM, Addi Wei wrote:



Hopefully simple question:  What is the best way to name, and treat  
factor

columns for data that has lots of columns?

This is my column list:
id pID50 D.1 D.2 D.3 D.4 D.5 , etc. all the way to D.185

I was under the impression from several R examples in pls that if  
you name
your columns like above, you should be able to simply call all the D  
factors
with "D", instead of going in and putting a plus sign between each  
column.

miceD <- plsr(pID50~D, ncomp=10,data = micetitletest)
Error in model.frame.default(formula = pID50 ~ D, data =  
micetitletest) :

 invalid type (closure) for variable 'D'


"D" is a function name. As are "c", "data", and "df"



VS.

miceD <- plsr(pID50 ~ D.1 + D.2 + D.3 + D.4 etc. to D.185 ,  
ncomp=10, data =

micetitletest)

What am I missing above that's causing that error message in bold?   
Is there

a better strategy for naming my columns in order to make R use easier?

--


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] What is the name of function for calculating mod?

2010-07-08 Thread Erik Iverson

?Arithmetic , specifically %%

Soyeon Kim wrote:

Dear All,

I try to find the name of function to calculate mod(or Modular).
Do you anyone know the name of function?

Thank you so much,
Soyeon Kim

__
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] What is the name of function for calculating mod?

2010-07-08 Thread Soyeon Kim
Dear All,

I try to find the name of function to calculate mod(or Modular).
Do you anyone know the name of function?

Thank you so much,
Soyeon Kim

__
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] Brewer.pal error

2010-07-08 Thread Trying To learn again
Hi all,

I have 35 years, I have been working since I exit from University. I have
returned to make a phd...I´m fortunatelly I´m working so unfortunatelly I
have few time to study (I have also a baby with 16 months).

I´m trying to use R but sometimes it gets very difficult.

I´m trying to put this code in my polygon function
colramp=colorRampPalette(brewer.pal(9,"YlOrRd")

to use brever.pal I have installed this lybrary

library(“RColorBrewer”)

but when I try to run it appears this message:

Error in col2rgb(colors) : cannot find function "brewer.pal"

If you want I can attach the zip I use.

Can anyone please guide me how to make this run?

MAny thanks in advance.

I really think I have never will get my phd but it wa a key I have in mind
and years before I´m trying.

My neurons are limited but I will fight to achieve...

[[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] ttrTests Error

2010-07-08 Thread Raghu
spData <- as.vector(getYahooData("SPY",
start="19900101",end="20081231")[,"Close"])
> cr <- cReturns(spData, ttr = "sma", params=c(20))
Error in ind[t - k] <- pos[t - k + 1] - pos[t - k] :
  replacement has length zero

I am getting the above error when running the cReturns function. Any ideas
on this? How does one drill down into finction codes in R?

Tx


-- 
'Raghu'

[[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] Loading .Rdata within an R function

2010-07-08 Thread Giles Crane

Colleagues:

I am having trouble loading data from within .Rdata file
within the environment of a function.  That is,
the following always loads to the global environment:

   f1 <- function(){

   load("mydata.Rdata")

   #  compute with objects from mydata.Rdata.

   }

I wish to load mydata.Rdata only within the function f1.
Perhaps I have misunderstood the capabilities of load(),
or the environment concepts.

Thank you for any help you may give.
Cordially,
Giles Crane

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Loading-Rdata-within-an-R-function-tp2282751p2282751.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] R2 function from PLS to use a model on test data

2010-07-08 Thread Addi Wei

I figured out the answer.  Since I have both the predicted and actual values,
I simply need to call the lm function, and summary to see R^2 which matches
what MOE provided.  

myline.fit <-lm( y~x)
summary(myline.fit)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R2-function-from-PLS-to-use-a-model-on-test-data-tp2281426p2282684.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] Column header strategy

2010-07-08 Thread Addi Wei

Hopefully simple question:  What is the best way to name, and treat factor
columns for data that has lots of columns? 
 
This is my column list:
id pID50 D.1 D.2 D.3 D.4 D.5 , etc. all the way to D.185

I was under the impression from several R examples in pls that if you name
your columns like above, you should be able to simply call all the D factors
with "D", instead of going in and putting a plus sign between each column.  
miceD <- plsr(pID50~D, ncomp=10,data = micetitletest)
Error in model.frame.default(formula = pID50 ~ D, data = micetitletest) : 
  invalid type (closure) for variable 'D'

VS.

miceD <- plsr(pID50 ~ D.1 + D.2 + D.3 + D.4 etc. to D.185 , ncomp=10, data =
micetitletest)

What am I missing above that's causing that error message in bold?  Is there
a better strategy for naming my columns in order to make R use easier? 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Column-header-strategy-tp2282740p2282740.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] Kite diagrams

2010-07-08 Thread Graham Smith
I asked the same question on  R-sig-eco, and Ben Bolker provided this
solution, which as I assume this should show up in a search I copy
here.

However, if someone can come up with a single function, that would be good.

--

 I don't do kite diagrams at all, but here are some quick & dirty solutions.

## inspired by violin plots in:
##
http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/

X <- read.table(textConnection("dist spA spB spC
0 0 0 0
5 0 4 0
10 0 20 0
15 5 30 0
20 10 20 0
25 20 8  4
30 15 2  5
35 5  0  10
40 0  0  20
45 0  0  10
50 0  0  5
55 0  0  0"),header=TRUE)


library(reshape)
mX <- melt(X,id.var="dist")
names(mX)[2:3] <- c("species","abundance")
mX$fabund <- cut(mX$abundance,
 breaks=c(-0.01,0,5,20,100),
 labels=c("Abs","Rare","Common","Abundant"))

library(ggplot2)
p <- ggplot(mX, aes(x=dist))

## plot by proportion
p + geom_ribbon(aes(ymax = -abundance, ymin = +abundance))+
  facet_grid(species ~ .)

## plot by abundance category
p + geom_ribbon(aes(ymax = as.numeric(fabund)-1,
ymin = -(as.numeric(fabund)-1)))+
  facet_grid(species ~ .)


-- Ben Bolker Associate professor, Biology Dep't, Univ. of Florida
bol...@ufl.edu / people.biology.ufl.edu/bolker GPG key:
people.biology.ufl.edu/bolker/benbolker-publickey.asc


Graham

__
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] Function for gruping similar variables?

2010-07-08 Thread Timo W
Does anyone have an idea on this?

On 6 Lip, 11:32, Timo W  wrote:
> Hi,
>
> I have a matrix of results of multiple 2x2 chi^2 tests, non-
> significant tests are marked as TRUE. Is there a function for grouping
> those variables in a similar way LSD.test from agricolae library does?
> I reviewed LSD.test's source but it's not helpful for me.
>
> This is my matrix:
>
>    [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]
> 1  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
> 2 FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
> 3  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE
> 4  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 5  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
> 6 FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 7  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
>
> And I'd like to get similar output to this (LSD.test):
>
> Groups, Treatments and means
> a        oo      36.9
> a        ff      36.3
>  b       cc      24.4
>   c      fc      12.86667
>
> For example, there's a group of variables 4, 5, 6, & 7 that don't
> significantly differ from each other. Is there any _simple_ way to
> mark all of them as a group?
>
> If you have any ideas, I'd be grateful.
>
> Thanks in advance,
> Timo
>
> __
> 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] Function for gruping similar variables?

2010-07-08 Thread Timo W
Does anyone have an idea on this?

On 6 Lip, 11:32, Timo W  wrote:
> Hi,
>
> I have a matrix of results of multiple 2x2 chi^2 tests, non-
> significant tests are marked as TRUE. Is there a function for grouping
> those variables in a similar way LSD.test from agricolae library does?
> I reviewed LSD.test's source but it's not helpful for me.
>
> This is my matrix:
>
>    [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]
> 1  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
> 2 FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
> 3  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE
> 4  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 5  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
> 6 FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 7  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
>
> And I'd like to get similar output to this (LSD.test):
>
> Groups, Treatments and means
> a        oo      36.9
> a        ff      36.3
>  b       cc      24.4
>   c      fc      12.86667
>
> For example, there's a group of variables 4, 5, 6, & 7 that don't
> significantly differ from each other. Is there any _simple_ way to
> mark all of them as a group?
>
> If you have any ideas, I'd be grateful.
>
> Thanks in advance,
> Timo
>
> __
> 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] Function for gruping similar variables?

2010-07-08 Thread Timo W
Does anyone have an idea on this?

On 6 Lip, 11:32, Timo W  wrote:
> Hi,
>
> I have a matrix of results of multiple 2x2 chi^2 tests, non-
> significant tests are marked as TRUE. Is there a function for grouping
> those variables in a similar way LSD.test from agricolae library does?
> I reviewed LSD.test's source but it's not helpful for me.
>
> This is my matrix:
>
>    [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]
> 1  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
> 2 FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
> 3  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE
> 4  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 5  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
> 6 FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
> 7  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
>
> And I'd like to get similar output to this (LSD.test):
>
> Groups, Treatments and means
> a        oo      36.9
> a        ff      36.3
>  b       cc      24.4
>   c      fc      12.86667
>
> For example, there's a group of variables 4, 5, 6, & 7 that don't
> significantly differ from each other. Is there any _simple_ way to
> mark all of them as a group?
>
> If you have any ideas, I'd be grateful.
>
> Thanks in advance,
> Timo
>
> __
> 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] plotting lines when data has missing/NA values

2010-07-08 Thread Ted Harding
On 08-Jul-10 19:52:36, Justin Fincher wrote:
> Howdy,
>I have done many searches and can't seem to find a way around this.
>  I am reading in a .csv file where each row is a dataset and each
> column represents a position.  The values are sparse (there are 2003
> positions but usually only 100-200 values) and the idea is to be able
> to plot each dataset (row) and overlay them in different combinations.
>  What I would like to do is have a plot where each data point is
> connected by a line, but since there are numerous NA values between
> each real data value, I have yet to find out to do this.  Essentially
> I would like each data point to be connected to the next non-NA data
> point.  I also thought about subsetting the relevant data points out,
> but am unsure how to do this while retaining the column numbers so
> they will not be affected spatially.  Any help would be greatly
> appreciated.
> 
> - Fincher

The following small artificial example may do what you seem to want
(if the general idea is right, it should be straightforward to
modify the details to taste):

set.seed(54321)
D <- matrix(rep(NA,60),nrow=4)
D[sample(60,20)] <-runif(20)
print(D,3)
#   [,1] [,2]  [,3]   [,4] [,5]  [,6]  [,7]  [,8]
# [1,] 0.825   NANA NA   NA 0.905NANA
# [2,]NA   NANA 0.0763 0.54NANANA
# [3,]NA   NA 0.130 0.2061   NA 0.622NA 0.330
# [4,] 0.879   NANA NA   NA 0.937 0.204 0.953
#[,9] [,10] [,11] [,12] [,13] [,14] [,15]
# [1,] 0.0378 0.170NANANANANA
# [2,] NA 0.484 0.894 0.230NANANA
# [3,] NANANANANA 0.131NA
# [4,] NANA 0.389 0.859NANANA
posns<-(1:15)
cols <-c("red","green","blue","yellow")
M<-max(D,na.rm=TRUE)
ix.NA <- which(!is.na(D[1,]))
plot(posns[ix.NA],D[1,ix.NA],pch="+",xlim=c(0,16),ylim=c(0,M))
lines(posns[ix.NA],D[1,ix.NA])
for(i in (2:nrow(D))){
  ix.NA <- which(!is.na(D[i,]))
  points(posns[ix.NA],D[i,ix.NA],pch="+",ylim=c(0,M))
  lines(posns[ix.NA],D[i,ix.NA],col=cols[(i-1)])
}

Hoping this helps!
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 08-Jul-10   Time: 21:34:18
-- XFMail --

__
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] combining P values from different tests

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 2:45 PM, Jonathan Baron wrote:

On 07/08/10 19:25, Knut Krueger wrote:
> Hi to all,
> is there any function available to combine those p values;
> 
> 
> Kind Regards Knut


Here's a couple of functions I've used for one thing that you might
mean.  The idea is that you have two p-values for different tests of
the same hypothesis, and you want to get an overall p-value for the
hypothesis.  The first method, for combining two p-values, was
invented by Fisher a very long time ago.  The second method I do not
remember a thing about, but I found it somewhere.  You need to look
these up before trusting them.

# combine and output one-tailed p's.  Enter 2-tailed p's.
combine <- function(x,y)
return(pchisq(-2*log(x/2)-2*log(y/2),4,low=F)) 
  
This assumes the two p values are independent, but you don't want to 
divide x and y by 2:  that biases things towards smaller p-values.  (I'm 
not sure what you mean by "2-tailed p's" though, so I might be wrong.)

# Stouffer's method for vector x, gives 2-tailed result
 pnorm(sum(qnorm(x))/sqrt(length(x)))
  

This also assumes independence between the tests.

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] Error in which()

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 3:23 PM, Muhammad Rahiz wrote:


Hi all,

I'm trying to filter data into respective numbers. For example, if  
the data ranges from 0 to <0.1, group the data. And so on for the  
rest of the data.
There are inconsistencies in the output. For example, b1[[3]] lumps  
all the 0.2s and 0.3s together while 0.6s are not in the output.


Any time you are working with floating point numbers you should be  
using all.equal rather than ==. You could easily be getting bitten by  
a test for >= that declares this to be FALSE when you expected it to  
be TRUE


Running the function - table(f1) - shows that each of the components/ 
numbers has x number of elements in them. But this is not showing in  
the results of the script.


Can anyone assist?


Thanks,

Muhammad




f1 <- read.table("data.txt")
f1 <- f1[which(is.na(f1)==FALSE),1]


f1 is a data.frame and "[which( ==FALSE), "  is same as "[ !is.na() ,  
" so could use


f1 <- f1[ !is.na(f1[,1]), 1]1]


x0 <- seq(0,1,0.1)
x1 <- x0 +0.1

b1 <- c()
for (a in 1:length(x)){
b1[[a]] <- f1[which(f1 >= x0[a] & f1 < x1[a])]
}


That was really not a minimal example, now was it? Used a very small  
fraction of your data.


For me this throws an error since x is not defined. Modifying it so x  
becomes x0 and adding the column number "1" to f1's indexing gets me  
something like what you are describing. It's undoubtedly a case of FAQ  
7.31


> b2 <-findInterval(f1[,1], seq(0, 1, by=0.1) )
> str(b2)
 int [1:120] 11 10 9 10 10 7 10 9 9 7 ...
> table(b2)
b2
 2  3  5  6  7  9 10 11
 1 15 17 56 21  5  4  1
> table(f1[,1])

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9   1
  1   4  11  17  18  38  21   5   4   1

Notice that the 0.5 and 0.6es get lumped into the same box. Methods  
for discrete variables are more appropriate here. However, if you know  
that you numbers are all rounded to the nearest tenth, then add (or  
subtract) 0.05 to your boundary criteria so you won't run into  
numerical representation problems. (See below. I'm not sure that cut()  
will solve your troubles here.)


> table(cut(f1[,], seq(0,1,by=0.1) , include.lowest=TRUE,  
right=FALSE ))


  [0,0.1) [0.1,0.2) [0.2,0.3) [0.3,0.4) [0.4,0.5) [0.5,0.6) [0.6,0.7)  
[0.7,0.8)
0 115 01756 
21 0

[0.8,0.9)   [0.9,1]
5 5

Notice the gap in the 0.4 category. This may be why the S/R designers  
chose to make the default for right=TRUE.





--

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] plotting lines when data has missing/NA values

2010-07-08 Thread Justin Fincher
Howdy,
   I have done many searches and can't seem to find a way around this.
 I am reading in a .csv file where each row is a dataset and each
column represents a position.  The values are sparse (there are 2003
positions but usually only 100-200 values) and the idea is to be able
to plot each dataset (row) and overlay them in different combinations.
 What I would like to do is have a plot where each data point is
connected by a line, but since there are numerous NA values between
each real data value, I have yet to find out to do this.  Essentially
I would like each data point to be connected to the next non-NA data
point.  I also thought about subsetting the relevant data points out,
but am unsure how to do this while retaining the column numbers so
they will not be affected spatially.  Any help would be greatly
appreciated.

- Fincher

__
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] Error in which()

2010-07-08 Thread Sarah Goslee
Congratulations, you've run afoul of:

 7.31 Why doesn't R think these numbers are equal?

> x0[7]
[1] 0.6
>
> x0[7] == .6
[1] FALSE
>

Sarah

On Thu, Jul 8, 2010 at 3:23 PM, Muhammad Rahiz
 wrote:
> Hi all,
>
> I'm trying to filter data into respective numbers. For example, if the data
> ranges from 0 to <0.1, group the data. And so on for the rest of the data.
> There are inconsistencies in the output. For example, b1[[3]] lumps all the
> 0.2s and 0.3s together while 0.6s are not in the output.
>
> Running the function - table(f1) - shows that each of the components/numbers
> has x number of elements in them. But this is not showing in the results of
> the script.
>
> Can anyone assist?
>
>
> Thanks,
>
> Muhammad
>
>
>
>
> f1 <- read.table("data.txt")
> f1 <- f1[which(is.na(f1)==FALSE),1]
>
>
> x0 <- seq(0,1,0.1)
> x1 <- x0 +0.1
>
> b1 <- c()
> for (a in 1:length(x)){
> b1[[a]] <- f1[which(f1 >= x0[a] & f1 < x1[a])]
> }
>
> --



-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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] Error in which()

2010-07-08 Thread Muhammad Rahiz

Hi all,

I'm trying to filter data into respective numbers. For example, if the 
data ranges from 0 to <0.1, group the data. And so on for the rest of 
the data.
There are inconsistencies in the output. For example, b1[[3]] lumps all 
the 0.2s and 0.3s together while 0.6s are not in the output.


Running the function - table(f1) - shows that each of the 
components/numbers has x number of elements in them. But this is not 
showing in the results of the script.


Can anyone assist?


Thanks,

Muhammad




f1 <- read.table("data.txt")
f1 <- f1[which(is.na(f1)==FALSE),1]


x0 <- seq(0,1,0.1)
x1 <- x0 +0.1

b1 <- c()
for (a in 1:length(x)){
b1[[a]] <- f1[which(f1 >= x0[a] & f1 < x1[a])]
}

--

1
0.9
0.8
0.9
0.9
0.7
0.9
0.8
0.8
0.7
0.7
0.8
0.5
0.6
0.3
0.6
0.5
0.7
0.7
0.7
0.5
0.4
0.4
0.7
0.8
0.4
0.5
0.5
0.6
0.7
0.6
0.5
0.6
0.4
0.6
0.7
0.5
0.4
0.5
0.4
0.6
0.6
0.5
0.6
0.6
0.6
0.6
0.6
0.6
0.5
0.6
0.4
0.4
0.3
0.6
0.6
0.7
0.7
0.6
0.6
0.7
0.6
0.6
0.2
0.3
0.4
0.3
0.3
0.3
0.3
0.7
0.6
0.6
0.6
0.7
0.7
0.6
0.5
0.6
0.6
0.4
0.4
0.4
0.2
0.2
0.3
0.5
0.6
0.6
0.7
0.6
0.7
0.6
0.6
0.7
0.6
0.5
0.5
0.4
0.5
0.2
0.3
0.3
0.4
0.5
0.5
0.4
0.7
0.4
0.7
0.7
0.6
0.6
0.6
0.6
0.1
0.6
0.3
0.5
0.4
0.4
0.2
0.3
0.6
0.5
0.5
0.5
0.4
0.6
0.6
0.6
0.6
0.6
0.6
0.6
0.1
0.1
0.7
0.5
0.5
0.4
0.3
0.4
0.4
0.4
0.5
0.4
0.6
0.4
0.4
0.7
0.5
0.7
0.6
0.6
0.6
0.1
0.1
0.5
0.3
0.6
0.3
0.4
0.5
0.6
0.6
0.4
0.5
0.5
0.4
0.5
0.7
0.7
0.4
0.6
0
0
0
0
0
0.1
0.1
0.1
0.4
0.4
0.4
0.6
0.4
0.4
0.6
0.6
0.7
0.6
0.6
0.6
0.5
0.6
0.7
0
0
0
0
0
0
0
0
0
0
0
0.1
0.1
0.4
0.3
0.5
0.4
0.3
0.5
0.2
0.6
0.7
0.6
0.7
0.7
0.5
0.6
0.6
0.6
0
0
0
0
0
0
0
0
0.2
0
0.1
0.1
0.1
0.1
0.5
0.5
0.4
0.5
0.4
0.4
0.3
0.5
0.5
0.7
0.7
0.7
0.6
0.7
0.7
0.6
0.6
0.5
0.5
0.6
0
0
0
0
0
0
0
0
0.3
0.5
0.4
0.4
0.5
0.5
0.4
0.4
0.3
0.4
0.5
0.3
0.7
0.6
0.6
0.5
0.6
0.4
0.5
0.5
0.5
0.6
0
0
0
0
0
0
0.2
0.3
0.3
0.5
0.5
0.5
0.3
0.6
0.5
0.3
0.3
0.5
0.4
0.7
0.6
0.6
0.6
0.5
0.5
0.5
0.5
0.6
0.6
0.3
0
0
0
0
0.1
0
0.2
0.2
0.3
0.3
0.4
0.2
0.3
0.4
0.4
0.4
0.4
0.3
0.7
0.6
0.7
0.6
0.6
0.6
0.5
0.4
0.5
0.5
0.6
0.5
0.5
0.5
0.6
0.5
0.1
0.1
0
0
0.1
0.1
0
0.1
0.1
0.1
0.2
0.2
0.5
0.4
0.4
0.3
0.3
0.3
0.3
0.5
0.4
0.5
0.7
0.5
0.7
0.6
0.6
0.6
0.5
0.5
0.4
0.5
0.5
0.5
0.5
0.5
0.6
0.6
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.3
0.3
0.3
0.4
0.5
0.4
0.4
0.4
0.4
0.6
0.5
0.6
0.7
0.7
0.6
0.6
0.7
0.5
0.5
0.5
0.6
0.5
0.6
0.5
0.5
0.5
0.5
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.2
0.1
0
0.2
0.4
0.3
0.5
0.4
0.4
0.5
0.5
0.5
0.5
0.6
0.7
0.7
0.6
0.6
0.6
0.6
0.6
0.6
0.7
0.6
0.6
0.5
0.6
0.6
0.5
0.5
0.1
0.1
0.1
0.1
0.1
0.2
0.1
0.1
0.2
0.1
0.1
0
0
0
0.2
0.2
0.3
0.3
0.5
0.6
0.5
0.5
0.5
0.6
0.6
0.4
0.4
0.4
0.4
0.5
0.4
0.5
0.6
0.7
0.6
0.6
0.6
0.5
0.6
0.6
0.6
0.6
0.6
0.6
0.1
0.1
0.1
0.1
0.1
0.2
0.2
0.2
0.2
0.1
0.1
0
0.1
0.1
0
0.1
0.2
0.2
0.2
0.3
0.4
0.3
0.3
0.5
0.6
0.5
0.6
0.6
0.6
0.5
0.7
0.7
0.6
0.4
0.4
0.4
0.6
0.7
0.7
0.7
0.7
0.6
0.6
0.5
0.6
0.5
0.5
0.5
0
0
0.1
0.1
0.1
0.2
0.2
0.2
0.2
0.2
0
0
0
0.1
0.1
0.2
0.2
0.3
0.2
0.4
0.3
0.3
0.4
0.4
0.3
0.5
0.5
0.5
0.4
0.5
0.7
0.7
0.6
0.5
0.4
0.4
0.4
0.4
0.7
0.6
0.6
0.6
0.6
0.7
0.6
0.5
0.5
0.5
0.2
0.2
0.2
0.2
0.1
0.1
0.2
0.2
0.2
0.2
0.2
0.1
0
0
0
0
0.1
0.1
0.1
0.1
0.3
0.3
0.2
0.2
0.4
0.3
0.4
0.4
0.3
0.4
0.5
0.3
0.7
0.4
0.5
0.6
0.6
0.5
0.6
0.6
0.6
0.5
0.5
0.6
0.6
0.5
0.6
0.5
0.3
0.5
0.5
0.5
0.6
0.4
0.3
0.3
0
0.1
0.1
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0.1
0
0
0
0
0.1
0
0.2
0.2
0.1
0.1
0.2
0.1
0.1
0.2
0.1
0.1
0.2
0.4
0.2
0.2
0.2
0.3
0.4
0.4
0.4
0.3
0.3
0.4
0.5
0.5
0.5
0.7
0.6
0.6
0.6
0.6
0.7
0.6
0.5
0.7
0.7
0.5
0.6
0.7
0.5
0.5
0.5
0.4
0.5
0.2
0.4
0.5
0.3
0.2
0.2
0.3
0
0.1
0.1
0.1
0.1
0.2
0.2
0.3
0.2
0.1
0
0
0
0.1
0.2
0.1
0.2
0.2
0.2
0.1
0.1
0.2
0.1
0.1
0.1
0.1
0.2
0.1
0.1
0.1
0.1
0.1
0.2
0.2
0.4
0.2
0.3
0.4
0.4
0.4
0.4
0.6
0.7
0.4
0.4
0.5
0.6
0.6
0.6
0.7
0.5
0.5
0.6
0.6
0.6
0.7
0.7
0.6
0.6
0.5
0.5
0.3
0.3
0.1
0.4
0.4
0.3
0.3
0.3
0.3
0.1
0.1
0.1
0.1
0.1
0.1
0.2
0.2
0.1
0.1
0
0
0
0.2
0.2
0.2
0.2
0.2
0.1
0.2
0.1
0.1
0.2
0.1
0.2
0.2
0.1
0.1
0.2
0.2
0.2
0.2
0.2
0.2
0.3
0.4
0.4
0.4
0.5
0.7
0.7
0.6
0.5
0.6
0.6
0.4
0.5
0.6
0.6
0.7
0.6
0.6
0.5
0.5
0.5
0.4
0.4
0.3
0.3
0.2
0.1
0.1
0.1
0.1
0.1
0.1
0.1
0.2
0.1
0.1
0.1
0.2
0.2
0.2
0.2
0.1
0
0.1
0.2
0.1
0.2
0.2
0.2
0.1
0.1
0.1
0.2
0.3
0.3
0.3
0.4
0.4
0.3
0.6
0.6
0.4
0.5
0.6
0.6
0.6
0.6
0.6
0.6
0.6
0.5
0.5
0.3
0.3
0
0
0.2
0.2
0.2
0.2
0.1
0.1
0
0.1
0.1
0.1
0.2
0.2
0.1
0.1
0.3
0.1
0.1
0.1
0.2
0.1
0.3
0.3
0.3
0.4
0.5
0.5
0.5
0.6
0.6
0.6
0.6
0.6
0.6
0.5
0.5
0.5
0.2
0.3
0.2
0.2
0
0.2
0.2
0.2
0
0.2
0.2
0.1
0.1
0.1
0.1
0.3
0.3
0.1
0.3
0.3
0.2
0.1
0.2
0.1
0.2
0.2
0.3
0.3
0.4
0.4
0.4
0.3
0.6
0.5
0.6
0.6
0.6
0.4
0.6
0.6
0.6
0.5
0.5
0.2
0.2
0.2
0.3
0
0
0.2
0.2
0.2
0.1
0.1
0.1
0.1
0.2
0.2
0.1
0.2
0.1
0.2
0.3
0.3
0.2
0.3
0.2
0.2
0.2
0.2
0.2
0.3
0.6
0.4
0.5
0.4
0.4
0.3
0.2
0.4
0.6
0.6
0.6
0.6
0.6
0.5
0.6
0.6
0.3
0.2
0.3
0.3
0.2
0.1
0.2
0.2
0.1
0.1
0
0.1
0
0
0.2
0
0.1
0.1
0.2
0.1
0.1
0.2
0.1
0.2
0.3
0.3
0.2
0.3
0.3
0.2
0.2
0.2
0.3
0.2
0.2
0.3
0.3
0.4
0.3
0.3
0.4
0.4
0.4
0.4
0.4
0.4
0.3
0.3
0.5
0.7
0.6
0.7
0.7
0.7
0.6
0.6
0.2
0.3
0.2
0.3
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0.2
0
0
0
0
0.1
0
0.1
0.1
0
0
0
0.1
0.2
0.2
0.1
0
0.2
0.1
0.1
0

Re: [R] combining P values from different tests

2010-07-08 Thread Achim Zeileis

On Thu, 8 Jul 2010, David Winsemius wrote:



On Jul 8, 2010, at 2:17 PM, Stephan Kolassa wrote:


Knut Krueger schrieb:

Hi to all,
is there any function available to combine those p values;



Hi Knut,

?"+"



That is certainly in the running for shortest possible fortune.


Added to the devel-version on R-Forge.

It is related (both in length and content) to fortune(264). :-)

Soham: How to compute the p-value of a statistic generally?
Berton Gunter: runif(1)
   -- Soham and Berton Gunter
  R-help (May 2010)




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

Best,
Stephan



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-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] combining P values from different tests

2010-07-08 Thread Jonathan Baron
On 07/08/10 19:25, Knut Krueger wrote:
> Hi to all,
> is there any function available to combine those p values;
> 
> 
> Kind Regards Knut

Here's a couple of functions I've used for one thing that you might
mean.  The idea is that you have two p-values for different tests of
the same hypothesis, and you want to get an overall p-value for the
hypothesis.  The first method, for combining two p-values, was
invented by Fisher a very long time ago.  The second method I do not
remember a thing about, but I found it somewhere.  You need to look
these up before trusting them.

# combine and output one-tailed p's.  Enter 2-tailed p's.
combine <- function(x,y)
return(pchisq(-2*log(x/2)-2*log(y/2),4,low=F)) 

# Stouffer's method for vector x, gives 2-tailed result
 pnorm(sum(qnorm(x))/sqrt(length(x)))
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

__
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] combining P values from different tests

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 2:17 PM, Stephan Kolassa wrote:


Knut Krueger schrieb:

Hi to all,
is there any function available to combine those p values;



Hi Knut,

?"+"



That is certainly in the running for shortest possible fortune.


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

Best,
Stephan



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] Query about using timestamps returned by SQL as 'factor' for split

2010-07-08 Thread Ted Byers
I have a simple query as follows:

"SELECT
m_id,sale_date,YEAR(sale_date),WEEK(sale_date),return_type,DATEDIFF(return_date,sale_date)
AS elapsed_time FROM risk_input"

I can get, and view, all the data that that query returns.  The question is,
sale_date is a timestamp, and I need to call split to group this data by
m_id and the week in which the sale occurred.  Obviously, I would normally
need both YEAR and WEEK so that data from April this year is not combined
with that from last year (the system is non-autonomous).  And then I need to
use lapply to apply fitdistr to each subsample.

Obviously, I can handle all this data in either a data.frame or in a
data.table.

There are two aspects of the question.

1) Is there a function (or package) that will let me group (or regroup) time
series data into the week in which the data apply, properly taking into
account the year that applies, in a single call passing sale_date as the
argument?  If I can, then I can reduce the amount of data I draw from my
MySQL server and the computational load it bears.

2) The example provided for split splits only according to a single variable
(*g <- airquality$Month;l <- split(airquality, g)*).  How would that example
be changed if there were two or more columns in the data.frame that are
needed to define the groups?  I.E. in my example, I'd need to group by m_id,
and the year and week values that can be computed from sale_date.

Thanks

Ted

[[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] Psudeo R^2 (or other effect size) in spatial gls regressions

2010-07-08 Thread J. Sebastian Tello
Dear all,

I have been using the function gls in the package nlme in R to fit some spatial 
regressions (as described in Dormann et al.). However, I have been struggling 
trying to find a way to calculate a measure of effect size from these models, 
so 
I wanted to know if any of you had an idea on how to do this.

More precisely, I am producing a multiple model with an exponential correlation 
structure:

spatial.gls<-gls(Y~X+Z, correlation=corExp(form=~long+lat))

I know that in this kind of models one possible measure of effect size is a 
pseudo R^2 value, so I have been calculating it like this:

null.gls<-gls(Y~1)
yN<-length(Y)

lL.B<-logLik(spatial.gls)
lL.0<-logLik(null.gls)

Nagelkerke<-(1-exp((lL.B-lL.0)*(-2/yN)))/(1-exp((lL.0)*(2/yN)))
Nagelkerke[1]

However, the value that is produced is extremely close to 1 (>0.97), very 
different from the R^2 produced by a simple linear model model:

no.spatial.lm<-lm(Y~X+Z)

or equivalently by the pseudo R^2 as calculated above of the non spatial gls

no.spatial.gls<-gls(Y~X+Z)

Which is only of about 0.5. So it seems to me that the Pseudo R^2 calculated as 
I have reflects the fit of the model including the spatial structure, and not 
only the effect of the predictors in the model. Is there a way to calculate an 
effect size (e.g. a pseudo R^2) of these “spatial” gls models that only 
measures 
the effect of the predictors in the model?

I'd really appreciate any insights into this.

Very best,

Sebastian



 J. Sebastián Tello


Department of Biological Sciences
285 Life Sciences Building
Louisiana State University
Baton Rouge, LA, 70803
(225) 578-4284 (office and lab.)



  
[[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] combining P values from different tests

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 1:25 PM, Knut Krueger wrote:

Hi to all,
is there any function available to combine those p values;


No, not in general, because the proper way to do it depends on the joint 
distribution of the inputs, and what you want to use the combined value 
to test.


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] combining P values from different tests

2010-07-08 Thread Stephan Kolassa

Hi Knut,

?"+"

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

Best,
Stephan


Knut Krueger schrieb:

Hi to all,
is there any function available to combine those p values;


Kind Regards Knut

__
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] Using nlm or optim

2010-07-08 Thread Anita Narwani
Hi All,

Thanks for all of your help. I hadn't posted error messages, because I had
tried many different formulations of those functions and each one gave a
different error message. However, using your suggestions, I managed to make
it work.

You were right in that I only needed to call the constant parameters, c and
z. I wanted to define s within the nll() function. Mean and Var are
variables that are attached to the workspace in a dataframe. This worked:

Predict <- function(Mean,c,z)
{
v = c*Mean^z
return(v)
}

nll <- function(c,z){
n<-length(Mean)
s<-(sum(Var-Predict(Mean,c,z))^2)/n
logl<- -0.5*n*log(2*pi) -0.5*n*log(s) -
(1/(2*s))*sum((Var-Predict(Mean,c,z))^2)
return(-logl)
}

Mean <- rexp(130)
Var <- runif(130)

mle(nll,start=list(c=0.01,z=2.1))

It also worked for my actual data. It gives similar estimates for c and z as
nls, which is also a good sign, although, given normal errors, I believe nls
and maximum likelihood estimation should give the same parameter estimates.

Thanks again.
Anita.




On Thu, Jul 8, 2010 at 6:48 AM, Ravi Varadhan  wrote:

> Hi,
>
> When you report errors please send a reproducible example that will allow
> us to better help you.  At a minimum, you should cut and paste the actual
> call and the error message.
>
> I think the problem is that you should only have parameters as arguments,
> i.e. only c and z should be in the argument list to nll().
>
> This works:
>
> Predict <- function(M,c,z){
> v = c*M^z
> return(v)
> }
>
> nll <- function(c,z){
> n<-length(M)
> logl<- -.5*n*log(2*pi) -.5*n*log(s) - (1/(2*s))*sum((V-Predict(M,c,z))^2)
> return(-logl)
> }
>
> M <- rexp(130)
> V <- runif(130)
> s <- 200
>
> mle(nll,start=list(c=0.01,z=2.1))
>
> > mle(nll,start=list(c=0.01,z=2.1))
>
> Call:
> mle(minuslogl = nll, start = list(c = 0.01, z = 2.1))
>
> Coefficients:
>  c   z
>  0.48547691 -0.01018601
> >
>
> Hope this helps,
> Ravi.
> 
>
> Ravi Varadhan, Ph.D.
> Assistant Professor,
> Division of Geriatric Medicine and Gerontology
> School of Medicine
> Johns Hopkins University
>
> Ph. (410) 502-2619
> email: rvarad...@jhmi.edu
>
>
> - Original Message -
> From: Anita Narwani 
> Date: Wednesday, July 7, 2010 9:11 pm
> Subject: [R] Using nlm or optim
> To: r-help@r-project.org
>
>
> > Hello,
> >  I am trying to use nlm to estimate the parameters that minimize the
> >  following function:
> >
> >  Predict<-function(M,c,z){
> >  + v = c*M^z
> >  + return(v)
> >  + }
> >
> >  M is a variable and c and z are parameters to be estimated.
> >
> >  I then write the negative loglikelihood function assuming normal errors:
> >
> >  nll<-function(M,V,c,z,s){
> >  n<-length(Mean)
> >  logl<- -.5*n*log(2*pi) -.5*n*log(s) -
> (1/(2*s))*sum((V-Predict(Mean,c,z))^2)
> >  return(-logl)
> >  }
> >
> >  When I put the Mean and Variance (variables with 136 observations)
> > into this
> >  function, and estimates for c,z, and s, it outputs the estimate for the
> >  normal negative loglikelihood given the data, so I know that this works.
> >
> >  However, I am unable to use mle to estimate the parameters c, z, and
> > s. I do
> >  not know how or where the data i.e. Mean (M) and Variance (V) should
> > enter
> >  into the mle function. I have tried variations on
> >
> >  mle(nll,start=list(c=0.01,z=2.1,s=200)) including
> >  mle(nll,start=list(M=Mean,V=Var, c=0.01,z=2.1,s=200))
> >
> >  I keep getting errors and am quite certain that I just have a syntax
> > error
> >  in the script because I don't know how to enter the variables into MLE.
> >
> >  Thanks for your help,
> >  Anita.
> >
> >   [[alternative HTML version deleted]]
> >
> >  __
> >  R-help@r-project.org mailing list
> >
> >  PLEASE do read the posting guide
> >  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] combining P values from different tests

2010-07-08 Thread Knut Krueger

Hi to all,
is there any function available to combine those p values;


Kind Regards Knut

__
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] Custom multi-line header for pair plots

2010-07-08 Thread Tal Galili
Have a look at the
text.panel
parameter in ?pairs

Cheers,
Tal


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 Thu, Jul 8, 2010 at 5:36 PM,  wrote:

> Hi All,
>
> Is there a possible way to customize the header text appearing on the
> diagonal of a pair plot? My header is:
>
> Biomass PoB QoB ... etc.
>
> I want to put additional information in the diagonal boxes where header
> text appears such as mean, standard deviation of data. If I add these
> information to the header row of my data, the font size becomes to small
> and R plots the header text in one line therefore it does not fit inside
> the box.
>
> Can you help me?
>
> Regards,
>
> Ekin Akoglu
>
> __
> 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.


Re: [R] How can i draw a graph with high and low data points

2010-07-08 Thread Tal Galili
Hi Nathaniel,

Here are a few links for (short) articles that can help you get comfortable
in doing such tasks:
http://www.statmethods.net/graphs/line.html
http://www.statmethods.net/graphs/scatterplot.html

Here is a tiny example:


x <- 1:100
y <- rnorm(100)

plot(y~x)
lines(loess(y~x)$fitted ~ x)
lines(loess(y~x)$fitted + 1.96 ~ x, col = 2, lty = 2)
lines(loess(y~x)$fitted - 1.96 ~ x, col = 2, lty = 2)


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 Thu, Jul 8, 2010 at 7:00 PM, Nathaniel Saxe wrote:

>
> Hi,
> This is my first time so bear with me if I do anything silly. I'll learn!
> I'm a relatively new user of R as well so will appreciate any help.
> I have a data set in the form
> Trial.Group MeanHeart Rate  Upper confidence level
>  Lower confidence level
> 333subj: 0-5 M  80  60
>  120etcetc
>
> I want to plot a graph that has Trial.Group on the x axis(names, not just
> an index number), Heart rate on the y axis with the Mean and upper and lower
> confidence levels. Then add a line linking the upper and lower confidence
> interval together and for the Mean heart rate values to go from high to low
> (descending ).
> Thanks
>
> henry gu
> _
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] download gplots and caTools

2010-07-08 Thread Tal Galili
Hi Tra,
Try another mirror, and worst case - just download it from the CRAN website

Cheers,
Tal

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 Thu, Jul 8, 2010 at 6:28 PM, Tra, Yolande  wrote:

> Dear list,
>
> I am using R.2.11.1 version on a PC. I downloaded successfully gplots_2.8.0
>  but I could not find where to download caTools
>
> > library("gplots")
> Loading required package: caTools
> Error: package 'caTools' could not be loaded
> In addition: Warning message:
> In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc =
> lib.loc) :
>  there is no package called 'caTools'
>
> any help is greatly appreciated
> Yolande
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] glmnet - choosing the number of features

2010-07-08 Thread Steve Lianoglou
Hi Brian,

On Wed, Jul 7, 2010 at 10:54 PM, Brian Tsai  wrote:
> Hi,
>
> I am trying to use the glmnet package to do some simple feature selection.
>  However,  I would ideally like to be able to specify the number of features
> to return (the glmnet package, as far as I can tell, only allows
> specification of a regularization parameter, lambda, that in turn returns a
> model with a specific number of non-zero features).
>
> Is there a straightforward way of calculating the lambda value that will
> return a specific number of features? I realize there is a range of lambdas
> that should give a certain number of non-zero features, but is there an easy
> way of figuring out what this range is?

Perhaps the "dfmax" argument to the glmnet function is what you're after?

dfmax::
Limit the maximum number of variables in the model. Useful for very
large nvars, if a partial path is desired.

See ?glmnet for more information.

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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 Assignment -- Why won't it let me do it?

2010-07-08 Thread Adam Berrones

That was it!  You honestly made my week, thank you for that.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Vector-Assignment-Why-won-t-it-let-me-do-it-tp2281698p2282562.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] How can i draw a graph with high and low data points

2010-07-08 Thread Nathaniel Saxe

Hi, 
This is my first time so bear with me if I do anything silly. I'll learn!
I'm a relatively new user of R as well so will appreciate any help.
I have a data set in the form
Trial.Group MeanHeart Rate  Upper confidence level  
Lower confidence level  
333subj: 0-5 M  80  60  
120etcetc

I want to plot a graph that has Trial.Group on the x axis(names, not just an 
index number), Heart rate on the y axis with the Mean and upper and lower 
confidence levels. Then add a line linking the upper and lower confidence 
interval together and for the Mean heart rate values to go from high to low 
(descending ). 
Thanks

henry gu  
_


[[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 Gnuplot from R

2010-07-08 Thread Erik Iverson
See this page for an alternative approach.  It shows how you can use R 
with gnuplot.


http://orgmode.org/worg/org-contrib/babel/examples/data-collection-analysis.php

Octave is also supported by org-babel.



Matt Shotwell wrote:

I recently wrote a small R function to draw simple ASCII scatterplots.
http://biostatmatt.com/archives/491
Bill Harris commented that the plots reminded him of the "dumb" terminal
of Gnuplot. I think it would be really neat to have an R graphics driver
to Gnuplot in order to generate more complete ASCII graphics in R. Maybe
there are other good reasons also? I believe octave makes good use of
Gnuplot...

-Matt

On Thu, 2010-07-08 at 11:28 -0400, Erik Iverson wrote:
If you use Emacs, you can use org-mode with org-babel to facilitate 
this... I'll refrain from asking why :).


See: http://orgmode.org/worg/org-contrib/babel/index.php

Christopher Desjardins wrote:

Hi,
I am wondering if there is a way to call Gnuplot from R and/or if anyone can
recommend a package on CRAN capable of doing this?
Thanks,
Chris
PS - Please cc me on the response.

[[alternative HTML version deleted]]

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

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


__
R-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] download gplots and caTools

2010-07-08 Thread Tra, Yolande
Dear list,

I am using R.2.11.1 version on a PC. I downloaded successfully gplots_2.8.0  
but I could not find where to download caTools

> library("gplots")
Loading required package: caTools
Error: package 'caTools' could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = 
lib.loc) :
  there is no package called 'caTools'

any help is greatly appreciated
Yolande

[[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 Gnuplot from R

2010-07-08 Thread Matt Shotwell
I recently wrote a small R function to draw simple ASCII scatterplots.
http://biostatmatt.com/archives/491
Bill Harris commented that the plots reminded him of the "dumb" terminal
of Gnuplot. I think it would be really neat to have an R graphics driver
to Gnuplot in order to generate more complete ASCII graphics in R. Maybe
there are other good reasons also? I believe octave makes good use of
Gnuplot...

-Matt

On Thu, 2010-07-08 at 11:28 -0400, Erik Iverson wrote:
> If you use Emacs, you can use org-mode with org-babel to facilitate 
> this... I'll refrain from asking why :).
> 
> See: http://orgmode.org/worg/org-contrib/babel/index.php
> 
> Christopher Desjardins wrote:
> > Hi,
> > I am wondering if there is a way to call Gnuplot from R and/or if anyone can
> > recommend a package on CRAN capable of doing this?
> > Thanks,
> > Chris
> > PS - Please cc me on the response.
> > 
> > [[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.
-- 
Matthew S. Shotwell
Graduate Student
Division of Biostatistics and Epidemiology
Medical University of South Carolina
http://biostatmatt.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 do I test against a simple null that tworegressions coefficients are equal?

2010-07-08 Thread chen jia
Bert,

Thanks for replying. Actually, Chuck and Mark's suggestions already
helped, especially regarding to the problem you call type III error.

Best,
Jia

On Thu, Jul 8, 2010 at 11:06 AM, Bert Gunter  wrote:
> Inline below.
>
> Bert Gunter
> Genentech Nonclinical Statistics
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>> On Behalf Of markle...@verizon.net
>> Sent: Thursday, July 08, 2010 7:52 AM
>> To: chen_1...@fisher.osu.edu
>> Cc: r-help@r-project.org; cbe...@tajo.ucsd.edu
>> Subject: Re: [R] How do I test against a simple null that tworegressions
>> coefficients are equal?
>>
>>
>>    hi: no. it's not the same. if you read the paper that I referenced last
>>    night, that explains how to do the following  test :
>>    Ho: R2 = R1
>>    H1: R2 != R1
>>    that's a different test from what you did but i think it's what you
>> want.
>>
>>    On Jul 8, 2010, chen jia  wrote:
>>
>>      Thanks, Chuck. I am reading the references, which are helpful.
>>      Just to understand what I have done wrong here,
>>      I proposed an alternative testing strategy:
>>      I run regressions y = a3 + b1 * x + b2 * z + e3 and test alternative
>>      hypothesis b1 != b2 against the null hypothesis b1 = b2 in this
>>      equation.
>
> If this is what you want (see below) try this:
>
> w <- x + z
>
> anova(lm(y ~ w), lm(y ~ x + w))
>
>
> However, as you seem to be somewhat at sea in your basic statistical
> knowledge, I suggest you consult a local statistician to make sure whether
> you are asking sensible questions in the first place. You appear to be at
> high risk for type III error (right answer to wrong question).
>
> -- Bert
>
>
>
>
>>      Is it this the same test as
>>      y = a1 + b1*x + e1
>>      y = a2 + b2*x + e2
>>      test alternative hypothesis b1 != b2 against null hypothesis b1 = b2.
>>      Best,
>>      Jia
>>      On Wed, Jul 7, 2010 at 11:12 PM, Charles C. Berry
>> 
>>      wrote:
>>      > On Wed, 7 Jul 2010, chen jia wrote:
>>      >
>>      >> Hi there,
>>      >>
>>      >> I run two regressions:
>>      >>
>>      >> y = a1 + b1 * x + e1
>>      >> y = a2 + b2 * z + e2
>>      >>
>>      >> I want to test against the null hypothesis: b1 = b2. Â How do I
>> design
>>      the
>>      >> test?
>>      >>
>>      >
>>      >  You  are testing a non-nested hypothesis, which requires special
>>      handling.
>>      >
>>      > The classical test is due to Hotelling, but see the references (and
>> R
>>      code
>>      > snippets) in this posting:
>>      >
>>      > Â  Â  Â  Â http://markmail.org/message/egnowmdzpzjtahy7
>>      >
>>      > (it is the merest coincidence that the above thread was initiated
>> by
>>      Mark
>>      > Leeds and that the URL is 'markmail' :-) )
>>      >
>>      > HTH,
>>      >
>>      > Chuck
>>      >
>>      >
>>      >> I think I can add two equations together and divide both sides by
>> 2:
>>      >> y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1
>> +
>>      e2).
>>      >> or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
>>      >>
>>      >> If I run this new regression, I can test against the null b1 = b2
>> in
>>      >> this regression. Â Is it an equivalent test as the original one?
>> If
>>      >> yes, how do I do that in R?
>>      >>
>>      >> Alternatively, I think I can just test against the null:
>>      >> correlation(y, x) = correlation(y, z), where correlation(. , .) is
>> the
>>      >> correlation between two random variables. Is this equivalent too?
>> If
>>      >> yes, how do I do it in R?
>>      >>
>>      >> Thanks.
>>      >>
>>      >> Best,
>>      >> Jia
>>      >>
>>      >> --
>>      >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Ohio State University - Finance
>>      >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 248 Fisher Hall
>>      >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  2100 Neil Ave.
>>      >>   Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Columbus, Ohio  43210
>>      >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Telephone: 614-292-2830
>>      >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> http://www.fisher.osu.edu/~chen_1002/
>>      >>
>>      >> __
>>      >> 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.
>>      >>
>>      >
>>      > Charles C. Berry   Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â (858)
>> 534-2098
>>      > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> Dept of
>>      Family/Preventive
>>      > Medicine
>>      > E mailto:cbe...@tajo.ucsd.edu   Â  Â  Â  Â  Â  Â  UC San Diego
>>      >  http://famprevmed.ucsd.edu/faculty/cberry/ Â La Jolla, San Diego
>>      92093-0901
>>      >
>>      >
>>      >
>>      --
>>      Ohio State University

Re: [R] How do I test against a simple null that two regressions coefficients are equal?

2010-07-08 Thread chen jia
OK. Thanks again.

I will read the references more.

Best,
Jia

On Thu, Jul 8, 2010 at 10:51 AM,   wrote:
> hi: no. it's not the same. if you read the paper that I referenced last
> night, that explains how to do the following  test :
>
> Ho: R2 = R1
>
> H1: R2 != R1
>
> that's a different test from what you did but i think it's what you want.
>
>
>
>
> On Jul 8, 2010, chen jia  wrote:
>
> Thanks, Chuck. I am reading the references, which are helpful.
>
> Just to understand what I have done wrong here,
>
> I proposed an alternative testing strategy:
> I run regressions y = a3 + b1 * x + b2 * z + e3 and test alternative
> hypothesis b1 != b2 against the null hypothesis b1 = b2 in this
> equation.
>
> Is it this the same test as
>
> y = a1 + b1*x + e1
> y = a2 + b2*x + e2
> test alternative hypothesis b1 != b2 against null hypothesis b1 = b2.
>
> Best,
> Jia
>
> On Wed, Jul 7, 2010 at 11:12 PM, Charles C. Berry 
> wrote:
>> On Wed, 7 Jul 2010, chen jia wrote:
>>
>>> Hi there,
>>>
>>> I run two regressions:
>>>
>>> y = a1 + b1 * x + e1
>>> y = a2 + b2 * z + e2
>>>
>>> I want to test against the null hypothesis: b1 = b2.  How do I design the
>>> test?
>>>
>>
>> You are testing a non-nested hypothesis, which requires special handling.
>>
>> The classical test is due to Hotelling, but see the references (and R code
>> snippets) in this posting:
>>
>>        http://markmail.org/message/egnowmdzpzjtahy7
>>
>> (it is the merest coincidence that the above thread was initiated by Mark
>> Leeds and that the URL is 'markmail' :-) )
>>
>> HTH,
>>
>> Chuck
>>
>>
>>> I think I can add two equations together and divide both sides by 2:
>>> y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 + e2).
>>> or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
>>>
>>> If I run this new regression, I can test against the null b1 = b2 in
>>> this regression.  Is it an equivalent test as the original one? If
>>> yes, how do I do that in R?
>>>
>>> Alternatively, I think I can just test against the null:
>>> correlation(y, x) = correlation(y, z), where correlation(. , .) is the
>>> correlation between two random variables. Is this equivalent too? If
>>> yes, how do I do it in R?
>>>
>>> Thanks.
>>>
>>> Best,
>>> Jia
>>>
>>> --
>>>                        Ohio State University - Finance
>>>                                  248 Fisher Hall
>>>                                   2100 Neil Ave.
>>>                             Columbus, Ohio  43210
>>>                            Telephone: 614-292-2830
>>>                      http://www.fisher.osu.edu/~chen_1002/
>>>
>>> __
>>> 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.
>>>
>>
>> Charles C. Berry                            (858) 534-2098
>>                                            Dept of Family/Preventive
>> Medicine
>> E mailto:cbe...@tajo.ucsd.edu               UC San Diego
>> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>>
>>
>>
>
>
>
> --
> Ohio State University - Finance
> 248 Fisher Hall
> 2100 Neil Ave.
> Columbus, Ohio 43210
> Telephone: 614-292-2830
> http://www.fisher.osu.edu/~chen_1002/
>
> __
> 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.
>



-- 
 Ohio State University - Finance
   248 Fisher Hall
2100 Neil Ave.
  Columbus, Ohio  43210
 Telephone: 614-292-2830
   http://www.fisher.osu.edu/~chen_1002/

__
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 Gnuplot from R

2010-07-08 Thread Erik Iverson
If you use Emacs, you can use org-mode with org-babel to facilitate 
this... I'll refrain from asking why :).


See: http://orgmode.org/worg/org-contrib/babel/index.php

Christopher Desjardins wrote:

Hi,
I am wondering if there is a way to call Gnuplot from R and/or if anyone can
recommend a package on CRAN capable of doing this?
Thanks,
Chris
PS - Please cc me on the response.

[[alternative HTML version deleted]]

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


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


[R] Calling Gnuplot from R

2010-07-08 Thread Christopher Desjardins
Hi,
I am wondering if there is a way to call Gnuplot from R and/or if anyone can
recommend a package on CRAN capable of doing this?
Thanks,
Chris
PS - Please cc me on the response.

[[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 do I test against a simple null that tworegressions coefficients are equal?

2010-07-08 Thread Bert Gunter
Inline below.

Bert Gunter
Genentech Nonclinical Statistics

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of markle...@verizon.net
> Sent: Thursday, July 08, 2010 7:52 AM
> To: chen_1...@fisher.osu.edu
> Cc: r-help@r-project.org; cbe...@tajo.ucsd.edu
> Subject: Re: [R] How do I test against a simple null that tworegressions
> coefficients are equal?
> 
> 
>hi: no. it's not the same. if you read the paper that I referenced last
>night, that explains how to do the following  test :
>Ho: R2 = R1
>H1: R2 != R1
>that's a different test from what you did but i think it's what you
> want.
> 
>On Jul 8, 2010, chen jia  wrote:
> 
>  Thanks, Chuck. I am reading the references, which are helpful.
>  Just to understand what I have done wrong here,
>  I proposed an alternative testing strategy:
>  I run regressions y = a3 + b1 * x + b2 * z + e3 and test alternative
>  hypothesis b1 != b2 against the null hypothesis b1 = b2 in this
>  equation.

If this is what you want (see below) try this:

w <- x + z

anova(lm(y ~ w), lm(y ~ x + w))


However, as you seem to be somewhat at sea in your basic statistical
knowledge, I suggest you consult a local statistician to make sure whether
you are asking sensible questions in the first place. You appear to be at
high risk for type III error (right answer to wrong question).

-- Bert




>  Is it this the same test as
>  y = a1 + b1*x + e1
>  y = a2 + b2*x + e2
>  test alternative hypothesis b1 != b2 against null hypothesis b1 = b2.
>  Best,
>  Jia
>  On Wed, Jul 7, 2010 at 11:12 PM, Charles C. Berry
> 
>  wrote:
>  > On Wed, 7 Jul 2010, chen jia wrote:
>  >
>  >> Hi there,
>  >>
>  >> I run two regressions:
>  >>
>  >> y = a1 + b1 * x + e1
>  >> y = a2 + b2 * z + e2
>  >>
>  >> I want to test against the null hypothesis: b1 = b2. Â How do I
> design
>  the
>  >> test?
>  >>
>  >
>  >  You  are testing a non-nested hypothesis, which requires special
>  handling.
>  >
>  > The classical test is due to Hotelling, but see the references (and
> R
>  code
>  > snippets) in this posting:
>  >
>  > Â  Â  Â  Â http://markmail.org/message/egnowmdzpzjtahy7
>  >
>  > (it is the merest coincidence that the above thread was initiated
> by
>  Mark
>  > Leeds and that the URL is 'markmail' :-) )
>  >
>  > HTH,
>  >
>  > Chuck
>  >
>  >
>  >> I think I can add two equations together and divide both sides by
> 2:
>  >> y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1
> +
>  e2).
>  >> or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
>  >>
>  >> If I run this new regression, I can test against the null b1 = b2
> in
>  >> this regression. Â Is it an equivalent test as the original one?
> If
>  >> yes, how do I do that in R?
>  >>
>  >> Alternatively, I think I can just test against the null:
>  >> correlation(y, x) = correlation(y, z), where correlation(. , .) is
> the
>  >> correlation between two random variables. Is this equivalent too?
> If
>  >> yes, how do I do it in R?
>  >>
>  >> Thanks.
>  >>
>  >> Best,
>  >> Jia
>  >>
>  >> --
>  >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Ohio State University - Finance
>  >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 248 Fisher Hall
>  >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  2100 Neil Ave.
>  >>                             Columbus, Ohio  43210
>  >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Telephone: 614-292-2830
>  >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
> http://www.fisher.osu.edu/~chen_1002/
>  >>
>  >> __
>  >> 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.
>  >>
>  >
>  > Charles C. Berry                            (858)
> 534-2098
>  > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
> Dept of
>  Family/Preventive
>  > Medicine
>  > E mailto:cbe...@tajo.ucsd.edu               UC San Diego
>  >  http://famprevmed.ucsd.edu/faculty/cberry/ Â La Jolla, San Diego
>  92093-0901
>  >
>  >
>  >
>  --
>  Ohio State University - Finance
>  248 Fisher Hall
>  2100 Neil Ave.
>  Columbus, Ohio 43210
>  Telephone: 614-292-2830
>  http://www.fisher.osu.edu/~chen_1002/
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide
>  http://www

Re: [R] F# vs. R

2010-07-08 Thread Steve Lianoglou
On Thu, Jul 8, 2010 at 4:44 AM, Patrick Burns  wrote:
> I'd like to hear answers to this as well.
> A language doesn't have to be a complete
> replacement to be useful.

Totally agree.

> F# seems to have some nice features.

My intention isn't to have this explode into a language war, so
apologies in advance for any collateral damage but Scala is similar in
flavor to F# and runs on the JVM, which gives it bonus points in my
mind since the JVM is open source and runs on pretty much all major
platforms.

Also Scala recently added some support for increased speed over
primitive arrays (in the upcoming v2.8) via the @specialized
annotation:
http://twitter.com/alexcruise/status/1879654400 (has a link through to PDF)

Also, the scalala library is likely something people around these
parts would be interested in:
http://code.google.com/p/scalala/wiki/QuickStart

(it's currently going through a reboot to better fit w/ scala 2.8)

There are other (similar) packages in pure java that can drop down to
using native blas/lapack libraries installed in the system (like MTJ:
http://code.google.com/p/matrix-toolkits-java/) and one could imagine
wrapping them in more idiomatic scala to make them more
friendly/succinct.

Lastly, if people are looking for another rabbit hole to explore, you
could check out Incanter (written in Clojure) for reasons that should
become immediately obvious after visiting its site:
http://incanter.org/

Sorry for the diversion. Couldn't resist :-)

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] F# vs. R

2010-07-08 Thread Ed Keith
It's been a long time since I used Fortran, and I have only dabbled in F#, but 
I do not think translating Fortran (or R) to F# will be easy. F# is basicly a 
functional language (like ML) and a very differant mind set than Fortran (or R).

   -EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com


--- On Thu, 7/8/10, rkevinbur...@charter.net  wrote:

> From: rkevinbur...@charter.net 
> Subject: Re: [R] F# vs. R
> To: r-help@r-project.org, "Patrick Burns" , 
> serg...@gmail.com
> Date: Thursday, July 8, 2010, 10:16 AM
> True, porting old C and Fortran code
> to C# or F# would be a pain and probably riddled with errors
> but it is not too soon to start looking to see if there is a
> better way. There have been numerous ports of LAPACK, BLAS,
> etc. to C#. Maybe they could be leveraged.
> 
> Maybe just allowing packages to be wrtten in C# or F# would
> be helpful. And remember there is Mono.
> 
> Just my 2 cents.
> 
>  Patrick Burns 
> wrote: 
> > I'd like to hear answers to this as well.
> > A language doesn't have to be a complete
> > replacement to be useful.
> > 
> > F# seems to have some nice features.
> > 
> > Pat
> > 
> > On 07/07/2010 17:54, Sergey Goriatchev wrote:
> > > Hello, Marc
> > >
> > > No, I do not want to validate Cox PH. :-)
> > > I do use R daily, though right now I do not use
> the statistical part that much.
> > >
> > > I just generally wonder if any R-user tried F#
> and his/her opinions.
> > >
> > > Regards,
> > > Sergey
> > >
> > >
> > > On Wed, Jul 7, 2010 at 17:56, Marc Schwartz 
> wrote:
> > >> On Jul 7, 2010, at 10:31 AM, Sergey
> Goriatchev wrote:
> > >>
> > >>> Hello, everyone
> > >>>
> > >>> F# is now public. Compiled code should
> run  faster than R.
> > >>>
> > >>> Anyone has opinion on F# vs. R? Just
> curious
> > >>>
> > >>> Best,
> > >>> S
> > >>
> > >>
> > >> The key time critical parts of R are written
> in compiled C and FORTRAN.
> > >>
> > >> Of course, if you want to take the time to
> code and validate a Cox PH or mixed effects model in F# and
> then run them against R's coxph() or lme()/lmer() functions
> to test the timing, feel free...  :-)
> > >>
> > >> So unless there is a pre-existing library of
> statistical and related functionality for F#, perhaps you
> need to reconsider your query.
> > >>
> > >> Regards,
> > >>
> > >> Marc Schwartz
> > >>
> > >>
> > >
> > >
> > >
> > 
> > -- 
> > 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.
> 
> __
> 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 do I test against a simple null that two regressions coefficients are equal?

2010-07-08 Thread markleeds

   hi: no. it's not the same. if you read the paper that I referenced last
   night, that explains how to do the following  test :
   Ho: R2 = R1
   H1: R2 != R1
   that's a different test from what you did but i think it's what you want.

   On Jul 8, 2010, chen jia  wrote:

 Thanks, Chuck. I am reading the references, which are helpful.
 Just to understand what I have done wrong here,
 I proposed an alternative testing strategy:
 I run regressions y = a3 + b1 * x + b2 * z + e3 and test alternative
 hypothesis b1 != b2 against the null hypothesis b1 = b2 in this
 equation.
 Is it this the same test as
 y = a1 + b1*x + e1
 y = a2 + b2*x + e2
 test alternative hypothesis b1 != b2 against null hypothesis b1 = b2.
 Best,
 Jia
 On Wed, Jul 7, 2010 at 11:12 PM, Charles C. Berry 
 wrote:
 > On Wed, 7 Jul 2010, chen jia wrote:
 >
 >> Hi there,
 >>
 >> I run two regressions:
 >>
 >> y = a1 + b1 * x + e1
 >> y = a2 + b2 * z + e2
 >>
 >> I want to test against the null hypothesis: b1 = b2. Â How do I design
 the
 >> test?
 >>
 >
 >  You  are testing a non-nested hypothesis, which requires special
 handling.
 >
 > The classical test is due to Hotelling, but see the references (and R
 code
 > snippets) in this posting:
 >
 > Â  Â  Â  Â http://markmail.org/message/egnowmdzpzjtahy7
 >
 > (it is the merest coincidence that the above thread was initiated by
 Mark
 > Leeds and that the URL is 'markmail' :-) )
 >
 > HTH,
 >
 > Chuck
 >
 >
 >> I think I can add two equations together and divide both sides by 2:
 >> y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 +
 e2).
 >> or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
 >>
 >> If I run this new regression, I can test against the null b1 = b2 in
 >> this regression. Â Is it an equivalent test as the original one? If
 >> yes, how do I do that in R?
 >>
 >> Alternatively, I think I can just test against the null:
 >> correlation(y, x) = correlation(y, z), where correlation(. , .) is the
 >> correlation between two random variables. Is this equivalent too? If
 >> yes, how do I do it in R?
 >>
 >> Thanks.
 >>
 >> Best,
 >> Jia
 >>
 >> --
 >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Ohio State University - Finance
 >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â 248 Fisher Hall
 >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  2100 Neil Ave.
 >>                             Columbus, Ohio  43210
 >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Telephone: 614-292-2830
 >> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â http://www.fisher.osu.edu/~chen_1002/
 >>
 >> __
 >> 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.
 >>
 >
 > Charles C. Berry                            (858) 534-2098
 > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â Dept of
 Family/Preventive
 > Medicine
 > E mailto:cbe...@tajo.ucsd.edu               UC San Diego
 >  http://famprevmed.ucsd.edu/faculty/cberry/ Â La Jolla, San Diego
 92093-0901
 >
 >
 >
 --
 Ohio State University - Finance
 248 Fisher Hall
 2100 Neil Ave.
 Columbus, Ohio 43210
 Telephone: 614-292-2830
 http://www.fisher.osu.edu/~chen_1002/
 __
 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 do I test against a simple null that two regressions coefficients are equal?

2010-07-08 Thread chen jia
Thanks, Chuck. I am reading the references, which are helpful.

Just to understand what I have done wrong here,

I proposed an alternative testing strategy:
I run regressions y = a3 + b1 * x + b2 * z + e3 and test alternative
hypothesis b1 !=  b2 against the null hypothesis b1 = b2 in this
equation.

Is it this the same test as

y = a1 + b1*x + e1
y = a2 + b2*x + e2
test alternative hypothesis b1 != b2 against null hypothesis b1 = b2.

Best,
Jia

On Wed, Jul 7, 2010 at 11:12 PM, Charles C. Berry  wrote:
> On Wed, 7 Jul 2010, chen jia wrote:
>
>> Hi there,
>>
>> I run two regressions:
>>
>> y = a1 + b1 * x + e1
>> y = a2 + b2 * z + e2
>>
>> I want to test against the null hypothesis: b1 = b2.  How do I design the
>> test?
>>
>
> You are testing a non-nested hypothesis, which requires special handling.
>
> The classical test is due to Hotelling, but see the references (and R code
> snippets) in this posting:
>
>        http://markmail.org/message/egnowmdzpzjtahy7
>
> (it is the merest coincidence that the above thread was initiated by Mark
> Leeds and that the URL is 'markmail' :-) )
>
> HTH,
>
> Chuck
>
>
>> I think I can add two equations together and divide both sides by 2:
>> y = 0.5*(a1+a2) + 0.5*b1 * x + 0.5*b2 * z + e3, where e3 = 0.5*(e1 + e2).
>> or just y = a3 + 0.5*b1 * x + 0.5*b2 * z + e3
>>
>> If I run this new regression, I can test against the null b1 = b2 in
>> this regression.  Is it an equivalent test as the original one? If
>> yes, how do I do that in R?
>>
>> Alternatively, I think I can just test against the null:
>> correlation(y, x) = correlation(y, z), where correlation(. , .) is the
>> correlation between two random variables. Is this equivalent too? If
>> yes, how do I do it in R?
>>
>> Thanks.
>>
>> Best,
>> Jia
>>
>> --
>>                        Ohio State University - Finance
>>                                  248 Fisher Hall
>>                                   2100 Neil Ave.
>>                             Columbus, Ohio  43210
>>                            Telephone: 614-292-2830
>>                      http://www.fisher.osu.edu/~chen_1002/
>>
>> __
>> 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.
>>
>
> Charles C. Berry                            (858) 534-2098
>                                            Dept of Family/Preventive
> Medicine
> E mailto:cbe...@tajo.ucsd.edu               UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>
>
>



-- 
 Ohio State University - Finance
   248 Fisher Hall
2100 Neil Ave.
  Columbus, Ohio  43210
 Telephone: 614-292-2830
   http://www.fisher.osu.edu/~chen_1002/

__
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] Custom multi-line header for pair plots

2010-07-08 Thread ekin
Hi All,

Is there a possible way to customize the header text appearing on the
diagonal of a pair plot? My header is:

Biomass PoB QoB ... etc.

I want to put additional information in the diagonal boxes where header
text appears such as mean, standard deviation of data. If I add these
information to the header row of my data, the font size becomes to small
and R plots the header text in one line therefore it does not fit inside
the box.

Can you help me?

Regards,

Ekin Akoglu

__
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] ANOVA-Formula

2010-07-08 Thread shabnam k
Hi,

I have taken one microarray experiment and trying to implement same
statistical measures what they have done.I have taken datasets from GEO
platform with accession number GSE1557. In the experiment,about half of
double transgenic rats (dTGR) over-expressing the human renin and
angiotensinogen genes die by age 7 weeks of terminal heart failure (THF);
the other
(preterminal) half develops cardiac damage, but survives to week 7. The aim
of the study was to elucidate the difference in cardiac gene expression of
dTGR with THF compared to dTGR showing compensated cardiac hypertrophy, but
not yet THF.Experiments were conducted in age-matched 4 week-old male
untreated dTGR.Untreated dTGR were divided in two subgroups, rats with
cardiac hypertrophy (n=18) and rats with THF (n=8).Rats were killed at age 7
weeks.Total RNAs (five animals per group) were isolated from the left
ventricle.For all rgu34_a affymetrix chips were used.

Iam using maanova package. In using fitmaanova function, we have to set
variables to formula and random.Plz, suggest me what to take in formula and
random.

*fit.fix <- fitmaanova(rat, formula = ~Array+sample, random = ~Array)*
Error in fitmaanova(rat, formula = ~Array + sample, random = ~Array) :
  Not enough degree of freedom to do regression.
   You need to remove some terms in your model.
In addition: Warning message:
In any(parsed.formula$random) :
  coercing argument of type 'double' to logical
 *fit.fix <- fitmaanova(rat, formula = ~Array+sample, random = ~sample)*
Error in fitmaanova(rat, formula = ~Array + sample, random = ~sample) :
  Not enough degree of freedom to do regression.
   You need to remove some terms in your model.
In addition: Warning message:
In any(parsed.formula$random) :
  coercing argument of type 'double' to logical


But, these are working...

* fit.fix <- fitmaanova(rat, formula = ~sample, random = ~sample)*
Fitting mixed effect model...
Finish gene number 100 ...
Finish gene number 200 ...
Finish gene number 300 ...
Finish gene number 400 ...

* fit.fix <- fitmaanova(rat, formula = ~Array, random = ~Array)*
Fitting mixed effect model...
Finish gene number 100 ...
Finish gene number 200 ...
Finish gene number 300 ...
Finish gene number 400 ...
Finish gene number 500 ...
Finish gene number 600 ...
Finish gene number 700 ...
Finish gene number 800 ..


 Am unable to understand, how it is correct, as according to my experiment
.I have read all respective manuals.

[[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] F# vs. R

2010-07-08 Thread rkevinburton
True, porting old C and Fortran code to C# or F# would be a pain and probably 
riddled with errors but it is not too soon to start looking to see if there is 
a better way. There have been numerous ports of LAPACK, BLAS, etc. to C#. Maybe 
they could be leveraged.

Maybe just allowing packages to be wrtten in C# or F# would be helpful. And 
remember there is Mono.

Just my 2 cents.

 Patrick Burns  wrote: 
> I'd like to hear answers to this as well.
> A language doesn't have to be a complete
> replacement to be useful.
> 
> F# seems to have some nice features.
> 
> Pat
> 
> On 07/07/2010 17:54, Sergey Goriatchev wrote:
> > Hello, Marc
> >
> > No, I do not want to validate Cox PH. :-)
> > I do use R daily, though right now I do not use the statistical part that 
> > much.
> >
> > I just generally wonder if any R-user tried F# and his/her opinions.
> >
> > Regards,
> > Sergey
> >
> >
> > On Wed, Jul 7, 2010 at 17:56, Marc Schwartz  wrote:
> >> On Jul 7, 2010, at 10:31 AM, Sergey Goriatchev wrote:
> >>
> >>> Hello, everyone
> >>>
> >>> F# is now public. Compiled code should run  faster than R.
> >>>
> >>> Anyone has opinion on F# vs. R? Just curious
> >>>
> >>> Best,
> >>> S
> >>
> >>
> >> The key time critical parts of R are written in compiled C and FORTRAN.
> >>
> >> Of course, if you want to take the time to code and validate a Cox PH or 
> >> mixed effects model in F# and then run them against R's coxph() or 
> >> lme()/lmer() functions to test the timing, feel free...  :-)
> >>
> >> So unless there is a pre-existing library of statistical and related 
> >> functionality for F#, perhaps you need to reconsider your query.
> >>
> >> Regards,
> >>
> >> Marc Schwartz
> >>
> >>
> >
> >
> >
> 
> -- 
> 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.

__
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] package installation for Windows 7

2010-07-08 Thread Joris Meys
On Thu, Jul 8, 2010 at 3:39 PM, Duncan Murdoch  wrote:
> On 08/07/2010 9:26 AM, David Bickel wrote:
>>
>> Yes, the User into which I logged in before launching RGui is an
>> Administrator. Correct, the problem is not limited to Bioconductor packages.
>>
>
> On Windows 7, it's not enough to have the user be an administrator, you need
> to run programs specifically with administrative rights.  You do this by
> right clicking on the icon, and choosing "Run as administrator".

Reason for this is that "Program Files" is a protected directory, and
changes can only be done by programs that get administrator rights
(which is not the same as running a program in an administrator
account). Without those administrator rights, R cannot access the
default folder for the packages, as that one is also included in the
Program Files. Also changing the Rprofile.site becomes a hassle, as so
many other tweaks.

Actually, the only programs getting there are Microsoft related
applications. If there's no strict need to place a program there, I
stay away from that folder as far as possible. Vista has the same
problem by the way, and obviously the same solutions.

Cheers
Joris

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] package installation for Windows 7

2010-07-08 Thread David Bickel
Thanks, Joris. Your suggestion solved the problem without requiring me 
to run R as an administrator.


Best regards,
David


On 08/07/2010 8:45 AM, Joris Meys wrote:

Hi,

I am running Windows 7 and R 2.11.1, and everything is installing just
fine for me. Did you install R in the "Program Files" folder? If so,
uninstall and try to re-install R in another folder (e.g.
c:\R\R2.11.1\ like on my computer). I noticed in the past that the
access control of Windows treats the "Program Files" folder different
compared to other folders.

Cheers
Joris

On Thu, Jul 8, 2010 at 1:15 PM, Dave Bickel
  wrote:
   

Neither biocLite nor the GUI menus can install packages on my system. Here
is relevant output:

 

version
   

_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 11.1
year 2010
month 05
day 31
svn rev 52157
language R
version.string R version 2.11.1 (2010-05-31)
 

source("http://bioconductor.org/biocLite.R";)
   

BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
 

biocLite("ALL")
   

Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "ALL"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 

source("http://bioconductor.org/biocLite.R";)
   

BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
 

biocLite()
   

Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 

biocLite()
   

Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 

library(Biobase)
   

Error in library(Biobase) : there is no package called 'Biobase'
 

biocLite("Biobase")
   

Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 

source("http://bioconductor.org/biocLite.R";)
   

BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
 

biocLite("Biobase")
   

Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed

 

utils:::menuInstallLocal() # "Install package(s) from local zip files..."
   

Error in if (ok) { : missing value where TRUE/FALSE needed

 

utils:::menuInstallPkgs() # "Install package(s)..."
   

--- Please select a CRAN mirror for use in this session ---
Error in if (ok) { : missing value where TRUE/FALSE needed


I would appreciate any assistance.

David

--
David R. Bickel, PhD
Associate Professor
Ottawa Institute of Systems Biology
Biochem., Micro. and I. Department
Mathematics and Statistics Department
University of Ottawa
451 Smyth Road
Ottawa, Ontario K1H 8M5

http://www.statomics.com

Office Tel: (613) 562-5800 ext. 8670
Office Fax: (613) 562-5185
Office Room: RGN 4510F (Follow the signs to the elevator, and take it to the
fourth floor. Turn left and go all the way to the end of the hall, and enter
the door to the OISB area.)
Lab Tel.: (613) 562-5800 ext. 8304
Lab Room: RGN 4501T

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo

Re: [R] Appropriateness of survdiff {survival} for non-censored data

2010-07-08 Thread Terry Therneau
The query:

"Thus I question the appropriateness of using survdiff in my analysis; I
have exact data yet I would be testing on the Kaplan-Meir estimate of
these data in survdiff.  Thanks for any help."

My thoughts:
  There are two aspects of survival analysis you need to think of.  The
first, as you've noted, is the nuisance of censored data and the fact
that this forces different software.  All of that software works fine
with uncensored data, the Kaplan-Meier for instance simply reduces to
the emprical cdf.  
  The second is that the models commonly used are ones that have been
found to work well for this kind of data.  It is easy to do a censored
data t-test for instance [survreg(Surv(y) ~ x, dist='gaussian')] but it
is almost never done.  The reason is that the effect of covariates on
survival times is not well described by a location shift, e.g.,
"everyone gets 3 more weeks".  The log rank test is most powerful for a
shift in the hazard rate, which is how a lot of covariates seem to work
for this data.  BTW in uncensored data the LR is equivalent to the
Savage exponential scores test which comes from the non-parametrics
literature but is rarely used there: most of that literature deals with
problems where the effect of 'x' is not a shift in hazard.

If the way in which covariates affect insect lifetimes is similar to how
they work in human biology or industrial reliabily, then survival
methods would be good choice.  The answer to this is biological, not
statistical.

Terry Therneau

__
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] package installation for Windows 7

2010-07-08 Thread David Bickel
Yes, the User into which I logged in before launching RGui is an 
Administrator. Correct, the problem is not limited to Bioconductor packages.


David


On 08/07/2010 8:55 AM, Duncan Murdoch wrote:

On 08/07/2010 7:15 AM, Dave Bickel wrote:

Neither biocLite nor the GUI menus can install packages on my system.


This is probably a permissions problem.  Are you running R as an
administrator when you try the install?  If not, you won't be able to
install to the default location, but you should be able to set up your
own library somewhere else, and install there.

The error message should be fixed; we shouldn't give

Error in if (ok) { : missing value where TRUE/FALSE needed


but I doubt if that's the source of your problem.

BTW, in future Bioconductor questions should go to their list.  In
this case it looks as though it's not a BioC problem, but that just
means there's no need to list all the biocLite.R material at the
start:  short simple bug reports are easier to deal with.

Duncan Murdoch


Here is relevant output:

> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 11.1
year 2010
month 05
day 31
svn rev 52157
language R
version.string R version 2.11.1 (2010-05-31)
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
> biocLite("ALL")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "ALL"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
> biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> library(Biobase)
Error in library(Biobase) : there is no package called 'Biobase'
> biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
> biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed

> utils:::menuInstallLocal() # "Install package(s) from local zip
files..."
Error in if (ok) { : missing value where TRUE/FALSE needed

> utils:::menuInstallPkgs() # "Install package(s)..."
--- Please select a CRAN mirror for use in this session ---
Error in if (ok) { : missing value where TRUE/FALSE needed


I would appreciate any assistance.

David






--
David R. Bickel, PhD
Associate Professor
Ottawa Institute of Systems Biology
Biochem., Micro. and I. Department
Mathematics and Statistics Department
University of Ottawa
451 Smyth Road
Ottawa, Ontario K1H 8M5

http://www.statomics.com
dbic...@uottawa.ca

Office Tel: (613) 562-5800 ext. 8670
Office Fax: (613) 562-5185
Office Room: RGN 4510F (Follow the signs to the elevator, and take it to 
the fourth floor. Turn left and go all the way to the end of the hall, 
and enter the door to 

Re: [R] Using nlm or optim

2010-07-08 Thread Joris Meys
Without data I can't check, but try :
mle(nll,start=list(c=0.01,z=2.1,s=200),fixed=list(V=Var,M=Mean))

With a random dataset I get :
> Mean <- rnorm(136)

> Var <- 1 + rnorm(136)^2
> mle(nll,start=list(c=0.01,z=2.1,s=200),fixed=list(V=Var,M=Mean))
Error in optim(start, f, method = method, hessian = TRUE, ...) :
  initial value in 'vmmin' is not finite

This might be just a data problem, but again, I'm not sure.

Cheers
Joris

On Thu, Jul 8, 2010 at 3:11 AM, Anita Narwani  wrote:
> Hello,
> I am trying to use nlm to estimate the parameters that minimize the
> following function:
>
> Predict<-function(M,c,z){
> + v = c*M^z
> + return(v)
> + }
>
> M is a variable and c and z are parameters to be estimated.
>
> I then write the negative loglikelihood function assuming normal errors:
>
> nll<-function(M,V,c,z,s){
> n<-length(Mean)
> logl<- -.5*n*log(2*pi) -.5*n*log(s) - (1/(2*s))*sum((V-Predict(Mean,c,z))^2)
> return(-logl)
> }
>
> When I put the Mean and Variance (variables with 136 observations) into this
> function, and estimates for c,z, and s, it outputs the estimate for the
> normal negative loglikelihood given the data, so I know that this works.
>
> However, I am unable to use mle to estimate the parameters c, z, and s. I do
> not know how or where the data i.e. Mean (M) and Variance (V) should enter
> into the mle function. I have tried variations on
>
> mle(nll,start=list(c=0.01,z=2.1,s=200)) including
> mle(nll,start=list(M=Mean,V=Var, c=0.01,z=2.1,s=200))
>
> I keep getting errors and am quite certain that I just have a syntax error
> in the script because I don't know how to enter the variables into MLE.
>
> Thanks for your help,
> Anita.
>
>        [[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.
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] package installation for Windows 7

2010-07-08 Thread David Bickel
Yes, the User into which I logged in before launching RGui is an 
Administrator. Correct, the problem is not limited to Bioconductor packages.


David


On 08/07/2010 8:55 AM, Duncan Murdoch wrote:

On 08/07/2010 7:15 AM, Dave Bickel wrote:
Neither biocLite nor the GUI menus can install packages on my system. 


This is probably a permissions problem.  Are you running R as an 
administrator when you try the install?  If not, you won't be able to 
install to the default location, but you should be able to set up your 
own library somewhere else, and install there.


The error message should be fixed; we shouldn't give

Error in if (ok) { : missing value where TRUE/FALSE needed


but I doubt if that's the source of your problem.

BTW, in future Bioconductor questions should go to their list.  In 
this case it looks as though it's not a BioC problem, but that just 
means there's no need to list all the biocLite.R material at the 
start:  short simple bug reports are easier to deal with.


Duncan Murdoch


Here is relevant output:

> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 11.1
year 2010
month 05
day 31
svn rev 52157
language R
version.string R version 2.11.1 (2010-05-31)
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
> biocLite("ALL")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "ALL"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
> biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> library(Biobase)
Error in library(Biobase) : there is no package called 'Biobase'
> biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
> source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
> biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed

> utils:::menuInstallLocal() # "Install package(s) from local zip 
files..."

Error in if (ok) { : missing value where TRUE/FALSE needed

> utils:::menuInstallPkgs() # "Install package(s)..."
--- Please select a CRAN mirror for use in this session ---
Error in if (ok) { : missing value where TRUE/FALSE needed


I would appreciate any assistance.

David





__
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] random sample from arrays

2010-07-08 Thread David Winsemius


On Jul 8, 2010, at 2:04 AM, Assa Yeroslaviz wrote:


Hello R users,

I'm trying to extract random samples from a big array I have.

I have a data frame of over 40k lines and would like to produce  
around 50

random sample of around 200 lines each from this array.

this is the matrix
 ID xxx_1c xxx__2c xxx__3c xxx__4c xxx__5T xxx__6T xxx__7T  
xxx__8T

yyy_1c yyy_1c _2c
1 A_512  2.150295  2.681759  2.177138  2.142790  2.115344  2.013047
2.115634  2.189372  1.643328  1.563523
2 A_134 12.832488 12.596373 12.882581 12.987091 11.956149 11.994779
11.650336 11.995504 13.024494 12.776322
3 A_152  2.063276  2.160961  2.067549  2.059732  2.656416  2.075775
2.033982  2.111937  1.606340  1.548940
4 A_163  9.570761 10.448615  9.432859  9.732615 10.354234 10.993279
9.160038  9.104121 10.079177  9.828757
5 A_184  3.574271  4.680859  4.517047  4.047096  3.623668  3.021356
3.559434  3.156093  4.308437  4.045098
6 A_199  7.593952  7.454087  7.513013  7.449552  7.345718  7.367068
7.410085  7.022582  7.668616  7.953706
...

I tried to do it with a for loop:

genelist <- read.delim("/user/R/raw_data.txt")
rownames(genelist) <- genelist[,1]
genes <- rownames(genelist)



One method:

totsize  <- 50 * 200
$ create matrix of indices
smatrix <- matrix(sample( 1:length(genelist$ID), totsize), nrow=200,  
ncol=50)


# Then any one sample would be:

 genelist[ smatrix[,i], ] for i in 1:50.

You do need to decide whether this approach which creates 50 mutually  
exclusive samples (if the ID's are unique) is really what you want,  
since they are not truly independent draws. I think this could be an  
issue with a ratio of universe:sample ~ 4:1. It's not a bootstrap  
sample. Could add replace=TRUE in the sample call to fix that.



--
David


x <- 1:4
set <- matrix(nrow = 50, ncol = 11)

for(i in c(1:50)){
   set[i] <-sample(x,50)
   print(c(i,"->", set), quote = FALSE)
   }

which basically do the trick, but I just can't save the results  
outside the

loop.
After having the random sets of lines it wasn't a problem to extract  
the

line from the arrays using subset.

genSet1 <-sample(x,50)
random1 <- genes %in% genSet1
subsetGenelist <- subset(genelist, random1)


is there a different way of creating these random vectors or saving  
the loop

results outside tjhe loop so I cn work with them?

Thanks a lot

Assa

[[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] Using nlm or optim

2010-07-08 Thread Ravi Varadhan
Hi,

When you report errors please send a reproducible example that will allow us to 
better help you.  At a minimum, you should cut and paste the actual call and 
the error message.

I think the problem is that you should only have parameters as arguments, i.e. 
only c and z should be in the argument list to nll().   

This works:

Predict <- function(M,c,z){
v = c*M^z
return(v)
}

nll <- function(c,z){
n<-length(M)
logl<- -.5*n*log(2*pi) -.5*n*log(s) - (1/(2*s))*sum((V-Predict(M,c,z))^2)
return(-logl)
}

M <- rexp(130)
V <- runif(130)
s <- 200

mle(nll,start=list(c=0.01,z=2.1)) 

> mle(nll,start=list(c=0.01,z=2.1)) 

Call:
mle(minuslogl = nll, start = list(c = 0.01, z = 2.1))

Coefficients:
  c   z 
 0.48547691 -0.01018601 
>

Hope this helps,
Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Anita Narwani 
Date: Wednesday, July 7, 2010 9:11 pm
Subject: [R] Using nlm or optim
To: r-help@r-project.org


> Hello,
>  I am trying to use nlm to estimate the parameters that minimize the
>  following function:
>  
>  Predict<-function(M,c,z){
>  + v = c*M^z
>  + return(v)
>  + }
>  
>  M is a variable and c and z are parameters to be estimated.
>  
>  I then write the negative loglikelihood function assuming normal errors:
>  
>  nll<-function(M,V,c,z,s){
>  n<-length(Mean)
>  logl<- -.5*n*log(2*pi) -.5*n*log(s) - (1/(2*s))*sum((V-Predict(Mean,c,z))^2)
>  return(-logl)
>  }
>  
>  When I put the Mean and Variance (variables with 136 observations) 
> into this
>  function, and estimates for c,z, and s, it outputs the estimate for the
>  normal negative loglikelihood given the data, so I know that this works.
>  
>  However, I am unable to use mle to estimate the parameters c, z, and 
> s. I do
>  not know how or where the data i.e. Mean (M) and Variance (V) should 
> enter
>  into the mle function. I have tried variations on
>  
>  mle(nll,start=list(c=0.01,z=2.1,s=200)) including
>  mle(nll,start=list(M=Mean,V=Var, c=0.01,z=2.1,s=200))
>  
>  I keep getting errors and am quite certain that I just have a syntax 
> error
>  in the script because I don't know how to enter the variables into MLE.
>  
>  Thanks for your help,
>  Anita.
>  
>   [[alternative HTML version deleted]]
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  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] 0 exit status on packages update try

2010-07-08 Thread stephen sefick
I am not entirely sure what is going on.  I am sure that I am missing
something.  maptools won't detach...  Thanks for all of your help.

R 2.11.1
OS Ubuntu 10.04

R --vanilla

install.packages("sp", dep=TRUE)

Loading required package: reshape
Loading required package: plyr
Loading required package: grid
Loading required package: proto
This is vegan 1.17-3
Loading required package: zoo
Loading required package: stats
Loading required package: chron
Loading required package: maptools
Loading required package: foreign
Loading required package: sp
Loading required package: lattice

Note: polygon geometry computations in maptools
depend on the package gpclib, which has a
restricted licence. It is disabled by default;
to enable gpclib, type gpclibPermit()

Checking rgeos availability as gpclib substitute:
FALSE
General Polygon Clipper Library for R (version 1.5-1)
Type 'class ? gpc.poly' for help

[1] TRUE
* installing *source* package ‘sp’ ...
** libs
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c
Rcentroid.c -o Rcentroid.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c gcdist.c -o gcdist.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c init.c -o init.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c pip.c -o pip.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c pip2.c -o pip2.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c
sp_xports.c -o sp_xports.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c
surfaceArea.c -o surfaceArea.o
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c zerodist.c
-o zerodist.o
gcc -std=gnu99 -shared -o sp.so Rcentroid.o gcdist.o init.o pip.o
pip2.o sp_xports.o surfaceArea.o zerodist.o -L/usr/lib64/R/lib -lR
installing to /home/ssefick/R/x86_64-pc-linux-gnu-library/2.11/sp/libs
** R
** data
** demo
** inst
** preparing package for lazy loading
Error: package ‘sp’ is required by ‘maptools’ so will not be detached
* removing ‘/home/ssefick/R/x86_64-pc-linux-gnu-library/2.11/sp’
* restoring previous ‘/home/ssefick/R/x86_64-pc-linux-gnu-library/2.11/sp’

The downloaded packages are in
‘/tmp/Rtmp3UTqA6/downloaded_packages’
Warning message:
In install.packages("sp", dep = TRUE) :
  installation of package 'sp' had non-zero exit status

-- 
Stephen Sefick

| Auburn University   |
| Department of Biological Sciences   |
| 331 Funchess Hall  |
| Auburn, Alabama   |
| 36849|
|___|
| sas0...@auburn.edu |
| http://www.auburn.edu/~sas0025 |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] xyplot: key inside the plot region / lme: confidence bands for predicted

2010-07-08 Thread Michael Friendly

Kingsford Jones wrote:

On Wed, Jul 7, 2010 at 8:59 AM, Michael Friendly  wrote:
  

No one replied to my second question: how to get standard errors or
confidence intervals for the
estimated fixed effects from lme().AFAICS, intervals() only gives CIs
for coefficients.



Assuming you mean 'predictions based on the estimated fixed effects'
rather than 'estimated fixed effects', for one solution have a look at
Ben Bolker's r-sig-mixed-models FAQ, about 2/3 of the way down:
http://glmm.wikidot.com/faq

Googling "lme prediction intervals" turns up quite a bit.  Here's a
recent conversation:


hope it helps,

Kingsford Jones

  
Thanks, Kingsford.  Exactly what I was looking for, both for code and 
explanations of alternatives.



--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
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] package installation for Windows 7

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 9:26 AM, David Bickel wrote:
Yes, the User into which I logged in before launching RGui is an 
Administrator. Correct, the problem is not limited to Bioconductor packages.
  


On Windows 7, it's not enough to have the user be an administrator, you 
need to run programs specifically with administrative rights.  You do 
this by right clicking on the icon, and choosing "Run as administrator".


Duncan Murdoch

David


On 08/07/2010 8:55 AM, Duncan Murdoch wrote:
> On 08/07/2010 7:15 AM, Dave Bickel wrote:
>> Neither biocLite nor the GUI menus can install packages on my system. 
>
> This is probably a permissions problem.  Are you running R as an 
> administrator when you try the install?  If not, you won't be able to 
> install to the default location, but you should be able to set up your 
> own library somewhere else, and install there.

>
> The error message should be fixed; we shouldn't give
>
> Error in if (ok) { : missing value where TRUE/FALSE needed
>
>
> but I doubt if that's the source of your problem.
>
> BTW, in future Bioconductor questions should go to their list.  In 
> this case it looks as though it's not a BioC problem, but that just 
> means there's no need to list all the biocLite.R material at the 
> start:  short simple bug reports are easier to deal with.

>
> Duncan Murdoch
>
>> Here is relevant output:
>>
>> > version
>> _
>> platform i386-pc-mingw32
>> arch i386
>> os mingw32
>> system i386, mingw32
>> status
>> major 2
>> minor 11.1
>> year 2010
>> month 05
>> day 31
>> svn rev 52157
>> language R
>> version.string R version 2.11.1 (2010-05-31)
>> > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>> > biocLite("ALL")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "ALL"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>> > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>> Warning messages:
>> 1: In safeSource() : Redefining ‘biocinstall’
>> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
>> 3: In safeSource() : Redefining ‘biocinstallRepos’
>> > biocLite()
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "affy" "affydata" "affyPLM" "affyQCReport"
>> [5] "annaffy" "annotate" "Biobase" "biomaRt"
>> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
>> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
>> [17] "marray" "multtest" "vsn" "xtable"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>> > biocLite()
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "affy" "affydata" "affyPLM" "affyQCReport"
>> [5] "annaffy" "annotate" "Biobase" "biomaRt"
>> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
>> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
>> [17] "marray" "multtest" "vsn" "xtable"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>> > library(Biobase)
>> Error in library(Biobase) : there is no package called 'Biobase'
>> > biocLite("Biobase")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "Biobase"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>> > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>> Warning messages:
>> 1: In safeSource() : Redefining ‘biocinstall’
>> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
>> 3: In safeSource() : Redefining ‘biocinstallRepos’
>> > biocLite("Biobase")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "Biobase"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>
>> > utils:::menuInstallLocal() # "Install package(s) from local zip 
>> files..."

>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>
>> > utils:::menuInstallPkgs() # "Install package(s)..."
>> --- Please select a CRAN mirror for use in this sessio

Re: [R] strsplit("dia ma", "\\b") splits characterwise

2010-07-08 Thread Gabor Grothendieck
On Thu, Jul 8, 2010 at 4:15 AM, Suharto Anggono Suharto Anggono
 wrote:
> \b is word boundary.
> But, unexpectedly, strsplit("dia ma", "\\b") splits character by character.
>
>> strsplit("dia ma", "\\b")
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>> strsplit("dia ma", "\\b", perl=TRUE)
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>
> How can that be?
>
> This is the output of 'gregexpr'.
>
>> gregexpr("\\b", "dia ma")
> [[1]]
> [1] 1 2 3 4 5 6
> attr(,"match.length")
> [1] 0 0 0 0 0 0
>
>> gregexpr("\\b", "dia ma", perl=TRUE)
> [[1]]
> [1] 1 4 5 7
> attr(,"match.length")
> [1] 0 0 0 0
>
>
> The output from gregexpr("\\b", "dia ma", perl=TRUE) is what I expect. I 
> expect 'strsplit' to split at that points.

You can use strapply in the gsubfn function to match all words and non-words:

library(gsubfn)
strapply("dia ma", "\\w+|\\W+", c) # c("dia", " ", "ma")

or all spaces and non-spaces:

strapply("dia ma", "\\s+|\\S+", c) # c("dia", " ", "ma")

__
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] [OOPS] Re: hi... problems about adjacency matrix

2010-07-08 Thread Ted Harding
See at end ...

On 08-Jul-10 12:41:03, Ted Harding wrote:
> On 08-Jul-10 10:33:56, Gina Liao wrote:
>> Dear all,
>> Hi, I have the problems about converting the matrix to adjacency
>> matrix.Here's my example,
>>   ab   cd 
>> e   fa 1.000 0.4048823682 0.1228531 0.49046991
>> 0.4945158868 0.307443317b 0.4048824 1.00 0.4367475 0.96949219
>> 0.0007378596 0.560747765c 0.1228531 0.4367474719 1.000 0.40037341
>> 0.3157538204 0.428183667d 0.4904699 0.9694921891 0.4003734 1.
>> 0.0661313658 0.575606129e 0.4945159 0.0007378596 0.3157538 0.06613137
>> 1.00 0.001076251f 0.3074433 0.5607477645 0.4281837 0.57560613
>> 0.0010762514 1.0
>> and my threshold value is 0.4763, which means any value above it is
>> "1"
>> and any values below it is "0".
>> so my adjacency matrix should be like this,
>>  a   b   c   d   e   fa   1   0   0   1   1   0b   0   1   0   1  
>> 0   1c   0   0   1   0   0   0d   1   1   0   1   0   1e   1   0   0  
>> 0   1   0f0   1   0   1   0   1
>> 
>> I'd like to ask how to convert the matrix to adjacency matrix.
>> Thanks!!!
>> 
>> Gina
> 
> If B is your original matrix of numbers, and A is to be the adjacency
> matrix which you want, then:
> 
>   B <- 1*(A > 0.4763)
> 
> Ted.

OOPS! I got that the wrong way round! It should of course have been

  A <- 1*(B > 0.4763)

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 08-Jul-10   Time: 14:31:30
-- XFMail --

__
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] random sample from arrays

2010-07-08 Thread Joris Meys
Don't know what exactly you're trying to do, but you make a matrix
with 11 columns and 50 rows, then treat it as a vector. On top of
that, you try to fill 50 rows/columns with 50 values. Off course that
doesn't work. Did you check the warning messages when running the
code?

Either do :

 for(i in c(1:11)){
set[,i] <-sample(x,50)
print(c(i,"->", set), quote = FALSE)
   }

or

 for(i in c(1:50)){
set[i,] <-sample(x,11)
print(c(i,"->", set), quote = FALSE)
   }

Or just forget about the loop altogether and do :

set <- replicate(11,sample(x,50))
or
set <- t(replicate(50,sample(x,11)))

cheers

On Thu, Jul 8, 2010 at 8:04 AM, Assa Yeroslaviz  wrote:
> Hello R users,
>
> I'm trying to extract random samples from a big array I have.
>
> I have a data frame of over 40k lines and would like to produce around 50
> random sample of around 200 lines each from this array.
>
> this is the matrix
>          ID xxx_1c xxx__2c xxx__3c xxx__4c xxx__5T xxx__6T xxx__7T xxx__8T
> yyy_1c yyy_1c _2c
> 1 A_512  2.150295  2.681759  2.177138  2.142790  2.115344  2.013047
> 2.115634  2.189372  1.643328  1.563523
> 2 A_134 12.832488 12.596373 12.882581 12.987091 11.956149 11.994779
> 11.650336 11.995504 13.024494 12.776322
> 3 A_152  2.063276  2.160961  2.067549  2.059732  2.656416  2.075775
> 2.033982  2.111937  1.606340  1.548940
> 4 A_163  9.570761 10.448615  9.432859  9.732615 10.354234 10.993279
> 9.160038  9.104121 10.079177  9.828757
> 5 A_184  3.574271  4.680859  4.517047  4.047096  3.623668  3.021356
> 3.559434  3.156093  4.308437  4.045098
> 6 A_199  7.593952  7.454087  7.513013  7.449552  7.345718  7.367068
> 7.410085  7.022582  7.668616  7.953706
> ...
>
> I tried to do it with a for loop:
>
> genelist <- read.delim("/user/R/raw_data.txt")
> rownames(genelist) <- genelist[,1]
> genes <- rownames(genelist)
>
> x <- 1:4
> set <- matrix(nrow = 50, ncol = 11)
>
> for(i in c(1:50)){
>    set[i] <-sample(x,50)
>    print(c(i,"->", set), quote = FALSE)
>    }
>
> which basically do the trick, but I just can't save the results outside the
> loop.
> After having the random sets of lines it wasn't a problem to extract the
> line from the arrays using subset.
>
> genSet1 <-sample(x,50)
> random1 <- genes %in% genSet1
> subsetGenelist <- subset(genelist, random1)
>
>
> is there a different way of creating these random vectors or saving the loop
> results outside tjhe loop so I cn work with them?
>
> Thanks a lot
>
> Assa
>
>        [[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.
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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 two files into one and vlookup

2010-07-08 Thread Dennis Murphy
Hi:

> merge(file2, file1, by = 'Date')
DatePrice.x  Price.y
1 03/07/2010   5.312006 56.92826
2 04/07/2010 673.070592 39.27409
3 05/07/2010 442.467939 42.59834
4 06/07/2010 851.915899 70.68512
5 07/07/2010 581.859242 10.92505

HTH,
Dennis

On Wed, Jul 7, 2010 at 8:07 AM, Raghu  wrote:

> Say I have two files file and file2:
>
> file1 contains the following:
> DatePrice
> 02/07/2010  53.96597903
> 03/07/2010  56.92825807
> 04/07/2010  39.27408645
> 05/07/2010  42.59834151
> 06/07/2010  70.68512383
> 07/07/2010  10.92505265
> 08/07/2010  52.12492249
> 09/07/2010  49.88767957
>
> file2 contains the following:
> DatePrice
> 03/07/2010  5.312006403
> 04/07/2010  673.0705924
> 05/07/2010  442.4679386
> 06/07/2010  851.9158985
> 07/07/2010  581.8592424
>
> I want to create a new file that should look like:
> Date  Price1Price2
> 03/07/2010  5.31200640356.928
> 04/07/2010  673.070592439.274
> 05/07/2010  442.467938642.598
> 06/07/2010  851.915898570.685
> 07/07/2010  581.859242410.925
>
> Thx
>
>
>
> On 7/7/10, Erik Iverson  wrote:
> > raghu wrote:
> >> I have two files with dates and prices in each. The number of rows in
> each
> >> of
> >> them will differ. How do I create a new file which contains data from
> both
> >> these files? Cbind and merge are not helpful. For cbind because the rows
> >> are
> >> not the same replication occurs. Also if I have similar data how do I
> >> write
> >> a vlookup kind of function? I am giving an example below:
> >> Say Price1 file contains the following:
> >> Date Price
> >> 2/3/2010   134.00
> >> 3/3/2010   133.90
> >> 4/3/2010   135.55
> >>
> >> And say price2 contains the following:
> >> Date  Price
> >> 2/3/20102300
> >> 3/3/20103200
> >> 4/3/20101800
> >> 5/3/20101900
> >>
> >> I want to take both these data together in a single file, and take the
> >> smaller vector (or matrix or dataframe??..i am new to R and still
> confused
> >> with the various objects) which is file1 (because it contains fewer rows
> )
> >> and vlookup prices in the second file basedon the dates on file1 and
> write
> >> three columns (date, price from 1 and price from2) in a new file. How do
> i
> >> do this please?
> >
> > I think all this can be accomplished with merge.  Can you give
> reproducible
> > examples as the posting guide suggests?
> >
> > Use read.table to read in your data into R objects, then use ?dput to
> give
> > us
> > the exact copies of the objects (probably data.frames by your example),
> and
> > what
> > output you want to have.  Being precise with the classes of objects
> you're
> > working with is key, and ?dput is a great way to make sure we have the
> same
> > objects as you.
> >
> > Another tip is common terminology. For instance, `vlookup` is not a term
> > used in
> > R, and many people will not know what it means.
> >
> > This way, everything is reproducible for us, and we can offer suggestions
> > and
> > show you what the exact output will be.  In short, making sure everyone
> is
> > on
> > the same page goes a long way when getting help from a mailing list.
> >
> >
>
>
> --
> 'Raghu'
>
> __
> 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.


Re: [R] package installation for Windows 7

2010-07-08 Thread Joris Meys
As far as my experience goes, there is no need whatsoever to run R as
an administrator for installation of any package, including
BioConductor, provided you stay away from the "Program Files" folder.

Cheers
Joris

On Thu, Jul 8, 2010 at 2:55 PM, Duncan Murdoch  wrote:
> On 08/07/2010 7:15 AM, Dave Bickel wrote:
>>
>> Neither biocLite nor the GUI menus can install packages on my system.
>
> This is probably a permissions problem.  Are you running R as an
> administrator when you try the install?  If not, you won't be able to
> install to the default location, but you should be able to set up your own
> library somewhere else, and install there.
>
> The error message should be fixed; we shouldn't give
>
> Error in if (ok) { : missing value where TRUE/FALSE needed
>
>
> but I doubt if that's the source of your problem.
>
> BTW, in future Bioconductor questions should go to their list.  In this case
> it looks as though it's not a BioC problem, but that just means there's no
> need to list all the biocLite.R material at the start:  short simple bug
> reports are easier to deal with.
>
> Duncan Murdoch
>
>> Here is relevant output:
>>
>>  > version
>> _
>> platform i386-pc-mingw32
>> arch i386
>> os mingw32
>> system i386, mingw32
>> status
>> major 2
>> minor 11.1
>> year 2010
>> month 05
>> day 31
>> svn rev 52157
>> language R
>> version.string R version 2.11.1 (2010-05-31)
>>  > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>>  > biocLite("ALL")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "ALL"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>  > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>> Warning messages:
>> 1: In safeSource() : Redefining ‘biocinstall’
>> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
>> 3: In safeSource() : Redefining ‘biocinstallRepos’
>>  > biocLite()
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "affy" "affydata" "affyPLM" "affyQCReport"
>> [5] "annaffy" "annotate" "Biobase" "biomaRt"
>> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
>> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
>> [17] "marray" "multtest" "vsn" "xtable"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>  > biocLite()
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "affy" "affydata" "affyPLM" "affyQCReport"
>> [5] "annaffy" "annotate" "Biobase" "biomaRt"
>> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
>> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
>> [17] "marray" "multtest" "vsn" "xtable"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>  > library(Biobase)
>> Error in library(Biobase) : there is no package called 'Biobase'
>>  > biocLite("Biobase")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "Biobase"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>  > source("http://bioconductor.org/biocLite.R";)
>> BioC_mirror = http://www.bioconductor.org
>> Change using chooseBioCmirror().
>> Warning messages:
>> 1: In safeSource() : Redefining ‘biocinstall’
>> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
>> 3: In safeSource() : Redefining ‘biocinstallRepos’
>>  > biocLite("Biobase")
>> Using R version 2.11.1, biocinstall version 2.6.7.
>> Installing Bioconductor version 2.6 packages:
>> [1] "Biobase"
>> Please wait...
>>
>> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
>> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>
>>  > utils:::menuInstallLocal() # "Install package(s) from local zip
>> files..."
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>
>>  > utils:::menuInstallPkgs() # "Install package(s)..."
>> --- Please select a CRAN mirror for use in this session ---
>> Error in if (ok) { : missing value where TRUE/FALSE needed
>>
>>
>> I would appreciate any assistance.
>>
>> David
>>
>>
>
> __
> R-help@r-project.org ma

Re: [R] strsplit("dia ma", "\\b") splits characterwise

2010-07-08 Thread Joris Meys
l guess this is expected behaviour, although counterintuitive. \b
represents an empty string indicating a word boundary, but is coerced
to character and thus simply the empty string. This means the output
you get is the same as
> strsplit("dia ma", "",perl=T)
[[1]]
[1] "d" "i" "a" " " "m" "a"

I'd use the seperating character as split in strsplit, eg

> strsplit("dia ma", "\\s")
[[1]]
[1] "dia" "ma"

If you need the space in the list as well, you'll have to go around it I guess.

> test <- as.vector(gregexpr("\\b", "dia ma", perl=TRUE)[[1]])
> test
[1] 1 4 5 7
> apply(embed(test,2),1,function(x) substr("dia ma",x[2],x[1]-1))
[1] "dia" " "   "ma"

It would be nice if special characters like \b would be recognized by
strsplit as well though.

Cheers
Joris

On Thu, Jul 8, 2010 at 10:15 AM, Suharto Anggono Suharto Anggono
 wrote:
> \b is word boundary.
> But, unexpectedly, strsplit("dia ma", "\\b") splits character by character.
>
>> strsplit("dia ma", "\\b")
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>> strsplit("dia ma", "\\b", perl=TRUE)
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>
> How can that be?
>
> This is the output of 'gregexpr'.
>
>> gregexpr("\\b", "dia ma")
> [[1]]
> [1] 1 2 3 4 5 6
> attr(,"match.length")
> [1] 0 0 0 0 0 0
>
>> gregexpr("\\b", "dia ma", perl=TRUE)
> [[1]]
> [1] 1 4 5 7
> attr(,"match.length")
> [1] 0 0 0 0
>
>
> The output from gregexpr("\\b", "dia ma", perl=TRUE) is what I expect. I 
> expect 'strsplit' to split at that points.
>
> This is in Windows. R was installed from binary.
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> 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] stats     graphics  grDevices utils     datasets  methods   base
>
>
>
> R 2.8.1 shows the same 'strsplit' behavior, but the behavior of default 
> 'gregexpr' (i.e. perl=FALSE) is different.
>
>> strsplit("dia ma", "\\b")
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>> strsplit("dia ma", "\\b", perl=TRUE)
> [[1]]
> [1] "d" "i" "a" " " "m" "a"
>
>> gregexpr("\\b", "dia ma")
> [[1]]
> [1] 1 4 5 7
> attr(,"match.length")
> [1] 0 0 0 0
>
>> gregexpr("\\b", "dia ma", perl=TRUE)
> [[1]]
> [1] 1 4 5 7
> attr(,"match.length")
> [1] 0 0 0 0
>
>> sessionInfo()
> R version 2.8.1 (2008-12-22)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
> States.1252;LC_MON
> ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United 
> States.1252
>
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
>
>
>
> __
> 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.
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] forcing a zero level in contr.sum

2010-07-08 Thread Bond, Stephen
Peter,

I am asked to show seasonal effects vs a general averaged level without any 
seasonal effects. That's why contr.sum and not treatment.
The estimates show that some coefs are not stat different from 0, which is also 
the enforced total average. So, my understanding of model selection leads me to 
force certain seasons to be zero.

For example:
Y= a0 + b1 + Xb  | factor=1
Y= a0 +Xb| factor=2
Y= a0 + b2 + Xb  | factor=3

b1+b2=0   | which in this case means b1=-b2 but with more levels not necessarily

Stephen Bond | 

-Original Message-
From: Peter Dalgaard [mailto:pda...@gmail.com] 
Sent: Thursday, July 08, 2010 4:09 AM
To: Bond, Stephen
Cc: r-help@r-project.org
Subject: Re: [R] forcing a zero level in contr.sum

Bond, Stephen wrote:
> I need to use contr.sum and observe that some levels are not
> statistically different from the overall mean of zero. What is the
> proper way of forcing the zero estimate? It seems the column
> corresponding to that level should become a column of zeros. Is there
> a way to achieve that without me constructing the design matrix?

As Berwin (indirectly) points out, you probably overlooked the how.many
argument to C().

However, are you _sure_ that you want to do this? This is like testing
that one treatment is exactly equal to the average of all other
treatments, which is a rather strange hypothesis.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] hi... problems about adjacency matrix

2010-07-08 Thread Steve Lianoglou
Hi Gina,

On Thu, Jul 8, 2010 at 6:33 AM, Gina Liao  wrote:
>
> Dear all,
> Hi, I have the problems about converting the matrix to adjacency 
> matrix.Here's my example,
>          a            b               c                d                 e    
>            fa 1.000 0.4048823682 0.1228531 0.49046991 0.4945158868 
> 0.307443317b 0.4048824 1.00 0.4367475 0.96949219 0.0007378596 
> 0.560747765c 0.1228531 0.4367474719 1.000 0.40037341 0.3157538204 
> 0.428183667d 0.4904699 0.9694921891 0.4003734 1. 0.0661313658 
> 0.575606129e 0.4945159 0.0007378596 0.3157538 0.06613137 1.00 
> 0.001076251f 0.3074433 0.5607477645 0.4281837 0.57560613 0.0010762514 
> 1.0
> and my threshold value is 0.4763, which means any value above it is "1" and 
> any values below it is "0".
> so my adjacency matrix should be like this,
>     a   b   c   d   e   fa   1   0   0   1   1   0b   0   1   0   1   0   1c  
>  0   0   1   0   0   0d   1   1   0   1   0   1e   1   0   0   0   1   0f    
> 0   1   0   1   0   1
>
> I'd like to ask how to convert the matrix to adjacency matrix.
> Thanks!!!

Just a note for future postings: use dput (?dput) to get your matrix
into a "pastable" format that we can use to copy into a working R
session and provide code.

I'll just make own random matrix for now that I'll turn into an
adjacency matrix:

R> set.seed(123)
R> real <- matrix(runif(30, 0, 1), nrow=6)
R> colnames(real) <- c('a', 'b', 'c', 'd', 'e')

(oops that has one less column than you)

Now I can use "ifelse" to convert to an adjacency matrix
R> adj <- ifelse(real > 0.4763, 1, 0)
R> adj
 a b c d e
[1,] 0 1 1 0 1
[2,] 1 1 1 1 1
[3,] 0 1 0 1 1
[4,] 1 0 1 1 1
[5,] 1 1 0 1 0
[6,] 0 0 0 1 0

The "ifelse" call could have been broken down into several steps. To
make it more clear:

Set up an "empty" adj matrix to fill w/ ones where appropriate
R> adj2 <- matrix(0, nrow=nrow(real), ncol=ncol(real))
R> colnames(adj2) <- colnames(real)

Now fill with ones:
R> adj2[real > 0.4763] <- 1
R> all(adj == adj2)
[1] TRUE

Also works.

And just to give you an idea of how to use dput:

R> dput(adj)
structure(c(1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1), .Dim = c(6L, 5L), .Dimnames = list(
NULL, c("a", "b", "c", "d", "e")))

Hope that helps.

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] can't open file

2010-07-08 Thread Gabor Grothendieck
On Thu, Jul 8, 2010 at 8:47 AM, Sebastian Kruk  wrote:
>>> I tried:
>>>
>>> L <- readLines(con <- file("log2.log", encoding="UCS-2LE")
>>> z <- read.zoo(textConnection(L), index = 1:2,FUN = function(x)
>>> paste(x[,1], x[,2]))
>>>
>>> Error:
>>> Error en x[, 1] : número incorreto de dimensiones
>>>
>
>>Please provide a reproducible example like this:
>
>>library(zoo)
>>L <- "4/4/200 10:10:10 3000
>>5/5/2000 12:12:12 4000"
>>read.zoo(textConnection(L), index = 1:2, FUN = function(x) >paste(x[,1], 
>>x[,2]))
>
>>which gives me
>  >4/4/200 10:10:10 5/5/2000 12:12:12
>   >         3000              4000
>
> 1st line
> #Prueba
> Second line
> "04/04/200 10:10:10 3000 Juan"
> 2nd
> "05/05/2000 12:12:12 4000 -"
> ...
> 10th line:
> 05/04/2010 10:10:10 3000 Juan
> ...
> nth line
> "01/01/2009 21:10:10 50 Varela"
> ...
> last line
> "11/11/2008 23:20:32 5091 Laura"
>
> It's a window's unicode text file.
>

We need to be able to reproduce what you have done to offer more than
guesses.  Read the last line at the bottom of every message to r-help.

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


Re: [R] package installation for Windows 7

2010-07-08 Thread Duncan Murdoch

On 08/07/2010 7:15 AM, Dave Bickel wrote:
Neither biocLite nor the GUI menus can install packages on my system. 
  


This is probably a permissions problem.  Are you running R as an 
administrator when you try the install?  If not, you won't be able to 
install to the default location, but you should be able to set up your 
own library somewhere else, and install there.


The error message should be fixed; we shouldn't give

Error in if (ok) { : missing value where TRUE/FALSE needed


but I doubt if that's the source of your problem.

BTW, in future Bioconductor questions should go to their list.  In this 
case it looks as though it's not a BioC problem, but that just means 
there's no need to list all the biocLite.R material at the start:  short 
simple bug reports are easier to deal with.


Duncan Murdoch


Here is relevant output:

 > version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 11.1
year 2010
month 05
day 31
svn rev 52157
language R
version.string R version 2.11.1 (2010-05-31)
 > source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
 > biocLite("ALL")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "ALL"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 > source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
 > biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 > biocLite()
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "affy" "affydata" "affyPLM" "affyQCReport"
[5] "annaffy" "annotate" "Biobase" "biomaRt"
[9] "Biostrings" "DynDoc" "gcrma" "genefilter"
[13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
[17] "marray" "multtest" "vsn" "xtable"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 > library(Biobase)
Error in library(Biobase) : there is no package called 'Biobase'
 > biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed
 > source("http://bioconductor.org/biocLite.R";)
BioC_mirror = http://www.bioconductor.org
Change using chooseBioCmirror().
Warning messages:
1: In safeSource() : Redefining ‘biocinstall’
2: In safeSource() : Redefining ‘biocinstallPkgGroups’
3: In safeSource() : Redefining ‘biocinstallRepos’
 > biocLite("Biobase")
Using R version 2.11.1, biocinstall version 2.6.7.
Installing Bioconductor version 2.6 packages:
[1] "Biobase"
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
Error in if (ok) { : missing value where TRUE/FALSE needed

 > utils:::menuInstallLocal() # "Install package(s) from local zip 
files..."

Error in if (ok) { : missing value where TRUE/FALSE needed

 > utils:::menuInstallPkgs() # "Install package(s)..."
--- Please select a CRAN mirror for use in this session ---
Error in if (ok) { : missing value where TRUE/FALSE needed


I would appreciate any assistance.

David




__
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 determine order of arima bt acf and pacf

2010-07-08 Thread Joris Meys
Did you read these already?

http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf

http://www.barigozzi.eu/ARIMA.pdf

Cheers
Joris

On Thu, Jul 8, 2010 at 11:45 AM, vijaysheegi  wrote:
>
> Hi R community,
> I am new to R.Have  some doubts on ACF and pacf.Appying acf and pacf to
> dataframe or table.How to determine ARIMA degrees which suits our example .
> Please assist me on this and also please give me link for the same so that i
> will also try understand the solution.
>
> Thanks in advance
> vijaysheegi
> student
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-determine-order-of-arima-bt-acf-and-pacf-tp2282053p2282053.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.
>



-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] can't open file

2010-07-08 Thread Sebastian Kruk
>> I tried:
>>
>> L <- readLines(con <- file("log2.log", encoding="UCS-2LE")
>> z <- read.zoo(textConnection(L), index = 1:2,FUN = function(x)
>> paste(x[,1], x[,2]))
>>
>> Error:
>> Error en x[, 1] : número incorreto de dimensiones
>>

>Please provide a reproducible example like this:

>library(zoo)
>L <- "4/4/200 10:10:10 3000
>5/5/2000 12:12:12 4000"
>read.zoo(textConnection(L), index = 1:2, FUN = function(x) >paste(x[,1], 
>x[,2]))

>which gives me
 >4/4/200 10:10:10 5/5/2000 12:12:12
   > 3000  4000

1st line
#Prueba
Second line
"04/04/200 10:10:10 3000 Juan"
2nd
"05/05/2000 12:12:12 4000 -"
...
10th line:
05/04/2010 10:10:10 3000 Juan
...
nth line
"01/01/2009 21:10:10 50 Varela"
...
last line
"11/11/2008 23:20:32 5091 Laura"

It's a window's unicode text file.

__
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] package installation for Windows 7

2010-07-08 Thread Joris Meys
Hi,

I am running Windows 7 and R 2.11.1, and everything is installing just
fine for me. Did you install R in the "Program Files" folder? If so,
uninstall and try to re-install R in another folder (e.g.
c:\R\R2.11.1\ like on my computer). I noticed in the past that the
access control of Windows treats the "Program Files" folder different
compared to other folders.

Cheers
Joris

On Thu, Jul 8, 2010 at 1:15 PM, Dave Bickel
 wrote:
> Neither biocLite nor the GUI menus can install packages on my system. Here
> is relevant output:
>
>> version
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 11.1
> year 2010
> month 05
> day 31
> svn rev 52157
> language R
> version.string R version 2.11.1 (2010-05-31)
>> source("http://bioconductor.org/biocLite.R";)
> BioC_mirror = http://www.bioconductor.org
> Change using chooseBioCmirror().
>> biocLite("ALL")
> Using R version 2.11.1, biocinstall version 2.6.7.
> Installing Bioconductor version 2.6 packages:
> [1] "ALL"
> Please wait...
>
> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
> Error in if (ok) { : missing value where TRUE/FALSE needed
>> source("http://bioconductor.org/biocLite.R";)
> BioC_mirror = http://www.bioconductor.org
> Change using chooseBioCmirror().
> Warning messages:
> 1: In safeSource() : Redefining ‘biocinstall’
> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
> 3: In safeSource() : Redefining ‘biocinstallRepos’
>> biocLite()
> Using R version 2.11.1, biocinstall version 2.6.7.
> Installing Bioconductor version 2.6 packages:
> [1] "affy" "affydata" "affyPLM" "affyQCReport"
> [5] "annaffy" "annotate" "Biobase" "biomaRt"
> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
> [17] "marray" "multtest" "vsn" "xtable"
> Please wait...
>
> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
> Error in if (ok) { : missing value where TRUE/FALSE needed
>> biocLite()
> Using R version 2.11.1, biocinstall version 2.6.7.
> Installing Bioconductor version 2.6 packages:
> [1] "affy" "affydata" "affyPLM" "affyQCReport"
> [5] "annaffy" "annotate" "Biobase" "biomaRt"
> [9] "Biostrings" "DynDoc" "gcrma" "genefilter"
> [13] "geneplotter" "GenomicRanges" "hgu95av2.db" "limma"
> [17] "marray" "multtest" "vsn" "xtable"
> Please wait...
>
> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
> Error in if (ok) { : missing value where TRUE/FALSE needed
>> library(Biobase)
> Error in library(Biobase) : there is no package called 'Biobase'
>> biocLite("Biobase")
> Using R version 2.11.1, biocinstall version 2.6.7.
> Installing Bioconductor version 2.6 packages:
> [1] "Biobase"
> Please wait...
>
> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
> Error in if (ok) { : missing value where TRUE/FALSE needed
>> source("http://bioconductor.org/biocLite.R";)
> BioC_mirror = http://www.bioconductor.org
> Change using chooseBioCmirror().
> Warning messages:
> 1: In safeSource() : Redefining ‘biocinstall’
> 2: In safeSource() : Redefining ‘biocinstallPkgGroups’
> 3: In safeSource() : Redefining ‘biocinstallRepos’
>> biocLite("Biobase")
> Using R version 2.11.1, biocinstall version 2.6.7.
> Installing Bioconductor version 2.6 packages:
> [1] "Biobase"
> Please wait...
>
> Warning in install.packages(pkgs = pkgs, repos = repos, ...) :
> argument 'lib' is missing: using '\Users\dbickel/R/win-library/2.11'
> Error in if (ok) { : missing value where TRUE/FALSE needed
>
>> utils:::menuInstallLocal() # "Install package(s) from local zip files..."
> Error in if (ok) { : missing value where TRUE/FALSE needed
>
>> utils:::menuInstallPkgs() # "Install package(s)..."
> --- Please select a CRAN mirror for use in this session ---
> Error in if (ok) { : missing value where TRUE/FALSE needed
>
>
> I would appreciate any assistance.
>
> David
>
> --
> David R. Bickel, PhD
> Associate Professor
> Ottawa Institute of Systems Biology
> Biochem., Micro. and I. Department
> Mathematics and Statistics Department
> University of Ottawa
> 451 Smyth Road
> Ottawa, Ontario K1H 8M5
>
> http://www.statomics.com
>
> Office Tel: (613) 562-5800 ext. 8670
> Office Fax: (613) 562-5185
> Office Room: RGN 4510F (Follow the signs to the elevator, and take it to the
> fourth floor. Turn left and go all the way to the end of the hall, and enter
> the door to the OISB area.)
> Lab Tel.: (613) 562-5800 ext. 8304
> Lab Room: RGN 4501T
>
> __
> 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, minim

Re: [R] hi... problems about adjacency matrix

2010-07-08 Thread Ted Harding
On 08-Jul-10 10:33:56, Gina Liao wrote:
> Dear all,
> Hi, I have the problems about converting the matrix to adjacency
> matrix.Here's my example,
>   ab   cd  
> e   fa 1.000 0.4048823682 0.1228531 0.49046991
> 0.4945158868 0.307443317b 0.4048824 1.00 0.4367475 0.96949219
> 0.0007378596 0.560747765c 0.1228531 0.4367474719 1.000 0.40037341
> 0.3157538204 0.428183667d 0.4904699 0.9694921891 0.4003734 1.
> 0.0661313658 0.575606129e 0.4945159 0.0007378596 0.3157538 0.06613137
> 1.00 0.001076251f 0.3074433 0.5607477645 0.4281837 0.57560613
> 0.0010762514 1.0
> and my threshold value is 0.4763, which means any value above it is "1"
> and any values below it is "0".
> so my adjacency matrix should be like this,
>  a   b   c   d   e   fa   1   0   0   1   1   0b   0   1   0   1  
> 0   1c   0   0   1   0   0   0d   1   1   0   1   0   1e   1   0   0  
> 0   1   0f0   1   0   1   0   1
> 
> I'd like to ask how to convert the matrix to adjacency matrix.
> Thanks!!!
> 
> Gina

If B is your original matrix of numbers, and A is to be the adjacency
matrix which you want, then:

  B <- 1*(A > 0.4763)

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 08-Jul-10   Time: 13:41:00
-- XFMail --

__
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 process this in R

2010-07-08 Thread Tony B
I don't have R on the netbook I'm writing this from, but I *think* the
following will work:

> 1. how can i only read in the files with the string patterns ggg or fff as
> part of the file names?
>   for instance, I only need the file names with the ggg or fff in it
>      x_ggg_y_1.txt
>      _fff__xxx.txt
>
>     i don't need to read in the files, such as _aaa_.txt

Maybe something like:
d <- "C:\\FilesFolder\\"
f <- list.files(path = d, pattern = "(ggg)|(fff)", full.names = TRUE)
x <- lapply(f, read.table, header = TRUE)


> 2.how cam rename the files:
>
>   for instance: x_ggg_y_1.txt ==> changed to ggg1a.txt

see ?file.rename

> 3.after the files read in, how can i only keep the rows with the aaa and
> bbb, everything elses show be removed from the files, but the files still
> remain the same file name?
>
>    for instance, in the x_ggg_y_1.txt file, it shouls looks like:
>  name    count
>
> 1. aaa    100
> 2. bbb    2000
> 3. aaa    300
> 4. bbb    400

Something along the following lines should work:
DF <- data.frame(name=rep(c("aaa", "bbb"), 2), count = c(100, 2000,
300, 400))

  name count
1  aaa   100
2  bbb  2000
3  aaa   300
4  bbb   400

subset(DF, name == "aaa")
  name count
1  aaa   100
3  aaa   300

HTH
Tony Breyal

__
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] x-axis labels for barplot of zoo object

2010-07-08 Thread Rainer M Krug
On Thu, Jul 8, 2010 at 12:42 PM, Gabor Grothendieck  wrote:

> On Thu, Jul 8, 2010 at 4:17 AM, Rainer M Krug  wrote:
> > Hi
> >
> > Let's assume, I have a dataset of 1000 datapoints, which represent daily
> > recordings of a measurement.
> > They are stored as a ts object (see example below)
> >
> > Now I want to represent them as a barplot. I found the barplot in the zoo
> > package, but I have one problem: the x-axis labels. I would like to have
> the
> > x-axis labels as either years only (located at the beginning of the
> year),
> > or year/month. So my question:
> >
> > How can I set the x-axis labels to years
> >
> > I can change the start / end of the time series if necessary or use
> another
> > barplot.
> >
> > Below find a small example:
> >
> > library(zoo)
> > x <- ts(runif(1000), start=c(2000, 150), frequency=365)
> > barplot(zoo(x))
> >
> >
>
> Try this:
>
> library(zoo)
> plot(as.zoo(x), type = "h", xaxt = "n")
> axis(1, unique(floor(time(x
>
> or this:
>
> plot(x, type = "h", xaxt = "n")
> axis(1, unique(floor(time(x
>

Thanks a lot Gabor - works perfectly.



Cheers,

Rainer




-- 
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)321 2125 2244
email:  rai...@krugs.de

Skype:  RMkrug
Google: r.m.k...@gmail.com

[[alternative HTML version deleted]]

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


  1   2   >