Re: [R] data frame names in sequence. please help!!!

2010-01-09 Thread Berend Hasselman



Zoho wrote:
> 
> I've been stuck with this problem for a whole afternoon. It's silly but
> totally pissed me off. I have a set of data frames with names in a
> sequence: df_1, df_2, df_3, ..., df_20. Now I want to access each data
> frame (read or write) in a for loop, in a way something like this:
> 
> for (i in 1:20) {
>   df_i <- ##
>   length(which(df_i[,7]==1))
>   ##
> }
> 
> I tried paste or cat ("df_", i, sep=""). But neither way works. Your help
> is highly appreciated!! Thanks in advance!
> 

df_1 <- data.frame(x1=3,x2=5)
df_2 <- data.frame(x1=2,x2=7)
df_3 <- data.frame(x1=-1,x2=1)

for(k in 1:3){v <- paste("df_",k,sep=""); print(get(v))}
for(k in 1:3){v <- paste("df",k,sep="_"); print(get(v)[,2])}

Have a look at get:

?get

Berend
-- 
View this message in context: 
http://n4.nabble.com/data-frame-names-in-sequence-please-help-tp1010518p1010585.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] Mixtures of Discrete Uniforms

2010-01-09 Thread Jim Silverton
I want to create the mixture formulation of a discrete uniform ie, say
f(x) = 1/10, for i = 1,2,3,4,5,6,7,8,9 and 10 and
another discrete distribution which has the same values of x, but he
probabilities can vary. Can this be done on any package in R?  an if so, can
the package estimate the 'probabilities' of each of the x value as well as
the mixing proportion if I have the data?


Thanks,

Jim

[[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 to organize a lot of R source files

2010-01-09 Thread Henrik Bengtsson
Hi.

On Sat, Jan 9, 2010 at 6:16 PM, Hao Cen  wrote:
> Hi Henrik,
>
> Thanks for your suggestion. I created a directory with 10 R files and
> tried the following and measured its time
>
> system.time(sourceDirectory("~/fun", modifiedOnly = F))
> system.time(sourceDirectory("~/fun", modifiedOnly = T))
>
> But the second line seems to spend as much time as the first line, I
> thought   the second line would be faster since no modification is made.

Use modifiedOnly=TRUE the first time too, and you'll see it'll work
the 2nd time.  When you call it the first time, R consider it as
"modified" (since last time), because it has never seen the code
before (in that R session).  If you add some verbose output in your
scripts, you'll definitely see when the scripts get sourced.

I guess you could say it should the way you did it, but the way it is
currently designed/implemented is that it does not record the last
"source" time unless you use modifiedOnly=TRUE.  Next release will
also support what you did.

>
> Also the first line reports a warning as follows
> In readLines(con = fh) :
>  incomplete final line found on "~/fun/util1.R"
> I don't see such a warning when I use source.

Unrelated.  Nothing to worry about.  I've added readLines(con=fh,
warn=FALSE) for the next release to get rid of such warnings.

/Henrik

>
> Maybe the two issues are related. Please advise.
>
> thanks
>
> Jeff
>
>
> On Fri, January 8, 2010 7:56 pm, Henrik Bengtsson wrote:
>> library("R.utils"); sourceDirectory("myRFiles/", modifiedOnly=TRUE);
>>
>> See ?sourceDirectory (regardless what the Rd help say, any '...'
>> argument is passed to sourceTo()).
>>
>> /Henrik
>>
>>
>> On Fri, Jan 8, 2010 at 7:38 AM, Hao Cen  wrote:
>>
>>> Hi,
>>>
>>>
>>> I wonder what is a better way to organize a lot of R source files. I
>>> have a lot of utility functions written and store them in several source
>>> files (e.g util1.R, util2.R,..utilN.R). I also have a master file in
>>> which the source command is used to load all the util.R files. When I
>>> need to use the utility functions in a new project, I create a new R
>>> file (e.g main.R) in which I "source" the master file.
>>>
>>> The problem with this approach is that anytime a single utility
>>> function is modified, I need to rerun the source command in main.R to
>>> load the master file, which loads all the utility R files via a loop
>>> over each file. Sometimes I have to wait for 10 seconds to get them all
>>> loaded. Sometimes I forget to run the source command. Is there a way in
>>> R to 1)
>>> only reload the file changed (like a make utility) when I run source on
>>> all utility files and/or even better 2)  reload the changed utility
>>> files, when I run a command that use one of those utility functions,
>>> without the need for me to source those files.
>>>
>>> Not sure if packaging solves this issue because the library command has
>>> be used every time a utility function is modified and in addition the
>>> package has to be rebuilt. I don't worry about sharing the source files
>>> at this moment as I am the only user of those utility files.
>>>
>>> This may be a common issue many R users face. I wonder how other R
>>> users solve this issue.
>>>
>>> thanks
>>>
>>> Jeff
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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] scatterplot matrix with ggplot2

2010-01-09 Thread Ista Zahn
I don't think this approach will work. In your call to facet_grid you
call variable twice. Another way to do this is create another
variable, call it "variable2" and set it equal to variable. Now look
at the dataframe. You have values for variable = x1, variable2 = x1,
but no values for variable = x1, variable2 = x2 etc. In other words, I
think it's more complicated than you were hoping.

There is plotmatrix, but I've never been able to get it to work
correctly when I try to map additional variables to color or shape
scales etc.

-Ista

On Sat, Jan 9, 2010 at 8:02 PM, stephen sefick  wrote:
> #I would like to use the below data to make a scatter plot matrix with
> #code similar to that below the data
> #conceptually this is the right approach I think
> #thanks in advance
>
> melt.gg <- structure(list(stream = c("Bonham Lower", "Bonham Lower",
> "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "D13", "D13",
> "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
> "D13", "D13", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
> "D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
> "D13", "D13", "D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
> "Bonham Upper", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
> "D13", "D13", "D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
> "Sally Lower", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
> "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper"),
>    agg_site = c("Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
>    "Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
>    "Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
>    "Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
>    "Bonham", "Bonham", "Bonham", "D13", "D13", "D13", "D13",
>    "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
>    "sally", "sally", "sally", "sally", "sally", "sally", "sally",
>    "sally", "sall

Re: [R] how to organize a lot of R source files

2010-01-09 Thread Hao Cen
Hi Henrik,

Thanks for your suggestion. I created a directory with 10 R files and
tried the following and measured its time

system.time(sourceDirectory("~/fun", modifiedOnly = F))
system.time(sourceDirectory("~/fun", modifiedOnly = T))

But the second line seems to spend as much time as the first line, I
thought   the second line would be faster since no modification is made.

Also the first line reports a warning as follows
In readLines(con = fh) :
  incomplete final line found on "~/fun/util1.R"
I don't see such a warning when I use source.

Maybe the two issues are related. Please advise.

thanks

Jeff


On Fri, January 8, 2010 7:56 pm, Henrik Bengtsson wrote:
> library("R.utils"); sourceDirectory("myRFiles/", modifiedOnly=TRUE);
>
> See ?sourceDirectory (regardless what the Rd help say, any '...'
> argument is passed to sourceTo()).
>
> /Henrik
>
>
> On Fri, Jan 8, 2010 at 7:38 AM, Hao Cen  wrote:
>
>> Hi,
>>
>>
>> I wonder what is a better way to organize a lot of R source files. I
>> have a lot of utility functions written and store them in several source
>> files (e.g util1.R, util2.R,..utilN.R). I also have a master file in
>> which the source command is used to load all the util.R files. When I
>> need to use the utility functions in a new project, I create a new R
>> file (e.g main.R) in which I "source" the master file.
>>
>> The problem with this approach is that anytime a single utility
>> function is modified, I need to rerun the source command in main.R to
>> load the master file, which loads all the utility R files via a loop
>> over each file. Sometimes I have to wait for 10 seconds to get them all
>> loaded. Sometimes I forget to run the source command. Is there a way in
>> R to 1)
>> only reload the file changed (like a make utility) when I run source on
>> all utility files and/or even better 2)  reload the changed utility
>> files, when I run a command that use one of those utility functions,
>> without the need for me to source those files.
>>
>> Not sure if packaging solves this issue because the library command has
>> be used every time a utility function is modified and in addition the
>> package has to be rebuilt. I don't worry about sharing the source files
>> at this moment as I am the only user of those utility files.
>>
>> This may be a common issue many R users face. I wonder how other R
>> users solve this issue.
>>
>> thanks
>>
>> Jeff
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] scatterplot matrix with ggplot2

2010-01-09 Thread stephen sefick
#I would like to use the below data to make a scatter plot matrix with
#code similar to that below the data
#conceptually this is the right approach I think
#thanks in advance

melt.gg <- structure(list(stream = c("Bonham Lower", "Bonham Lower",
"Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "D13", "D13",
"D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"D13", "D13", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"D13", "D13", "D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Lower", "Bonham Lower", "Bonham Lower", "Bonham Lower",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "Bonham Upper", "Bonham Upper", "Bonham Upper",
"Bonham Upper", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"D13", "D13", "D13", "D13", "D13", "D13", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower", "Sally Lower",
"Sally Lower", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper",
"Sally Upper", "Sally Upper", "Sally Upper", "Sally Upper"),
agg_site = c("Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "D13", "D13", "D13", "D13",
"D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"sally", "sally", "sally", "sally", "sally", "sally", "sally",
"sally", "sally", "sally", "sally", "sally", "sally", "sally",
"sally", "sally", "sally", "sally", "sally", "sally", "sally",
"sally", "sally", "sally", "sally", "sally", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"Bonham", "Bonham", "Bonham", "Bonham", "Bonham", "Bonham",
"D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13", "D13",
"D13", "D13", "D13", "D13", "sally", "sally", "sally", "sally",
"sally", "sally", "sally", "sally", "sally", "sally", "sally",
"sally", "sally", "sally", "sally", "sally", "sally", "sally",
"sally", 

Re: [R] string functions

2010-01-09 Thread Ista Zahn
Maybe I don't understand the question. I can think of four ways to
count, none of which give me 7:

a <- "Hello World"
b <- "Hello Peter"

#counting duplicates and the space:
sa <- strsplit(a, split="")[[1]]
sb <- strsplit(b, split="")[[1]]
length(which(sb %in% sa == TRUE))

#counting the space but not the duplicates:
sa <- unique(strsplit(a, split="")[[1]])
sb <- unique(strsplit(b, split="")[[1]])
length(which(sb %in% sa == TRUE))

#counting the duplicates but not the space:
sa <- strsplit(a, split="")[[1]]
sa <- sa[-which(sa == " ")]
sb <- strsplit(b, split="")[[1]]
sb <- sb[-which(sb ==" ")]
length(which(sb %in% sa == TRUE))

#not counting duplicates or the space:
sa <- unique(sa)
sb <- unique(sb)
length(which(sb %in% sa == TRUE))

What am I missing?


On Sat, Jan 9, 2010 at 4:51 PM, Laetitia Schmid  wrote:
> Hi!
> Does anybody know a string function that would calculate how many characters
> two strings share? I.e. ("Hello World","Hello Peter") would be 7.
> Thanks.
> Laetitia
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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.


Re: [R] Linear regression - R^2

2010-01-09 Thread milton ruser
Dear Csanad,

PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
Reproducible code/problem are welcome.
By the way, who you believe is right?

bests

milton
On Sat, Jan 9, 2010 at 5:40 PM, Csanád Bertók wrote:

> Hello,
>
> I was doing a linear regression with the following formula:
> *lm(y~x+0)*, so it passes through the origin. But when I called the summary
> of the regression i saw that R squared is abnormally high (it's a lot lower
> in other programs such as SigmaPlot and MS Excel).The manual explained the
> cause of the difference (because of the different computing method), but
> what should I do to get the same R^2 in excel and R?
>
> WITHOUT PASSING THROUGH THE ORIGIN:
> R^2: Multiple R-squared: 0.9711, Adjusted R-squared: 0.9654
> In MS Excel: 0,9711
>
> *So it's OK.*
>
>
> WITH PASSING THROUGH THE ORIGIN:
> Multiple R-squared: 0.9848, Adjusted R-squared: 0.9822
> In MS Excel: 0,8907
>
> *So almost 10% difference.*
>
> Thank you for your help.
>
> Csanad Bertok, Hungary
>
>[[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] string functions

2010-01-09 Thread Greg Hirson

Laetitia,

One approach:

lettermatch <- function(stringA, stringB) {
sum(unique(unlist(strsplit(stringA, ""))) %in% 
unique(unlist(strsplit(stringB, ""

}

lettermatch("Hello World","Hello Peter")
yields 6, as the l is only singly counted.

This treats uppercase and lowercase as different letters and counts how 
many of the unique letters in stringA show up in stringB.


In another approach, letters are set to lowercase first. This I think 
gives you what you want:


lettermatch2 <- function(stringA, stringB) {
tb <- merge(as.data.frame(table(strsplit(tolower(stringA), ""))), 
as.data.frame(table(strsplit(tolower(stringB), ""))), by="Var1")

sum(apply(tb[-1], 1, min))
}

lettermatch("Hello World","Hello Peter")
yields 7.

Greg

On 1/9/10 1:51 PM, Laetitia Schmid wrote:

Hi!
Does anybody know a string function that would calculate how many 
characters two strings share? I.e. ("Hello World","Hello Peter") would 
be 7.

Thanks.
Laetitia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


--
Greg Hirson
ghir...@ucdavis.edu

Graduate Student
Agricultural and Environmental Chemistry

1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 FING.EXE under RGui.EXE for windows.

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:

That doesn't explain why this returns character(o) even though we have
launched a console for it:

system("cmd /c C:\\windows\\system32\\find /?", intern = TRUE)


I don't see any console launched.  R redirects stdin and stdout (and 
stderr, I think), and it appears that Windows doesn't open a console.  I 
do see a console flash by if I do


system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE, 
invisible=FALSE)


but of course then we don't capture the output, so it's not very useful. 
 Looking at the source, the only case where we ask to create a console 
is the combination "wait=FALSE, invisible=FALSE", but there might be 
combinations of other options that make this a default.  The MS 
documentation says that a console will be created automatically for any 
console application, but that doesn't appear to be happening.


So I guess you could get find.exe to work by calling it from a batch 
file with a "pause" at the end and using the wait=FALSE,invisible=FALSE 
options.


The above observations are in Win XP SP3, not anything newer.

Duncan Murdoch



On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch  wrote:

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.

I don't know exactly what's going on, but it looks as though it is something
specific to the find.exe utility, e.g. maybe it is assuming that it's being
run inside a console and reading CONIN$ or writing to CONOUT$ without
checking whether they can be opened.  When you run it from Rterm, Rterm is
in a console, which appears to be good enough.

So it may be anyone who wants to use it will have to contact Microsoft to
find out how...

Duncan Murdoch


Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] "R version 2.10.1 Patched (2010-01-01 r50884)"


system("C:\\windows\\system32\\find /?", intern = TRUE)

character(0)


system("cmd /c C:\\windows\\system32\\find /?", intern = TRUE)

character(0)


shell("C:\\windows\\system32\\find /?")

Warning message:
In shell("C:\\windows\\system32\\find /?") :
 'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Ligges:

On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.

I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a
command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayder
 wrote:

This is sort of a strange bug.  Not show stopping, but annoying.  I
was
wondering if anyone else has noticed this and reported it before I
submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that "Find String
[grep]
Utility has encountered a problem and needs to close."  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
 It can be reproduced by simply typing  "System("find")" in RGui.
 What I
found strange is that I have been running this script daily without
this
problem for months.  I now realize I never ran that portion of the
script
while in RGui.exe.  It has always run in batch mode which is done by
Rterm.exe.

I have tried this on three separate machines now all running Windows
XP
SP3, with versions of R 2.8.1 and R 2.10.1  If executing
"System("find")
under RGui, an error window for the Find String Utility is generated
and
the command is not exectuted.  If the same command is issued in Rterm
the
expected "FIND: Parameter format not correct" message is properly
returned.

It doesn't seem an important bug, but it could be the canary in the
mine
for a larger problem somewhere down the road.

Re,
John Schexnayder

IBM Tape Manufacturing - Information Technology
San Jose, CA  95138
jsc...@us.ibm.com

   [[alternative HTML version deleted]]

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-proje

Re: [R] string functions

2010-01-09 Thread Liviu Andronic
On 1/9/10, Laetitia Schmid  wrote:
>  Does anybody know a string function that would calculate how many characters 
> two strings share? I.e. ("Hello World","Hello Peter") would be 7.
>
Perhaps package ‘stringr’ has something related?
Liviu

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


[R] commandArgs return value

2010-01-09 Thread Ben Tupper

Hello,

I plan to use a script with R CMD BATCH on different platforms Linux,  
Windows and Mac OSX.  I use the commandArgs(trailing = FALSE) function  
to retrieve the name of the script and the arguments (example below  
with output.)  The online docs for "Introduction to R" (sections B.1  
Invoking R from the command line and  B.4 Scripting with R) and  
help("commandArgs") leave my head spinning regarding the contents of  
the arguments when trailing = FALSE.



(1) What should I expect from commandArgs() when used with R CMD BATCH?

The docs for commandArgs() states, "These arguments are captured  
before the standard R command line processing takes place. This means  
that they are the unmodified values."  However, if I call a script  
like this ...


R CMD BATCH --slave --vanilla '--args dogs cats verbose=TRUE' /Users/ 
Shared/code/R/hbb/pam/script.r my.out


... the actual arguments are as shown in the example output below.
You can see that "--restore --save --no-readline" were picked up which  
seems to contradict the documentation.  In the online docs (http://cran.r-project.org/doc/manuals/R-intro.html#Invoking-R 
) the --vanilla argument is described as a combination of --no-save, -- 
no-environ, --no-site-file, --no-init-file and --no-restore.  So now I  
am wondering if I am confounding the arguments to invoke R with the  
arguments to invoke R via CMD BATCH.


(2) Does the name of the script being called always fall in the third  
element of the commandArgs() value?  If so, does it always include the  
full path?


(3) Are "--arg" and the supplied arguments always last in the  
commandArgs() value?  The docs for commandArgs() states, "This is  
especially useful with the --args command-line flag to R, as all of  
the command line after that flag is skipped," so I feel pretty  
confident that they will be last.  But given my confusion in (1)  
above 



Thanks,
Ben


## script begin
args = commandArgs()

cat("All the arguments...\n\n")
cat(args, sep = "\n")
cat(" \n")
cat(paste("nargs=", length(args)), "\n")
cat(" \n")
cat(paste("source is", basename(args[3]), sep = " "), sep = "\n")

ix = grep("--arg", args, fixed = TRUE)
if (ix < length(args)){
   for (i in (ix+1):length(args)) {
cat(paste("argument #",i-ix,"-->",args[i], sep=" "), sep = "\n")
   }
}

ecode = 0
q(runLast = FALSE, save = "no", status = ecode)
## script end

##  output file begin
All the arguments...

/Library/Frameworks/R.framework/Resources/bin/exec/i386/R
-f
/Users/Shared/code/R/hbb/pam/script.r
--restore
--save
--no-readline
--slave
--vanilla
--args
dogs
cats
verbose=TRUE

nargs= 12

source is script.r
argument # 1 --> dogs
argument # 2 --> cats
argument # 3 --> verbose=TRUE
 output file end


# session info
> sessionInfo()
R version 2.10.1 (2009-12-14)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] tools_2.10.1
###

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


[R] string functions

2010-01-09 Thread Laetitia Schmid

Hi!
Does anybody know a string function that would calculate how many  
characters two strings share? I.e. ("Hello World","Hello Peter") would  
be 7.

Thanks.
Laetitia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 FING.EXE under RGui.EXE for windows.

2010-01-09 Thread Gabor Grothendieck
That doesn't explain why this returns character(o) even though we have
launched a console for it:

system("cmd /c C:\\windows\\system32\\find /?", intern = TRUE)

On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch  wrote:
> On 07/01/2010 1:25 PM, Uwe Ligges wrote:
>>
>> Argh. I see it as well. Will dig a lit tomorrow.
>
> I don't know exactly what's going on, but it looks as though it is something
> specific to the find.exe utility, e.g. maybe it is assuming that it's being
> run inside a console and reading CONIN$ or writing to CONOUT$ without
> checking whether they can be opened.  When you run it from Rterm, Rterm is
> in a console, which appears to be good enough.
>
> So it may be anyone who wants to use it will have to contact Microsoft to
> find out how...
>
> Duncan Murdoch
>
>>
>> Uwe
>>
>>
>>
>>
>>
>> On 07.01.2010 12:25, Gabor Grothendieck wrote:
>>>
>>> I get a problem with shell too:
>>>
>>> Under Rgui:
>>>
 R.version.string
>>>
>>> [1] "R version 2.10.1 Patched (2010-01-01 r50884)"
>>>
 system("C:\\windows\\system32\\find /?", intern = TRUE)
>>>
>>> character(0)
>>>
 system("cmd /c C:\\windows\\system32\\find /?", intern = TRUE)
>>>
>>> character(0)
>>>
 shell("C:\\windows\\system32\\find /?")
>>>
>>> Warning message:
>>> In shell("C:\\windows\\system32\\find /?") :
>>>  'C:\windows\system32\find /?' execution failed with error code 1
>>>
>>> They all work, i.e. they give the required help message, under Rterm
>>> and when I issue this from the Windows console it works:
>>> C:\windows\system32\find /?
>>>
>>>
>>> 2010/1/7 Uwe Ligges:

 On 07.01.2010 02:04, Gabor Grothendieck wrote:
>
> If you have C:\Rtools\bin on your PATH note that it contains a
> UNIX-like find utility that conflicts with the find utility in
> Windows.  If that is the problem then remove that from your PATH and
> then run the batch file.
>
> The batchfiles distribution at http://batchfiles.googlecode.com  has
> utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
> add C:\Rtools\bin to your path temporarily or only while R is running
> so that you can leave it off your PATH.

 I guess it's the use of system() rather than shell() that causes the
 problem. Under Windows, you have to use shell in order to start a
 command
 interpreter.

 Uwe Ligges


> On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayder
>  wrote:
>>
>> This is sort of a strange bug.  Not show stopping, but annoying.  I
>> was
>> wondering if anyone else has noticed this and reported it before I
>> submit
>> a bug report.
>>
>> I noticed while running the RGui and attempting to debug one of my
>> scripts
>> that I encountered a Windows error informing me that "Find String
>> [grep]
>> Utility has encountered a problem and needs to close."  It is being
>> generated by a call to a DOS batch file which contains a call to
>> Find.exe.
>>  It can be reproduced by simply typing  "System("find")" in RGui.
>>  What I
>> found strange is that I have been running this script daily without
>> this
>> problem for months.  I now realize I never ran that portion of the
>> script
>> while in RGui.exe.  It has always run in batch mode which is done by
>> Rterm.exe.
>>
>> I have tried this on three separate machines now all running Windows
>> XP
>> SP3, with versions of R 2.8.1 and R 2.10.1  If executing
>> "System("find")
>> under RGui, an error window for the Find String Utility is generated
>> and
>> the command is not exectuted.  If the same command is issued in Rterm
>> the
>> expected "FIND: Parameter format not correct" message is properly
>> returned.
>>
>> It doesn't seem an important bug, but it could be the canary in the
>> mine
>> for a larger problem somewhere down the road.
>>
>> Re,
>> John Schexnayder
>>
>> IBM Tape Manufacturing - Information Technology
>> San Jose, CA  95138
>> jsc...@us.ibm.com
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/p

Re: [R] R^2 in linear regression

2010-01-09 Thread Terias

Thank you, it worked :)

Csanad Bertok
Biology BSc
University of Debrecen
Debrecen, Hungary
-- 
View this message in context: 
http://n4.nabble.com/Re-R-2-in-linear-regression-tp1010477p1010484.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] R^2 in linear regression

2010-01-09 Thread Peter Dalgaard

Terias wrote:

Hello,

I was doing a linear regression with the following formula:
lm(y~x+0), so it passes through the origin. But when I called the summary of
the regression i saw that R squared is abnormally high (it's a lot lower in
other programs such as SigmaPlot and MS Excel).The manual explained the
cause of the difference (because of the different computing method), but
what should I do to get the same R^2 in excel and R?



If you insist, I think you can get what Excel does like this:

> x <- 1:10
> y <- rnorm(10)

## Residual sums of squares
> ss1 <- anova(lm(y~1))[1,2]
> ss2 <- anova(lm(y~x+0))[2,2]

## Relative reduction in sum of squares
> (ss1-ss2)/ss1
[1] -0.08576713

Now if you dislike the fact that R^2 can come out negative, that's your 
problem





WITHOUT PASSING THROUGH THE ORIGIN:
R^2: Multiple R-squared: 0.9711, Adjusted R-squared: 0.9654
In MS Excel: 0,9711

So it's OK.


WITH PASSING THROUGH THE ORIGIN:
Multiple R-squared: 0.9848, Adjusted R-squared: 0.9822
In MS Excel: 0,8907

So almost 10% difference.

Thank you for your help.

Csanad Bertok, Hungary




--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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


[R] R^2 in linear regression

2010-01-09 Thread Terias

Hello,

I was doing a linear regression with the following formula:
lm(y~x+0), so it passes through the origin. But when I called the summary of
the regression i saw that R squared is abnormally high (it's a lot lower in
other programs such as SigmaPlot and MS Excel).The manual explained the
cause of the difference (because of the different computing method), but
what should I do to get the same R^2 in excel and R?

WITHOUT PASSING THROUGH THE ORIGIN:
R^2: Multiple R-squared: 0.9711, Adjusted R-squared: 0.9654
In MS Excel: 0,9711

So it's OK.


WITH PASSING THROUGH THE ORIGIN:
Multiple R-squared: 0.9848, Adjusted R-squared: 0.9822
In MS Excel: 0,8907

So almost 10% difference.

Thank you for your help.

Csanad Bertok, Hungary

-- 
View this message in context: 
http://n4.nabble.com/R-2-in-linear-regression-tp1010473p1010473.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] Linear regression - R^2

2010-01-09 Thread Csanád Bertók
Hello,

I was doing a linear regression with the following formula:
*lm(y~x+0)*, so it passes through the origin. But when I called the summary
of the regression i saw that R squared is abnormally high (it's a lot lower
in other programs such as SigmaPlot and MS Excel).The manual explained the
cause of the difference (because of the different computing method), but
what should I do to get the same R^2 in excel and R?

WITHOUT PASSING THROUGH THE ORIGIN:
R^2: Multiple R-squared: 0.9711, Adjusted R-squared: 0.9654
In MS Excel: 0,9711

*So it's OK.*


WITH PASSING THROUGH THE ORIGIN:
Multiple R-squared: 0.9848, Adjusted R-squared: 0.9822
In MS Excel: 0,8907

*So almost 10% difference.*

Thank you for your help.

Csanad Bertok, Hungary

[[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 FING.EXE under RGui.EXE for windows.

2010-01-09 Thread Duncan Murdoch

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.


I don't know exactly what's going on, but it looks as though it is 
something specific to the find.exe utility, e.g. maybe it is assuming 
that it's being run inside a console and reading CONIN$ or writing to 
CONOUT$ without checking whether they can be opened.  When you run it 
from Rterm, Rterm is in a console, which appears to be good enough.


So it may be anyone who wants to use it will have to contact Microsoft 
to find out how...


Duncan Murdoch



Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] "R version 2.10.1 Patched (2010-01-01 r50884)"


system("C:\\windows\\system32\\find /?", intern = TRUE)

character(0)


system("cmd /c C:\\windows\\system32\\find /?", intern = TRUE)

character(0)


shell("C:\\windows\\system32\\find /?")

Warning message:
In shell("C:\\windows\\system32\\find /?") :
  'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Ligges:


On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.


I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayder
  wrote:

This is sort of a strange bug.  Not show stopping, but annoying.  I was
wondering if anyone else has noticed this and reported it before I submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that "Find String [grep]
Utility has encountered a problem and needs to close."  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
  It can be reproduced by simply typing  "System("find")" in RGui.  What I
found strange is that I have been running this script daily without this
problem for months.  I now realize I never ran that portion of the script
while in RGui.exe.  It has always run in batch mode which is done by
Rterm.exe.

I have tried this on three separate machines now all running Windows XP
SP3, with versions of R 2.8.1 and R 2.10.1  If executing "System("find")
under RGui, an error window for the Find String Utility is generated and
the command is not exectuted.  If the same command is issued in Rterm the
expected "FIND: Parameter format not correct" message is properly
returned.

It doesn't seem an important bug, but it could be the canary in the mine
for a larger problem somewhere down the road.

Re,
John Schexnayder

IBM Tape Manufacturing - Information Technology
San Jose, CA  95138
jsc...@us.ibm.com

[[alternative HTML version deleted]]

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] svm

2010-01-09 Thread Steve Lianoglou
Hi,

On Fri, Jan 8, 2010 at 11:57 AM, Amy Hessen  wrote:
> Hi Steve,
>
> Thank you very much for your reply. Your code is more readable and obvious 
> than mine…

No Problem.

> Could you please help me in these questions?:
>
> 1) “Formula” is an alternative to “y” parameter in SVM. is it correct?

No, that's not correct.

There are two svm functions, one that takes a "formula" object
(svm.formula), and one that takes an x matrix, and a y vector
(svm.default). The svm.formula function is called when the first
argument in your "svm(..)" call is a formula object. This function
simply parses the formula and manipulates your data object into an x
matrix and y vector, then calls the svm.default function with those
params ... I usually prefer to just skip the formula and provide the x
and y objects directly.

Load the e1071 library and look at the source code:

R> library(e1071)
R> e1071:::svm.formula

You'll see what I mean.

> 2) I forgot to remove the “class label” from the dataset besides I gave the
> program the class label in formula parameter but the program works! Could
> you please clarify this point to me?

The author of the e1071 package did you a favor. The predict.svm
function checks to see if your svm object was built using the formula
interface .. if so, it looks for you label column in the data you are
trying to predict on and ignores it.

Look at the function's source code (eg, type e1071:::predict.svm at
the R prompt), and look for the call to the delete.response function
... you can also look at the help in ?delete.response.

-steve


>> Date: Wed, 6 Jan 2010 18:44:13 -0500
>> Subject: Re: [R] svm
>> From: mailinglist.honey...@gmail.com
>> To: amy_4_5...@hotmail.com
>> CC: r-help@r-project.org
>>
>> Hi Amy,
>>
>> On Wed, Jan 6, 2010 at 4:33 PM, Amy Hessen  wrote:
>> > Hi Steve,
>> >
>> > Thank you very much for your reply.
>> >
>> > I’m trying to do something systematic/general in the program so that I
>> > can
>> > try different datasets without changing much in the program (without
>> > knowing
>> > the name of the class label that has different name from dataset to
>> > another…)
>> >
>> > Could you please tell me your opinion about this code:-
>> >
>> > library(e1071)
>> >
>> > mydata<-read.delim("the_whole_dataset.txt")
>> >
>> > class_label <- names(mydata)[1]    # I’ll always put
>> > the
>> > class label in the first column.
>> >
>> > myformula <- formula(paste(class_label,"~ ."))
>> >
>> > x <- subset(mydata, select = - mydata[, 1])
>> >
>> > mymodel<-(svm(myformula, x, cross=3))
>> >
>> > summary(model)
>> >
>> > 
>>
>> Since you're not doing anything funky with the formula, a preference
>> of mine is to just skip this way of calling SVM and go "straight" to
>> the svm(x,y,...) method:
>>
>> R> mydata <- as.matrix(read.delim("the_whole_dataset.txt"))
>> R> train.x <- mydata[,-1]
>> R> train.y <- mydata[,1]
>>
>> R> mymodel <- svm(train.x, train.y, cross=3, type="C-classification")
>> ## or
>> R> mymodel <- svm(train.x, train.y, cross=3, type="eps-regression")
>>
>> As an aside, I also like to be explicit about the type="" parameter to
>> tell what I want my SVM to do (regression or classification). If it's
>> not specified, the SVM picks which one to do based on whether or not
>> your y vector is a vector of factors (does classification), or not
>> (does regression)
>>
>> > Do I have to the same steps with testingset? i.e. the testing set must
>> > not
>> > contain the label too? But contains the same structure as the training
>> > set?
>> > Is it correct?
>>
>> I guess you'll want to report your accuracy/MSE/something on your
>> model for your testing set? Just load the data in the same way then
>> use `predict` to calculate the metric your after. You'll have to have
>> the labels for your data to do that, though, eg:
>>
>> testdata <- as.matrix(read.delim('testdata.txt'))
>> test.x <- testdata[,-1]
>> test.y <- testdata[,1]
>> preds <- predict(mymodel, test.x)
>>
>> Let's assume you're doing classification, so let's report the accuracy:
>>
>> acc <- sum(preds == test.y) / length(test.y)
>>
>> Does that help?
>> -steve
>>
>> --
>> 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
>
> 
> Sell your old one fast! Time for a new car?



-- 
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] R in English Version

2010-01-09 Thread David Winsemius


On Jan 9, 2010, at 12:45 PM, pooja pandey wrote:


Dear Sir/Madam

I am living in germany but do not know German Language. so could you  
please help me to download R in English working Language, because  
automatically it gives German version of R when I download it from  
UK or US or Germany.


http://cran.r-project.org/doc/manuals/R-admin.html#Localization-of-messages


--
David Winsemius, MD
Heritage Laboratories
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] R in English Version

2010-01-09 Thread Uwe Ligges



On 09.01.2010 18:45, pooja pandey wrote:

Dear Sir/Madam

I am living in germany but do not know German Language.



So time to learn it... ;-)



so could you please help me to download R in English working Language, because 
automatically it gives German version of R when I download it from UK or US or 
Germany.



Well, R uses the language reported by the OS (and you have not said 
which one it is).


For details how to change and understand what happens see the manual "R 
Installation and Administration", particularly section 7.2 (for 
R-2.10.1): "Localization of messages".


Best wishes,
Uwe Ligges





Thanking you and Best regards
Pooja



[[alternative HTML version deleted]]




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


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


Re: [R] Directory operations

2010-01-09 Thread Uwe Ligges



On 09.01.2010 19:04, anupam sinha wrote:

Hi Jim,
 Thanks for your suggestion. I tried scripting but gives me an
error. Can you tell me what am I doing wrong here ?


*>  list.files()->org_xml_dirs


Please do turn that arrow around


for (i in org_xml_dirs){

+ setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i")}



There is no directory .../i
Your probably want:
setwd(file.path("/home/anupam/Research/Anupam_data/ORG_XML_FILES/", i))

Uwe Ligges





   Error in setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i") :
   cannot change working directory
*


On Fri, Jan 8, 2010 at 11:37 PM, jim holtman  wrote:


?list.files
?file.info
?setwd

You can get a list of all the files in a directory (list.files) and then do
a file.info to determine which ones are the directories you want to
search.  A list.files on that directory will give you the list of file names
that you can then process.




On Fri, Jan 8, 2010 at 12:41 PM, anupam sinhawrote:


Dear all,
  I have this directory structure :

Dir1   Dir2   Dir3  Dir4  .
A.xml D.xmlG.xml
B.xml E.xml H.xml
C.xml F.xml I.xml

Within each of these directories (Dir1, Dir2 etc) there are a num of xml
files (A.xml, B.xml etc).

What I want to do is to enter into the first directory read all the xml
files do certain operations come out  of the directory and do the same
thing
for another directory. Can anyone help me out ? Thanks in advance for any
suggestions.

Regards,

Anupam Sinha

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





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

What is the problem that you are trying to solve?







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


[R] R in English Version

2010-01-09 Thread pooja pandey
Dear Sir/Madam
 
I am living in germany but do not know German Language. so could you please 
help me to download R in English working Language, because automatically it 
gives German version of R when I download it from UK or US or Germany.
 
Thanking you and Best regards
Pooja


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

2010-01-09 Thread Peter Ehlers

I'm guessing that you want side-by-side boxplots.
If that's correct, then try the following.
It stacks the y-values, makes an appropriate grouping
factor and plots with reasonable spacing.

dat <- read.table(textConnection("
 tank TanksTotal cons_hat
1aa4 5.651017 5.59
2aa5 5.017499 5.29
3aa6 4.894238 4.69
4cc4 3.986347 3.40
5cc5 4.099442 3.58
6cc6 4.150522 3.64
7hh4 5.187792 6.32
8hh5 6.713422 6.44
9hh6 5.168555 5.62"),header=T)
closeAllConnections()

library(reshape) #or you can use stats::reshape() with suitable
 # modifications
tmp <- melt(dat, id.vars="tank",
   measure.vars=c("Total", "cons_hat"),
   variable_name="Group")
tmp

tmp$grp <- with(tmp, factor(paste(tank, as.numeric(Group), sep=":")))
tmp

boxplot(value ~ grp, data=tmp, boxwex=0.5,
   col=c("red", "blue"),
   at=c(1.2,1.8,3.2,3.8,5.2,5.8))

 -Peter Ehlers

Marlin Keith Cox wrote:

I have a data set with four columns and need to make boxplots from them.
 Data is as follows:
 tank TanksTotal cons_hat
1aa4 5.651017 5.59
2aa5 5.017499 5.29
3aa6 4.894238 4.69
4cc4 3.986347 3.40
5cc5 4.099442 3.58
6cc6 4.150522 3.64
7hh4 5.187792 6.32
8hh5 6.713422 6.44
9hh6 5.168555 5.62

This is simply consumption data with Total being the actual measured
consumption and cons_hat being the predicted.  I need a boxplot of tank "a"
(consisting of a4,a5,a6) "Total" vs. "cons_hat".

boxplot(Total~tank) of course creates a boxplot with only Total by tank, but
how do I put the other column in this boxplot?

Thanks ahead of time.

keith



--
Peter Ehlers
University of Calgary
403.202.3921

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Online R documentation

2010-01-09 Thread Dieter Menne



Duncan Murdoch wrote:
> 
> Including graphical output in the man pages is one of the eventual goals 
> of the new help system.  I doubt it will make it into 2.11.x, but it 
> will probably be there in 2.12.x.
> 

This is good news; while I did not love Hadley Wickham's decision to put
documentation of ggplot2 on an external server, I can understand his
rationale that documenting a graphics package in ASCII/Unicode is not a good
idea.

Maybe we should have a small-footprint portable help server that could be
run as a service/daemon without the overhead of calling rterm for 2.10.

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Online-R-documentation-tp1009656p1010385.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] Panel order in lattice with xyplot

2010-01-09 Thread Dieter Menne



Carol wrote:
> 
> I am a new user of R  and I am going very slow….
> 
Never mind, R has s a steep (or, more accurately, shallow) learning curve.


Carol wrote:
> 
> I am using lattice and am trying to draw a multipanel figure. The problems
> are that I am not able to find out how to: 
> 1. Set the order of the panels.
> 2. Set the order of the x axes.
> 

For an easy, but restricted, way to change the order of the panels, see
as.table in the documentation of xyplot. To change the order panels with
categorical variable, it is easiest to change the order of the categories;
see, for example, "reorder".
 

Carol wrote:
> 
> Benthic<- read.table(file="WWTP 1 WICK 5.txt",header = TRUE)
> .. Code removed
> 

Your example is fine, with the exception that other people cannot reproduce
it because they do not have the data file. So always include dummy data for
a detailed reply


-- 
View this message in context: 
http://n4.nabble.com/Panel-order-in-lattice-with-xyplot-tp1009866p1010379.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] Directory operations

2010-01-09 Thread anupam sinha
Hi Jim,
Thanks for your suggestion. I tried scripting but gives me an
error. Can you tell me what am I doing wrong here ?


*> list.files()->org_xml_dirs
> for (i in org_xml_dirs){
+ setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i")}

  Error in setwd("/home/anupam/Research/Anupam_data/ORG_XML_FILES/i") :
  cannot change working directory
*


On Fri, Jan 8, 2010 at 11:37 PM, jim holtman  wrote:

> ?list.files
> ?file.info
> ?setwd
>
> You can get a list of all the files in a directory (list.files) and then do
> a file.info to determine which ones are the directories you want to
> search.  A list.files on that directory will give you the list of file names
> that you can then process.
>
>
>
>
> On Fri, Jan 8, 2010 at 12:41 PM, anupam sinha wrote:
>
>> Dear all,
>>  I have this directory structure :
>>
>> Dir1   Dir2   Dir3  Dir4  .
>> A.xml D.xmlG.xml
>> B.xml E.xml H.xml
>> C.xml F.xml I.xml
>>
>> Within each of these directories (Dir1, Dir2 etc) there are a num of xml
>> files (A.xml, B.xml etc).
>>
>> What I want to do is to enter into the first directory read all the xml
>> files do certain operations come out  of the directory and do the same
>> thing
>> for another directory. Can anyone help me out ? Thanks in advance for any
>> suggestions.
>>
>> Regards,
>>
>> Anupam Sinha
>>
>>[[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.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>



-- 
Graduate Student,
Laboratory of Computtational Biology,
Centre For DNA Fingerprinting And Diagnostics,
4-1-714 to 725/2, Tuljaguda complex
Mozamzahi Road, Nampally,
Hyderabad-51

[[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] Online R documentation

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 12:48 PM, Dieter Menne wrote:


Karl Ove Hufthammer wrote:
In case anybody is looking for ideas in how to improve the above 
site, inclusion of rendered example graphs, similar to the ones at 
"http://www.metaresearch.de/exlib/";, would be nice.




If the format you use on your site were  accepted as the standard in R, this
would be a great step forward in improving the dinosaur.

I prefer to have help locally, though, because I would like to have the
first search restricted to the packages I have installed, to avoid being
drowned by 2000 packages I never need.


Including graphical output in the man pages is one of the eventual goals 
of the new help system.  I doubt it will make it into 2.11.x, but it 
will probably be there in 2.12.x.


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] Online R documentation

2010-01-09 Thread Dieter Menne


Karl Ove Hufthammer wrote:
> 
> In case anybody is looking for ideas in how to improve the above 
> site, inclusion of rendered example graphs, similar to the ones at 
> "http://www.metaresearch.de/exlib/";, would be nice.
> 

If the format you use on your site were  accepted as the standard in R, this
would be a great step forward in improving the dinosaur.

I prefer to have help locally, though, because I would like to have the
first search restricted to the packages I have installed, to avoid being
drowned by 2000 packages I never need.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/Online-R-documentation-tp1009656p1010376.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] errors when installing packages (ubuntu)

2010-01-09 Thread Uwe Ligges
Looks like spam depends on R-2.10.x which the package maintainer (CCing) 
has not declared in the DESCRIPTION file.
So either install R-2.10.1 and try again or use an older spam version 
from the CRAN archives for your old version of R.


To Reinhard Furrer: can you please upload a new version with increased 
version number to CRAN that declares the dependency. Thank you.


Best wishes,
Uwe Ligges


On 09.01.2010 14:27, romunov wrote:

Hi List,

I'm having problems installing certain packages. When I try to install
fields, I get the output below. I have highlighted the what I perceive as
the first error (spam seems to be a dependency of fields). Can I assume this
is causing dependency problems for fields, which fails to install at the
end, or is there a deeper problem? I run Ubuntu Karmic Koala on R 2.9.2.

2>  install.packages("fields")
Warning in install.packages("fields") :
   argument 'lib' is missing: using
'/home/romunov/R/i486-pc-linux-gnu-library/2.9'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
also installing the dependency ‘spam’

trying URL 'http://cran.at.r-project.org/src/contrib/spam_0.20-2.tar.gz'
Content type 'application/x-gzip' length 470013 bytes (458 Kb)
opened URL
==
downloaded 458 Kb

trying URL 'http://cran.at.r-project.org/src/contrib/fields_6.01.tar.gz'
Content type 'application/x-gzip' length 3670039 bytes (3.5 Mb)
opened URL
==
downloaded 3.5 Mb

* Installing *source* package ‘spam’ ...
** libs
gfortran   -fpic  -g -O2 -c bckslvmodified.f -o bckslvmodified.o
gfortran   -fpic  -g -O2 -c cholmodified.f -o cholmodified.o
gfortran   -fpic  -g -O2 -c dist.f -o dist.o
gfortran   -fpic  -g -O2 -c fromsparsekit.f -o fromsparsekit.o
gfortran   -fpic  -g -O2 -c kronecker.f -o kronecker.o
gfortran   -fpic  -g -O2 -c spamown.f -o spamown.o
gfortran   -fpic  -g -O2 -c xybind.f -o xybind.o
gcc -std=gnu99 -shared -o spam.so bckslvmodified.o cholmodified.o dist.o
fromsparsekit.o kronecker.o spamown.o xybind.o -lgfortran -lm
-L/usr/lib/R/lib -lR
** R
** data
**  moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Creating a new generic function for "print" in "spam"
Creating a new generic function for "summary" in "spam"
Creating a new generic function for "diag" in "spam"
Creating a new generic function for "diag<-" in "spam"
Creating a new generic function for "t" in "spam"
Error in setOldClass(c("dist", "numeric")) :
   inconsistent old-style class information for "numeric"; the class is
defined but does not extend "oldClass"
Error : unable to load R code in package 'spam'
ERROR: lazy loading failed for package ‘spam’
* Removing ‘/home/romunov/R/i486-pc-linux-gnu-library/2.9/spam’
* Installing *source* package ‘fields’ ...
** libs
gfortran   -fpic  -g -O2 -c css.f -o css.o
gfortran   -fpic  -g -O2 -c csstr.f -o csstr.o
gfortran   -fpic  -g -O2 -c cvrf.f -o cvrf.o
gfortran   -fpic  -g -O2 -c dchold.f -o dchold.o
gfortran   -fpic  -g -O2 -c dcopy.f -o dcopy.o
gfortran   -fpic  -g -O2 -c ddfind.f -o ddfind.o
gfortran   -fpic  -g -O2 -c ddot.f -o ddot.o
gfortran   -fpic  -g -O2 -c derrb.f -o derrb.o
gfortran   -fpic  -g -O2 -c dlv.f -o dlv.o
gfortran   -fpic  -g -O2 -c dmaket.f -o dmaket.o
gfortran   -fpic  -g -O2 -c drdfun.f -o drdfun.o
gfortran   -fpic  -g -O2 -c dsetup.f -o dsetup.o
gfortran   -fpic  -g -O2 -c evlpoly.f -o evlpoly.o
gfortran   -fpic  -g -O2 -c evlpoly2.f -o evlpoly2.o
gfortran   -fpic  -g -O2 -c expbs.f -o expbs.o
gfortran   -fpic  -g -O2 -c expfn.f -o expfn.o
gfortran   -fpic  -g -O2 -c gaspbs.f -o gaspbs.o
gfortran   -fpic  -g -O2 -c gaspfn.f -o gaspfn.o
gfortran   -fpic  -g -O2 -c gcvcss.f -o gcvcss.o
gfortran   -fpic  -g -O2 -c gcvfc.f -o gcvfc.o
gfortran   -fpic  -g -O2 -c hsort.f -o hsort.o
gfortran   -fpic  -g -O2 -c ifind.f -o ifind.o
gfortran   -fpic  -g -O2 -c igpoly.f -o igpoly.o
gfortran   -fpic  -g -O2 -c inpoly.f -o inpoly.o
gfortran   -fpic  -g -O2 -c lscv.f -o lscv.o
gfortran   -fpic  -g -O2 -c m2deb.f -o m2deb.o
gfortran   -fpic  -g -O2 -c mkpoly.f -o mkpoly.o
gfortran   -fpic  -g -O2 -c mltdrb.f -o mltdrb.o
gfortran   -fpic  -g -O2 -c mltdtd.f -o mltdtd.o
gfortran   -fpic  -g -O2 -c msort.f -o msort.o
gfortran   -fpic  -g -O2 -c multeb.f -o multeb.o
gfortran   -fpic  -g -O2 -c multgb.f -o multgb.o
gfortran   -fpic  -g -O2 -c multrb.f -o multrb.o
gfortran   -fpic  -g -O2 -c radbas.f -o radbas.o
gfortran   -fpic  -g -O2 -c radfn2.f -o radfn2.o
gfortran   -fpic  -g -O2 -c radfun.f -o radfun.o
gfortran   -fpic  -g -O2 -c rcss.f -o rcss.o
gfortran   -fpic  -g -O2 -c rcssr.f -o rcssr.o
gfortran   -fpic  -g -O2 -c rcsswt.f -o rcsswt.o
gfortran   -fpic  -g -O2 -c sortm.f -o sortm.o
gcc -std=gnu99 -shared -o fields.so css.o csstr.o cvrf.o dchold.o dcopy.o
ddfind.o ddot.o derrb.o dlv.o dmaket.o drdfun.o dsetup.o evlpoly.o
evlpoly2.o expbs.o expfn.o gaspbs.o gaspfn.o gcvcss.o gcvfc.o hsort.o
ifi

[R] bootstrapping a matrix using boot package

2010-01-09 Thread Amit
Dear All,
I am trying to bootstrap a large data matrix 'exp' of dimension
9275x898 using package 'boot'. I am trying to calculate correlation of
the obtained samples. I have done following so far:

>library(boot)
>load("ratio_exp.RData") #loading the data matrix
>dim(ratio_exp)
[1] 9275  898
>sample.cor=function(ratio_exp,d){return(cor(t(ratio_exp[d,])))} #function for 
>obtaing correlation
>boot.exp=boot(ratio_exp,sample.cor,R=50)
Error in matrix(NA, sum(R), lt0) : too many elements specified

But when I reduced the no of replication that is 10 then I got following
>boot.exp=boot(ratio_exp,sample.cor,R=10)
> str(boot.exp$t)
 num [1:5, 1:86025625] 1 1 1 1 1 ...

In both the cases its not correct. So I am doing something wrong in
writing the function sample.cor. Please help!

regards
Amit

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reducing the size of a large script top speed onset of execution

2010-01-09 Thread Dennis Fisher

Professor Ripley,

Thanks for your suggestions.  I will look into the package approach.

As far as the "source" speed issue, you suggested that the problem may  
relate to guessing encodings so I added:

options(encoding="UTF-8")
at the beginning of the code (was this the correct approach to the  
problem?).  That did not make any obvious difference to the duration  
to source the script.  Do you have an specific suggestions that might  
speed the process?


Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

On Jan 9, 2010, at 8:53 AM, Prof Brian Ripley wrote:

Please just use make a package; then all the effort of parsing the  
code is done at install time, you can use lazy-loading   Or if  
you are for some reason averse to that, source the code into an  
environment, save that and simply attach() its save file next time.


Packages of that size load in a few milliseconds (as you see each  
time you start R:  stats is 27000 lines).


source() is doing more work to allow it to guess encodings, keeping  
references to the original sources, back out code if the whole  
script does not parse 


On Sat, 9 Jan 2010, Dennis Fisher wrote:


Colleagues,

(R 2.10 on all platforms)

I have a lengthy script (18000 lines) that runs within a graphical  
interface. The script consists of 100's of function followed by a  
single command that calls these functions (execution depends on a  
number of environment variables passed to the script).  As a  
result, nothing is executed until the final line of code is read.
It takes 15-20 seconds to load the code - I would like to speed  
that process.  Two questions:


1.  The code contains numerous large blocks that are executed under  
only one set of conditions (which are known when the code is  
called).  For example, there might be code such as:

if (CONDITION)
{
... (hundreds of lines of code, including embedded curly 
brackets)
} else invisible()
if (!CONDITION)
{
... (hundreds of lines of code, including embedded curly 
brackets)
}
I assume that I could speed loading appreciably if I set up two  
scripts, each of which excluded "irrelevant" code depending on the  
CONDITION.  For example, if I knew that CONDITION was false, I  
would exclude the first block of code above; conversely, if I know  
that CONDITION was true, I would exclude the second block.


I would like to write code in R (or in sed [UNIX stream editor]) to  
create these two new scripts.  However, the regular expressions  
that would be needed are beyond me and I would appreciate help from  
this forum.  Specifically, I would like to search for:

if (CONDITION or
if (!CONDITION
as the start of the block and
} - the matching curly bracket
at the end of the block, then remove those lines from the code.   
These text entries are always on a line by themselves.  Finding the  
"if (CONDITION" line should be relatively easy.  The difficulty for  
me is identifying the matching curly bracket - there are often  
paired brackets within the block of code:


if (CONDITION)
{
...
if (SOMETHINGELSE)  {   }
if (YETANOTHER)
{
}
}   <-  this is the bracket that I 
need to match

There are also instances in which the entire block occurs on one  
line:

if (CONDITION)  { ...} else invisible()
or
if (CONDITION ... else invisible()

Of note, I can remove the "else invisible() statements if they are  
problematic to a solution.


2.  A related issue regards loading in the graphical interface vs.  
loading at the command line (OS X).  The graphical interface loads  
in 15-20 seconds - the graphical interface is sending code as  
rapidly as it can.  In contrast, at the command line, the course is  
source()'d and it takes 30-40 seconds.  I would have expected the  
latter approach to be as fast or faster because R would accept code  
as fast as it could.


Does anyone have an explanation for this behavior; also, any ideas  
as to how to speed the process at the command line would be  
appreciated.  Thanks for any suggestions.


Dennis




Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of

[R] [Lattice] panel.levelplot - shrink argument to highlight absolute z-values

2010-01-09 Thread nabble . 30 . miller_2555
Hi -

I have a levelplot with positive and negative z-values. I'd like
to scale the levelplot rectangles proportional to the *absolute*
z-values to highlight the z-value extremes (while retaining the color
difference to track the positive/negative attribute). I've likely
missed something in the documentation, but have been at it a couple
days without finding a solution (other than patching the
panel.levelplot routine). Is there a way to do this? If not, can we
add the functionality?

By way of a very simple example, I'd like to make the deep-colors
bigger in the following example (please note the I am using the
`expression` version of the leveplot() function with a data frame
instead of the `matrix` version in my particular application).

   >  
levelplot(matrix(runif(21),nrow=7,ncol=3)-0.5,panel=function(x,y,z,subscript,
...) { panel.levelplot(x,y,z,shrink=c(0,2),...)})


Thanks!

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


Re: [R] postscript, greek lellters

2010-01-09 Thread bernardo lagos alvarez
The problem is of the .dvi. It was arranged,using the solution of Baptiste.
Bernardo.

2010/1/9 bernardo lagos alvarez :
> Thank you, Dennis and Baptisite
>
> By including the. eps in my  . tex and the compilation of the .tex,
> this does not generate the symbol of the greek letter.
>
> Bernardo.
>
> 2010/1/9 baptiste auguie :
>> Hi,
>>
>> Something like this maybe,
>>
>> plot.new()
>>
>> lab = expression(bar(T)*"("*-x*" ; "*alpha*")"-G*"("*x*" ; "*alpha*" , 
>> "*J*")")
>>
>> text(0.5,0.5,lab)
>>
>> ?plotmath
>>
>> HTH,
>>
>> baptiste
>>
>> 2010/1/8 bernardo lagos alvarez :
>>> Dear useRs,
>>>
>>> How can I, writting the correct greek letter using postscrip or pdf 
>>> function.
>>>
>>> In my  figures appears  only the first letter  (a of alpha, n of nu)
>>> when include the graphs in my .tex doxument. I am using
>>>
>>> title( expression(bar(T)(paste(-x,";",alpha))-G(paste(x,";",alpha,",",J
>>> title( expression(bar(T)(paste(-x,";"~alpha))-G(paste(x,";"~alpha,",",J
>>> title( expression(bar(T)(paste(-x,";"*alpha))-G(paste(x,";"*alpha,",",J,
>>> not work.
>>>
sessionInfo()
>>> R version 2.9.0 (2009-04-17)
>>> i386-pc-mingw32
>>>
>>> locale:
>>> LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>>
>>> Thanks for your help,
>>>
>>> Bernardo.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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] postscript, greek lellters

2010-01-09 Thread bernardo lagos alvarez
Thank you, Dennis and Baptisite

By including the. eps in my  . tex and the compilation of the .tex,
this does not generate the symbol of the greek letter.

Bernardo.

2010/1/9 baptiste auguie :
> Hi,
>
> Something like this maybe,
>
> plot.new()
>
> lab = expression(bar(T)*"("*-x*" ; "*alpha*")"-G*"("*x*" ; "*alpha*" , 
> "*J*")")
>
> text(0.5,0.5,lab)
>
> ?plotmath
>
> HTH,
>
> baptiste
>
> 2010/1/8 bernardo lagos alvarez :
>> Dear useRs,
>>
>> How can I, writting the correct greek letter using postscrip or pdf function.
>>
>> In my  figures appears  only the first letter  (a of alpha, n of nu)
>> when include the graphs in my .tex doxument. I am using
>>
>> title( expression(bar(T)(paste(-x,";",alpha))-G(paste(x,";",alpha,",",J
>> title( expression(bar(T)(paste(-x,";"~alpha))-G(paste(x,";"~alpha,",",J
>> title( expression(bar(T)(paste(-x,";"*alpha))-G(paste(x,";"*alpha,",",J,
>> not work.
>>
>>>sessionInfo()
>> R version 2.9.0 (2009-04-17)
>> i386-pc-mingw32
>>
>> locale:
>> LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>
>> Thanks for your help,
>>
>> Bernardo.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Reducing the size of a large script top speed onset of execution

2010-01-09 Thread Prof Brian Ripley
Please just use make a package; then all the effort of parsing the 
code is done at install time, you can use lazy-loading   Or if you 
are for some reason averse to that, source the code into an 
environment, save that and simply attach() its save file next time.


Packages of that size load in a few milliseconds (as you see each time 
you start R:  stats is 27000 lines).


source() is doing more work to allow it to guess encodings, keeping 
references to the original sources, back out code if the whole script 
does not parse 


On Sat, 9 Jan 2010, Dennis Fisher wrote:


Colleagues,

(R 2.10 on all platforms)

I have a lengthy script (18000 lines) that runs within a graphical interface. 
The script consists of 100's of function followed by a single command that 
calls these functions (execution depends on a number of environment variables 
passed to the script).  As a result, nothing is executed until the final line 
of code is read.   It takes 15-20 seconds to load the code - I would like to 
speed that process.  Two questions:


1.  The code contains numerous large blocks that are executed under only one 
set of conditions (which are known when the code is called).  For example, 
there might be code such as:

if (CONDITION)
{
		... (hundreds of lines of code, including embedded curly 
brackets)

} else invisible()
if (!CONDITION)
{
		... (hundreds of lines of code, including embedded curly 
brackets)

}
I assume that I could speed loading appreciably if I set up two scripts, each 
of which excluded "irrelevant" code depending on the CONDITION.  For example, 
if I knew that CONDITION was false, I would exclude the first block of code 
above; conversely, if I know that CONDITION was true, I would exclude the 
second block.


I would like to write code in R (or in sed [UNIX stream editor]) to create 
these two new scripts.  However, the regular expressions that would be needed 
are beyond me and I would appreciate help from this forum.  Specifically, I 
would like to search for:
	if (CONDITION 
or

if (!CONDITION
as the start of the block and
} - the matching curly bracket
at the end of the block, then remove those lines from the code.  These text 
entries are always on a line by themselves.  Finding the "if (CONDITION" line 
should be relatively easy.  The difficulty for me is identifying the matching 
curly bracket - there are often paired brackets within the block of code:


if (CONDITION)
{
...
if (SOMETHINGELSE)  {   }
if (YETANOTHER)
{
}
		}<-  this is the bracket that 
I need to match


There are also instances in which the entire block occurs on one line:
if (CONDITION)  { ...} else invisible()
or
if (CONDITION ... else invisible()

Of note, I can remove the "else invisible() statements if they are 
problematic to a solution.


2.  A related issue regards loading in the graphical interface vs. loading at 
the command line (OS X).  The graphical interface loads in 15-20 seconds - 
the graphical interface is sending code as rapidly as it can.  In contrast, 
at the command line, the course is source()'d and it takes 30-40 seconds.  I 
would have expected the latter approach to be as fast or faster because R 
would accept code as fast as it could.


Does anyone have an explanation for this behavior; also, any ideas as to how 
to speed the process at the command line would be appreciated.  Thanks for 
any suggestions.


Dennis




Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] aov vs lme for split plot analysis

2010-01-09 Thread Rafael Rubio de Casas

Dear R community,

I am trying to do a split-plot analysis as follows. I have a data set 
(“morf”) with plant data from 6 “blocks” at different latitudes, each 
divided in 3 plots. The full-plot “treatment” is “soil type” and has 
three levels. Within each plot I have two levels of radiation, coded as 
“SUN” and “SHADE”. I have data for several response traits for 30 plants 
within each subplot, that is 1080 plants in total (6 Blocks x 3Plots x 
2Radiation levels x 30 Plants).
I want to measure a) if there are differences between latitudes 
(“blocks”) and b) how these differences interact with radiation levels. 
I am not so interested in the effect of soil type, which I already know, 
but radiation effects depend on soil type. The model I’m looking for 
should look something like:

Response ~ Block*Radiation | Soil type
I have tried to use lme. The basic formulation I have tried is:
lme(Resp~Block*Radiation, random=~ 1 | Plot/Radiation, data=morf)
but I keep on getting the error message:
“Error in getGroups.data.frame(dataMix, groups) : Invalid formula for 
groups”
I don’t know why this is happening, could it be because “Radiation” has 
only two levels? I don't have missing values or any other obvious source 
of "noise"
Since neither lme nor lmer weren’t working, I tried “aov”. I played 
around a bit with the "Oats" data set and saw that:

aov( yield ~ ordered(nitro) * Variety + Error(Block/Variety), data = Oats)
gives the same results as the standard
lme( yield ~ ordered(nitro) * Variety, data = Oats, random = ~ 1 | 
Block/Variety )

So I used the following formulation
aov(Resp~Block*Radiation+Error(Plot/Radiation), data=morf)
This seems to work fine, but I am not that confident I am using the 
correct syntax.

Any advice and/or guidance would be much appreciated.

Thank you in advance.

RAFA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 numeric values against non numeric items

2010-01-09 Thread jim holtman
Try this:

# create data
x <- rbind("Not Stir"=c(400, 700), Stir=c(50, 180))
matplot(x, type='o', pch=16, cex=2, xaxt='n')
axis(1, at=1:2, labels=rownames(x))





On Sat, Jan 9, 2010 at 9:29 AM, lse1986  wrote:

>
> Hey Jim,
>
> Thanks for your reply!
>
> I tried what you said, i still kept getting errors.
>
> here's what i want my graph to look like:
>
> http://i.imagehost.org/0474/Untitled_5.jpg
>
> i have x<-c("not stir", "stir")
>
> i can't plot it though :(
>
>
> Jim Lemon wrote:
> >
> > On 01/09/2010 12:38 PM, lse1986 wrote:
> >> Hi i want do a line graph.
> >>
> >> My y axis contains numeric values. My x axis contains non numeric
> >> statements.
> >>
> >> This is what i want the graph to look like.
> >>
> >> When i try to plot this graph on R it comes up with the following error
> >> message:
> >>
> >> "Error in plot.window(...) : need finite 'xlim' values
> >> In addition: Warning messages:
> >> 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
> >> 2: In min(x) : no non-missing arguments to min; returning Inf
> >> 3: In max(x) : no non-missing arguments to max; returning -Inf"
> >>
> >>
> > Hi Sam,
> > While I don't know what you want the graph to look like, I would suggest
> > the following:
> >
> > xf<-factor(x)
> > plot(as.numeric(xf),rnorm(10),type="l",xaxt="n")
> > axis(1,at=1:10,labels=xf)
> >
> > Jim
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> --
> View this message in context:
> http://n4.nabble.com/Plotting-numeric-values-against-non-numeric-items-tp1010129p1010311.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.
>



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

What is the problem that you are trying to solve?

[[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] Building static HTML help pages in R 2.10.x on Windows

2010-01-09 Thread Dieter Menne


Michal Kulich wrote:
> 
> This works. Not entirely invisible but not a big deal about that.
> The R code run within Rterm is
> 
> options(help_type="html",help.ports=6800)
> help.start()
> library(audio)
> wait(-1)
> 
> 

I tried to run your code with System.sleep(10) instead of wait(-1)
inside Winserv, which is an open-source replacement for srvany (MS). Winserv
has a very clean interface and is much more flexible than srvany.

http://sw4me.com/wiki/Winserv?v=qw0

The service installs (install) and runs (start), status is "RUNNING", but I
could not connect to the port. 

Dieter


-- 
View this message in context: 
http://n4.nabble.com/Building-static-HTML-help-pages-in-R-2-10-x-on-Windows-tp977326p1010340.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] Plotting numeric values against non numeric items

2010-01-09 Thread lse1986

Hey Jim,

Thanks for your reply!

I tried what you said, i still kept getting errors.

here's what i want my graph to look like:

http://i.imagehost.org/0474/Untitled_5.jpg

i have x<-c("not stir", "stir")

i can't plot it though :(


Jim Lemon wrote:
> 
> On 01/09/2010 12:38 PM, lse1986 wrote:
>> Hi i want do a line graph.
>>
>> My y axis contains numeric values. My x axis contains non numeric
>> statements.
>>
>> This is what i want the graph to look like.
>>
>> When i try to plot this graph on R it comes up with the following error
>> message:
>>
>> "Error in plot.window(...) : need finite 'xlim' values
>> In addition: Warning messages:
>> 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
>> 2: In min(x) : no non-missing arguments to min; returning Inf
>> 3: In max(x) : no non-missing arguments to max; returning -Inf"
>>
>>
> Hi Sam,
> While I don't know what you want the graph to look like, I would suggest 
> the following:
> 
> xf<-factor(x)
> plot(as.numeric(xf),rnorm(10),type="l",xaxt="n")
> axis(1,at=1:10,labels=xf)
> 
> Jim
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Plotting-numeric-values-against-non-numeric-items-tp1010129p1010311.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] Reducing the size of a large script top speed onset of execution

2010-01-09 Thread Dennis Fisher

Colleagues,

(R 2.10 on all platforms)

I have a lengthy script (18000 lines) that runs within a graphical  
interface.  The script consists of 100's of function followed by a  
single command that calls these functions (execution depends on a  
number of environment variables passed to the script).  As a result,  
nothing is executed until the final line of code is read.   It takes  
15-20 seconds to load the code - I would like to speed that process.   
Two questions:


1.  The code contains numerous large blocks that are executed under  
only one set of conditions (which are known when the code is called).   
For example, there might be code such as:

if (CONDITION)
{
... (hundreds of lines of code, including embedded curly 
brackets)
} else invisible()
if (!CONDITION)
{
... (hundreds of lines of code, including embedded curly 
brackets)
}
I assume that I could speed loading appreciably if I set up two  
scripts, each of which excluded "irrelevant" code depending on the  
CONDITION.  For example, if I knew that CONDITION was false, I would  
exclude the first block of code above; conversely, if I know that  
CONDITION was true, I would exclude the second block.


I would like to write code in R (or in sed [UNIX stream editor]) to  
create these two new scripts.  However, the regular expressions that  
would be needed are beyond me and I would appreciate help from this  
forum.  Specifically, I would like to search for:

if (CONDITION   
or
if (!CONDITION
as the start of the block and
} - the matching curly bracket
at the end of the block, then remove those lines from the code.  These  
text entries are always on a line by themselves.  Finding the "if  
(CONDITION" line should be relatively easy.  The difficulty for me is  
identifying the matching curly bracket - there are often paired  
brackets within the block of code:


if (CONDITION)
{
...
if (SOMETHINGELSE)  {   }
if (YETANOTHER)
{
}
}   <-  this is the bracket that I 
need to match

There are also instances in which the entire block occurs on one line:
if (CONDITION)  { ...} else invisible()
or
if (CONDITION ... else invisible()

Of note, I can remove the "else invisible() statements if they are  
problematic to a solution.


2.  A related issue regards loading in the graphical interface vs.  
loading at the command line (OS X).  The graphical interface loads in  
15-20 seconds - the graphical interface is sending code as rapidly as  
it can.  In contrast, at the command line, the course is source()'d  
and it takes 30-40 seconds.  I would have expected the latter approach  
to be as fast or faster because R would accept code as fast as it could.


Does anyone have an explanation for this behavior; also, any ideas as  
to how to speed the process at the command line would be appreciated.   
Thanks for any suggestions.


Dennis




Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] Boxplots

2010-01-09 Thread Marlin Keith Cox
I have a data set with four columns and need to make boxplots from them.
 Data is as follows:
 tank TanksTotal cons_hat
1aa4 5.651017 5.59
2aa5 5.017499 5.29
3aa6 4.894238 4.69
4cc4 3.986347 3.40
5cc5 4.099442 3.58
6cc6 4.150522 3.64
7hh4 5.187792 6.32
8hh5 6.713422 6.44
9hh6 5.168555 5.62

This is simply consumption data with Total being the actual measured
consumption and cons_hat being the predicted.  I need a boxplot of tank "a"
(consisting of a4,a5,a6) "Total" vs. "cons_hat".

boxplot(Total~tank) of course creates a boxplot with only Total by tank, but
how do I put the other column in this boxplot?

Thanks ahead of time.

keith

-- 
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

[[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] importing home range polygon

2010-01-09 Thread Mustafa Durmus
Hi everyone,

I am using adehabitat package for habitat selection analysis, I know R also
do home range analysis, but I want to import home range polygon to R and run
K-select analysis on this home range polygon. Do you know any material to
help me?

Thanks,

Mustafa

[[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] parsing pdf files

2010-01-09 Thread Laurent Rhelp

David Kane a écrit :


I have a pdf file that I would like to parse into R:

http://www.williams.edu/Registrar/geninfo/faculty.pdf

For now, I open the file in Acrobat by hand, then save it "as text"
and then use readLines(). That works fine but a) I am concerned that
some information may be lost and b) I may be doing this a lot, so I
would rather have R grab the information from the pdf file directly.

So: is there something like readPDF() for R?

Thanks,

Dave Kane

PS. If you're curious, here is the sort of work that I want to do with
this data:
http://www.ephblog.com/2010/01/08/class-update-and-faculty-ages/

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

 


Did you know this site ?

http://www.accesspdf.com/pdftk/

There could be a command line to transform the pdf file in XML format 
and then read the XML file with R.


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


Re: [R] parsing pdf files

2010-01-09 Thread Albert-Jan Roskam
Hi,

I used pdftk (pdf toolkit) before. A quick glance at the features seems to tell 
that it does *not* support what you are looking for, but it may nonetheless be 
a useful starting point:
http://www.accesspdf.com/pdftk/ .
The nice thing is that it's a command-line tool.

Cheers!!

Albert-Jan



~~

In the face of ambiguity, refuse the temptation to guess.

~~

--- On Sat, 1/9/10, Barry Rowlingson  wrote:

From: Barry Rowlingson 
Subject: Re: [R] parsing pdf files
To: "David Kane" 
Cc: r-help@r-project.org
Date: Saturday, January 9, 2010, 2:47 PM

On Sat, Jan 9, 2010 at 1:11 PM, David Kane  wrote:
> I have a pdf file that I would like to parse into R:
>
> http://www.williams.edu/Registrar/geninfo/faculty.pdf
>
> For now, I open the file in Acrobat by hand, then save it "as text"
> and then use readLines(). That works fine but a) I am concerned that
> some information may be lost and b) I may be doing this a lot, so I
> would rather have R grab the information from the pdf file directly.
>
> So: is there something like readPDF() for R?

 What could it do that saving as text from Acrobat couldn't do? Here's
the problem - PDF is a page description format, it's not designed to
be read back. There's no guarantee that the letters on the page appear
in the PDF in the same order as they seem on the page. The page could
have all the letter 'a's, then the 'b's and so on, positioned in their
right places to make up words. To reconstruct the words you'd have to
spot where the letters were being placed, and then figure out the
breaks and make up the words. Good luck making the sentences.

 Most PDFs aren't that perverse, and you can often get sensible text
out of them. But then you run into font encodings and graphics and
column layouts and stuff. Any effort put into writing a readPDF()
would have to be redone every time someone tried to read a PDF :)

 On Linux/Unix there's a bunch of command line tools for trying to do
this kind of thing with PDF files - see pdftotext for example. You
could run that from R with system() and then read the text with
readLines. But there's absolutely no guarantees this will work.
Windows/Mac versions (did you say what your platform was?) of the
command line tools may be available.

 The real answer is to get the original data in a format with some
kind of semantics that R could read, for example a CSV or some nice
XML format.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] parsing pdf files

2010-01-09 Thread Barry Rowlingson
On Sat, Jan 9, 2010 at 1:11 PM, David Kane  wrote:
> I have a pdf file that I would like to parse into R:
>
> http://www.williams.edu/Registrar/geninfo/faculty.pdf
>
> For now, I open the file in Acrobat by hand, then save it "as text"
> and then use readLines(). That works fine but a) I am concerned that
> some information may be lost and b) I may be doing this a lot, so I
> would rather have R grab the information from the pdf file directly.
>
> So: is there something like readPDF() for R?

 What could it do that saving as text from Acrobat couldn't do? Here's
the problem - PDF is a page description format, it's not designed to
be read back. There's no guarantee that the letters on the page appear
in the PDF in the same order as they seem on the page. The page could
have all the letter 'a's, then the 'b's and so on, positioned in their
right places to make up words. To reconstruct the words you'd have to
spot where the letters were being placed, and then figure out the
breaks and make up the words. Good luck making the sentences.

 Most PDFs aren't that perverse, and you can often get sensible text
out of them. But then you run into font encodings and graphics and
column layouts and stuff. Any effort put into writing a readPDF()
would have to be redone every time someone tried to read a PDF :)

 On Linux/Unix there's a bunch of command line tools for trying to do
this kind of thing with PDF files - see pdftotext for example. You
could run that from R with system() and then read the text with
readLines. But there's absolutely no guarantees this will work.
Windows/Mac versions (did you say what your platform was?) of the
command line tools may be available.

 The real answer is to get the original data in a format with some
kind of semantics that R could read, for example a CSV or some nice
XML format.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] errors when installing packages (ubuntu)

2010-01-09 Thread romunov
Hi List,

I'm having problems installing certain packages. When I try to install
fields, I get the output below. I have highlighted the what I perceive as
the first error (spam seems to be a dependency of fields). Can I assume this
is causing dependency problems for fields, which fails to install at the
end, or is there a deeper problem? I run Ubuntu Karmic Koala on R 2.9.2.

2> install.packages("fields")
Warning in install.packages("fields") :
  argument 'lib' is missing: using
'/home/romunov/R/i486-pc-linux-gnu-library/2.9'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
also installing the dependency ‘spam’

trying URL 'http://cran.at.r-project.org/src/contrib/spam_0.20-2.tar.gz'
Content type 'application/x-gzip' length 470013 bytes (458 Kb)
opened URL
==
downloaded 458 Kb

trying URL 'http://cran.at.r-project.org/src/contrib/fields_6.01.tar.gz'
Content type 'application/x-gzip' length 3670039 bytes (3.5 Mb)
opened URL
==
downloaded 3.5 Mb

* Installing *source* package ‘spam’ ...
** libs
gfortran   -fpic  -g -O2 -c bckslvmodified.f -o bckslvmodified.o
gfortran   -fpic  -g -O2 -c cholmodified.f -o cholmodified.o
gfortran   -fpic  -g -O2 -c dist.f -o dist.o
gfortran   -fpic  -g -O2 -c fromsparsekit.f -o fromsparsekit.o
gfortran   -fpic  -g -O2 -c kronecker.f -o kronecker.o
gfortran   -fpic  -g -O2 -c spamown.f -o spamown.o
gfortran   -fpic  -g -O2 -c xybind.f -o xybind.o
gcc -std=gnu99 -shared -o spam.so bckslvmodified.o cholmodified.o dist.o
fromsparsekit.o kronecker.o spamown.o xybind.o -lgfortran -lm
-L/usr/lib/R/lib -lR
** R
** data
**  moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
Creating a new generic function for "print" in "spam"
Creating a new generic function for "summary" in "spam"
Creating a new generic function for "diag" in "spam"
Creating a new generic function for "diag<-" in "spam"
Creating a new generic function for "t" in "spam"
Error in setOldClass(c("dist", "numeric")) :
  inconsistent old-style class information for "numeric"; the class is
defined but does not extend "oldClass"
Error : unable to load R code in package 'spam'
ERROR: lazy loading failed for package ‘spam’
* Removing ‘/home/romunov/R/i486-pc-linux-gnu-library/2.9/spam’
* Installing *source* package ‘fields’ ...
** libs
gfortran   -fpic  -g -O2 -c css.f -o css.o
gfortran   -fpic  -g -O2 -c csstr.f -o csstr.o
gfortran   -fpic  -g -O2 -c cvrf.f -o cvrf.o
gfortran   -fpic  -g -O2 -c dchold.f -o dchold.o
gfortran   -fpic  -g -O2 -c dcopy.f -o dcopy.o
gfortran   -fpic  -g -O2 -c ddfind.f -o ddfind.o
gfortran   -fpic  -g -O2 -c ddot.f -o ddot.o
gfortran   -fpic  -g -O2 -c derrb.f -o derrb.o
gfortran   -fpic  -g -O2 -c dlv.f -o dlv.o
gfortran   -fpic  -g -O2 -c dmaket.f -o dmaket.o
gfortran   -fpic  -g -O2 -c drdfun.f -o drdfun.o
gfortran   -fpic  -g -O2 -c dsetup.f -o dsetup.o
gfortran   -fpic  -g -O2 -c evlpoly.f -o evlpoly.o
gfortran   -fpic  -g -O2 -c evlpoly2.f -o evlpoly2.o
gfortran   -fpic  -g -O2 -c expbs.f -o expbs.o
gfortran   -fpic  -g -O2 -c expfn.f -o expfn.o
gfortran   -fpic  -g -O2 -c gaspbs.f -o gaspbs.o
gfortran   -fpic  -g -O2 -c gaspfn.f -o gaspfn.o
gfortran   -fpic  -g -O2 -c gcvcss.f -o gcvcss.o
gfortran   -fpic  -g -O2 -c gcvfc.f -o gcvfc.o
gfortran   -fpic  -g -O2 -c hsort.f -o hsort.o
gfortran   -fpic  -g -O2 -c ifind.f -o ifind.o
gfortran   -fpic  -g -O2 -c igpoly.f -o igpoly.o
gfortran   -fpic  -g -O2 -c inpoly.f -o inpoly.o
gfortran   -fpic  -g -O2 -c lscv.f -o lscv.o
gfortran   -fpic  -g -O2 -c m2deb.f -o m2deb.o
gfortran   -fpic  -g -O2 -c mkpoly.f -o mkpoly.o
gfortran   -fpic  -g -O2 -c mltdrb.f -o mltdrb.o
gfortran   -fpic  -g -O2 -c mltdtd.f -o mltdtd.o
gfortran   -fpic  -g -O2 -c msort.f -o msort.o
gfortran   -fpic  -g -O2 -c multeb.f -o multeb.o
gfortran   -fpic  -g -O2 -c multgb.f -o multgb.o
gfortran   -fpic  -g -O2 -c multrb.f -o multrb.o
gfortran   -fpic  -g -O2 -c radbas.f -o radbas.o
gfortran   -fpic  -g -O2 -c radfn2.f -o radfn2.o
gfortran   -fpic  -g -O2 -c radfun.f -o radfun.o
gfortran   -fpic  -g -O2 -c rcss.f -o rcss.o
gfortran   -fpic  -g -O2 -c rcssr.f -o rcssr.o
gfortran   -fpic  -g -O2 -c rcsswt.f -o rcsswt.o
gfortran   -fpic  -g -O2 -c sortm.f -o sortm.o
gcc -std=gnu99 -shared -o fields.so css.o csstr.o cvrf.o dchold.o dcopy.o
ddfind.o ddot.o derrb.o dlv.o dmaket.o drdfun.o dsetup.o evlpoly.o
evlpoly2.o expbs.o expfn.o gaspbs.o gaspfn.o gcvcss.o gcvfc.o hsort.o
ifind.o igpoly.o inpoly.o lscv.o m2deb.o mkpoly.o mltdrb.o mltdtd.o msort.o
multeb.o multgb.o multrb.o radbas.o radfn2.o radfun.o rcss.o rcssr.o
rcsswt.o sortm.o -lgfortran -lm -L/usr/lib/R/lib -lR
** R
** data
** preparing package for lazy loading
Warning in library(pkg, character.only = TRUE, logical.return = TRUE,
lib.loc = lib.loc) :
  there is no package called 'spam'
Error : package 'spam' could not be loaded
ERROR: lazy loading failed 

[R] parsing pdf files

2010-01-09 Thread David Kane
I have a pdf file that I would like to parse into R:

http://www.williams.edu/Registrar/geninfo/faculty.pdf

For now, I open the file in Acrobat by hand, then save it "as text"
and then use readLines(). That works fine but a) I am concerned that
some information may be lost and b) I may be doing this a lot, so I
would rather have R grab the information from the pdf file directly.

So: is there something like readPDF() for R?

Thanks,

Dave Kane

PS. If you're curious, here is the sort of work that I want to do with
this data:
http://www.ephblog.com/2010/01/08/class-update-and-faculty-ages/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] postscript, greek lellters

2010-01-09 Thread baptiste auguie
Hi,

Something like this maybe,

plot.new()

lab = expression(bar(T)*"("*-x*" ; "*alpha*")"-G*"("*x*" ; "*alpha*" , "*J*")")

text(0.5,0.5,lab)

?plotmath

HTH,

baptiste

2010/1/8 bernardo lagos alvarez :
> Dear useRs,
>
> How can I, writting the correct greek letter using postscrip or pdf function.
>
> In my  figures appears  only the first letter  (a of alpha, n of nu)
> when include the graphs in my .tex doxument. I am using
>
> title( expression(bar(T)(paste(-x,";",alpha))-G(paste(x,";",alpha,",",J
> title( expression(bar(T)(paste(-x,";"~alpha))-G(paste(x,";"~alpha,",",J
> title( expression(bar(T)(paste(-x,";"*alpha))-G(paste(x,";"*alpha,",",J,
> not work.
>
>>sessionInfo()
> R version 2.9.0 (2009-04-17)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
>
> Thanks for your help,
>
> Bernardo.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] how to flatten a list to the same level?

2010-01-09 Thread Mark Heckmann

Henrique,

thanks for the code!! It works out fine for vectors. I forgot to  
mention I also have dataframes as list elements.

Thus I want the structure of the list element to be kept intact.

I tried an recursive approach (which unfortunately resulted in some  
more code) which works.


.getNonListElements <- function(x, env){
if(class(x)=="list") {
		for(i in seq(along=x)) .getNonListElements(x[[i]], env)	# call  
recursively

} else {
res <- get("res", envir = env) # get res from other 
env
res <- c(res, list(x))   # add one 
list element
assign("res", res, envir=env) # assign back to env
}
}

flattenList <- function(l){
res <- list()# make 
list object
env <- environment() # get current env  
 
.getNonListElements(l, env) # search for non list elements 
recursively
return(res)
}


l <- list(DF=data.frame(A=c(1,2)), vec=c("a", "b"))
l <- list(l,l)

> flattenList(l)
[[1]]
  A
1 1
2 2

[[2]]
[1] "a" "b"

[[3]]
  A
1 1
2 2

[[4]]
[1] "a" "b"

I am not sure if one can avoid the wrapper function or still use  
rapply to simplify the code. I do not know how.
One more thing I would like to add are the objects names to the  
generated list. But I did not succeed in that.


Mark


Am 08.01.2010 um 18:29 schrieb Henrique Dallazuanna:


Try something about like this:

split(unlist(l), rep(1:length(idx <- rapply(l, length)), idx))

On Fri, Jan 8, 2010 at 1:35 PM, Mark Heckmann   
wrote:

I have a nested list l like:

l <- list(A=c(1,2,3), B=c("a", "b"))
l <- list(l,l, list(l,l))

I want the list to be unlisted, but not on the lowest level of each
"branch".
I want the lowest level of each list branch to remain as it is.
So unlist or unlist(rec=F) do not work here as the level of nesting  
may

differ on the elements.
The result should look like:

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

Any ideas?
TIA!

Mark


–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.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.





--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O


–––
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstraße 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.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] Arguments of a function

2010-01-09 Thread Gabor Grothendieck
Normally one designs their function to input a formula in such a case
rather than design it to take the names directly.  Thus:

f <- function(formula = ~ x1 + x2) {
  xs <- c(x1 = 1, x2 = exp(1), x3 = 2*pi)
  v <- all.vars(formula)
  stopifnot(length(v) == 2, all(v %in% names(xs)))
  sum(xs[v])
}

# test
f()
f(~ x1 + x2) # same
f(~ x2+x3)


On Fri, Jan 8, 2010 at 1:15 PM, Lisa  wrote:
>
> Dear all,
>
> I have a question about how to set arguments in my own function. For
> example, I have a function that looks like this:
>
> my.f <- function(a = x1, b = x2)
> {
>   x1 = equation 1
>   x2 = equation 2
>   x3 = equation 3
>   y = a + b
> }
>
> x1, x2, and x3 are temporary variables (intermediate results) calculated
> from other variables within the funciton. I want to use two of these three
> variables to calculate y, and write R script as below:
>
> my.f(a = x1, b = x2)
>
> or
>
> my.f(a = x2, b = x3)
>
> The error information shows that: “objects 'x1', 'x2', or 'x3' not found”.
>
> Can anybody help me solve this problem? Thanks in advance.
>
> Lisa
>
> --
> View this message in context: 
> http://n4.nabble.com/Arguments-of-a-function-tp1009883p1009883.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] time series analysis for a time series without a regular frequency

2010-01-09 Thread Achim Zeileis

On Fri, 8 Jan 2010, Erin Hestir wrote:


I am trying to conduct a time series analysis on historic hydrologic data,
but I cannot coerce it into class ts because it does not have regular
sampling intervals (some years have 20 samples, other have 8). Specifically
I am trying to perform a CUSUM or or other step change detection, but the
packages all seem to require data as ts.


As Gabor already pointed out: the zoo package can be used to store such 
data.


If you want to use the strucchange package for detecting changes then you 
can do two things:

  -  use a plain data.frame (without ts or some other time
 series class) which can be easily produced via
 as.data.frame(zoo_obj).
 Then the axis annotation in graphics won't be the time axis but
 the standard unit interval (= proportion of data). This is not so
 pretty but all statistical interpretations are still correct.
  - If zoo_obj is just a univariate series and you want to conduct a
CUSUM test for a change in the mean you can do
  cus <- gefp(zoo_obj ~ 1)
  plot(cus)
  plot(cus, functional = meanL2BB)
and so on. gefp() is the only function in strucchange that
automatically supports "zoo".

hth,
Z


Is there a way to coerce my data into ts while maintaining all of my
samples?

Or alternatively, can someone recommend a package that does not require data
as ts?

Thanks!



--
Erin Hestir
Center for Spatial Technology and Remote Sensing
University of California Davis

[[alternative HTML version deleted]]

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




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


Re: [R] aov function syntax

2010-01-09 Thread Dave Deriso
Thank you for your help professor Ripley!

I suppose my problem is more theoretical related than syntax. I will review
your suggested literature.

and yes, I did error on the data source, thank you for catching my mistake!!

Best,

Dave

On Sat, Jan 9, 2010 at 3:56 AM, Prof Brian Ripley wrote:

> What are you trying to do?  Your example is not what is commonly called
> ANOVA (some call it ANCOVA) and more often lm() is used.
>
> I suspect that you intended 'population' to be a factor, and it is not.  So
> population:condition is not an interaction but different slopes for
> population by levels of condition.
>
> population*condition expands to
>
> population + condition + population:condition
>
> and this is a larger model with different intercepts by levels of
> condition.
>
> I suggest you need study the primary reference (Chambers & Hastie 1992) or
> at least Bill Venables' exposition in MASS (the book, any edition).  And
> note that you cannot test interactions in a two-way layout without
> replication, so perhaps you also need to talk to a statistician about ANOVA.
>
> BTW: I think you have messed up your first example: perhaps you meant
>
> studentDataSource="http://files.davidderiso.com/r/studentData.data";
>
> There are no P values in that example because there is no residual
> variation: the model fits exactly.
>
>
> On Sat, 9 Jan 2010, Dave Deriso wrote:
>
>  Hello,
>>
>> I have a simple question about using the aov function syntax (ie. * + or
>> :)
>> for the interaction of 2 factors. I have read the help files, and
>> researched
>> other sites, and have included my source files. My goal is to measure the
>> signifigance of the interaction between population and condition (aka.
>> population:condition). I can't seem to figure it out.
>>
>> 1. In the first example the significance of population:condition works
>> with
>> the "allData" but not with the "studentData." Can you please explain why
>> it
>> fails and how I can fix it?
>>
>> 2. In the second example I can get the measure the significance of
>> population:condition with 2 different methods, but I get 2 different
>> results
>> (using the "allData" source). Can you please explain why these Pr(>F)
>> values
>> are different?
>>
>> Thank you so much for your help!!
>>
>> Sincerely,
>>
>> Dave Deriso
>> UCSD Psychiatry
>>
>>
>> #Example 1 ---COPY & PASTE THE FOLLOWING
>>
>> #import the data
>> allDataSource="http://files.davidderiso.com/r/allData.data";
>> allData.import=read.table(allDataSource,header=T)
>> studentDataSource="http://files.davidderiso.com/r/allData.data";
>> studentData.import=read.table(studentDataSource,header=T)
>>
>>
>> #aov for allData WORKS
>> allData.integral.aov = aov(integral~population*condition,
>> data=allData.import)
>> summary(allData.integral.aov)
>>
>> #aov for studentData DOES NOT GIVE Pr(>F) of population:condition
>> studentData.integral.aov = aov(integral~population*condition,
>> data=studentData.import)
>> summary(studentData.integral.aov)
>>
>>
>>
>> #Example 2 ---COPY & PASTE THE FOLLOWING
>>
>> #population:condition has a Pr(>F) of 0.96372
>> allData.integral.aov = aov(integral~population*condition,
>> data=allData.import)
>> summary(allData.integral.aov)
>>
>> #population:condition has a Pr(>F) of 1.070e-06 ***
>> allData.integral.aov = aov(integral~population:condition,
>> data=allData.import)
>> summary(allData.integral.aov)
>>
>>[[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.
>>
>>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>

[[alternative HTML version deleted]]

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


Re: [R] aov function syntax

2010-01-09 Thread Prof Brian Ripley
What are you trying to do?  Your example is not what is commonly 
called ANOVA (some call it ANCOVA) and more often lm() is used.


I suspect that you intended 'population' to be a factor, and it is 
not.  So population:condition is not an interaction but different 
slopes for population by levels of condition.


population*condition expands to

population + condition + population:condition

and this is a larger model with different intercepts by levels of 
condition.


I suggest you need study the primary reference (Chambers & Hastie 
1992) or at least Bill Venables' exposition in MASS (the book, any 
edition).  And note that you cannot test interactions in a two-way 
layout without replication, so perhaps you also need to talk to a 
statistician about ANOVA.


BTW: I think you have messed up your first example: perhaps you meant

studentDataSource="http://files.davidderiso.com/r/studentData.data";

There are no P values in that example because there is no residual 
variation: the model fits exactly.


On Sat, 9 Jan 2010, Dave Deriso wrote:


Hello,

I have a simple question about using the aov function syntax (ie. * + or :)
for the interaction of 2 factors. I have read the help files, and researched
other sites, and have included my source files. My goal is to measure the
signifigance of the interaction between population and condition (aka.
population:condition). I can't seem to figure it out.

1. In the first example the significance of population:condition works with
the "allData" but not with the "studentData." Can you please explain why it
fails and how I can fix it?

2. In the second example I can get the measure the significance of
population:condition with 2 different methods, but I get 2 different results
(using the "allData" source). Can you please explain why these Pr(>F) values
are different?

Thank you so much for your help!!

Sincerely,

Dave Deriso
UCSD Psychiatry


#Example 1 ---COPY & PASTE THE FOLLOWING

#import the data
allDataSource="http://files.davidderiso.com/r/allData.data";
allData.import=read.table(allDataSource,header=T)
studentDataSource="http://files.davidderiso.com/r/allData.data";
studentData.import=read.table(studentDataSource,header=T)


#aov for allData WORKS
allData.integral.aov = aov(integral~population*condition,
data=allData.import)
summary(allData.integral.aov)

#aov for studentData DOES NOT GIVE Pr(>F) of population:condition
studentData.integral.aov = aov(integral~population*condition,
data=studentData.import)
summary(studentData.integral.aov)



#Example 2 ---COPY & PASTE THE FOLLOWING

#population:condition has a Pr(>F) of 0.96372
allData.integral.aov = aov(integral~population*condition,
data=allData.import)
summary(allData.integral.aov)

#population:condition has a Pr(>F) of 1.070e-06 ***
allData.integral.aov = aov(integral~population:condition,
data=allData.import)
summary(allData.integral.aov)

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] strange behavior of R

2010-01-09 Thread Liviu Andronic
On Fri, Jan 8, 2010 at 10:57 PM, Fahim  wrote:
>> arr
> [1] "y1" "y2"
>
At this moment 'arr' no longer has two dimensions, but only one. So
you can access it only as a vector.

> Problem: I want to access the first row now using:
>>arr[1, ]
> Error in arr[1, 1] : incorrect number of dimensions
>
Correct. It has only one dim.

> Though it is showing the value  as under:
>> arr[1]
> [1] "y1"
>
>> arr[2]
> [1] "y2"
>
This is how you would access individual elements in vectors.
Liviu

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


Re: [R] aov function syntax

2010-01-09 Thread Dave Deriso
Oops small error

Use this to import the data

#import the data
allData.import=read.table("http://files.davidderiso.com/r/allData.data
",header=T)
studentData.import=read.table("
http://files.davidderiso.com/r/studentData.data",header=T)

everything else is good

On Sat, Jan 9, 2010 at 3:33 AM, Dave Deriso  wrote:

> Hello,
>
> I have a simple question about using the aov function syntax (ie. * + or :)
> for the interaction of 2 factors. I have read the help files, and researched
> other sites, and have included my source files. My goal is to measure the
> signifigance of the interaction between population and condition (aka.
> population:condition). I can't seem to figure it out.
>
> 1. In the first example the significance of population:condition works with
> the "allData" but not with the "studentData." Can you please explain why it
> fails and how I can fix it?
>
> 2. In the second example I can get the measure the significance of
> population:condition with 2 different methods, but I get 2 different results
> (using the "allData" source). Can you please explain why these Pr(>F) values
> are different?
>
> Thank you so much for your help!!
>
> Sincerely,
>
> Dave Deriso
> UCSD Psychiatry
>
>
> #Example 1 ---COPY & PASTE THE FOLLOWING
>
> #import the data
> allDataSource="http://files.davidderiso.com/r/allData.data";
> allData.import=read.table(allDataSource,header=T)
> studentDataSource="http://files.davidderiso.com/r/allData.data";
> studentData.import=read.table(studentDataSource,header=T)
>
>
> #aov for allData WORKS
> allData.integral.aov = aov(integral~population*condition,
> data=allData.import)
> summary(allData.integral.aov)
>
> #aov for studentData DOES NOT GIVE Pr(>F) of population:condition
> studentData.integral.aov = aov(integral~population*condition,
> data=studentData.import)
> summary(studentData.integral.aov)
>
>
>
> #Example 2 ---COPY & PASTE THE FOLLOWING
>
> #population:condition has a Pr(>F) of 0.96372
> allData.integral.aov = aov(integral~population*condition,
> data=allData.import)
> summary(allData.integral.aov)
>
> #population:condition has a Pr(>F) of 1.070e-06 ***
> allData.integral.aov = aov(integral~population:condition,
> data=allData.import)
> summary(allData.integral.aov)
>

[[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] aov function syntax

2010-01-09 Thread Dave Deriso
Hello,

I have a simple question about using the aov function syntax (ie. * + or :)
for the interaction of 2 factors. I have read the help files, and researched
other sites, and have included my source files. My goal is to measure the
signifigance of the interaction between population and condition (aka.
population:condition). I can't seem to figure it out.

1. In the first example the significance of population:condition works with
the "allData" but not with the "studentData." Can you please explain why it
fails and how I can fix it?

2. In the second example I can get the measure the significance of
population:condition with 2 different methods, but I get 2 different results
(using the "allData" source). Can you please explain why these Pr(>F) values
are different?

Thank you so much for your help!!

Sincerely,

Dave Deriso
UCSD Psychiatry


#Example 1 ---COPY & PASTE THE FOLLOWING

#import the data
allDataSource="http://files.davidderiso.com/r/allData.data";
allData.import=read.table(allDataSource,header=T)
studentDataSource="http://files.davidderiso.com/r/allData.data";
studentData.import=read.table(studentDataSource,header=T)


#aov for allData WORKS
allData.integral.aov = aov(integral~population*condition,
data=allData.import)
summary(allData.integral.aov)

#aov for studentData DOES NOT GIVE Pr(>F) of population:condition
studentData.integral.aov = aov(integral~population*condition,
data=studentData.import)
summary(studentData.integral.aov)



#Example 2 ---COPY & PASTE THE FOLLOWING

#population:condition has a Pr(>F) of 0.96372
allData.integral.aov = aov(integral~population*condition,
data=allData.import)
summary(allData.integral.aov)

#population:condition has a Pr(>F) of 1.070e-06 ***
allData.integral.aov = aov(integral~population:condition,
data=allData.import)
summary(allData.integral.aov)

[[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] Is there any function in R like ezplot in matlab?

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 5:22 AM, 军 吕 wrote:

Hi,

Is there any function in R like ezplot in matlab?

How to draw the relationship  between x y like this

x^y+y^(sinx)=log(x+y)




It's not pre-packaged, but drawing a contour plot of the function

f <- function(x,y) x^y+y^sin(x) - log(x+y)

should do it:

xvals <- yvals <- seq(0, 30, len=1000)
zvals <- outer(xvals, yvals, f)
contour(xvals, yvals, zvals, levels=0)


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] Is there any function in R like ezplot in matlab?

2010-01-09 Thread 军 吕
Hi,

Is there any function in R like ezplot in matlab?

How to draw the relationship  between x y like this

x^y+y^(sinx)=log(x+y)

Thanks

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


Re: [R] Arguments of a function

2010-01-09 Thread Peter Ehlers

You could define a list and then just access the
appropriate elements of that list:

my.f <- function(a, b)
{
  x1 = equation 1
  x2 = equation 2
  x3 = equation 3
  L <- list(x1, x2, x3)
  y <- L[[a]] + L[[b]]
}

my.f(1,2)
my.f(2,3)

 -Peter Ehlers

Lisa wrote:

Dear all,

I have a question about how to set arguments in my own function. For
example, I have a function that looks like this:

my.f <- function(a = x1, b = x2)
{
   x1 = equation 1
   x2 = equation 2
   x3 = equation 3
   y = a + b   
}


x1, x2, and x3 are temporary variables (intermediate results) calculated
from other variables within the funciton. I want to use two of these three
variables to calculate y, and write R script as below:

my.f(a = x1, b = x2)
 
or 


my.f(a = x2, b = x3)

The error information shows that: “objects 'x1', 'x2', or 'x3' not found”. 


Can anybody help me solve this problem? Thanks in advance.

Lisa



--
Peter Ehlers
University of Calgary
403.202.3921

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 numeric values against non numeric items

2010-01-09 Thread Jim Lemon

On 01/09/2010 12:38 PM, lse1986 wrote:

Hi i want do a line graph.

My y axis contains numeric values. My x axis contains non numeric
statements.

This is what i want the graph to look like.

When i try to plot this graph on R it comes up with the following error
message:

"Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf"

   

Hi Sam,
While I don't know what you want the graph to look like, I would suggest 
the following:


xf<-factor(x)
plot(as.numeric(xf),rnorm(10),type="l",xaxt="n")
axis(1,at=1:10,labels=xf)

Jim

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