[R] mlogit and weights

2010-06-02 Thread Misha Spisok
Hello,

I can't figure out why using and not using weights in mlogit yields
identical results.  My motivation is for the case when an
"observation" or "individual" represents a number of individuals.  For
example,

library(mlogit)
library(AER)
data("TravelMode", package = "AER")
TM <- mlogit.data(TravelMode, choice = "choice", shape = "long",
 alt.levels = c("air", "train", "bus", "car"))
myweight = rep(floor(1000*runif(nrow(TravelMode)/4)), each = 4)

summary(mlogit(choice ~ wait + vcost + travel + gcost, data=TM))
summary(mlogit(choice ~ wait + vcost + travel + gcost, weights=income, data=TM))
summary(mlogit(choice ~ wait + vcost + travel + gcost,
weights=myweight, data=TM))

Each gives the same result.  Am I specifying "weights" incorrectly?

Is there a better way to do what I want to do?  That is, if "myweight"
contains the number of observations represented by an "observation,"
is this the correct approach?  If so, what am I doing wrong?  If not,
what suggestions are there?

Thank you for your time.

Best,

Misha

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 linux install: FORTRAN compiling error

2010-06-02 Thread Prof Brian Ripley

On Wed, 2 Jun 2010, Matt Shotwell wrote:


This is not an issue with R, but with gfortran. See the following:

http://gcc.gnu.org/wiki/GFortran#news (under heading "gfortran 4.5")

http://gcc.gnu.org/ml/fortran/2010-04/msg00061.html

Also, I suspect you are using a precompiled gcc/gfortran, and it assumes
you have libmpc.so.2  installed. If you
compile all of gcc, you won't see this problem. However, this is
probably not the simplest solution. I'd try the solution in the second
link above. Else, if `gcc --version` <= 4.4, get the compiled gfortran
at that version.


And as the output indicates it is 4.1.2.  So this is an ancient Linux 
(perhaps RHEL?), and you really need the gfortran (and libgfortran) 
from the distribution.


Mixing an unreleased bleeding-edage gfortran with a gcc from early 
2007 is not going to work well, most likely not at all.




P.S. `grep -R mpc.h R-2.11.1/*` indicates R does not depend on libmpc


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


On Wed, 2010-06-02 at 17:07 -0400, vaneet wrote:

Hello,

I have basic familiarity with Unix but by most standards a novice.  I am
trying to install R on a linux machine and am following the instructions in
the R install and admin guide in terms of what is required to compile the R
source code.  I downloaded R version 2.11.1 and extracted the files into my
home directory.  I realize I need a FORTRAN compiler to help with this
process and have tried installing a few but still cannot past the
configuration step of installing R:

./configure --with-readline=no

Once I run this command after installing GFortran I get the following error:
...
checking whether we can compute C Make dependencies... yes, using gcc
-std=gnu99 -MM
checking whether gcc -std=gnu99 supports -c -o FILE.lo... yes
checking how to get verbose linking output from gfortran... configure:
WARNING: compilation failed

checking for Fortran 77 libraries of gfortran...
checking how to get verbose linking output from gcc -std=gnu99... -v
checking for C libraries of gcc -std=gnu99...  -L/usr/local/lib64
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -lgcc_s
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... configure: error: in
`/home/lotayv01/R-2.11.1':
configure: error: cannot compile a simple Fortran program
See `config.log' for more details.

For more details I can show you the section in the config.log file

...
/data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
error while loading shared libraries: libmpc.so.2: cannot open shared object
file: No such file or directory
configure:22471: $? = 1
configure: failed program was:
|   program main
|
|   end
configure:22548: WARNING: compilation failed
configure:22554: result:
configure:22556: checking for Fortran 77 libraries of gfortran
configure:22579: gfortran -o conftest -L/usr/local/lib64 conftest.f
/data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
error while loading shared libraries: libmpc.so.2: cannot open shared object
file: No such file or directory
...

When I check the version of Gfortran at the console command line I get this:
GNU Fortran (GCC) 4.6.0 20100407 (experimental) [trunk revision 158083]
Copyright (C) 2010 Free Software Foundation, Inc.

Even before this I tried the g95 fortran compiler and the same thing
happened, how can I fix this problem, any help on this matter would be
greatly appreciated.

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.



--
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] textbox in lattice

2010-06-02 Thread baptiste auguie
Hi,

On 3 June 2010 05:26, Paul Murrell  wrote:

> Or the same drawing calculations have to be repeated within
> width/heightDetails - those methods should get run within the same graphical
> context as the drawDetails method.
>

Yes, the idea crossed my mind, but I did not find it very appealing
(already the function is slower than it could/should be). Something to
consider though, in a future version.

Thanks,

baptiste





> Paul
>
>> Best,
>>
>> baptiste
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> p...@stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/
>

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

2010-06-02 Thread Joshua Wiley
On Wed, Jun 2, 2010 at 9:40 PM, RICHARD M. HEIBERGER  wrote:
>> #Error that is returned from above code…..
>>
>> >'C:\Program' is not recognized as an internal or external command,
>> operable program or
>
>
> This statement means that the Windows CMD processor does not realize that
> 'C:\Program Files' is a single word.  Use the 8.3 version of the filename
> 'C:\progra~1' instead.  Get the correct 8.3 name for your computer from the
> Windows
>   dir /x
> command on the appropriate directory.  Maybe you can use the ENVIRONMENT
> variable  %PROGRAMFILES% directly.  Sometimes you can use explicit quotation

just wanted to add that I routinely use environment variables directly
for paths from the Windows command prompt.  shell() seems to be okay
with it too.  For example this should (confirmed on on Windows
versions 5.1.2600 and 6.1.7600) open the basic calculator:

shell("%WINDIR%/System32/calc.exe")


> marks "c:\Program Files\rest of path\yourprogram.exe" to get past this
> issue.
>
> This problem may be happening inside the program you are calling, not at
> your level.
>
> Uwe, a discussion of %PROGRAMFILES% and 8.3 names needs to be added
> to the Windows FAQ.  I think it belongs in "Section 5 Windows Features"
> because it is
> a standard Windows feature to put software in the "Program Files" directory
> with an
> embedded blank in its name and it is a standard MSDOS feature to trip on
> embedded blanks.
>
> Rich
>
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


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

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


Re: [R] 3dimensional array in r

2010-06-02 Thread Tsjerk Wassenaar
Hi Suman,

Try:

array(1:24,c(4,3,2))

Cheers,

Tsjerk

On Thu, Jun 3, 2010 at 6:52 AM, suman dhara  wrote:
> Sir,
> I want to use a 3-dimensional array in R. How can I initialize the array?
> Can you give me a eaxmple?
>
> Thanks & Regards,
>
> Suman Dhara
>
>        [[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.
>



-- 
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Molecular Dynamics Group
Groningen Institute for Biomolecular Research and Biotechnology
University of Groningen
The Netherlands

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

2010-06-02 Thread suman dhara
Sir,
I want to use a 3-dimensional array in R. How can I initialize the array?
Can you give me a eaxmple?

Thanks & Regards,

Suman Dhara

[[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] Shell command help

2010-06-02 Thread RICHARD M. HEIBERGER
> #Error that is returned from above code…..
>
> >'C:\Program' is not recognized as an internal or external command,
> operable program or


This statement means that the Windows CMD processor does not realize that
'C:\Program Files' is a single word.  Use the 8.3 version of the filename
'C:\progra~1' instead.  Get the correct 8.3 name for your computer from the
Windows
   dir /x
command on the appropriate directory.  Maybe you can use the ENVIRONMENT
variable  %PROGRAMFILES% directly.  Sometimes you can use explicit quotation
marks "c:\Program Files\rest of path\yourprogram.exe" to get past this
issue.

This problem may be happening inside the program you are calling, not at
your level.

Uwe, a discussion of %PROGRAMFILES% and 8.3 names needs to be added
to the Windows FAQ.  I think it belongs in "Section 5 Windows Features"
because it is
a standard Windows feature to put software in the "Program Files" directory
with an
embedded blank in its name and it is a standard MSDOS feature to trip on
embedded blanks.

Rich

[[alternative HTML version deleted]]

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


[R] Continous variables with implausible transformation?

2010-06-02 Thread zhu yao
Dear r users

I have a question in coding continuous variables in logistic regression.

When "rcs" is used in transforming variables, sometime it gives implausible
associations with the outcome although the model x2 is high.

So what's your tips and tricks in coding continuous variables.

P.S. How to code variables as linear+square in the formula such as lrm.
lrm(y~x+sqrt(x)) can't work.

Many thanks.

Yao Zhu.

[[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] problem with 'svyby' function from SURVEY package

2010-06-02 Thread Roni Kobrosly
Hello,

I'm using a complex survey dataset and my goal is to simply spit out a bunch of 
probability-weighted outcome variable means for the different levels of 
covariate. So I first define the structure of the study design (I'm using the 
CDC's NHANES data):

dhanes <- svydesign(id=~PSU, strat=~STRATA, weight=~lab_weight, data=final, 
nest=TRUE)

No problem there.
Now I use the "svyby" function as follows:

svyby(~outcome, ~covariate, design=dhanes, svymean, na.rm=T) -> haha
print(haha)

   covariate outcome   se.outcome
11   0.4961189 0.08828457
22   0.4474706 0.22214557
33   0.5157026 0.12076008
44   0.6773910 0.20605025
NA  NA   0.8728167 0.15622274

...and it works just fine. I get a nice table of the mean and standard error 
for each level of the covariate. I started writing a custom function to 
automate this and I had problems. Consider this really basic custom function 
(that does not seem very different from the above code):

this_is_a_test <-function(outcome, covariate)
{

svyby(~outcome, ~covariate, design=dhanes, svymean, na.rm=T) -> haha

print(hah)


}

I get the following output:

Error in `[.survey.design2`(design, nas == 0, ) : 
  (subscript) logical subscript too long


I really don't understand this because I haven't done anything too different. 
Before I can even start writing up the rest of the function, I have to settle 
this. Any ideas?

-Roni




[[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] lapply or data.table to find a unit's previous transaction

2010-06-02 Thread Gabor Grothendieck
On Wed, Jun 2, 2010 at 10:29 PM, William Rogers  wrote:
> I have a dataset of property transactions that includes the
> transaction ID (TranID), property ID (UnitID), and transaction date
> (TranDt). I need to create a data frame (or data table) that includes
> the previous transaction date, if one exists.
> This is an easy problem in SQL, where I just run a sub-query, but I'm
> trying to make R my one-stop-shopping program.  The following code

The sqldf package lets you use SQL queries on R data frames.  See its
home page at:
http://sqldf.googlecode.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] textbox in lattice

2010-06-02 Thread Paul Murrell

Hi

On 2/06/2010 7:33 p.m., baptiste auguie wrote:

On 2 June 2010 07:55, Deepayan Sarkar  wrote:



Something like this should also work, except that the grob produced by
tableGrob() doesn't seem to know its height.


Indeed, I have not been successful in writing good
widthDetails/heightDetails methods for this grob since all the drawing
calculations are made in the drawDetails method. Maybe some of these
calculations don't really need to be made at drawing time.


Or the same drawing calculations have to be repeated within 
width/heightDetails - those methods should get run within the same 
graphical context as the drawDetails method.


Paul


Best,

baptiste

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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lapply or data.table to find a unit's previous transaction

2010-06-02 Thread William Rogers
I have a dataset of property transactions that includes the
transaction ID (TranID), property ID (UnitID), and transaction date
(TranDt). I need to create a data frame (or data table) that includes
the previous transaction date, if one exists.
This is an easy problem in SQL, where I just run a sub-query, but I'm
trying to make R my one-stop-shopping program.  The following code
works on a subset of my data, but I can't run this on my full dataset
because my computer runs out of memory after about 30 minutes. (Using
a 32-bit machine.)
Use the following synthetic data for example.

n<- 100
TranID<- lapply(n:(2*n), function(x) (
as.matrix(paste(x, sample(seq(as.Date('2000-01-01'),
as.Date('2010-01-01'), "days"), sample(1:5, 1)), sep= "D"), ncol= 1)))
TranID<- do.call("rbind", TranID)
UnitID<- substr(TranID, 1, nchar(n))
TranDt<- substr(TranID, nchar(n)+2, nchar(n)+11)
Data<- data.frame(TranID= TranID, UnitID= UnitID, TranDt= as.Date(TranDt))

#First I create a list of all the previous transactions by unit

TranList<- as.matrix(Data$TranID, ncol= 1)
PreTran<- lapply(TranList,
  function(x) (with(Data,
  Data[
  UnitID== substr(x, 1, nchar(n))&
  TranDt< Data[TranID== x, "TranDt"], ]
  ))
  )

#I do get warnings about missing data because some transactions have
no predecessor.
#Some transactions have no previous transactions, others have many so
I pick the most recent

BeforeTran<- lapply(seq_along(PreTran), function(x) (
with(PreTran[[x]], PreTran[[x]][which(TranDt== max(TranDt)), ])))

#I need to add the current transaction's TranID to the list so I can merge later

BeforeTran<- lapply(seq_along(PreTran), function(x) (
transform(BeforeTran[[x]], TranID= TranList[x, 1])))

#Finally, I convert from a list to a data frame

BeforeTran<- do.call("rbind", BeforeTran)

#I have used a combination of data.table and for loops, but that seems
cheesey and doesn't preform much better.

library(data.table)

#First I create a list of all the previous transactions by unit

TranList2<- vector(nrow(Data), mode= "list")
names(TranList2)<- levels(Data$TranID)
DataDT<- data.table(Data)

#Use a for loop and data.table to find the date of the previous transaction

for (i in levels(Data$TranID)) {
if (DataDT[UnitID== substr(i, 1, nchar(n))&
   TranDt<= (DataDT[TranID== i, TranDt]),
length(TranDt)]> 1)
TranList2[[i]]<- cbind(TranID= i,
DataDT[UnitID== substr(i, 1, nchar(n))&
TranDt< (DataDT[TranID== i, TranDt]),
list(TranDt= max(TranDt))])
}

#Finally, I convert from a list to a data table

BeforeTran2<- do.call("rbind", TranList2)

#My intution says that this code doesn't take advantage of
data.table's attributes.
#Are there any ideas out there?  Thank you.
#P.S. I've tried plyr and it does not help my memory problem.

--
William H. Rogers

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

2010-06-02 Thread galen kaufman

Uwe,

 

Thank you so much for the response. I tried running the command in the format 
you suggested but still could not get the shell command to execute. The 
following is the command that I used per your suggestion and the subsequent 
error message.

 

shell('"C:\\programx.exe"' -import '"C:\\inputx.inp"' -run -quit)

 
#Error that is returned from above code…..
 
>'C:\Program' is not recognized as an internal or external command, operable 
>program or >batch file.
>Warning message:
>In shell("\"C:\\programx.exe\" -import >\"C:\\input.inp\" -run -quit") :
 >'"C:\programx.exe" -import "C:\input.inp" -run -quit' execution failed with 
 >error code 1

Thinking that it may be a problem with the command line I checked with 
developer of the program and he said that it should be the correct language.

 

Any thoughts?

 

Thank you again,

 

Galen 

 

 
> Date: Mon, 3 May 2010 09:19:49 +0200
> From: lig...@statistik.tu-dortmund.de
> To: leavealett...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] Shell command help
> 
> 
> 
> On 02.05.2010 21:55, galen kaufman wrote:
> >
> > Dear R Community,
> >
> > I am trying to run a command line in R that will open an external program, 
> > have it import a specific input file, run the program, then close the 
> > program. The command line that I got from the developer of the model to do 
> > this looks like what you see below:
> >
> > c:\programx.exe -import 'inputx.inp' -run -quit
> >
> > I have been trying to use shell() or shell.exec() to run this in R. I can 
> > get R to open the program but I have not been able to do the rest of the 
> > steps.
> >
> > I have been able to open the model using :
> >
> >> shell('"C:\\programx.exe"')
> >
> > or
> >
> >> shell.exec("C:\\programx.exe")
> >
> > To do the rest I have been trying variations of the following:
> >
> >> shell('"C:\\programx.exe"' -import '"C:\\inputx.inp"' -run –quit)
> 
> 
> 
> Hm, you need to pass one string to the shell (and the underlking 
> system()) call:
> 
> shell('"C:\\programx.exe" -import "C:\\inputx.inp" -run –quit')
> 
> Best,
> Uwe Ligges
> 
> 
> 
> > but I am not getting anywhere.
> >
> > Can you provide any insight as to how to do the rest?
> >
> > Thank you,
> >
> > Galen 
> > _
> > Hotmail is redefining busy with tools for the New Busy. Get more from your 
> > inbox.
> >
> > N:WL:en-US:WM_HMP:042010_2
> > [[alternative HTML version deleted]]
> >
> >
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
  
_
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.

ID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
[[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] Matrix subsetting with rownames

2010-06-02 Thread RICHARD M. HEIBERGER
> tmp <- matrix(1:24, 6, 4, dimnames=list(letters[1:6], LETTERS[1:4]))
> tmp
  A  B  C  D
a 1  7 13 19
b 2  8 14 20
c 3  9 15 21
d 4 10 16 22
e 5 11 17 23
f 6 12 18 24
> tmp[c("a", "c", "d", "f"), ]
  A  B  C  D
a 1  7 13 19
c 3  9 15 21
d 4 10 16 22
f 6 12 18 24
>


See
   ?`[`
for discussion.

[[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] Matrix subsetting with rownames

2010-06-02 Thread Smarsupilami

Hi,
I have a large matrix containing 1 rows and 60 columns. I would like to
subset this matrix by using a list of several hundred row names. I tried to
find how to do that, eg with %in% or subset commands, but I never succeed
and I do not find the proper method on internet. How to proceed ?
Thanks
Muppy
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-subsetting-with-rownames-tp2241038p2241038.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] Nested ANOVA with covariate using Type III sums of squares in R

2010-06-02 Thread Anita Narwani
Hello,

I have been trying to get an ANOVA table for a linear model containing a
single nested factor, two fixed factors and a covariate:

carbonmean<-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto
+ Zoop*Diversity/Phyto)

where, Mean.richness is a covariate, Zoop is a categorical variable (the
species), Diversity is a categorical variable (Low or High), and Phyto
(community composition) is also categorical but is nested within the level
of Diversity. Quinn & Keough's statistics text recommends using Type III
SS for a nested ANOVA with a covariate.

I get the following output using the Type I SS ANOVA:

Analysis of Variance Table
Response: C.Mean
Df  Sum Sq  Mean Sq 
F value Pr(>F)
Mean.richness   1   563853265638532623.5855 
3.239e-05 ***
Diversity   1   14476593144765936.0554  
0.019634 *
Zoop1   13002135130021355.4387  
0.026365 *
Diversity:Phyto 6   126089387   210148988.7904  
1.257e-05 ***
Diversity:Zoop  1   263036  263036  0.1100  
0.742347
Diversity:Zoop:Phyto6   61710145102850244.3021  
0.002879 **
Residuals   31  741109112390675
I have tried using both the drop1() command and the Anova() command in the
car package.
When I use the Anova command I get the following error message:
>Anova(carbonmean,type="III")
“Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry,:
One or more terms aliased in model.”

I am not sure why this is aliased. There are no missing cells, and the
cells are balanced (aside from for the covariate). Each Phyto by Zoop
cross is replicated 3 times, and there are four Phyto levels within each
level of Diversity. When I remove the nested factor (Phyto), I am able to
get the Type III SS output.

Then when I use drop1(carbonmean,.~.,Test=”F”) I get the following output:
> drop1(carbonmean,.~.,Test="F")
Single term deletions

Model:
C.Mean ~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop *
Diversity/Phyto
Df  Sum of Sq   RSS 
AIC
  74110911   718
Mean.richness   1   49790403123901314   741
Diversity   0   0   74110911
718
Zoop0   0   74110911
718
Diversity:Phyto 6   118553466   192664376   752
Diversity:Zoop  0   -1.49e-08   74110911718
Diversity:Zoop:Phyto6   61710145135821055   735

There are zero degrees of freedom for Diversity, Zoop and their
interaction, and zero sums of sq for Diversity and Zoop. This cannot be
correct, however when I do the model simplification by dropping terms from
the models manually and comparing them using anova(), I get virtually the
same results.

I would appreciate any suggestions for things to try or pointers as to
what I may be doing incorrectly.

Thank you.
Anita Narwani.


PhD Candidate
Water & Aquatic Sciences Research Program
University of Victoria, Department of Biology

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

2010-06-02 Thread Tony Plate
trackObjs will not work together with mvbutils -- both use active 
bindings to store objects on disk, and I would expect that trying to use 
both together would cause all sort of nasty conflicts.  I would think it 
would be possible to fold the creation/modification time recording from 
trackObjs into mvbutils, but it would probably be a significant amount 
of work.


-- Tony Plate

On 05/31/2010 09:56 PM, Day, Roger S wrote:

Hello Colleagues,

I've recently become a fan of Mark Bravington's mvbutils package for organizing 
analysis projects in a tree.
Using cd(), Save(), fixr(), mlazy()   etcetera  solves nicely some of the 
nuisances that have worried or annoyed me and sometimes caused
big problems over the years.  Well thought out.

Now one feature that would be fabulous would be automatic time-stamping of 
objects.
The trackObjs package from provides this, among other services.

The question is, can the two packages work together peacefully?

One curiosity: they have opposite ideas of the word "cache".
In mvbutils, a cached object is one that is stored on disk, only retrieved into 
memory when needed.
In trackObjs, a cached object is one that is stored in memory as well as on 
disk.
More than a curiosity, also potentially a bad sign for compatibility between 
the two packages.

Anyone have experience with the two together, and care to share it?
Thanks!


Roger Day
University of Pittsburgh Departments of Biomedical Informatics and
Biostatistics
University of Pittsburgh Cancer Institute
University of Pittsburgh Molecular Medicine Institute
-
Room 310, Suite 301
Cancer Pavilion (CNPAV)
5150 Centre Ave.
Pittsburgh, PA 15232
e-mail:  da...@pitt.edu
cell phone 412-609-3918
assistant:
 Lucy Cafeo:   (412) 623-2952

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Joris Meys
that's diversity/phyto, zoop or phyto twice in the formula.

On Thu, Jun 3, 2010 at 3:00 AM, Joris Meys  wrote:

> That's what one would expect with type III sum of squares. You have Phyto
> twice in your model, but only as a nested factor. To compare the full model
> with a model without diversity of zoop, you have either the combination
> diversity/phyto, zoop/phyto or phyto twice in the formula. That's aliasing.
>
> Depending on how you stand on type III sum of squares, you could call that
> a "bug". Personally, I'd just not use them.
>
> https://stat.ethz.ch/pipermail/r-help/2001-October/015984.html
>
> Cheers
> Joris
>
>
> On Thu, Jun 3, 2010 at 2:13 AM, Anita Narwani wrote:
>
>> Hello,
>>
>> I have been trying to get an ANOVA table for a linear model containing a
>> single nested factor, two fixed factors and a covariate:
>>
>>  carbonmean<-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto
>> +
>> Zoop*Diversity/Phyto)
>>
>>
>>
>> where, *Mean.richness* is a covariate*, Zoop* is a categorical variable
>> (the
>> species), *Diversity* is a categorical variable (Low or High), and
>> *Phyto*(community composition) is also categorical but is nested
>> within the level
>> of *Diversity*. Quinn & Keough's statistics text recommends using Type III
>> SS for a nested ANOVA with a covariate.
>>
>> I get the following output using the Type I SS ANOVA:
>>
>>
>>
>> Analysis of Variance Table
>> Response: C.Mean
>>DfSum Sq
>> Mean
>> Sq  F valuePr(>F)
>> Mean.richness1  5638532656385326
>> 23.5855   3.239e-05 ***
>> Diversity 1  14476593
>>  14476593
>>  6.0554 0.019634 *
>> Zoop1  13002135
>> 13002135
>>  5.4387 0.026365 *
>> Diversity:Phyto  6  126089387  21014898
>> 8.7904 1.257e-05 ***
>> Diversity:Zoop   1  263036
>> 263036
>> 0.1100  0.742347
>> Diversity:Zoop:Phyto 6  6171014510285024
>> 4.3021
>>   0.002879 **
>> Residuals3174110911
>> 2390675
>>
>> I have tried using both the drop1() command and the Anova() command in the
>> car package.
>>
>> When I use the Anova command I get the following error message:
>>
>> >Anova(carbonmean,type="III")
>>
>> “Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry,:
>> One
>> or more terms aliased in model.”
>>
>>
>>
>> I am not sure why this is aliased. There are no missing cells, and the
>> cells
>> are balanced (aside from for the covariate). Each Phyto by Zoop cross is
>> replicated 3 times, and there are four Phyto levels within each level of
>> Diversity. When I remove the nested factor (Phyto), I am able to get the
>> Type III SS output.
>>
>>
>>
>> Then when I use drop1(carbonmean,.~.,Test=”F”) I get the following output:
>>
>> > drop1(carbonmean,.~.,Test="F")
>>
>> Single term deletions
>>
>>
>>
>> Model:
>>
>> C.Mean ~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop *
>> Diversity/Phyto
>>
>>DfSum of Sq
>> RSS AIC
>>
>> 74110911   718
>>
>> Mean.richness1  49790403123901314
>> 741
>>
>> Diversity 0 0
>> 74110911718
>>
>> Zoop0 0
>> 74110911718
>>
>> Diversity:Phyto  6  118553466  192664376
>> 752
>>
>> Diversity:Zoop   0  -1.49e-0874110911
>> 718
>>
>> Diversity:Zoop:Phyto 6  61710145135821055
>> 735
>>
>>
>>
>> There are zero degrees of freedom for Diversity, Zoop and their
>> interaction,
>> and zero sums of sq for Diversity and Zoop. This cannot be correct,
>> however
>> when I do the model simplification by dropping terms from the models
>> manually and comparing them using anova(), I get virtually the same
>> results.
>>
>>
>>
>> I would appreciate any suggestions for things to try or pointers as to
>> what
>> I may be doing incorrectly.
>>
>>
>>
>> Thank you.
>>
>> Anita Narwani.
>>
>>[[alternative HTML version deleted]]
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
> --
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> jor

Re: [R] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Joris Meys
That's what one would expect with type III sum of squares. You have Phyto
twice in your model, but only as a nested factor. To compare the full model
with a model without diversity of zoop, you have either the combination
diversity/phyto, zoop/phyto or phyto twice in the formula. That's aliasing.

Depending on how you stand on type III sum of squares, you could call that a
"bug". Personally, I'd just not use them.

https://stat.ethz.ch/pipermail/r-help/2001-October/015984.html

Cheers
Joris


On Thu, Jun 3, 2010 at 2:13 AM, Anita Narwani wrote:

> Hello,
>
> I have been trying to get an ANOVA table for a linear model containing a
> single nested factor, two fixed factors and a covariate:
>
>  carbonmean<-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto
> +
> Zoop*Diversity/Phyto)
>
>
>
> where, *Mean.richness* is a covariate*, Zoop* is a categorical variable
> (the
> species), *Diversity* is a categorical variable (Low or High), and
> *Phyto*(community composition) is also categorical but is nested
> within the level
> of *Diversity*. Quinn & Keough's statistics text recommends using Type III
> SS for a nested ANOVA with a covariate.
>
> I get the following output using the Type I SS ANOVA:
>
>
>
> Analysis of Variance Table
> Response: C.Mean
>DfSum Sq
> Mean
> Sq  F valuePr(>F)
> Mean.richness1  5638532656385326
> 23.5855   3.239e-05 ***
> Diversity 1  14476593
>  14476593
>  6.0554 0.019634 *
> Zoop1  13002135
> 13002135
>  5.4387 0.026365 *
> Diversity:Phyto  6  126089387  21014898
> 8.7904 1.257e-05 ***
> Diversity:Zoop   1  263036
> 263036
> 0.1100  0.742347
> Diversity:Zoop:Phyto 6  6171014510285024
> 4.3021
>   0.002879 **
> Residuals3174110911
> 2390675
>
> I have tried using both the drop1() command and the Anova() command in the
> car package.
>
> When I use the Anova command I get the following error message:
>
> >Anova(carbonmean,type="III")
>
> “Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry,: One
> or more terms aliased in model.”
>
>
>
> I am not sure why this is aliased. There are no missing cells, and the
> cells
> are balanced (aside from for the covariate). Each Phyto by Zoop cross is
> replicated 3 times, and there are four Phyto levels within each level of
> Diversity. When I remove the nested factor (Phyto), I am able to get the
> Type III SS output.
>
>
>
> Then when I use drop1(carbonmean,.~.,Test=”F”) I get the following output:
>
> > drop1(carbonmean,.~.,Test="F")
>
> Single term deletions
>
>
>
> Model:
>
> C.Mean ~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop *
> Diversity/Phyto
>
>DfSum of Sq
> RSS AIC
>
> 74110911   718
>
> Mean.richness1  49790403123901314
> 741
>
> Diversity 0 0
> 74110911718
>
> Zoop0 0
> 74110911718
>
> Diversity:Phyto  6  118553466  192664376
> 752
>
> Diversity:Zoop   0  -1.49e-0874110911
> 718
>
> Diversity:Zoop:Phyto 6  61710145135821055
> 735
>
>
>
> There are zero degrees of freedom for Diversity, Zoop and their
> interaction,
> and zero sums of sq for Diversity and Zoop. This cannot be correct, however
> when I do the model simplification by dropping terms from the models
> manually and comparing them using anova(), I get virtually the same
> results.
>
>
>
> I would appreciate any suggestions for things to try or pointers as to what
> I may be doing incorrectly.
>
>
>
> Thank you.
>
> Anita Narwani.
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

[[alternative HTML version deleted]]

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

[R] Nested ANOVA with covariate using Type III sums of squares

2010-06-02 Thread Anita Narwani
Hello,

I have been trying to get an ANOVA table for a linear model containing a
single nested factor, two fixed factors and a covariate:

 carbonmean<-lm(C.Mean~ Mean.richness + Diversity + Zoop + Diversity/Phyto +
Zoop*Diversity/Phyto)



where, *Mean.richness* is a covariate*, Zoop* is a categorical variable (the
species), *Diversity* is a categorical variable (Low or High), and
*Phyto*(community composition) is also categorical but is nested
within the level
of *Diversity*. Quinn & Keough's statistics text recommends using Type III
SS for a nested ANOVA with a covariate.

I get the following output using the Type I SS ANOVA:



Analysis of Variance Table
Response: C.Mean
DfSum Sq   Mean
Sq  F valuePr(>F)
Mean.richness1  5638532656385326
23.5855   3.239e-05 ***
Diversity 1  1447659314476593
  6.0554 0.019634 *
Zoop1  13002135
13002135
  5.4387 0.026365 *
Diversity:Phyto  6  126089387  21014898
8.7904 1.257e-05 ***
Diversity:Zoop   1  263036
263036
0.1100  0.742347
Diversity:Zoop:Phyto 6  6171014510285024
 4.3021
   0.002879 **
Residuals3174110911
2390675

I have tried using both the drop1() command and the Anova() command in the
car package.

When I use the Anova command I get the following error message:

>Anova(carbonmean,type="III")

“Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry,: One
or more terms aliased in model.”



I am not sure why this is aliased. There are no missing cells, and the cells
are balanced (aside from for the covariate). Each Phyto by Zoop cross is
replicated 3 times, and there are four Phyto levels within each level of
Diversity. When I remove the nested factor (Phyto), I am able to get the
Type III SS output.



Then when I use drop1(carbonmean,.~.,Test=”F”) I get the following output:

> drop1(carbonmean,.~.,Test="F")

Single term deletions



Model:

C.Mean ~ Mean.richness + Diversity + Zoop + Diversity/Phyto + Zoop *
Diversity/Phyto

DfSum of Sq
RSS AIC

74110911   718

Mean.richness1  49790403123901314
741

Diversity 0 0
74110911718

Zoop0 0
74110911718

Diversity:Phyto  6  118553466  192664376
752

Diversity:Zoop   0  -1.49e-0874110911
718

Diversity:Zoop:Phyto 6  61710145135821055
735



There are zero degrees of freedom for Diversity, Zoop and their interaction,
and zero sums of sq for Diversity and Zoop. This cannot be correct, however
when I do the model simplification by dropping terms from the models
manually and comparing them using anova(), I get virtually the same results.



I would appreciate any suggestions for things to try or pointers as to what
I may be doing incorrectly.



Thank you.

Anita Narwani.

[[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] Use apply only on non-missing values

2010-06-02 Thread Joris Meys
Not really a direct answer on your question, but:
> system.time(replicate(1,apply(as.matrix(theta), 1, rasch, b_vector)))
   user  system elapsed
   4.510.034.55

> system.time(replicate(1,theta%*%t(b_vector)))
   user  system elapsed
   0.250.000.25

It does make a difference on large datasets...
Cheers
Joris

On Wed, Jun 2, 2010 at 4:44 PM, Doran, Harold  wrote:

> I have a function that I am currently using very inefficiently. The
> following are needed to illustrate the problem:
>
> set.seed(12345)
> dat <- matrix(sample(c(0,1), 110, replace = TRUE), nrow = 11, ncol=10)
> mis <- sample(1:110, 5)
> dat[mis] <- NA
> theta <- rnorm(11)
> b_vector <- runif(10, -4,4)
> empty <- which(is.na(t(dat)))
>
> So, I have a matrix (dat) with some values within the matrix missing. In my
> real world problem, the matrix is huge, and most values are missing. The
> function in question is called derivs() and is below. But, let me step
> through the inefficient portions.
>
> First, I create a matrix of some predicted probabilities as:
>
> rasch <- function(theta,b) 1/ (1 + exp(b-theta))
> mat <- apply(as.matrix(theta), 1, rasch, b_vector)
>
> However, I only need those predicted probabilities in places where the data
> are not missing. So, the next step in the function is
>
> mat[empty] <- NA
>
> which manually places NAs in places where the data are missing (notice the
> matrix 'mat' is the transpose of the data matrix and so I get the empty
> positions from the transpose of dat).
>
> Afterwards, the function computes the gradient and hessians needed to
> complete the MLE estimation.
>
> All of this works in the sense that it yields the correct answers for my
> problem. But, the glaring problem is that I create predicted probabilities
> for every cell in 'mat' when in many cases they are not needed. I end up
> replacing those values with NAs. In my real world problem, this is horribly
> inefficient and slow.
>
> My question is then is there a way to use apply such that is computes the
> necessary predicted probabilities only when the data are not missing to
> yield the matrix 'mat'. My desired end result is the matrix 'mat' created
> after the manually placing the NAs in the appropriate cells.
>
> Thanks
> Harold
>
>
> derivs <- function(dat, b_vector, theta){
>mat <- apply(as.matrix(theta), 1, rasch,
> b_vector)
>mat[empty] <- NA
>gradient <- -(colSums(dat, na.rm = TRUE) -
> rowSums(mat, na.rm = TRUE))
>hessian <-  -(rowSums(mat * (1-mat), na.rm =
> TRUE))
>list('gradient' = gradient, 'hessian' =
> hessian)
>}
>
>
>
> > sessionInfo()
> R version 2.10.1 (2009-12-14)
> i386-pc-mingw32
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C   LC_TIME=English_United
> States.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tools_2.10.1
> >
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

[[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] Draw text with a box surround in plot.

2010-06-02 Thread Peter Ehlers

On 2010-06-02 16:57, g...@ucalgary.ca wrote:

text() can draw text on a plot.
Do we have a way/function to draw text with a box surround it?
Thanks,



There may be a function in some package, but I would just use rect().
?rect

 -Peter Ehlers

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


Re: [R] nnet: cannot coerce class c("terms", "formula") into a data.frame

2010-06-02 Thread Joris Meys
Without checking R or the rest of the code, the error seems quite clear to
me: R finds a formula where it expects a data frame. cvc_lda is not a
dataframe. Do str(cvc_lda) to check for yourself. You really need to learn
this btw. Whenever you get an error, first thing to do is to check whether
everything you put in the function is what you think it is, and is what R
needs it to be.

Before you overload the help list with questions, please take some time to
read the introduction to R thoroughly. You really need to get to understand
the differences between vectors or arrays, matrices, data frames, lists, ...
You struggle with it quite obviously, and that's a problem we cannot solve
for you.

http://cran.r-project.org/doc/manuals/R-intro.pdf

If there is something that is not clear to you, feel free to ask here.

Cheers
Joris

On Wed, Jun 2, 2010 at 8:15 PM, cobbler_squad  wrote:

>
> Dearest all,
>
> Objective: I am now learning neural networks. I want to see how well can
> train an artificial neural network model to discriminate between the two
> files I am attaching with this message.
>
> http://r.789695.n4.nabble.com/file/n2240582/3dMaskDump.txt 3dMaskDump.txt
> http://r.789695.n4.nabble.com/file/n2240582/test_vowels.txttest_vowels.txt
>
> Question: when I am attempting to run
> >cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100)
> I get an error saying:
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>  cannot coerce class c("terms", "formula") into a data.frame
>
> I have not encountered this error when I was running this script with
> previous lda results, and, I am not quite sure what the error means.
>
> Below is short (and, I hope, reproducible) code.
>
> library(nnet)
>
> cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100)
>
> predict(cvc_nnet,cvc_lda,type = "class")
> table(predict(cvc_nnet,cvc_lda,type = "class"),cvc_lda$G)
>
> cvc_nnet.out<-NULL
> all = c(1:52)
>
> for(n in all){
>   cvc_nnet <- nnet(G ~ ., data=cvc_lda[all != n,], CV
> =TRUE,size=1,iter=10,MaxNWts=100)
>cvc_nnet.out <- c(cvc_nnet.out,predict(cvc_nnet,cvc_lda[all == n,],type
> =
> "class"))
> }
>
> table(cvc_nnet.out,cvc_lda$G)
>
> ===
>
> to get cvc_lda:
>
> library(MASS)
>
> vowel_features <- data.frame(as.matrix(read.table(file =
> "test_vowels.txt")))
> mask_features <- data.frame(as.matrix(read.table(file = "3dmaskdump.txt")))
> G <-vowel_features[,41]
>
> cvc_lda <- lda(G ~ ., data=mask_features, na.action="na.omit", CV=TRUE)
>
>
> Your insight is very much appreciated it!
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/nnet-cannot-coerce-class-c-terms-formula-into-a-data-frame-tp2240582p2240582.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

[[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] Draw text with a box surround in plot.

2010-06-02 Thread guox
text() can draw text on a plot.
Do we have a way/function to draw text with a box surround it?
Thanks,

-james

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] why the dim gave me different results

2010-06-02 Thread Changbin Du
Thanks all of you, I appreciated!


On Wed, Jun 2, 2010 at 2:58 PM, Phil Spector wrote:

> Changbin -
>   If you take the time to look at your data frame,
> you'll see the following 24 numbers are missing
> from the rownames.
>
> 78  84 107 108 109 158 164 194 197 203 240 241 243 255 256 264 275 277 282
> 284 300 305 311 312
>
> (I found this using
>
>   (1:600)[!(1:600) %in% rownames(tmp)]
> )
>- Phil Spector
> Statistical Computing Facility
> Department of Statistics
> UC Berkeley
> spec...@stat.berkeley.edu
>
>
>
> On Wed, 2 Jun 2010, Changbin Du wrote:
>
>  dim(tmp)
>>>
>> [1] 576  12
>>
>>> tmp
>>>
>>
>>  1 10 11 12 13  2  3  4  5  6  7  9
>>  10  0  0  0  0  0  0 12  0  0  0  0
>>  20  0  0  0  0  0  0 15  0  0  0  0
>>  30  0  0  0  0  0  0 11  0  0  0  0
>>  40  0  0  0  0  0  0 11  0  0  0  0
>>  50  0  0  0  0  0  0 12  0  0  0  0
>>  60  0  0  0  0  0  0  6  0  0  0  0
>>  70  0  0  0  0  0  0  5  0  0  0  0
>>  80  0  0  0  0  0  0 11  0  0  0  0
>>  90  0  0  0  0  0  0 11  0  0  0  0
>>  10   0  0  0  0  0  0  0  5  0  0  0  0
>>  11   0  0  0  0  0  0  0  8  0  0  0  0
>>  12   0  0  0  0  0  0  0 12  0  0  0  0
>>  13   0  0  0  0  0  0  0  6  0  0  0  0
>>  14   0  0  0  0  0  0  0  5  0  0  0  0
>>  15   0  0  0  0  0  0  0  5  0  0  0  0
>>  16   0  0  0  0  0  0  0  6  0  0  0  0
>>  17   0  0  0  0  0  0  0  0  0  0  9  0
>>  18   0  0  0  0  0  0  0 13  0  0  0  0
>>  19   0  0  0  0  0  0  0  7  0  0  0  0
>>  20   0  0  0  0  0  0  0 10  0  0  0  0
>>  21   0  0  0  0  0  0  0 13  0  0  0  0
>>  22   0  0  0  0  0  0  0 17  0  0  0  0
>>  23   0  0  0  0  0  0  0 13  0  0  0  0
>>  24   0  0  0  0  0  0  0  5  0  0  0  0
>>  25   0  0  0  0  0  0  0  4  0  0  0  0
>>  26   0  0  0  0  0  0  0 10  0  0  0  0
>>  27   0  0  0  0  0  0  0  8  0  0  0  0
>>  28   0  0  0  0  0  0  0 11  0  0  0  0
>>  29   0  0  0  0  0  0  0 13  0  0  0  0
>>  30   0  0  0  0  0  0  0  7  0  0  0  0
>>  31   0  0  0  0  0  0  0  8  0  0  0  0
>>  32   0  0  0  0  0  0  0 14  0  0  0  0
>>  33   0  0  0  0  0  0  0  7  0  0  0  0
>>  34   0  0  0  0  0  0  0  6  0  0  0  0
>>  35   0  0  0  0  0  0  0  6  0  0  0  0
>>  36   0  0  0  0  0  0  0  8  0  0  0  0
>>  37   0  0  0  0  0  0  0 12  0  0  0  0
>>  38   0  0  0  0  0  0  0 10  0  0  0  0
>>  39   0  0  0  0  0  0  0 10  0  0  0  0
>>  40   0  0  0  0  0  0  0  0  0  0 14  0
>>  41   0  0  0  0  0  0  0  9  0  0  0  0
>>  42   0  0  0  0  0  0  0  7  0  0  0  0
>>  43   0  0  0  0  0  0  0  5  0  0  0  0
>>  44   0  0  0  0  0  0  0 14  0  0  0  0
>>  45   0  0  0  0  0  0  0  6  0  0  0  0
>>  46   0  0  0  0  0  0  0  0  0  0  3  0
>>  47   0  0  0  0  0  0  0  8  0  0  0  0
>>  48   0  0  0  0  0  0  0  9  0  0  0  0
>>  49   0  0  0  0  0  0  0  8  0  0  0  0
>>  50   0  0  0  0  0  0  0  7  0  0  0  0
>>  51   0  0  0  0  0  0  0 13  0  0  0  0
>>  52   0  0  0  0  0  0  0 13  0  0  0  0
>>  53   0  0  0  0  0  0  0  7  0  0  0  0
>>  54   0  0  0  0  0  0  0  8  0  0  0  0
>>  55   0  0  0  0  0  0  0  7  0  0  0  0
>>  56   0  0  0  0  0  0  0  4  0  0  0  0
>>  57   0  0  0  0  0  0  0  8  0  0  0  0
>>  58   0  0  0  0  0  0  0 13  0  0  0  0
>>  59   0  0  0  0  0  0  0 12  0  0  0  0
>>  60   0  0  0  0  0  0  0  7  0  0  0  0
>>  61   0  0  0  0  0  0  0  7  0  0  0  0
>>  62   0  0  0  0  0  0  0  9  0  0  0  0
>>  63   0  0  0  0  0  0  0 13  0  0  0  0
>>  64   0  0  0  0  0  0  0  8  0  0  0  0
>>  65   0  0  0  0  0  0  0  1  0  0  0  0
>>  66   0  0  0  0  0  0  0  9  0  0  0  0
>>  67   0  0  0  0  0  0  0  8  0  0  0  0
>>  68   0  0  0  0  0  0  0 11  0  0  0  0
>>  69   0  0  0  0  0  0  0  7  0  0  0  0
>>  70   0  0  0  0  0  0  0 11  0  0  0  0
>>  71   0  0  0  0  0  0  0  8  0  0  0  0
>>  72   0  0  0  0  0  0  0  6  0  0  0  0
>>  73   0  0  0  0  0  0  0 13  0  0  0  0
>>  74   0  0  0  0  0  0  0  7  0  0  0  0
>>  75   0  0  0  0  0  0  0  7  0  0  0  0
>>  76   0  0  0  0  0  0  0  6  0  0  0  0
>>  77   0  0  0  0  0  0  0  7  0  0  0  0
>>  79   0  0  0  0  0  0  0 12  0  0  0  0
>>  80   0  0  0  0  0  0  0  0  0  0 10  0
>>  81   0  0  0  0  0  0  0  9  0  0  0  0
>>  82   0  0  0  0  0  0  0  9  0  0  0  0
>>  83   0  0  0  0  0  0  0  9  0  0  0  0
>>  85   0  0  0  0  0  0  0  7  0  0  0  0
>>  86   0  0  0  0  0  0  0  7  0  0  0  0
>>  87   0  0  0  0  0  0  0 11  0  0  0  0
>>  88   0  0  0  0  0  0  0  0  0  0  4  0
>>  89   0  0  0  0  0  0  0  8  0  0  0  0
>>  90   0  0  0  0  0  0  0  6  0  0  0  0
>>  91   0  0  0  0  0  0  0 15  0  0  0  0
>>  92   0  0  0  0  0  0  0  7  0  0  0  0
>>  93   0  0  0  0  0  0  0  6  0  0  0  0
>>  94   0  0  0  0  0  0  0  7  0  0  0  0
>>  95   0  0  0  0  0  0  0  8  0  0  0  0
>>  96   0  0  0  0  0  0  0  3  0  0  0  0
>>  97

Re: [R] R linux install: FORTRAN compiling error

2010-06-02 Thread Matt Shotwell
This is not an issue with R, but with gfortran. See the following:

http://gcc.gnu.org/wiki/GFortran#news (under heading "gfortran 4.5")

http://gcc.gnu.org/ml/fortran/2010-04/msg00061.html

Also, I suspect you are using a precompiled gcc/gfortran, and it assumes
you have libmpc.so.2  installed. If you
compile all of gcc, you won't see this problem. However, this is
probably not the simplest solution. I'd try the solution in the second
link above. Else, if `gcc --version` <= 4.4, get the compiled gfortran
at that version.

P.S. `grep -R mpc.h R-2.11.1/*` indicates R does not depend on libmpc


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


On Wed, 2010-06-02 at 17:07 -0400, vaneet wrote:
> Hello,
> 
> I have basic familiarity with Unix but by most standards a novice.  I am
> trying to install R on a linux machine and am following the instructions in
> the R install and admin guide in terms of what is required to compile the R
> source code.  I downloaded R version 2.11.1 and extracted the files into my
> home directory.  I realize I need a FORTRAN compiler to help with this
> process and have tried installing a few but still cannot past the
> configuration step of installing R:
> 
> ./configure --with-readline=no
> 
> Once I run this command after installing GFortran I get the following error:
> ...
> checking whether we can compute C Make dependencies... yes, using gcc
> -std=gnu99 -MM
> checking whether gcc -std=gnu99 supports -c -o FILE.lo... yes
> checking how to get verbose linking output from gfortran... configure:
> WARNING: compilation failed
> 
> checking for Fortran 77 libraries of gfortran...
> checking how to get verbose linking output from gcc -std=gnu99... -v
> checking for C libraries of gcc -std=gnu99...  -L/usr/local/lib64
> -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2
> -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64
> -L/usr/lib/../lib64 -lgcc_s
> checking for dummy main to link with Fortran 77 libraries... none
> checking for Fortran 77 name-mangling scheme... configure: error: in
> `/home/lotayv01/R-2.11.1':
> configure: error: cannot compile a simple Fortran program
> See `config.log' for more details.
> 
> For more details I can show you the section in the config.log file
> 
> ...
> /data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
> error while loading shared libraries: libmpc.so.2: cannot open shared object
> file: No such file or directory
> configure:22471: $? = 1
> configure: failed program was:
> |   program main
> | 
> |   end
> configure:22548: WARNING: compilation failed
> configure:22554: result: 
> configure:22556: checking for Fortran 77 libraries of gfortran
> configure:22579: gfortran -o conftest -L/usr/local/lib64 conftest.f
> /data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
> error while loading shared libraries: libmpc.so.2: cannot open shared object
> file: No such file or directory
> ...
> 
> When I check the version of Gfortran at the console command line I get this:
> GNU Fortran (GCC) 4.6.0 20100407 (experimental) [trunk revision 158083]
> Copyright (C) 2010 Free Software Foundation, Inc.
> 
> Even before this I tried the g95 fortran compiler and the same thing
> happened, how can I fix this problem, any help on this matter would be
> greatly appreciated.
> 
> 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] why the dim gave me different results

2010-06-02 Thread RICHARD M. HEIBERGER
This is a guess since you didn't say where it comes from.
It looks like a data.frame where some rows were deleted.
Also, note that the column names in your example are sorted alphabetically
instead of numerically.  This example shows one way to get that behavior.

Rich


> tmp <- data.frame(matrix(1:24, 6, 4, dimnames=list(1:6, c(1,2,11,12
> tmp
  X1 X2 X11 X12
1  1  7  13  19
2  2  8  14  20
3  3  9  15  21
4  4 10  16  22
5  5 11  17  23
6  6 12  18  24
> dimnames(tmp)[[2]] <- sort(dimnames(tmp)[[2]])
> tmp
  X1 X11 X12 X2
1  1   7  13 19
2  2   8  14 20
3  3   9  15 21
4  4  10  16 22
5  5  11  17 23
6  6  12  18 24
> tmp[c(2,5,3),]
  X1 X11 X12 X2
2  2   8  14 20
5  5  11  17 23
3  3   9  15 21
>
On Wed, Jun 2, 2010 at 5:47 PM, Changbin Du  wrote:

> > dim(tmp)
> [1] 576  12
> > tmp
>
>   1 10 11 12 13  2  3  4  5  6  7  9
>  10  0  0  0  0  0  0 12  0  0  0  0
>  20  0  0  0  0  0  0 15  0  0  0  0
>

[[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] why the dim gave me different results

2010-06-02 Thread Murat Tasan
row names are not the same as line numbers or indices.
you've likely done some row-based selection on an original matrix or
data frame.
observe from the example below.
(and in the future please don't expect people to sort through your
500+ line matrices by hand to find your problems.)

> x <- matrix(1:12, byrow = TRUE, ncol = 3)
> rownames(x) <- 1:4
> x
  [,1] [,2] [,3]
1123
2456
3789
4   10   11   12
> y <- x[x[,2] != 5,]
> y
  [,1] [,2] [,3]
1123
3789
4   10   11   12
> dim(x)
[1] 4 3
> dim(y)
[1] 3 3

-murat


On Jun 2, 5:47 pm, Changbin Du  wrote:
> > dim(tmp)
> [1] 576  12
> > tmp
>
>        1 10 11 12 13  2  3  4  5  6  7  9
>   1    0  0  0  0  0  0  0 12  0  0  0  0
>   2    0  0  0  0  0  0  0 15  0  0  0  0
>   3    0  0  0  0  0  0  0 11  0  0  0  0
>   4    0  0  0  0  0  0  0 11  0  0  0  0
>   5    0  0  0  0  0  0  0 12  0  0  0  0
>   6    0  0  0  0  0  0  0  6  0  0  0  0
>   7    0  0  0  0  0  0  0  5  0  0  0  0
>   8    0  0  0  0  0  0  0 11  0  0  0  0
>   9    0  0  0  0  0  0  0 11  0  0  0  0
>   10   0  0  0  0  0  0  0  5  0  0  0  0
>   11   0  0  0  0  0  0  0  8  0  0  0  0
>   12   0  0  0  0  0  0  0 12  0  0  0  0
>   13   0  0  0  0  0  0  0  6  0  0  0  0
>   14   0  0  0  0  0  0  0  5  0  0  0  0
>   15   0  0  0  0  0  0  0  5  0  0  0  0
>   16   0  0  0  0  0  0  0  6  0  0  0  0
>   17   0  0  0  0  0  0  0  0  0  0  9  0
>   18   0  0  0  0  0  0  0 13  0  0  0  0
>   19   0  0  0  0  0  0  0  7  0  0  0  0
>   20   0  0  0  0  0  0  0 10  0  0  0  0
>   21   0  0  0  0  0  0  0 13  0  0  0  0
>   22   0  0  0  0  0  0  0 17  0  0  0  0
>   23   0  0  0  0  0  0  0 13  0  0  0  0
>   24   0  0  0  0  0  0  0  5  0  0  0  0
>   25   0  0  0  0  0  0  0  4  0  0  0  0
>   26   0  0  0  0  0  0  0 10  0  0  0  0
>   27   0  0  0  0  0  0  0  8  0  0  0  0
>   28   0  0  0  0  0  0  0 11  0  0  0  0
>   29   0  0  0  0  0  0  0 13  0  0  0  0
>   30   0  0  0  0  0  0  0  7  0  0  0  0
>   31   0  0  0  0  0  0  0  8  0  0  0  0
>   32   0  0  0  0  0  0  0 14  0  0  0  0
>   33   0  0  0  0  0  0  0  7  0  0  0  0
>   34   0  0  0  0  0  0  0  6  0  0  0  0
>   35   0  0  0  0  0  0  0  6  0  0  0  0
>   36   0  0  0  0  0  0  0  8  0  0  0  0
>   37   0  0  0  0  0  0  0 12  0  0  0  0
>   38   0  0  0  0  0  0  0 10  0  0  0  0
>   39   0  0  0  0  0  0  0 10  0  0  0  0
>   40   0  0  0  0  0  0  0  0  0  0 14  0
>   41   0  0  0  0  0  0  0  9  0  0  0  0
>   42   0  0  0  0  0  0  0  7  0  0  0  0
>   43   0  0  0  0  0  0  0  5  0  0  0  0
>   44   0  0  0  0  0  0  0 14  0  0  0  0
>   45   0  0  0  0  0  0  0  6  0  0  0  0
>   46   0  0  0  0  0  0  0  0  0  0  3  0
>   47   0  0  0  0  0  0  0  8  0  0  0  0
>   48   0  0  0  0  0  0  0  9  0  0  0  0
>   49   0  0  0  0  0  0  0  8  0  0  0  0
>   50   0  0  0  0  0  0  0  7  0  0  0  0
>   51   0  0  0  0  0  0  0 13  0  0  0  0
>   52   0  0  0  0  0  0  0 13  0  0  0  0
>   53   0  0  0  0  0  0  0  7  0  0  0  0
>   54   0  0  0  0  0  0  0  8  0  0  0  0
>   55   0  0  0  0  0  0  0  7  0  0  0  0
>   56   0  0  0  0  0  0  0  4  0  0  0  0
>   57   0  0  0  0  0  0  0  8  0  0  0  0
>   58   0  0  0  0  0  0  0 13  0  0  0  0
>   59   0  0  0  0  0  0  0 12  0  0  0  0
>   60   0  0  0  0  0  0  0  7  0  0  0  0
>   61   0  0  0  0  0  0  0  7  0  0  0  0
>   62   0  0  0  0  0  0  0  9  0  0  0  0
>   63   0  0  0  0  0  0  0 13  0  0  0  0
>   64   0  0  0  0  0  0  0  8  0  0  0  0
>   65   0  0  0  0  0  0  0  1  0  0  0  0
>   66   0  0  0  0  0  0  0  9  0  0  0  0
>   67   0  0  0  0  0  0  0  8  0  0  0  0
>   68   0  0  0  0  0  0  0 11  0  0  0  0
>   69   0  0  0  0  0  0  0  7  0  0  0  0
>   70   0  0  0  0  0  0  0 11  0  0  0  0
>   71   0  0  0  0  0  0  0  8  0  0  0  0
>   72   0  0  0  0  0  0  0  6  0  0  0  0
>   73   0  0  0  0  0  0  0 13  0  0  0  0
>   74   0  0  0  0  0  0  0  7  0  0  0  0
>   75   0  0  0  0  0  0  0  7  0  0  0  0
>   76   0  0  0  0  0  0  0  6  0  0  0  0
>   77   0  0  0  0  0  0  0  7  0  0  0  0
>   79   0  0  0  0  0  0  0 12  0  0  0  0
>   80   0  0  0  0  0  0  0  0  0  0 10  0
>   81   0  0  0  0  0  0  0  9  0  0  0  0
>   82   0  0  0  0  0  0  0  9  0  0  0  0
>   83   0  0  0  0  0  0  0  9  0  0  0  0
>   85   0  0  0  0  0  0  0  7  0  0  0  0
>   86   0  0  0  0  0  0  0  7  0  0  0  0
>   87   0  0  0  0  0  0  0 11  0  0  0  0
>   88   0  0  0  0  0  0  0  0  0  0  4  0
>   89   0  0  0  0  0  0  0  8  0  0  0  0
>   90   0  0  0  0  0  0  0  6  0  0  0  0
>   91   0  0  0  0  0  0  0 15  0  0  0  0
>   92   0  0  0  0  0  0  0  7  0  0  0  0
>   93   0  0  0  0  0  0  0  6  0  0  0  0
>   94   0  0  0  0  0  0  0  7  0  0  0  0
>   95   0  0  0  0  0  0  0  8  0  0  0  0
>   96   0  0  0  0  0  0  0  3  0  0  0  0
>   97   0  0  0  0  0  0  0  5  0  0  0  0
>   98   0  0  0  0  0  0  0  0  0  0  5  0
>   99   0  0  0  0  0  0  0 15  0  0  0  0
>   100  0  0  0  0  0  0  0 15 

Re: [R] why the dim gave me different results

2010-06-02 Thread Phil Spector

Changbin -
   If you take the time to look at your data frame,
you'll see the following 24 numbers are missing
from the rownames.

78  84 107 108 109 158 164 194 197 203 240 241 
243 255 256 264 275 277 282 284 300 305 311 312


(I found this using

   (1:600)[!(1:600) %in% rownames(tmp)]
)
- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Wed, 2 Jun 2010, Changbin Du wrote:


dim(tmp)

[1] 576  12

tmp


  1 10 11 12 13  2  3  4  5  6  7  9
 10  0  0  0  0  0  0 12  0  0  0  0
 20  0  0  0  0  0  0 15  0  0  0  0
 30  0  0  0  0  0  0 11  0  0  0  0
 40  0  0  0  0  0  0 11  0  0  0  0
 50  0  0  0  0  0  0 12  0  0  0  0
 60  0  0  0  0  0  0  6  0  0  0  0
 70  0  0  0  0  0  0  5  0  0  0  0
 80  0  0  0  0  0  0 11  0  0  0  0
 90  0  0  0  0  0  0 11  0  0  0  0
 10   0  0  0  0  0  0  0  5  0  0  0  0
 11   0  0  0  0  0  0  0  8  0  0  0  0
 12   0  0  0  0  0  0  0 12  0  0  0  0
 13   0  0  0  0  0  0  0  6  0  0  0  0
 14   0  0  0  0  0  0  0  5  0  0  0  0
 15   0  0  0  0  0  0  0  5  0  0  0  0
 16   0  0  0  0  0  0  0  6  0  0  0  0
 17   0  0  0  0  0  0  0  0  0  0  9  0
 18   0  0  0  0  0  0  0 13  0  0  0  0
 19   0  0  0  0  0  0  0  7  0  0  0  0
 20   0  0  0  0  0  0  0 10  0  0  0  0
 21   0  0  0  0  0  0  0 13  0  0  0  0
 22   0  0  0  0  0  0  0 17  0  0  0  0
 23   0  0  0  0  0  0  0 13  0  0  0  0
 24   0  0  0  0  0  0  0  5  0  0  0  0
 25   0  0  0  0  0  0  0  4  0  0  0  0
 26   0  0  0  0  0  0  0 10  0  0  0  0
 27   0  0  0  0  0  0  0  8  0  0  0  0
 28   0  0  0  0  0  0  0 11  0  0  0  0
 29   0  0  0  0  0  0  0 13  0  0  0  0
 30   0  0  0  0  0  0  0  7  0  0  0  0
 31   0  0  0  0  0  0  0  8  0  0  0  0
 32   0  0  0  0  0  0  0 14  0  0  0  0
 33   0  0  0  0  0  0  0  7  0  0  0  0
 34   0  0  0  0  0  0  0  6  0  0  0  0
 35   0  0  0  0  0  0  0  6  0  0  0  0
 36   0  0  0  0  0  0  0  8  0  0  0  0
 37   0  0  0  0  0  0  0 12  0  0  0  0
 38   0  0  0  0  0  0  0 10  0  0  0  0
 39   0  0  0  0  0  0  0 10  0  0  0  0
 40   0  0  0  0  0  0  0  0  0  0 14  0
 41   0  0  0  0  0  0  0  9  0  0  0  0
 42   0  0  0  0  0  0  0  7  0  0  0  0
 43   0  0  0  0  0  0  0  5  0  0  0  0
 44   0  0  0  0  0  0  0 14  0  0  0  0
 45   0  0  0  0  0  0  0  6  0  0  0  0
 46   0  0  0  0  0  0  0  0  0  0  3  0
 47   0  0  0  0  0  0  0  8  0  0  0  0
 48   0  0  0  0  0  0  0  9  0  0  0  0
 49   0  0  0  0  0  0  0  8  0  0  0  0
 50   0  0  0  0  0  0  0  7  0  0  0  0
 51   0  0  0  0  0  0  0 13  0  0  0  0
 52   0  0  0  0  0  0  0 13  0  0  0  0
 53   0  0  0  0  0  0  0  7  0  0  0  0
 54   0  0  0  0  0  0  0  8  0  0  0  0
 55   0  0  0  0  0  0  0  7  0  0  0  0
 56   0  0  0  0  0  0  0  4  0  0  0  0
 57   0  0  0  0  0  0  0  8  0  0  0  0
 58   0  0  0  0  0  0  0 13  0  0  0  0
 59   0  0  0  0  0  0  0 12  0  0  0  0
 60   0  0  0  0  0  0  0  7  0  0  0  0
 61   0  0  0  0  0  0  0  7  0  0  0  0
 62   0  0  0  0  0  0  0  9  0  0  0  0
 63   0  0  0  0  0  0  0 13  0  0  0  0
 64   0  0  0  0  0  0  0  8  0  0  0  0
 65   0  0  0  0  0  0  0  1  0  0  0  0
 66   0  0  0  0  0  0  0  9  0  0  0  0
 67   0  0  0  0  0  0  0  8  0  0  0  0
 68   0  0  0  0  0  0  0 11  0  0  0  0
 69   0  0  0  0  0  0  0  7  0  0  0  0
 70   0  0  0  0  0  0  0 11  0  0  0  0
 71   0  0  0  0  0  0  0  8  0  0  0  0
 72   0  0  0  0  0  0  0  6  0  0  0  0
 73   0  0  0  0  0  0  0 13  0  0  0  0
 74   0  0  0  0  0  0  0  7  0  0  0  0
 75   0  0  0  0  0  0  0  7  0  0  0  0
 76   0  0  0  0  0  0  0  6  0  0  0  0
 77   0  0  0  0  0  0  0  7  0  0  0  0
 79   0  0  0  0  0  0  0 12  0  0  0  0
 80   0  0  0  0  0  0  0  0  0  0 10  0
 81   0  0  0  0  0  0  0  9  0  0  0  0
 82   0  0  0  0  0  0  0  9  0  0  0  0
 83   0  0  0  0  0  0  0  9  0  0  0  0
 85   0  0  0  0  0  0  0  7  0  0  0  0
 86   0  0  0  0  0  0  0  7  0  0  0  0
 87   0  0  0  0  0  0  0 11  0  0  0  0
 88   0  0  0  0  0  0  0  0  0  0  4  0
 89   0  0  0  0  0  0  0  8  0  0  0  0
 90   0  0  0  0  0  0  0  6  0  0  0  0
 91   0  0  0  0  0  0  0 15  0  0  0  0
 92   0  0  0  0  0  0  0  7  0  0  0  0
 93   0  0  0  0  0  0  0  6  0  0  0  0
 94   0  0  0  0  0  0  0  7  0  0  0  0
 95   0  0  0  0  0  0  0  8  0  0  0  0
 96   0  0  0  0  0  0  0  3  0  0  0  0
 97   0  0  0  0  0  0  0  5  0  0  0  0
 98   0  0  0  0  0  0  0  0  0  0  5  0
 99   0  0  0  0  0  0  0 15  0  0  0  0
 100  0  0  0  0  0  0  0 15  0  0  0  0
 101  0  0  0  0  0  0  0 17  0  0  0  0
 102  0  0  0  0  0  0  0  5  0  0  0  0
 103  0  0  0  0  0  0  0  4  0  0  0  0
 104  0  0  0  0  0  0  0  8  0  0  0  0
 105  0  0  0  0  0  0  0  8  0  0  0  0
 106  0  0  0  0  0  0  0  6  0  0  0  0
 110  0  0  0  0

Re: [R] why the dim gave me different results

2010-06-02 Thread Joris Meys
Hi Changbin,

it's not line numbers. It's row names, and you deleted some of them. If you
checked, you'd have seen that eg 107-109 are missing. So you have 576 lines
left from a matrix that had 600 when it was formed.

Cheers
Joris

On Wed, Jun 2, 2010 at 11:47 PM, Changbin Du  wrote:

> > dim(tmp)
> [1] 576  12
> > tmp
>
>   1 10 11 12 13  2  3  4  5  6  7  9
>  10  0  0  0  0  0  0 12  0  0  0  0
>  20  0  0  0  0  0  0 15  0  0  0  0
>  30  0  0  0  0  0  0 11  0  0  0  0
>  40  0  0  0  0  0  0 11  0  0  0  0
>  50  0  0  0  0  0  0 12  0  0  0  0
>  60  0  0  0  0  0  0  6  0  0  0  0
>  70  0  0  0  0  0  0  5  0  0  0  0
>  80  0  0  0  0  0  0 11  0  0  0  0
>  90  0  0  0  0  0  0 11  0  0  0  0
>  10   0  0  0  0  0  0  0  5  0  0  0  0
>  11   0  0  0  0  0  0  0  8  0  0  0  0
>  12   0  0  0  0  0  0  0 12  0  0  0  0
>  13   0  0  0  0  0  0  0  6  0  0  0  0
>  14   0  0  0  0  0  0  0  5  0  0  0  0
>  15   0  0  0  0  0  0  0  5  0  0  0  0
>  16   0  0  0  0  0  0  0  6  0  0  0  0
>  17   0  0  0  0  0  0  0  0  0  0  9  0
>  18   0  0  0  0  0  0  0 13  0  0  0  0
>  19   0  0  0  0  0  0  0  7  0  0  0  0
>  20   0  0  0  0  0  0  0 10  0  0  0  0
>  21   0  0  0  0  0  0  0 13  0  0  0  0
>  22   0  0  0  0  0  0  0 17  0  0  0  0
>  23   0  0  0  0  0  0  0 13  0  0  0  0
>  24   0  0  0  0  0  0  0  5  0  0  0  0
>  25   0  0  0  0  0  0  0  4  0  0  0  0
>  26   0  0  0  0  0  0  0 10  0  0  0  0
>  27   0  0  0  0  0  0  0  8  0  0  0  0
>  28   0  0  0  0  0  0  0 11  0  0  0  0
>  29   0  0  0  0  0  0  0 13  0  0  0  0
>  30   0  0  0  0  0  0  0  7  0  0  0  0
>  31   0  0  0  0  0  0  0  8  0  0  0  0
>  32   0  0  0  0  0  0  0 14  0  0  0  0
>  33   0  0  0  0  0  0  0  7  0  0  0  0
>  34   0  0  0  0  0  0  0  6  0  0  0  0
>  35   0  0  0  0  0  0  0  6  0  0  0  0
>  36   0  0  0  0  0  0  0  8  0  0  0  0
>  37   0  0  0  0  0  0  0 12  0  0  0  0
>  38   0  0  0  0  0  0  0 10  0  0  0  0
>  39   0  0  0  0  0  0  0 10  0  0  0  0
>  40   0  0  0  0  0  0  0  0  0  0 14  0
>  41   0  0  0  0  0  0  0  9  0  0  0  0
>  42   0  0  0  0  0  0  0  7  0  0  0  0
>  43   0  0  0  0  0  0  0  5  0  0  0  0
>  44   0  0  0  0  0  0  0 14  0  0  0  0
>  45   0  0  0  0  0  0  0  6  0  0  0  0
>  46   0  0  0  0  0  0  0  0  0  0  3  0
>  47   0  0  0  0  0  0  0  8  0  0  0  0
>  48   0  0  0  0  0  0  0  9  0  0  0  0
>  49   0  0  0  0  0  0  0  8  0  0  0  0
>  50   0  0  0  0  0  0  0  7  0  0  0  0
>  51   0  0  0  0  0  0  0 13  0  0  0  0
>  52   0  0  0  0  0  0  0 13  0  0  0  0
>  53   0  0  0  0  0  0  0  7  0  0  0  0
>  54   0  0  0  0  0  0  0  8  0  0  0  0
>  55   0  0  0  0  0  0  0  7  0  0  0  0
>  56   0  0  0  0  0  0  0  4  0  0  0  0
>  57   0  0  0  0  0  0  0  8  0  0  0  0
>  58   0  0  0  0  0  0  0 13  0  0  0  0
>  59   0  0  0  0  0  0  0 12  0  0  0  0
>  60   0  0  0  0  0  0  0  7  0  0  0  0
>  61   0  0  0  0  0  0  0  7  0  0  0  0
>  62   0  0  0  0  0  0  0  9  0  0  0  0
>  63   0  0  0  0  0  0  0 13  0  0  0  0
>  64   0  0  0  0  0  0  0  8  0  0  0  0
>  65   0  0  0  0  0  0  0  1  0  0  0  0
>  66   0  0  0  0  0  0  0  9  0  0  0  0
>  67   0  0  0  0  0  0  0  8  0  0  0  0
>  68   0  0  0  0  0  0  0 11  0  0  0  0
>  69   0  0  0  0  0  0  0  7  0  0  0  0
>  70   0  0  0  0  0  0  0 11  0  0  0  0
>  71   0  0  0  0  0  0  0  8  0  0  0  0
>  72   0  0  0  0  0  0  0  6  0  0  0  0
>  73   0  0  0  0  0  0  0 13  0  0  0  0
>  74   0  0  0  0  0  0  0  7  0  0  0  0
>  75   0  0  0  0  0  0  0  7  0  0  0  0
>  76   0  0  0  0  0  0  0  6  0  0  0  0
>  77   0  0  0  0  0  0  0  7  0  0  0  0
>  79   0  0  0  0  0  0  0 12  0  0  0  0
>  80   0  0  0  0  0  0  0  0  0  0 10  0
>  81   0  0  0  0  0  0  0  9  0  0  0  0
>  82   0  0  0  0  0  0  0  9  0  0  0  0
>  83   0  0  0  0  0  0  0  9  0  0  0  0
>  85   0  0  0  0  0  0  0  7  0  0  0  0
>  86   0  0  0  0  0  0  0  7  0  0  0  0
>  87   0  0  0  0  0  0  0 11  0  0  0  0
>  88   0  0  0  0  0  0  0  0  0  0  4  0
>  89   0  0  0  0  0  0  0  8  0  0  0  0
>  90   0  0  0  0  0  0  0  6  0  0  0  0
>  91   0  0  0  0  0  0  0 15  0  0  0  0
>  92   0  0  0  0  0  0  0  7  0  0  0  0
>  93   0  0  0  0  0  0  0  6  0  0  0  0
>  94   0  0  0  0  0  0  0  7  0  0  0  0
>  95   0  0  0  0  0  0  0  8  0  0  0  0
>  96   0  0  0  0  0  0  0  3  0  0  0  0
>  97   0  0  0  0  0  0  0  5  0  0  0  0
>  98   0  0  0  0  0  0  0  0  0  0  5  0
>  99   0  0  0  0  0  0  0 15  0  0  0  0
>  100  0  0  0  0  0  0  0 15  0  0  0  0
>  101  0  0  0  0  0  0  0 17  0  0  0  0
>  102  0  0  0  0  0  0  0  5  0  0  0  0
>  103  0  0  0  0  0  0  0  4  0  0  0  0
>  104  0  0  0  0  0  0  0  8  0  0  0  0
>  105  0  0  0  0  0  0  0  8  0  0  0  0
>  106  0  0  0  0  0  0  0  6  0  0  0  0
>  110  0  0  0  0  0  0  0  6  0  0  0  0
>  111  0  0  0  0  0  0  0  6  0  0  0  0
>  112  0  0  0  0  0  0  0  5  0  0  0  0
>  113  0  0  0  0  0  0  0  8 

[R] why the dim gave me different results

2010-06-02 Thread Changbin Du
> dim(tmp)
[1] 576  12
> tmp

   1 10 11 12 13  2  3  4  5  6  7  9
  10  0  0  0  0  0  0 12  0  0  0  0
  20  0  0  0  0  0  0 15  0  0  0  0
  30  0  0  0  0  0  0 11  0  0  0  0
  40  0  0  0  0  0  0 11  0  0  0  0
  50  0  0  0  0  0  0 12  0  0  0  0
  60  0  0  0  0  0  0  6  0  0  0  0
  70  0  0  0  0  0  0  5  0  0  0  0
  80  0  0  0  0  0  0 11  0  0  0  0
  90  0  0  0  0  0  0 11  0  0  0  0
  10   0  0  0  0  0  0  0  5  0  0  0  0
  11   0  0  0  0  0  0  0  8  0  0  0  0
  12   0  0  0  0  0  0  0 12  0  0  0  0
  13   0  0  0  0  0  0  0  6  0  0  0  0
  14   0  0  0  0  0  0  0  5  0  0  0  0
  15   0  0  0  0  0  0  0  5  0  0  0  0
  16   0  0  0  0  0  0  0  6  0  0  0  0
  17   0  0  0  0  0  0  0  0  0  0  9  0
  18   0  0  0  0  0  0  0 13  0  0  0  0
  19   0  0  0  0  0  0  0  7  0  0  0  0
  20   0  0  0  0  0  0  0 10  0  0  0  0
  21   0  0  0  0  0  0  0 13  0  0  0  0
  22   0  0  0  0  0  0  0 17  0  0  0  0
  23   0  0  0  0  0  0  0 13  0  0  0  0
  24   0  0  0  0  0  0  0  5  0  0  0  0
  25   0  0  0  0  0  0  0  4  0  0  0  0
  26   0  0  0  0  0  0  0 10  0  0  0  0
  27   0  0  0  0  0  0  0  8  0  0  0  0
  28   0  0  0  0  0  0  0 11  0  0  0  0
  29   0  0  0  0  0  0  0 13  0  0  0  0
  30   0  0  0  0  0  0  0  7  0  0  0  0
  31   0  0  0  0  0  0  0  8  0  0  0  0
  32   0  0  0  0  0  0  0 14  0  0  0  0
  33   0  0  0  0  0  0  0  7  0  0  0  0
  34   0  0  0  0  0  0  0  6  0  0  0  0
  35   0  0  0  0  0  0  0  6  0  0  0  0
  36   0  0  0  0  0  0  0  8  0  0  0  0
  37   0  0  0  0  0  0  0 12  0  0  0  0
  38   0  0  0  0  0  0  0 10  0  0  0  0
  39   0  0  0  0  0  0  0 10  0  0  0  0
  40   0  0  0  0  0  0  0  0  0  0 14  0
  41   0  0  0  0  0  0  0  9  0  0  0  0
  42   0  0  0  0  0  0  0  7  0  0  0  0
  43   0  0  0  0  0  0  0  5  0  0  0  0
  44   0  0  0  0  0  0  0 14  0  0  0  0
  45   0  0  0  0  0  0  0  6  0  0  0  0
  46   0  0  0  0  0  0  0  0  0  0  3  0
  47   0  0  0  0  0  0  0  8  0  0  0  0
  48   0  0  0  0  0  0  0  9  0  0  0  0
  49   0  0  0  0  0  0  0  8  0  0  0  0
  50   0  0  0  0  0  0  0  7  0  0  0  0
  51   0  0  0  0  0  0  0 13  0  0  0  0
  52   0  0  0  0  0  0  0 13  0  0  0  0
  53   0  0  0  0  0  0  0  7  0  0  0  0
  54   0  0  0  0  0  0  0  8  0  0  0  0
  55   0  0  0  0  0  0  0  7  0  0  0  0
  56   0  0  0  0  0  0  0  4  0  0  0  0
  57   0  0  0  0  0  0  0  8  0  0  0  0
  58   0  0  0  0  0  0  0 13  0  0  0  0
  59   0  0  0  0  0  0  0 12  0  0  0  0
  60   0  0  0  0  0  0  0  7  0  0  0  0
  61   0  0  0  0  0  0  0  7  0  0  0  0
  62   0  0  0  0  0  0  0  9  0  0  0  0
  63   0  0  0  0  0  0  0 13  0  0  0  0
  64   0  0  0  0  0  0  0  8  0  0  0  0
  65   0  0  0  0  0  0  0  1  0  0  0  0
  66   0  0  0  0  0  0  0  9  0  0  0  0
  67   0  0  0  0  0  0  0  8  0  0  0  0
  68   0  0  0  0  0  0  0 11  0  0  0  0
  69   0  0  0  0  0  0  0  7  0  0  0  0
  70   0  0  0  0  0  0  0 11  0  0  0  0
  71   0  0  0  0  0  0  0  8  0  0  0  0
  72   0  0  0  0  0  0  0  6  0  0  0  0
  73   0  0  0  0  0  0  0 13  0  0  0  0
  74   0  0  0  0  0  0  0  7  0  0  0  0
  75   0  0  0  0  0  0  0  7  0  0  0  0
  76   0  0  0  0  0  0  0  6  0  0  0  0
  77   0  0  0  0  0  0  0  7  0  0  0  0
  79   0  0  0  0  0  0  0 12  0  0  0  0
  80   0  0  0  0  0  0  0  0  0  0 10  0
  81   0  0  0  0  0  0  0  9  0  0  0  0
  82   0  0  0  0  0  0  0  9  0  0  0  0
  83   0  0  0  0  0  0  0  9  0  0  0  0
  85   0  0  0  0  0  0  0  7  0  0  0  0
  86   0  0  0  0  0  0  0  7  0  0  0  0
  87   0  0  0  0  0  0  0 11  0  0  0  0
  88   0  0  0  0  0  0  0  0  0  0  4  0
  89   0  0  0  0  0  0  0  8  0  0  0  0
  90   0  0  0  0  0  0  0  6  0  0  0  0
  91   0  0  0  0  0  0  0 15  0  0  0  0
  92   0  0  0  0  0  0  0  7  0  0  0  0
  93   0  0  0  0  0  0  0  6  0  0  0  0
  94   0  0  0  0  0  0  0  7  0  0  0  0
  95   0  0  0  0  0  0  0  8  0  0  0  0
  96   0  0  0  0  0  0  0  3  0  0  0  0
  97   0  0  0  0  0  0  0  5  0  0  0  0
  98   0  0  0  0  0  0  0  0  0  0  5  0
  99   0  0  0  0  0  0  0 15  0  0  0  0
  100  0  0  0  0  0  0  0 15  0  0  0  0
  101  0  0  0  0  0  0  0 17  0  0  0  0
  102  0  0  0  0  0  0  0  5  0  0  0  0
  103  0  0  0  0  0  0  0  4  0  0  0  0
  104  0  0  0  0  0  0  0  8  0  0  0  0
  105  0  0  0  0  0  0  0  8  0  0  0  0
  106  0  0  0  0  0  0  0  6  0  0  0  0
  110  0  0  0  0  0  0  0  6  0  0  0  0
  111  0  0  0  0  0  0  0  6  0  0  0  0
  112  0  0  0  0  0  0  0  5  0  0  0  0
  113  0  0  0  0  0  0  0  8  0  0  0  0
  114  0  0  0  0  0  0  0  4  0  0  0  0
  115  0  0  0  0  0  0  0 11  0  0  0  0
  116  0  0  0  0  0  0  0  6  0  0  0  0
  117  0  0  0  0  0  0  0  5  0  0  0  0
  118  0  0  0  0  0  0  0  3  0  0  0  0
  119  0  0  0  0  0  0  0  0  0  0 10  0
  120  0  0  0  0  0  0  0  0  0  0  6  0
  121  0  0  0  0  0  0  0  8  0  0  0  0
  122  0  0  0  0  0  0  0  5  0  0  0  0
  123  0  0  

Re: [R] pdf function, resize xyplot plot automatically

2010-06-02 Thread Peter Ehlers

David,

I would use either the 'width=' argument to pdf() or
use a smaller font for the x-axis (or both).
Something like:

 pdf(file = "foo.pdf", width = 10)
 xyplot(Y ~ Time | as.factor(Subject), data = foo.frm,
layout = c(2,2),
scale = list(x = list(
 at = c(0, 15, 30, 45, 60, 90, 150, 210, 270),
 cex = 0.7)))
 dev.off()

  -Peter Ehlers

On 2010-06-02 12:34, Afshartous, David wrote:


All,

When saving plots to a pdf file via the pdf function, I would like to be
able to automatically expand the graphics device to achieve the same result
as when one does this manually (e.g., clicking the green expand button on
the upper left of the graph on Mac OS).   Consider simple example below:


library("lattice")
foo.frm = data.frame(Subject = rep(c(1:4), each = 9), Y = rnorm(36), Time =
rep(c( 0, 15, 30, 45, 60, 90, 150, 210, 270), 4))
xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x =
list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270

The tick marks are very close but this is resolved by expanding the graphics
device as mentioned above.   However, in the code below the file that is
created by the pdf function is created w/o such an adjustment.  I suppose
one could work around this via changing the number of tick marks, but if
there was a way to automatically achieve the expansion of the graph as when
done manually that would be great.  Any tips much appreciated.


pdf(file = "foo.pdf", onefile = T)
xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x =
list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270
dev.off()


Thanks,
David

--
David Afshartous, Ph.D.
Research Assistant Professor
University of Miami, Miller School of Medicine
Division of Clinical Pharmacology
1500 N.W. 12th Avenue, 15th Floor West
Miami, Florida 33136

E-mail: afs...@med.miami.edu
Phone: +1 305-243-1549



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 linux install: FORTRAN compiling error

2010-06-02 Thread vaneet

Hello,

I have basic familiarity with Unix but by most standards a novice.  I am
trying to install R on a linux machine and am following the instructions in
the R install and admin guide in terms of what is required to compile the R
source code.  I downloaded R version 2.11.1 and extracted the files into my
home directory.  I realize I need a FORTRAN compiler to help with this
process and have tried installing a few but still cannot past the
configuration step of installing R:

./configure --with-readline=no

Once I run this command after installing GFortran I get the following error:
...
checking whether we can compute C Make dependencies... yes, using gcc
-std=gnu99 -MM
checking whether gcc -std=gnu99 supports -c -o FILE.lo... yes
checking how to get verbose linking output from gfortran... configure:
WARNING: compilation failed

checking for Fortran 77 libraries of gfortran...
checking how to get verbose linking output from gcc -std=gnu99... -v
checking for C libraries of gcc -std=gnu99...  -L/usr/local/lib64
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2
-L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -lgcc_s
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... configure: error: in
`/home/lotayv01/R-2.11.1':
configure: error: cannot compile a simple Fortran program
See `config.log' for more details.

For more details I can show you the section in the config.log file

...
/data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
error while loading shared libraries: libmpc.so.2: cannot open shared object
file: No such file or directory
configure:22471: $? = 1
configure: failed program was:
|   program main
| 
|   end
configure:22548: WARNING: compilation failed
configure:22554: result: 
configure:22556: checking for Fortran 77 libraries of gfortran
configure:22579: gfortran -o conftest -L/usr/local/lib64 conftest.f
/data/home/lotayv01/usr/local/gfortran/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.0/f951:
error while loading shared libraries: libmpc.so.2: cannot open shared object
file: No such file or directory
...

When I check the version of Gfortran at the console command line I get this:
GNU Fortran (GCC) 4.6.0 20100407 (experimental) [trunk revision 158083]
Copyright (C) 2010 Free Software Foundation, Inc.

Even before this I tried the g95 fortran compiler and the same thing
happened, how can I fix this problem, any help on this matter would be
greatly appreciated.

Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-linux-install-FORTRAN-compiling-error-tp2240821p2240821.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] building time series/zoo/its from a data frame

2010-06-02 Thread Gabor Grothendieck
r-help seems to have rejected the first attempt at sending this so I
am trying again.

read.zoo has a split= argument which lets you read in the data and
split it all at the same time.  You can also use it on a data frame.
Due to a bug which is fixed in the development version, you will need
the development version of zoo which you can access as shown below.
First we show reading it in using read.zoo and splitting it at the
same time.  Next we assume its already been read in as a data frame in
which case we can also use read.zoo on a data.frame:

library(zoo)
source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/zoo/R/read.zoo.R?revision=717&root=zoo";)

Lines <- "datecond freq
1  04/01/09   Fever   12
2  04/02/09   Fever   11
3  04/03/09   Fever   10
4  04/04/09   Fever   13
5  04/05/09   Fever6
6  04/01/09Rash6
7  04/02/09Rash   10
8  04/03/09Rash9
9  04/04/09Rash   10
10 04/05/09Rash8
11 04/01/09 Respiratory   12
12 04/02/09 Respiratory9
13 04/03/09 Respiratory6
14 04/04/09 Respiratory   11
15 04/05/09 Respiratory   11"

# 1. reading it in and splitting at the same time
z <- read.zoo(textConnection(Lines), header = TRUE, split = "cond",
format = "%m/%d/%y")

# or, 2. if its already a data frame such as this one we can still use read.zoo
DF <- read.table(textConnection(Lines), header = TRUE)
z2 <- read.zoo(DF, split = 2, format = "%m/%d/%y")

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


Re: [R] glmnet strange error message

2010-06-02 Thread Joris Meys
Could you give us the traceback? (In case you don't know, just type
traceback() right after you got the error message.) I can't reproduce the
error, so it gets a bit difficult to solve without having the real data.

Cheers
Joris

On Wed, Jun 2, 2010 at 6:51 PM, Dave_F  wrote:

>
> Hello fellow R users,
>
> I have been getting a strange error message when using the cv.glmnet
> function in the glmnet package. I am attempting to fit a multinomial
> regression using the lasso. covars is a matrix with 80 rows and roughly
> 4000
> columns, all the covariates are binary. resp is an eight level factor. I
> can
> fit the model with no errors but when I try to cross-validate after about
> 30
> seconds I get the following:
>
>
> > glmnet.fit = glmnet(covars,resp,family="multinomial")
> > glmnet.cv = cv.glmnet(covars,resp,family="multinomial",type="class")
> Error in if (outlist$msg != "Unknown error") return(outlist) :
>  argument is of length zero
>
> It seems like it makes it through the first couple folds but trips up
> somewhere in the middle.
> The example in the documentation works perfectly on my machine. Any ideas
> on
> what the problem may be?
>
> Thanks!
> Dave
> --
> View this message in context:
> http://r.789695.n4.nabble.com/glmnet-strange-error-message-tp2240458p2240458.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

[[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] predict.Arima: warnings from xreg magic

2010-06-02 Thread Huber2010

I found the same annoying warning, but I ignore it, as you said it's not use
at all. The error (at least for me) is in the line

class(xreg) <- NULL

This makes xreg a list, so you cannot apply cbindmaybe they will fix
that some time in the future (you can always recompile the code)

Huber
-- 
View this message in context: 
http://r.789695.n4.nabble.com/predict-Arima-warnings-from-xreg-magic-tp1746944p2240731.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] nnet: cannot coerce class c("terms", "formula") into a data.frame

2010-06-02 Thread cobbler_squad

Dearest all,

Objective: I am now learning neural networks. I want to see how well can
train an artificial neural network model to discriminate between the two
files I am attaching with this message.

http://r.789695.n4.nabble.com/file/n2240582/3dMaskDump.txt 3dMaskDump.txt 
http://r.789695.n4.nabble.com/file/n2240582/test_vowels.txt test_vowels.txt 

Question: when I am attempting to run 
>cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100)
I get an error saying:
Error in as.data.frame.default(x[[i]], optional = TRUE) : 
  cannot coerce class c("terms", "formula") into a data.frame

I have not encountered this error when I was running this script with
previous lda results, and, I am not quite sure what the error means.

Below is short (and, I hope, reproducible) code. 

library(nnet)

cvc_nnet <- nnet(G ~ ., data=cvc_lda, size=1,iter=10,MaxNWts=100)

predict(cvc_nnet,cvc_lda,type = "class")
table(predict(cvc_nnet,cvc_lda,type = "class"),cvc_lda$G)

cvc_nnet.out<-NULL
all = c(1:52)

for(n in all){
  cvc_nnet <- nnet(G ~ ., data=cvc_lda[all != n,], CV
=TRUE,size=1,iter=10,MaxNWts=100)
   cvc_nnet.out <- c(cvc_nnet.out,predict(cvc_nnet,cvc_lda[all == n,],type =
"class"))
}

table(cvc_nnet.out,cvc_lda$G)

===

to get cvc_lda:

library(MASS)

vowel_features <- data.frame(as.matrix(read.table(file =
"test_vowels.txt")))
mask_features <- data.frame(as.matrix(read.table(file = "3dmaskdump.txt")))
G <-vowel_features[,41]

cvc_lda <- lda(G ~ ., data=mask_features, na.action="na.omit", CV=TRUE)


Your insight is very much appreciated it!

-- 
View this message in context: 
http://r.789695.n4.nabble.com/nnet-cannot-coerce-class-c-terms-formula-into-a-data-frame-tp2240582p2240582.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] Linear Discriminant Analysis in R

2010-06-02 Thread cobbler_squad

Joris,

Thank you, I have corrected my mistakes. I very much appreciate your time
and patience.

All my best,
Cobbler.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-Discriminant-Analysis-in-R-tp2231922p2240547.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] pdf function, resize xyplot plot automatically

2010-06-02 Thread Afshartous, David

All,

When saving plots to a pdf file via the pdf function, I would like to be
able to automatically expand the graphics device to achieve the same result
as when one does this manually (e.g., clicking the green expand button on
the upper left of the graph on Mac OS).   Consider simple example below:


library("lattice")
foo.frm = data.frame(Subject = rep(c(1:4), each = 9), Y = rnorm(36), Time =
rep(c( 0, 15, 30, 45, 60, 90, 150, 210, 270), 4))
xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x =
list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270

The tick marks are very close but this is resolved by expanding the graphics
device as mentioned above.   However, in the code below the file that is
created by the pdf function is created w/o such an adjustment.  I suppose
one could work around this via changing the number of tick marks, but if
there was a way to automatically achieve the expansion of the graph as when
done manually that would be great.  Any tips much appreciated.


pdf(file = "foo.pdf", onefile = T)
xyplot(Y ~ Time | as.factor(Subject), data = foo.frm, scale = list(x =
list(at = c(0, 15, 30, 45, 60, 90, 150, 210, 270
dev.off()


Thanks,
David

--
David Afshartous, Ph.D.
Research Assistant Professor
University of Miami, Miller School of Medicine
Division of Clinical Pharmacology
1500 N.W. 12th Avenue, 15th Floor West
Miami, Florida 33136

E-mail: afs...@med.miami.edu
Phone: +1 305-243-1549

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


Re: [R] help in expression( )

2010-06-02 Thread Uwe Ligges



On 02.06.2010 20:22, Shant Ch wrote:



Hi,
I was trying to have a graph whose axes are of the following type:

X axis: n and Y axis: var[U ((a,b) in suffix, and (n,d) in the power)].

U ((a,b) in suffix, and (n,d) in the power)-U^(n,d) _ (a,b).
Actually I require many plots involving different values of a,b,n,d, so need to 
keep this complicated notation.


The code I used:

plot(n, hn$h_pg,  ylab=expression(Var(U[2%,%1]^(n%,%0))-Var(U[1%,%1]^(n%,%0))), 
xlab="n",type="l");



  plot(1, 1, ylab = expression(var(U[list(a,b)]^(list(n,d,
   xlab = "n", type = "l")

or if you want to replace a, b, d, and n by values, use:

  a <- 1
  b <- 2
  d <- 3
  n <- 4

  plot(1, 1, ylab = substitute(var(U[list(a,b)]^(list(n,d))),
   list(a=a, b=b, d=d, n=n)),
   xlab = "n", type = "l")



The expression() didn't work out for this case. Can anyone help me out.

Also due to the size of the expression in the Y axis, I want to shift the graph 
in the R Graphics window, so that the Y labels are also fully visible. i don't 
know such command which will shift the whole graph a little in the  Graphics 
window.



Define other margins, see argument "mar" in ?par, e.g.

  par(mar=c(5,5,4,1)+.1)


Uwe Ligges



Thanks, in advance.
Shant




[[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] ESS (emacs speaks statistics) saving history

2010-06-02 Thread RICHARD M. HEIBERGER
I think you are asking for M-x ess-transcript-clean-buffer

Save your output file in a file named something.rt which will open
in ess-transcript-mode.  It opens read-only and you will need to C-x C-q
to make it writable.  Then run

M-x ess-transcript-clean-buffer


On Wed, Jun 2, 2010 at 2:35 PM, Murat Tasan  wrote:

> hi folks, i use ESS mode in emacs often to interact with R, and while
> i know how to save a session transcript, i'm wondering how to save
> just the history of the commands (i.e. identically to how R gives the
> history save option from its native CLI).
>
> if you use ESS with an R process, commands entered from a separate
> buffer and sent to the process do not get registered with the R
> history, and are thus not apparent when trying to save the history.
> and saving the full transcript can be tedious, as i don't need the
> output directly, but would like for others to be able to scroll
> through my series of commands.
>
> anyone else use ESS and have this problem, and maybe have a work-
> around?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Sweave glm.fit

2010-06-02 Thread Erik Iverson



Erik Iverson wrote:
How could we possibly tell without your code?  Do you call glm or fit 
*any* models in your code?  Can you use traceback() to see the trace of 
function calls that generated the error?




Sorry you aren't getting an error, but a warning, my mistake.

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

2010-06-02 Thread Erik Iverson
How could we possibly tell without your code?  Do you call glm or fit 
*any* models in your code?  Can you use traceback() to see the trace of 
function calls that generated the error?




Jimmy Söderly wrote:

Dear R users,

After running Sweave, this is what I get :

Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: algorithm did not converge
There is no glm.fit function in my code.

Where does it come from ? From Sweave ? From system.time ?

Thanks for your help,
Jimmy

[[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] ESS (emacs speaks statistics) saving history

2010-06-02 Thread Murat Tasan
hi folks, i use ESS mode in emacs often to interact with R, and while
i know how to save a session transcript, i'm wondering how to save
just the history of the commands (i.e. identically to how R gives the
history save option from its native CLI).

if you use ESS with an R process, commands entered from a separate
buffer and sent to the process do not get registered with the R
history, and are thus not apparent when trying to save the history.
and saving the full transcript can be tedious, as i don't need the
output directly, but would like for others to be able to scroll
through my series of commands.

anyone else use ESS and have this problem, and maybe have a work-
around?

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

2010-06-02 Thread Jimmy Söderly
Dear R users,

After running Sweave, this is what I get :

Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: algorithm did not converge
There is no glm.fit function in my code.

Where does it come from ? From Sweave ? From system.time ?

Thanks for your help,
Jimmy

[[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] using the design matrix to correctly configure contrasts

2010-06-02 Thread RICHARD M. HEIBERGER
Karl,

The definition and interpretation of contrasts is part of any intermediate
design of
experiments text.

Contrasts for interactions say that the effect of moving
"from level 1 of A to level 2 of A" depends on the level of B.
I will use notation YAB to indicate the levels of A and B.

For example, if

   (Y11 - Y21) differs from (Y12 - Y22)

we say that A and B have an interaction.  When A and B interact, then
the interpretation of "main effects" is ambiguous at best.  Instead,
we use the concept of simple effects, which, for example, are the
effects of changing levels of A while holding the levels of B
constant.

Interpreting the interactions themselves depends on knowing something
about the structure of the design, for example whether the effects (A
and B, here) are treatments, blocks, nested effects, or repeated
measures.

Simple effects are usually interpretable.  Interactions are tougher.

Rich
 

[[alternative HTML version deleted]]

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


[R] help in expression( )

2010-06-02 Thread Shant Ch


Hi, 
I was trying to have a graph whose axes are of the following type:

X axis: n and Y axis: var[U ((a,b) in suffix, and (n,d) in the power)]. 

U ((a,b) in suffix, and (n,d) in the power)-U^(n,d) _ (a,b).
Actually I require many plots involving different values of a,b,n,d, so need to 
keep this complicated notation. 


The code I used:

plot(n, hn$h_pg,  ylab=expression(Var(U[2%,%1]^(n%,%0))-Var(U[1%,%1]^(n%,%0))), 
xlab="n",type="l");

The expression() didn't work out for this case. Can anyone help me out. 

Also due to the size of the expression in the Y axis, I want to shift the graph 
in the R Graphics window, so that the Y labels are also fully visible. i don't 
know such command which will shift the whole graph a little in the  Graphics 
window.

Thanks, in advance.
Shant



  
[[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] Job Posting: Statistical Modeling and Advanced Analytics, Boston, All Levels

2010-06-02 Thread Iyue Sung
Position Profile:


This position will work directly with the head of the Advanced Analytics
group, as well as other members of the Marketing Evolution team, to
design and perform analytical research necessary to address client's
marketing issues.  Responsibilities include developing sophisticated
statistical models of marketing ROI, corresponding optimization
algorithms, as well as ad-hoc statistical analysis of primary and
secondary research data.  Depending on experience, additional
responsibilities include project management, design and implementation
of data collection efforts, methodological research and synthesis and
presentation of results.

Desired experience and qualifications:
-

* Ph.D. or Masters degree in
Statistics/Econometrics/Marketing/Operations Research or other related
quantitative fields 
* Expert knowledge of statistics/econometrics and hands on experience
applying various statistical techniques (e.g. choice models, multiple
types of regression modeling, segmentation, classification trees and
binary response model) 
* Expert knowledge of statistical packages such as SAS, SPSS and S+/R,
along with proven ability to rapidly acquire new analytics software and
programming skills 
* Persuasive and direct communication (both verbal and written) and
interpersonal skills 
* Business judgment and acumen with an ability to rapidly understand,
and then translate, customer business requirements into Marketing
Evolution solutions 
* A sense of urgency in executing work and the ability to multi-task 
* An ongoing desire to go beyond project-specific work, be creative, and
help originate Marketing Evolution's new business processes and product
roadmap path 
* Thirst for learning and long-term career growth and success

While media and/or marketing/customer analytics experience is certainly
a plus, more than anything we are looking for extremely smart,
intellectually curious, highly motivated team members that fit well
within our ethical, disciplined and fun team and working environment.

Compensation level will be competitive and commensurate with experience,
qualifications, and capabilities.  

Qualified individuals should submit a resume and cover letter to:
analyt...@marketingevolution.com


Company Overview


Marketing Evolution, founded in 2000, is a full service provider of
custom marketing ROI management and optimization solutions.  We help a
broad set of high profile clients more confidently and effectively
measure the impact of their marketing efforts, make marketing decisions,
meet business objectives, and improve marketing ROI through the use of
leading-edge market research, consulting services, and decision support
tools and systems.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] running admb from R using system()

2010-06-02 Thread Uwe Ligges



On 31.05.2010 10:31, Benedikt Gehr wrote:

Hi

I'm trying to run an admb model from R by using the system () command.
The admb model runs fine when running it from the admb command line or
when using emacs. However when I try it with system() then R crashes
every time.
And I tried using the R command line and RGui and in both it crashes. I
also tried it from different computers.

What I do is I first set the directory where I keep the admb template
file with the corresponding admb data file and then invoke the system
command either step by step or directly. I can build the model but when
executing the model.exe file R crashes.

##
setting the working directory
setwd("Documents and Settings\\Beni User\\Desktop\\Transfer\\Model
Fournier\\admb models\\simulated data\\stochastic\\pooled age classes")

building the model -> this works fine
system('makeadm stocpool')

running the model -> makes R crash
system('stoc.exe')


Since this is Windows, it might help to run from a Windows comand shell, 
hence try


shell('stoc.exe')

If its still fails: Is this R-2.11.1? If not, pealse update and try again.

Uwe Ligges



###
or directly lie this:
setwd("Documents and Settings\\Beni User\\Desktop\\Transfer\\Model
Fournier\\admb models\\simulated data\\stochastic\\pooled age classes")
system("./stocpool") -> makes R crash right away

Does anyone know why this happens and how I can make this work?

Thanks a lot for the help!!

cheers

Beni

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

2010-06-02 Thread Dave_F

Hello fellow R users,

I have been getting a strange error message when using the cv.glmnet
function in the glmnet package. I am attempting to fit a multinomial
regression using the lasso. covars is a matrix with 80 rows and roughly 4000
columns, all the covariates are binary. resp is an eight level factor. I can
fit the model with no errors but when I try to cross-validate after about 30
seconds I get the following:


> glmnet.fit = glmnet(covars,resp,family="multinomial")
> glmnet.cv = cv.glmnet(covars,resp,family="multinomial",type="class")
Error in if (outlist$msg != "Unknown error") return(outlist) : 
  argument is of length zero

It seems like it makes it through the first couple folds but trips up
somewhere in the middle.
The example in the documentation works perfectly on my machine. Any ideas on
what the problem may be?

Thanks!
Dave
-- 
View this message in context: 
http://r.789695.n4.nabble.com/glmnet-strange-error-message-tp2240458p2240458.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] using the design matrix to correctly configure contrasts

2010-06-02 Thread Walmes Zeviani

Take a look at contrast package. It has functions to handle with user
contrasts. Below you have a reproducible and minimal example using
contrast's functions.

da <- expand.grid(A=factor(paste("A", 1:3, sep="")),
  B=factor(paste("B", 1:4, sep="")), rep=1:4)
eta <- model.matrix(~A*B, da)%*%matrix(c(0, 1,2, -1,0,1, 0,1,2, 0,0,0))
da$y <- rnorm(da$A, mean=eta, sd=1)

g0 <- lm(y~A*B, data=da)
anova(g0)

require(contrast)

c0 <- contrast(g0,
   list(B="B1", A="A1"),
   list(B="B2", A="A1"))
c0
c0$X

Walmes.

-
..ooo0
...
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://r.789695.n4.nabble.com/using-the-design-matrix-to-correctly-configure-contrasts-tp2238719p2240372.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] DEOptim Parameters

2010-06-02 Thread galen kaufman

I am trying to figure out how parameters are defined in a function that is used 
by DEOptim.  That is, when I set upper and lower bounds for DEOptim how does it 
know which element of the function to apply those bounds to? For example, in 
DEOptim call below, when DEOptim goes into "optimfxn" how does it know what 
element of "optimfxn" to apply the upper and lower bounds to?  
 
optimization<-DEoptim( fn=optimfxn, lower=c(1.01000, 0.98000), upper=c(1.2, 
4.44000)
 
optimfxn<- function (x) { 
_
The New Busy is not the old busy. Search, chat and e-mail from your inbox.

N:WL:en-US:WM_HMP:042010_3
[[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] bind select data frames

2010-06-02 Thread arnaud Gaboury
Jorge,

Your line works and give the desired result. Now I need to be able to work
with i instead of 100419..., as I need to be able to change these numbers. 
TY for your help




From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] 
Sent: Wednesday, June 02, 2010 5:09 PM
To: arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] bind select data frames

Hi Arnaud,

Try the following (untested):

txt <- paste('DailyPL',c("100419", "100420", "100421"), sep = "")
do.call(rbind, lapply(txt, get))

HTH,
Jorge


On Wed, Jun 2, 2010 at 10:24 AM, arnaud Gaboury <> wrote:
Dear group,

Here is my environment:

> ls()
 [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"            "i"
"l"             "PLglobal"      "Pos100416"     "Pos100419"     "Pos100420"
"Pos100421"     "position"
[13] "result"        "sel"           "Trad100416"    "Trad100419"
"Trad100420"    "Trad100421"    "trade"

With "sel" the following element :

sel <-
c("100419", "100420", "100421")


"DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames with
same columns names. I want to rbind them with this condition :


for (i in sel[-1])

I have no idea how to write it.

TY for any help

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

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


Re: [R] building time series/zoo/its from a data frame

2010-06-02 Thread Dennis Murphy
Hi:

Here's one approach, converting the sub-data frames to zoo objects:

# Function to convert one of the data frames to a zoo object
makezoo <- function(df) {
 require(zoo)
 date <- as.Date(df[, 1], format = '%m/%d/%y')
 with(df, zoo(freq, date))
}
library(zoo)

# Split the data frame by condition:
tt <- split(x.df[, -2], x.df$cond)

# > str(tt[[1]])
# 'data.frame':   5 obs. of  2 variables:
#  $ date: Factor w/ 5 levels "04/01/09","04/02/09",..: 1 2 3 4 5
#  $ freq: int  12 11 10 13 6

# Apply the makezoo function to each component of the list tt:
(tser <- lapply(tt, makezoo))

$Fever
04/01/09 04/02/09 04/03/09 04/04/09 04/05/09
  12   11   10   136

$Rash
04/01/09 04/02/09 04/03/09 04/04/09 04/05/09
   6   109   108

$Respiratory
04/01/09 04/02/09 04/03/09 04/04/09 04/05/09
  1296   11   11

# Check that the classes are OK:
> sapply(tser, class)
  FeverRash Respiratory
  "zoo"   "zoo"   "zoo"

You can then do things like plot.ts, for example:

lapply(tser, plot.ts)

HTH,
Dennis

On Wed, Jun 2, 2010 at 8:37 AM, Erin Hodgess wrote:

> Dear R People:
>
> I have the following data frame:
>
> > x.df
>   datecond freq
> 1  04/01/09   Fever   12
> 2  04/02/09   Fever   11
> 3  04/03/09   Fever   10
> 4  04/04/09   Fever   13
> 5  04/05/09   Fever6
> 6  04/01/09Rash6
> 7  04/02/09Rash   10
> 8  04/03/09Rash9
> 9  04/04/09Rash   10
> 10 04/05/09Rash8
> 11 04/01/09 Respiratory   12
> 12 04/02/09 Respiratory9
> 13 04/03/09 Respiratory6
> 14 04/04/09 Respiratory   11
> 15 04/05/09 Respiratory   11
> >
>
> I would like to generate 3 time series (or zoo objects or its); one
> for Fever, one for Rash, and one for Respiratory.   There are 2
> questions here, please:
> a. How do I generate the series, please?
> b. Which is best, time series, zoo objects, or its objects, please?
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Use apply only on non-missing values

2010-06-02 Thread Doran, Harold
I have a function that I am currently using very inefficiently. The following 
are needed to illustrate the problem:

set.seed(12345)
dat <- matrix(sample(c(0,1), 110, replace = TRUE), nrow = 11, ncol=10)
mis <- sample(1:110, 5)
dat[mis] <- NA
theta <- rnorm(11)
b_vector <- runif(10, -4,4)
empty <- which(is.na(t(dat)))

So, I have a matrix (dat) with some values within the matrix missing. In my 
real world problem, the matrix is huge, and most values are missing. The 
function in question is called derivs() and is below. But, let me step through 
the inefficient portions.

First, I create a matrix of some predicted probabilities as:

rasch <- function(theta,b) 1/ (1 + exp(b-theta))
mat <- apply(as.matrix(theta), 1, rasch, b_vector)

However, I only need those predicted probabilities in places where the data are 
not missing. So, the next step in the function is

mat[empty] <- NA

which manually places NAs in places where the data are missing (notice the 
matrix 'mat' is the transpose of the data matrix and so I get the empty 
positions from the transpose of dat).

Afterwards, the function computes the gradient and hessians needed to complete 
the MLE estimation.

All of this works in the sense that it yields the correct answers for my 
problem. But, the glaring problem is that I create predicted probabilities for 
every cell in 'mat' when in many cases they are not needed. I end up replacing 
those values with NAs. In my real world problem, this is horribly inefficient 
and slow.

My question is then is there a way to use apply such that is computes the 
necessary predicted probabilities only when the data are not missing to yield 
the matrix 'mat'. My desired end result is the matrix 'mat' created after the 
manually placing the NAs in the appropriate cells.

Thanks
Harold


derivs <- function(dat, b_vector, theta){
mat <- apply(as.matrix(theta), 1, rasch, 
b_vector)
mat[empty] <- NA
gradient <- -(colSums(dat, na.rm = TRUE) - 
rowSums(mat, na.rm = TRUE))
hessian <-  -(rowSums(mat * (1-mat), na.rm = 
TRUE))
list('gradient' = gradient, 'hessian' = hessian)
}



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

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

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

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

[[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] Peak Over Threshold values

2010-06-02 Thread William Dunlap
> -Original Message-
> From: Tonja Krueger [mailto:tonja.krue...@web.de] 
> Sent: Monday, May 31, 2010 2:03 AM
> To: William Dunlap
> Cc: r-help@r-project.org
> Subject: RE: [R] Peak Over Threshold values
> 
> Thanks a lot for your help. That's the time period I was looking for. 
> 
> I've got one more question: for further analyses I need the 
> respective maximum values
> within these time periods (between the green and red lines). 
> Preferably in combination
> with the date the maximum event happened. 

Looping over the intervals found by f() (or f0()) is
simple to do and probably quick enough for you.  E.g.,
to get the position of the maximum of each interval use
something like

  positionOfMaxInEachInterval <- function (x, intervals) 
  {
  with(intervals, sapply(seq_along(start), function(i) start[i] + 
  which.max(x[start[i]:stop[i]]) - 1))
  }

The maxima themselve would be gotten by
  intervals <- f(x, startThreshold, stopThreshold, plot=TRUE)
  imax <- postionOfMaxInEachInterval(x, intervals)
  # abline(v=imax) if you had plot=TRUE above
  maxs <- x[imax]

By the way, the looping form of f() can be made much faster
than the f0 I showed earlier, in the case where there are
many intervals (e.g., f(sin(1:1e6),.1,0)), by preallocating
the output.  You may prefer to edit that version to get the
positions of the interval maxima as you compute the intervals.

f0a <-
function (x = walevel, startThreshhold = 5.45, stopThreshhold = 5.3, 
plot = TRUE) 
{
stopifnot(startThreshhold > stopThreshhold)
inRun <- FALSE
start <- integer(length(x))
stop <- integer(length(x))
nStart <- 0
nStop <- 0
for (i in seq_along(x)) {
if (inRun) {
if (x[i] < stopThreshhold) {
nStop <- nStop + 1
stop[nStop] <- i - 1L
inRun <- FALSE
}
}
else {
if (x[i] > startThreshhold) {
nStart <- nStart + 1
start[nStart] <- i
inRun <- TRUE
}
}
}
if (inRun) {
nStop <- nStop + 1
stop[nStop] <- length(x)
}
if (nStop > nStart) {
stop <- stop[-1]
nStop <- nStop - 1
}
length(stop) <- nStop
length(start) <- nStart
if (plot) {
plot(x, cex = 0.5)
abline(h = c(startThreshhold, stopThreshhold))
abline(v = start, col = "green")
abline(v = stop, col = "red")
}
data.frame(start = start, stop = stop)
}

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> Thank you
> in advance, 
> 
> Tonja
> 
> 
> 
> -Ursprüngliche Nachricht-
> Von: William Dunlap 
> Gesendet: 27.05.2010 22:13:21
> An: "Hutchinson,David [PYR]" 
> ,Tonja Krueger 
> Betreff: RE: [R] Peak Over Threshold values
> 
> >> -Original Message-
> >> From: r-help-boun...@r-project.org 
> >> [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap
> >> Sent: Thursday, May 27, 2010 12:24 PM
> >> To: Hutchinson,David [PYR]; Tonja Krueger
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] Peak Over Threshold values
> >> 
> >> Here is another version, loopless, but still
> >> a bit clumsy (can the call to which be removed?):
> >
> >Note that avoiding loops is mostly for
> >the aesthetic effect.  On my aging laptop
> >the following loopy and vector-growing version
> >takes 3 seconds on a million-long vector
> >while the non-loopy one takes 0.22 seconds
> >(timings done with plot=FALSE).  That is
> >a nice ratio but not much of a difference.
> >
> >f0 <- function (x = walevel,
> >startThreshhold = 5.45,
> >stopThreshhold = 5.3, 
> >plot = TRUE) 
> >{
> >stopifnot(startThreshhold > stopThreshhold)
> >inRun <- FALSE
> >start <- integer()
> >stop <- integer()
> >for (i in seq_along(x)) {
> >if (inRun) {
> >if (x[i] < stopThreshhold) {
> >stop[length(stop) + 1] <- i - 1
> >inRun <- FALSE
> >}
> >}
> >else {
> >if (x[i] > startThreshhold) {
> >start[length(start) + 1] <- i
> >inRun <- TRUE
> >}
> >}
> >}
> >if (inRun) 
> >stop[length(stop) + 1] <- length(x)
> >if (length(stop) > length(start)) 
> >stop <- stop[-1]
> >if (plot) {
> >plot(x, cex = 0.5)
> >abline(h = c(startThreshhold, stopThreshhold))
> >abline(v = start, col = "green")
> >abline(v = stop, col = "red")
> >}
> >data.frame(start = start, stop = stop)
> >}
> >
> >> 
> >> f <- function (x = walevel,
> >>startThreshhold = 5.45,
> >>stopThreshhold = 5.3, 
> >>plot = TRUE) 
> >> {
> >> stopifnot(startThreshhold > stopThreshhold)
> >> isFirstInRun <- function(x) c(TRUE, x[-1] != x[-length(x)])
> >> isLastInRun <- function(x) c(x[-1] != x[-length(x)], TRUE)
> >> isOverStart <- x >= startThreshh

Re: [R] compute the associate vector of distances between leaves in a binary non-rooted tree

2010-06-02 Thread Arnau Mir
El 02/06/10 15:14, Joris Meys escribió:
> Hi,
>
> with a little hack you can use the function cophenetic.phylo from ape. 
> You just set all branch lengths to 1 :
>
> require(ape)
>
> >tree <- rtree(5,rooted=F)
> >n <- length(tree$edge.length)
> >tree$edge.length <- rep(1,n)
> >cophenetic.phylo(tree)
>
>t3 t1 t2 t4 t5
> t3  0  3  3  3  3
> t1  3  0  2  4  4
> t2  3  2  0  4  4
> t4  3  4  4  0  2
> t5  3  4  4  2  0
>
> Cheers
>
>
> On Wed, Jun 2, 2010 at 2:47 PM, Arnau Mir Torres  > wrote:
>
> Hello.
>
> I'd like to compute the associate vector of distances between
> leaves in a binary non-rooted tree. The definition of a distance
> between two leaves in a binary non-rooted tree is the number of
> edges in the path joining the two leaves.
> I've tried the ape package but I'm unable to find this vector.
> For example, using rtree(5,rooted=F) I've obtained the following tree:
>
> $edge
> [,1] [,2]
> [1,]67
> [2,]71
> [3,]78
> [4,]82
> [5,]83
> [6,]64
> [7,]65
>
> $tip.label
> [1] "t4" "t3" "t2" "t1" "t5"
>
> $edge.length
> [1] 0.9126727 0.2765674 0.4996832 0.7904400 0.8508797 0.8174133
> 0.9027958
>
> $Nnode
> [1] 3
>
>
> My question is: how to compute the vector of distances between the
> 5 leaves. This vector is in this case:
> 
> v=(d(t1,t2),d(t1,t3),d(t1,t4),d(t1,t5),d(t2,t3),d(t2,t4),d(t2,t5),d(t3,t4),d(t3,t5),d(t4,t5))=(4,4,3,2,2,3,4,3,4,3).
>
>
> Thanks in advance,
>
> Arnau.
> 
> Arnau Mir Torres
> Edifici A. Turmeda
> Campus UIB
> Ctra. Valldemossa, km. 7,5
> 07122 Palma de Mca.
> tel: (+34) 971172987
> fax: (+34) 971173003
> email: arnau@uib.es 
> URL: http://dmi.uib.es/~arnau 
> 
>
>
>
>
>
>
>
>
> __
> R-help@r-project.org  mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> -- 
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
Thank you very much. It has been very useful.

I'd like to go one step further.

Would it be possible to obtain a "distance matrix" but with no 
permutation of the leaves? In the above example, the "distance matrix" 
must be transformed into:

t1 t2 t3 t4 t5
t1  0  2  3  4  4
t2  2  0  3  4  4
t3  3  3  0  3  3
t4  4  4  3  0  2
t5  4  4  3  2  0

Thanks,

Arnau.

[[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] code for power and suffix for x,y labels in plot( ).

2010-06-02 Thread Joshua Wiley
On Tue, Jun 1, 2010 at 9:59 PM, Shant Ch  wrote:
> Hi
>
> I was trying to have a graph whose axes are X axis: m, Y axis: var[X ((a,b) 
> in suffix, and (n,d) in the power)].
>
> X ((a,b) in suffix, and (n,d) in the power)-        X^(n,d) _ (a,b).
>
> Actually I require many plots involving different values of a,b,n,d, so need 
> to keep this complicated notation.
> The expression() didn't work out for this case. Can anyone help me out.
> Thanks, in advance.
> Shant
>
>
>
>
>
>
> uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, 
> tol = 0.001 )
>
> While using this I am getting the following error. Can anyone please help me 
> out.
> Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) - (3^x) +  :   
> f() values at end points not of opposite sign.

Here is your function:

temp.fun <- function(x) {
  value <- x*(3^x)*log(4)-x*log(4/3)-(3^x)+1
  return(value)
}

look what happens when you do:

temp.fun(-2)
temp.fun(2)

in both cases, it returns a positive value.  uniroot() requires "The
function values at the endpoints must be of opposite signs (or zero)",
hence the error.  I believe your function has a lower bound of 0,
which is obtained when the input is 0.  So one option would be to
change your argument to uniroot() so that lower=0.  Although the
results are not particularly interesting in this case.

uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = 0,
upper = 2, tol = 0.001 )

HTH,

Josh

>
> Thanks in advance.
>
> Shant
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] how to label the som notes by the majority vote

2010-06-02 Thread Changbin Du
Thanks, Joris!

It works!  I appreciated!


On Wed, Jun 2, 2010 at 4:23 AM, Joris Meys  wrote:

> Hi Changbin,
>
> I looked at your code again, and it appears as if you're using the mapping
> plot for something that it isn't meant for. The mapping shows you how many
> points you have in every circle, and these points are represented by the
> labels. Your first plot gives the majority vote.
>
> This said, you can hack the function using:
>
> classif <- predict(nir.xyf)
> tmp <- table(classif$unit.classif,classif$prediction)
> label <- colnames(tmp)
> label <- apply(tmp!=0,1,function(x){label[x]})[classif$unit.classif]
> label[-match(1:16,classif$unit.classif)] <- ""
>
>
> cl <- colors()
> bgcols <- rev(heat.colors(4))
> plot(nir.xyf,
> type="mapping",bgcol=bgcols[as.numeric(as.factor(temp.predict))],
>   main="Mapping plot",labels=label)
>
> It does not calculate the majority vote itself, it just assigns a label to
> the category based on the predicted labels. Which is equivalent in this
> case.
>
> Cheers
> Joris
>
>
> On Wed, Jun 2, 2010 at 5:08 AM, Changbin Du  wrote:
>
>>
>> library("kohonen")
>> data(nir)
>> attach(nir)
>>
>> #SOM, the supervised learning, train the map using temperature as the
>> class variable.
>> set.seed(13)
>> nir.xyf<- xyf(data=spectra, Y=classvec2classmat(temperature), xweight =
>> 0.9, grid=somgrid(4, 4, "hexagonal"))
>>
>>
>> temp.xyf <- predict(nir.xyf)$unit.prediction #get prediction
>> temp.predict<- as.numeric(classmat2classvec(temp.xyf)) #change matrix to
>> vectors.
>>
>> par(mfrow=c(1,2))
>>
>> plot(nir.xyf, type="property", property=temp.predict, palette.name=rainbow, 
>> main="Prediction ")
>>
>>
>> cl <- colors()
>> bgcols <- cl[2:14]
>> plot(nir.xyf, type="mapping", labels=nir$temperature,
>> bgcol=bgcols[as.integer(temp.predict)],
>>   main="Mapping plot")
>>
>> par(mfrow=c(1,1))
>>
>>
>>
>> HI, Joris,
>>
>> Thanks so much for your suggestion!   I have modified the above codes, and
>> what I want  is to label the notes by the temperature.
>> if a note has 3 objects mapped to it (the temperature are 30, 40, 30),
>> then I want the 30 be labeled on the note.
>>
>> the right plot is the mapping plot, I want it to be labeled by only one
>> temperature.
>>
>> Thanks so much!
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Jun 1, 2010 at 5:36 PM, Joris Meys  wrote:
>>
>>> Dear Changbin,
>>>
>>> Please provide a self-contained, minimal example, meaning the whole code
>>> should run and create the plot as it is now, without having to load your
>>> dataset (which we don't have). Otherwise it's impossible to see what's going
>>> on and help you.
>>>
>>> Cheers
>>> Joris
>>>
>>> On Wed, Jun 2, 2010 at 2:21 AM, Changbin Du  wrote:
>>>
 HI, Dear R community,

 I am using the following codes to do the som. I tried to label the notes
 by
 the majority vote. either through mapping or prediction.
 I attached my output, the left one dont have any labels in the note, the
 right one has  more than one label in each note. I need to have only one
 label for each note either by majority vote or prediction.

 Can anyone give some suggestions or advice? Thanks so much!



 alex<-read.table("/home/cdu/operon/alex2.txt", , sep="\t", skip=0,
 header=T,
 fill=T)
 alex1<-alex[,c(1:257)]
 levels(alex1$Label)

 alex1$outcome<-as.numeric(alex1$Label)
 alex1$outcome[1:20]


 #self-organizing maps(unsupervised learning)
 library("kohonen")


 #SOM, the supervised learning, train the map using outcome as the class
 variable.
 set.seed(13)
 final.xyf<- xyf(data=as.matrix(alex1[,c(1:256)]),
 Y=classvec2classmat(alex1$outcome), xweight = 0.99, grid=somgrid(20, 30,
 "hexagonal"))


 outcome.xyf <- predict(final.xyf)$unit.prediction#get prediction
 outcome.predict<- as.numeric(classmat2classvec(outcome.xyf)) #change
 matrix
 to vectors.

 outcome.label<-LETTERS[outcome.predict] #conver the numeric value to
 letters.


 plot(final.xyf, type="property", property=outcome.predict,
 labels=outcome.label, palette.name =rainbow, main="Prediction ")



 cl <- colors()
 bgcols <- cl[2:14]
 plot(final.xyf, type="mapping", labels=outcome.label, col="black",
 bgcol=bgcols[as.integer(outcome.predict)],
  main="Mapping plot")




 --
 Sincerely,
 Changbin
 --

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


>>>
>>>
>>> --
>>> Joris Meys
>>> Statistical Consultant
>>>
>>> Ghent University
>>> Faculty of Bioscience Engineering
>>> Department of Applied mathematics, biometrics and process control
>

Re: [R] R-help "spam" detection; please help the moderators

2010-06-02 Thread Joshua Wiley
Hello Martin and Ted,

First off thank you to you guys and all the volunteers for providing
this wonderful service.  I have two questions.

1)  Do you know if it is a problem to respond to a post from nabble
using a gmail account?

2)  Would it be easier for you if people just used non free accounts?
I don't particularly relish the idea, but if it helped it would be
worth it.


Thanks again,

Josh


On Tue, Jun 1, 2010 at 6:25 AM, Martin Maechler
 wrote:
> Dear readers of R-help
>
> as most of you will *not* be aware, R-help has continued to work the
> way it does, only thanks to a dozen of volunteers,
> see https://stat.ethz.ch/mailman/listinfo/r-help .
>
> The volunteers manually moderate e-mails that "look like spam" (and
> sometimes are and sometimes are not).
> While much more than 90% of the spam is filtered out long before
> a human sees it, with the increasing sophistication of spammers,
> manual intervention has deemed to be necessary and served the
> community very well.
>
> OTOH, in recent weeks, the amount of work for the volunteers has
> increased, mainly because an increasingly number of non-spam postings are
> erronously tagged as "possibly spam".
> We have discussed about this and done some analysis and found
> that most of these message that produce a considerable amount of
> extra work share two properties :
>  1) they are posted via Nabble  {which *always* attaches a small
>                                 pro-Nabble spam at the end of the message}
>  2) the e-mail address of the sender is from a freemail
>    provider, quite often 'at gmail dot com', and often the part
>    *before* the '@' (at-sign) ends with digits.
>
> We hereby ask those among you who use a freemail account to
> please no longer post via nabble.
>
> Thank you for your support of R-help, *the* "community mailing
> list" of the R project since even before that project existed
> "formally", namely since 1997-04-01,
> today 13 years and two months.
>
> Martin Maechler, ETH Zurich
> (and R-help creator and principal manager)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] building time series/zoo/its from a data frame

2010-06-02 Thread Erin Hodgess
Dear R People:

I have the following data frame:

> x.df
   datecond freq
1  04/01/09   Fever   12
2  04/02/09   Fever   11
3  04/03/09   Fever   10
4  04/04/09   Fever   13
5  04/05/09   Fever6
6  04/01/09Rash6
7  04/02/09Rash   10
8  04/03/09Rash9
9  04/04/09Rash   10
10 04/05/09Rash8
11 04/01/09 Respiratory   12
12 04/02/09 Respiratory9
13 04/03/09 Respiratory6
14 04/04/09 Respiratory   11
15 04/05/09 Respiratory   11
>

I would like to generate 3 time series (or zoo objects or its); one
for Fever, one for Rash, and one for Respiratory.   There are 2
questions here, please:
a. How do I generate the series, please?
b. Which is best, time series, zoo objects, or its objects, please?

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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


Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Here we go :

dd<-data.frame(do.call(rbind, 
mget(paste("DailyPL",sel[-1],sep=""),envir=.GlobalEnv)),row.names=NULL)


TY so much Joshua and Jorge.


> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Wednesday, June 02, 2010 5:11 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] bind select data frames
> 
> On Wed, Jun 2, 2010 at 8:06 AM, arnaud Gaboury
>  wrote:
> > I am working with something like this :
> >
> >  for (i in sel[-1])  {
> > dd<-data.frame(do.call(rbind,
> mget(paste("DailyPL",i,sep=""),envir=.GlobalEnv)),row.names=NULL)
> >
> >   }
> >
> > But the result is not good. In the case where sel[-1]<-c("100420",
> "100421"), "dd" is only equal to "DailyPL100421"
> 
> Yes, because it is in a loop, dd is reassigned for each value of i.
> That is why in the first loop I sent you I included the old data in
> the rbind, otherwise it is just overwritten everytime it loops.
> 
> Josh
> 
> >
> >
> >
> >
> >> -Original Message-
> >> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> >> Sent: Wednesday, June 02, 2010 4:48 PM
> >> To: arnaud Gaboury
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] bind select data frames
> >>
> >> Hello,
> >>
> >> Does this do what you are looking for?
> >>
> >> 
> >> output <- NULL
> >> for(i in paste("DailyPL", sel, sep="")[-1]){
> >>   output <- rbind(output, get(i))
> >>   }
> >> 
> >>
> >> If you just want to rbind all the data frames, there are ways of
> doing
> >> it without a loop too, but since you specifically asked with the
> >> condition for(i in sep[-1]) I did it using a loop.
> >>
> >> Best regards,
> >>
> >> Josh
> >>
> >>
> >> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
> >>  wrote:
> >> > Dear group,
> >> >
> >> > Here is my environment:
> >> >
> >> >> ls()
> >> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
> >>  "i"
> >> > "l" "PLglobal"  "Pos100416" "Pos100419"
> >> "Pos100420"
> >> > "Pos100421" "position"
> >> > [13] "result""sel"   "Trad100416""Trad100419"
> >> > "Trad100420""Trad100421""trade"
> >> >
> >> > With "sel" the following element :
> >> >
> >> > sel <-
> >> > c("100419", "100420", "100421")
> >> >
> >> >
> >> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data
> frames
> >> with
> >> > same columns names. I want to rbind them with this condition :
> >> >
> >> >
> >> > for (i in sel[-1])
> >> >
> >> > I have no idea how to write it.
> >> >
> >> > TY for any help
> >> >
> >> > __
> >> > R-help@r-project.org mailing list
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide http://www.R-project.org/posting-
> >> guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >> >
> >>
> >>
> >>
> >> --
> >> Joshua Wiley
> >> Senior in Psychology
> >> University of California, Riverside
> >> http://www.joshuawiley.com/
> >
> >
> 
> 
> 
> --
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.com/

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


Re: [R] lattice, xyplot, using "panel.segments" by just addressing one panel

2010-06-02 Thread Peter Ehlers

Doris,

You might get lucky and find some kind soul who's willing to
dig through your *un*reproducible code, but your chances for
help would probably increase dramatically if you were to
provide *reproducible* and *minimal* code to illustrate your
problem. I imagine that you might benefit from reading the
posting guide.

It may be that trellis.focus() solves your problem.

 -Peter Ehlers

On 2010-06-02 8:46, Doris wrote:


Hi R experts,

I'm using the xyplot function in lattice to draw a multipanel plot consiting
of 5x6 scatterplots.
Now I need to link single points in each of those scatterplots (=panel),but
the points, that need linking are different for each panel.
I tried to use the panel.segments function for that, but I can't address
each panel separately. Links right for panel 1, show up in all other panels,
too. Tried functions like [panel.number()], but didn't work.

Would be so great, if somebody could help me with that!

That's the code, I used:

library(lattice)
library(latticeExtra)
#[...]
attach(mydata)
attach(links)  #containing the coordinates for the segments fx, fy, tx, ty

fx<- fx
fy<- fy
tx<- tx
ty<- ty

xyplot(LogN~LogM|factor(surber),
par.settings = list(strip.background = list(col = "transparent")),
xlab = "Log M", ylab = "Log N",
layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE,
panel=function(x,y){
panel.xyplot(x,y,pch=20,col="black", bg="transparent")
panel.fill(col = "transparent")
panel.segments(fx,fy,tx,ty[panel.number()])

})


Also tried to split the data and loop it (but this code might be a bit
messy. Apologies!) sn is the variable used to split according to panel. I
just tried to do the links for 2 panel here:

fx<- split(links$fx,links$sn)
fy<- split(links$fy,links$sn)
tx<- split(links$tx,links$sn)
ty<- split(links$ty,links$sn)
sn<- sn
dothese<- c(1,2)
ct<- 0
for (i in dothese){
ct<- ct + 1
x1<- fx[[i]]
y1<- fy[[i]]
x2<- tx[[i]]
y2<- ty[[i]]
}


xyplot(LogN~LogM|factor(surber),
par.settings = list(strip.background = list(col = "transparent")),
xlab = "Log M", ylab = "Log N",
layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE,
panel=function(x,y){
panel.xyplot(x,y,pch=20,col="black", bg="transparent")
panel.fill(col = "transparent")
panel.segments (x1,y1,x2,y2 [panel.number(1,2)])

})



Thanks, Doris


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


Re: [R] Help barplots

2010-06-02 Thread khush ........
Hi all,

I want to draw a arrow (small) of any length along with OsCYP right side i.e
parrallel and antiparallel arrows both

 text(os[1], 10.2,  pos = 4, "OsCYP", font=1, cex = 1,  col = "red")

and

how can I connect two points with dotted line lets say

bp[1 ]10.2  bp[3], 15.2

how to make a dotted line using R, is it possible

Thank you in advance

Jeet


On Tue, Jun 1, 2010 at 4:31 PM, khush  wrote:

> Dear All,
>
> I am newbie to R, and I wanted to plot a barplots with R and in such a way
> that It will also show me position which I can plot on the bar line.
>
> Here is my code that I am using to plot,
>
> > chromosome <- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,
> 28.2)
> >barplot (chromosome, col="purple", xlab="Oryza sativa Chromosomes", border
> = NA, space = 5, ylim = c(0,45))
>
> I wanted to mark the position say on chromosome 1 (40.2) I need to mark
> 10.2 and on other also.
> I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 i.e
> gap of 5 instead of 10.
>
> please help me to solve my querygurus.
>
>
> Thank you
> Jeet
>

[[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] bind select data frames

2010-06-02 Thread arnaud Gaboury
Yes Joshua, it does the trick. Once more, I am surprised by the easiness and 
obviousness of R.
Now, I would like to add argument row.names=NULL.

dd <- do.call(rbind, mget(paste("DailyPL",sel[-1], sep=""),
 envir=.GlobalEnv),row.names=NULL)
> Error in do.call(rbind, mget(paste("DailyPL", sel[-1], sep = ""), envir = 
> .GlobalEnv),  : 
  unused argument(s) (row.names = NULL)

Why this error?

TY for your help





> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Wednesday, June 02, 2010 5:08 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] bind select data frames
> 
> This should do the trick:
> 
> dd <- do.call(rbind, mget(paste("DailyPL",sel[-1], sep=""),
> envir=.GlobalEnv))
> 
> 
> 
> On Wed, Jun 2, 2010 at 8:06 AM, arnaud Gaboury
>  wrote:
> > I am working with something like this :
> >
> >  for (i in sel[-1])  {
> > dd<-data.frame(do.call(rbind,
> mget(paste("DailyPL",i,sep=""),envir=.GlobalEnv)),row.names=NULL)
> >
> >   }
> >
> > But the result is not good. In the case where sel[-1]<-c("100420",
> "100421"), "dd" is only equal to "DailyPL100421"
> >
> >
> >
> >
> >> -Original Message-
> >> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> >> Sent: Wednesday, June 02, 2010 4:48 PM
> >> To: arnaud Gaboury
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] bind select data frames
> >>
> >> Hello,
> >>
> >> Does this do what you are looking for?
> >>
> >> 
> >> output <- NULL
> >> for(i in paste("DailyPL", sel, sep="")[-1]){
> >>   output <- rbind(output, get(i))
> >>   }
> >> 
> >>
> >> If you just want to rbind all the data frames, there are ways of
> doing
> >> it without a loop too, but since you specifically asked with the
> >> condition for(i in sep[-1]) I did it using a loop.
> >>
> >> Best regards,
> >>
> >> Josh
> >>
> >>
> >> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
> >>  wrote:
> >> > Dear group,
> >> >
> >> > Here is my environment:
> >> >
> >> >> ls()
> >> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
> >>  "i"
> >> > "l" "PLglobal"  "Pos100416" "Pos100419"
> >> "Pos100420"
> >> > "Pos100421" "position"
> >> > [13] "result""sel"   "Trad100416""Trad100419"
> >> > "Trad100420""Trad100421""trade"
> >> >
> >> > With "sel" the following element :
> >> >
> >> > sel <-
> >> > c("100419", "100420", "100421")
> >> >
> >> >
> >> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data
> frames
> >> with
> >> > same columns names. I want to rbind them with this condition :
> >> >
> >> >
> >> > for (i in sel[-1])
> >> >
> >> > I have no idea how to write it.
> >> >
> >> > TY for any help
> >> >
> >> > __
> >> > R-help@r-project.org mailing list
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide http://www.R-project.org/posting-
> >> guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >> >
> >>
> >>
> >>
> >> --
> >> Joshua Wiley
> >> Senior in Psychology
> >> University of California, Riverside
> >> http://www.joshuawiley.com/
> >
> >
> 
> 
> 
> --
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.com/

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


Re: [R] bind select data frames

2010-06-02 Thread Jorge Ivan Velez
Hi Arnaud,

Just replace c(...)  by sel[-1] in the paste(...) call and you will be ready
to go.

Regards,
Jorge


On Wed, Jun 2, 2010 at 11:13 AM, arnaud Gaboury <> wrote:

> Jorge,
>
> Your line works and give the desired result. Now I need to be able to work
> with i instead of 100419..., as I need to be able to change these numbers.
> TY for your help
>
>
>
>
> From: Jorge Ivan Velez [mailto:]
> Sent: Wednesday, June 02, 2010 5:09 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] bind select data frames
>
> Hi Arnaud,
>
> Try the following (untested):
>
> txt <- paste('DailyPL',c("100419", "100420", "100421"), sep = "")
> do.call(rbind, lapply(txt, get))
>
> HTH,
> Jorge
>
>
> On Wed, Jun 2, 2010 at 10:24 AM, arnaud Gaboury <> wrote:
> Dear group,
>
> Here is my environment:
>
> > ls()
>  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd""i"
> "l" "PLglobal"  "Pos100416" "Pos100419" "Pos100420"
> "Pos100421" "position"
> [13] "result""sel"   "Trad100416""Trad100419"
> "Trad100420""Trad100421""trade"
>
> With "sel" the following element :
>
> sel <-
> c("100419", "100420", "100421")
>
>
> "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames with
> same columns names. I want to rbind them with this condition :
>
>
> for (i in sel[-1])
>
> I have no idea how to write it.
>
> TY for any help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>

[[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] Seeking help on Vectorize()

2010-06-02 Thread Dennis Murphy
Hi:

This is shorter:

t(outer(x, y, '+'))
 [,1] [,2] [,3]
[1,]456
[2,]567
[3,]678
[4,]789
[5,]89   10

HTH,
Dennis

On Wed, Jun 2, 2010 at 2:25 AM, Megh Dal  wrote:

> Dear falks, here I have written following function :
>
> fn <- Vectorize(function(x = 1:3, y = 3:6) {
> x <- matrix(x, nrow=1)
> y <- matrix(y, ncol=1)
> dat <- apply(x, 2, function(xx) {
>   apply(y, 1, function(yy) {
>   return(xx + yy) } ) })
> return(dat)}, SIMPLIFY = TRUE)
>
> If I run this function, I got some warning message, even format of the
> returned object is not correct, for example :
>
> >  fn(x = 1:3, y = 3:7)
> [1] 4 6 8 7 9
> Warning message:
> In mapply(FUN = function (x = 1:3, y = 3:6)  :
>   longer argument not a multiple of length of shorter
>
> However if I run individual line of codes like :
>
> > x <- 1:3; y = 3:7
> > x <- matrix(x, nrow=1)
> > y <- matrix(y, ncol=1)
> > dat <- apply(x, 2, function(xx) {
> +   apply(y, 1, function(yy) {
> +   return(xx + yy) } ) })
> > dat
>  [,1] [,2] [,3]
> [1,]456
> [2,]567
> [3,]678
> [4,]789
> [5,]89   10
>
>
> I get exactly what I want. Where I am making fault?
>
> Thanks,
>
>
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[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] bind select data frames

2010-06-02 Thread Joshua Wiley
On Wed, Jun 2, 2010 at 8:06 AM, arnaud Gaboury  wrote:
> I am working with something like this :
>
>  for (i in sel[-1])  {
> dd<-data.frame(do.call(rbind, 
> mget(paste("DailyPL",i,sep=""),envir=.GlobalEnv)),row.names=NULL)
>
>               }
>
> But the result is not good. In the case where sel[-1]<-c("100420", "100421"), 
> "dd" is only equal to "DailyPL100421"

Yes, because it is in a loop, dd is reassigned for each value of i.
That is why in the first loop I sent you I included the old data in
the rbind, otherwise it is just overwritten everytime it loops.

Josh

>
>
>
>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Wednesday, June 02, 2010 4:48 PM
>> To: arnaud Gaboury
>> Cc: r-help@r-project.org
>> Subject: Re: [R] bind select data frames
>>
>> Hello,
>>
>> Does this do what you are looking for?
>>
>> 
>> output <- NULL
>> for(i in paste("DailyPL", sel, sep="")[-1]){
>>   output <- rbind(output, get(i))
>>   }
>> 
>>
>> If you just want to rbind all the data frames, there are ways of doing
>> it without a loop too, but since you specifically asked with the
>> condition for(i in sep[-1]) I did it using a loop.
>>
>> Best regards,
>>
>> Josh
>>
>>
>> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
>>  wrote:
>> > Dear group,
>> >
>> > Here is my environment:
>> >
>> >> ls()
>> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
>>  "i"
>> > "l"             "PLglobal"      "Pos100416"     "Pos100419"
>> "Pos100420"
>> > "Pos100421"     "position"
>> > [13] "result"        "sel"           "Trad100416"    "Trad100419"
>> > "Trad100420"    "Trad100421"    "trade"
>> >
>> > With "sel" the following element :
>> >
>> > sel <-
>> > c("100419", "100420", "100421")
>> >
>> >
>> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames
>> with
>> > same columns names. I want to rbind them with this condition :
>> >
>> >
>> > for (i in sel[-1])
>> >
>> > I have no idea how to write it.
>> >
>> > TY for any help
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Joshua Wiley
>> Senior in Psychology
>> University of California, Riverside
>> http://www.joshuawiley.com/
>
>



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

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


Re: [R] bind select data frames

2010-06-02 Thread Jorge Ivan Velez
Hi Arnaud,

Try the following (untested):

txt <- paste('DailyPL',c("100419", "100420", "100421"), sep = "")
do.call(rbind, lapply(txt, get))

HTH,
Jorge


On Wed, Jun 2, 2010 at 10:24 AM, arnaud Gaboury <> wrote:

> Dear group,
>
> Here is my environment:
>
> > ls()
>  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd""i"
> "l" "PLglobal"  "Pos100416" "Pos100419" "Pos100420"
> "Pos100421" "position"
> [13] "result""sel"   "Trad100416""Trad100419"
> "Trad100420""Trad100421""trade"
>
> With "sel" the following element :
>
> sel <-
> c("100419", "100420", "100421")
>
>
> "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames with
> same columns names. I want to rbind them with this condition :
>
>
> for (i in sel[-1])
>
> I have no idea how to write it.
>
> TY for any help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] bind select data frames

2010-06-02 Thread Joshua Wiley
This should do the trick:

dd <- do.call(rbind, mget(paste("DailyPL",sel[-1], sep=""), envir=.GlobalEnv))



On Wed, Jun 2, 2010 at 8:06 AM, arnaud Gaboury  wrote:
> I am working with something like this :
>
>  for (i in sel[-1])  {
> dd<-data.frame(do.call(rbind, 
> mget(paste("DailyPL",i,sep=""),envir=.GlobalEnv)),row.names=NULL)
>
>               }
>
> But the result is not good. In the case where sel[-1]<-c("100420", "100421"), 
> "dd" is only equal to "DailyPL100421"
>
>
>
>
>> -Original Message-
>> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
>> Sent: Wednesday, June 02, 2010 4:48 PM
>> To: arnaud Gaboury
>> Cc: r-help@r-project.org
>> Subject: Re: [R] bind select data frames
>>
>> Hello,
>>
>> Does this do what you are looking for?
>>
>> 
>> output <- NULL
>> for(i in paste("DailyPL", sel, sep="")[-1]){
>>   output <- rbind(output, get(i))
>>   }
>> 
>>
>> If you just want to rbind all the data frames, there are ways of doing
>> it without a loop too, but since you specifically asked with the
>> condition for(i in sep[-1]) I did it using a loop.
>>
>> Best regards,
>>
>> Josh
>>
>>
>> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
>>  wrote:
>> > Dear group,
>> >
>> > Here is my environment:
>> >
>> >> ls()
>> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
>>  "i"
>> > "l"             "PLglobal"      "Pos100416"     "Pos100419"
>> "Pos100420"
>> > "Pos100421"     "position"
>> > [13] "result"        "sel"           "Trad100416"    "Trad100419"
>> > "Trad100420"    "Trad100421"    "trade"
>> >
>> > With "sel" the following element :
>> >
>> > sel <-
>> > c("100419", "100420", "100421")
>> >
>> >
>> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames
>> with
>> > same columns names. I want to rbind them with this condition :
>> >
>> >
>> > for (i in sel[-1])
>> >
>> > I have no idea how to write it.
>> >
>> > TY for any help
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Joshua Wiley
>> Senior in Psychology
>> University of California, Riverside
>> http://www.joshuawiley.com/
>
>



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

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


Re: [R] bind select data frames

2010-06-02 Thread arnaud Gaboury
I am working with something like this :

  for (i in sel[-1])  {
dd<-data.frame(do.call(rbind, 
mget(paste("DailyPL",i,sep=""),envir=.GlobalEnv)),row.names=NULL)  
  
   }

But the result is not good. In the case where sel[-1]<-c("100420", "100421"), 
"dd" is only equal to "DailyPL100421"




> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Wednesday, June 02, 2010 4:48 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] bind select data frames
> 
> Hello,
> 
> Does this do what you are looking for?
> 
> 
> output <- NULL
> for(i in paste("DailyPL", sel, sep="")[-1]){
>   output <- rbind(output, get(i))
>   }
> 
> 
> If you just want to rbind all the data frames, there are ways of doing
> it without a loop too, but since you specifically asked with the
> condition for(i in sep[-1]) I did it using a loop.
> 
> Best regards,
> 
> Josh
> 
> 
> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
>  wrote:
> > Dear group,
> >
> > Here is my environment:
> >
> >> ls()
> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
>  "i"
> > "l" "PLglobal"  "Pos100416" "Pos100419"
> "Pos100420"
> > "Pos100421" "position"
> > [13] "result""sel"   "Trad100416""Trad100419"
> > "Trad100420""Trad100421""trade"
> >
> > With "sel" the following element :
> >
> > sel <-
> > c("100419", "100420", "100421")
> >
> >
> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames
> with
> > same columns names. I want to rbind them with this condition :
> >
> >
> > for (i in sel[-1])
> >
> > I have no idea how to write it.
> >
> > TY for any help
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> --
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.com/

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


Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi

I have original data for which sub(' +$', '', ...) did not work in Excel 
so I could try them again.

> grep("\t", as.character(becva$V1[1]))
integer(0)
> grep("\n", as.character(becva$V1[1]))
integer(0)

and Jim's solutions work as expected

> sub('[[:space:]]+$', '', becva$V1[1])
[1] "02.06.10 12:40"
> sub('\\W+$', '', becva$V1[1])
[1] "02.06.10 12:40"
> sub('+$', '', becva$V1[1])
[1] "02.06.10 12:40   "

However with data updated directly from internet there is no problem and 
all above commands work without problems. There could be some Excel data 
issues which is not worth solving.

Thank to you all.

Regards
Petr


Joris Meys  napsal dne 02.06.2010 16:11:05:

> Hi Petr,
> 
> Matt may very well have been right. As I copied the dput from the mail, 
any 
> white space is converted to spaces apparently. Still, it might be 
possible the
> white spaces in your original data are tabs or even newline characters. 
You 
> can check that easily with 
> 
> grep("\t", as.character(becva$V1[1]))
> grep("\n", as.character(becva$V1[1]))
> 
> Cheers
> Joris
> 
> 

> On Wed, Jun 2, 2010 at 3:54 PM, Petr PIKAL  
wrote:
> Hi
> 
> thanks. I am puzzled what was wrong. Now even
> 
> sub(' +$', '', bbb[1])
> 
> works. I am checking water throughput in nearby river and copying data
> from internet. So I wonder if there was some change recently as during
> floods they update it in about 10 minutes interval.
> 
> Regards
> Petr
> 
> 
> jim holtman  napsal dne 02.06.2010 15:44:42:
> 
> > You had the wrong case on 'w' and the wrong expression with
> > [:space:]';  see below
> >
> > > bbb <- c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00 
",
> > + "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> > + "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> > + "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> > + "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> > + "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> > + "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> > + "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> > + "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> > + "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> > + "27.05.10 05:00   ")
> > >  sub('\\W+$', '', bbb[1])
> > [1] "02.06.10 12:40"
> > > sub('[[:space:]]+$', '', bbb[1])
> > [1] "02.06.10 12:40"
> > >
> >
> >
> > On Wed, Jun 2, 2010 at 9:22 AM, Petr PIKAL 
> wrote:
> > > Hi
> > >
> > >> dput(bbb)
> > > c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
> > > "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> > > "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> > > "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> > > "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> > > "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> > > "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> > > "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> > > "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> > > "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> > > "27.05.10 05:00   ")
> > >>
> > >
> > > For simplicity I change the name and put it to single variable.
> > > I also reinstalled R to recent R-devel
> > >
> > >> sub('\\w+$', '', bbb[1])
> > > [1] "02.06.10 12:40   "
> > >> sub('[:space:]', '', bbb[1])
> > > [1] "02.06.10 1240   "
> > >>
> > >
> > > I also tried Matt's suggestion but it did not help.
> > >
> > > Regards
> > > Petr
> > >
> > > Joris Meys  napsal dne 02.06.2010 14:35:19:
> > >
> > >> Could you provide us with dput(becva$V1[1])?
> > >> Cheers
> > >> Joris
> > >
> > >> On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL 
> > > wrote:
> > >> Dear all
> > >>
> > >> I encountered strange problem with regexpr replacement
> > >>
> > >> I made this character object
> > >>
> > >> str <- "02.06.10 12:40 "
> > >>
> > >> > str(str)
> > >>  chr "02.06.10 12:40  "
> > >>
> > >> I read in an object which seems to be quite similar
> > >>
> > >> > str(as.character(becva$V1)[1])
> > >>  chr "02.06.10 12:40   "
> > >>
> > >> However I can not remove trailing spaces from it
> > >>
> > >> > sub(' +$', '', as.character(becva$V1[1]))
> > >>
> > >> [1] "02.06.10 12:40   "
> > >> > sub(' +$', '', str)
> > >> [1] "02.06.10 12:40"
> > >> >
> > >>
> > >> Do somebody have an idea what to do?
> > >>
> > >> $version.string
> > >> [1] "R version 2.12.0 Under development (unstable) (2010-04-25
> r51820)"
> > >>
> > >> on Windows
> > >>
> > >> Regards
> > >> Petr
> > >>
> > >> __
> > >> R-help@r-project.org mailing list
> > >> https://stat.ethz.ch/mailman/listinfo/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] bind select data frames

2010-06-02 Thread arnaud Gaboury
Yes indeed I just want to rbind the data frames with numbers belonging to 
"sel", and if possible, avoid a loop.

To be more precise, if sel[-1]<-c("100420", "100421"), I look for a line which 
will give me this result :

>dd<-rbind(DailyPL100420,DailyPL100421)




> -Original Message-
> From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
> Sent: Wednesday, June 02, 2010 4:48 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] bind select data frames
> 
> Hello,
> 
> Does this do what you are looking for?
> 
> 
> output <- NULL
> for(i in paste("DailyPL", sel, sep="")[-1]){
>   output <- rbind(output, get(i))
>   }
> 
> 
> If you just want to rbind all the data frames, there are ways of doing
> it without a loop too, but since you specifically asked with the
> condition for(i in sep[-1]) I did it using a loop.
> 
> Best regards,
> 
> Josh
> 
> 
> On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury
>  wrote:
> > Dear group,
> >
> > Here is my environment:
> >
> >> ls()
> >  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"
>  "i"
> > "l" "PLglobal"  "Pos100416" "Pos100419"
> "Pos100420"
> > "Pos100421" "position"
> > [13] "result""sel"   "Trad100416""Trad100419"
> > "Trad100420""Trad100421""trade"
> >
> > With "sel" the following element :
> >
> > sel <-
> > c("100419", "100420", "100421")
> >
> >
> > "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames
> with
> > same columns names. I want to rbind them with this condition :
> >
> >
> > for (i in sel[-1])
> >
> > I have no idea how to write it.
> >
> > TY for any help
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> --
> Joshua Wiley
> Senior in Psychology
> University of California, Riverside
> http://www.joshuawiley.com/

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


Re: [R] bind select data frames

2010-06-02 Thread Joshua Wiley
Hello,

Does this do what you are looking for?


output <- NULL
for(i in paste("DailyPL", sel, sep="")[-1]){
  output <- rbind(output, get(i))
  }


If you just want to rbind all the data frames, there are ways of doing
it without a loop too, but since you specifically asked with the
condition for(i in sep[-1]) I did it using a loop.

Best regards,

Josh


On Wed, Jun 2, 2010 at 7:24 AM, arnaud Gaboury  wrote:
> Dear group,
>
> Here is my environment:
>
>> ls()
>  [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd"            "i"
> "l"             "PLglobal"      "Pos100416"     "Pos100419"     "Pos100420"
> "Pos100421"     "position"
> [13] "result"        "sel"           "Trad100416"    "Trad100419"
> "Trad100420"    "Trad100421"    "trade"
>
> With "sel" the following element :
>
> sel <-
> c("100419", "100420", "100421")
>
>
> "DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames with
> same columns names. I want to rbind them with this condition :
>
>
> for (i in sel[-1])
>
> I have no idea how to write it.
>
> TY for any help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] lattice, xyplot, using "panel.segments" by just addressing one panel

2010-06-02 Thread Doris

Hi R experts, 

I'm using the xyplot function in lattice to draw a multipanel plot consiting
of 5x6 scatterplots.
Now I need to link single points in each of those scatterplots (=panel),but
the points, that need linking are different for each panel.
I tried to use the panel.segments function for that, but I can't address
each panel separately. Links right for panel 1, show up in all other panels,
too. Tried functions like [panel.number()], but didn't work. 

Would be so great, if somebody could help me with that!

That's the code, I used:

library(lattice)
library(latticeExtra)
#[...]
attach(mydata)
attach(links)  #containing the coordinates for the segments fx, fy, tx, ty

fx <- fx
fy <- fy
tx <- tx
ty <- ty

xyplot(LogN~LogM|factor(surber),
par.settings = list(strip.background = list(col = "transparent")),
xlab = "Log M", ylab = "Log N",  
layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE,
panel=function(x,y){
panel.xyplot(x,y,pch=20,col="black", bg="transparent")
panel.fill(col = "transparent")
panel.segments(fx,fy,tx,ty[panel.number()])

})


Also tried to split the data and loop it (but this code might be a bit
messy. Apologies!) sn is the variable used to split according to panel. I
just tried to do the links for 2 panel here:

fx <- split(links$fx,links$sn)
fy <- split(links$fy,links$sn)
tx <- split(links$tx,links$sn)
ty <- split(links$ty,links$sn)
sn <- sn
dothese <- c(1,2) 
ct <- 0 
for (i in dothese){
ct <- ct + 1 
x1 <- fx[[i]]
y1 <- fy[[i]]
x2 <- tx[[i]]
y2 <- ty[[i]]
}


xyplot(LogN~LogM|factor(surber),
par.settings = list(strip.background = list(col = "transparent")),
xlab = "Log M", ylab = "Log N",  
layout = c(6,5), aspect = 1, as.table = TRUE, strip=FALSE, 
panel=function(x,y){
panel.xyplot(x,y,pch=20,col="black", bg="transparent")
panel.fill(col = "transparent")
panel.segments (x1,y1,x2,y2 [panel.number(1,2)])

})



Thanks, Doris


-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-xyplot-using-panel-segments-by-just-addressing-one-panel-tp2240248p2240248.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] Problems installing data package on Windows

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


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

> Dear all,
> 
> I'm having difficulties installing a package on Windows. It has only R
> data files, no code. I've built it on a Linux platform and installed it
> there without problems. When I tried installing the .tar.gz on Windows,
> via install.packages, I got the following errors:
> 
> Error in gzfile(file, "r") : unable to open connection 
> In addition: Warning message:
> 1: In unzip(zipname, exdir = dest) :
>  error 1 in extracting from zip file 
> 2: In gzfile(file, "r") :
>  cannot open compressed file 'pkgname.tar.gz/DESCRIPTION', probable
> reason 'No such file or directory'
> 
> 
> After searching in the web, I tried installing the Rtools kit. The
> problem with install.packages remains, but I managed to install it with
> R CMD INSTALL. What could be wrong with install.packages? As far as I
> understood, installing a package without source code shouldn't need the
> resources in Rtools.
> 
> Thanks, 
> 
> Erick Fonseca
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


[R] bind select data frames

2010-06-02 Thread arnaud Gaboury
Dear group,

Here is my environment:

> ls()
 [1] "DailyPL100419" "DailyPL100420" "DailyPL100421" "dd""i"
"l" "PLglobal"  "Pos100416" "Pos100419" "Pos100420"
"Pos100421" "position" 
[13] "result""sel"   "Trad100416""Trad100419"
"Trad100420""Trad100421""trade"

With "sel" the following element :

sel <-
c("100419", "100420", "100421")


"DailyPL100419" , "DailyPL100420","DailyPL100421" are all data frames with
same columns names. I want to rbind them with this condition :


for (i in sel[-1])  

I have no idea how to write it.

TY for any help

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


Re: [R] data frame manipulation with zero rows

2010-06-02 Thread arnaud Gaboury
I do really think it is a very good idea.
TY





> -Original Message-
> From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On Behalf Of
> Hadley Wickham
> Sent: Wednesday, June 02, 2010 3:31 PM
> To: arnaud Gaboury
> Cc: Peter Ehlers; r-help@r-project.org; Prof Brian Ripley
> Subject: Re: [R] data frame manipulation with zero rows
> 
> Hi Arnaud,
> 
> I've added this case to the set of test cases in plyr and it will be
> fixed in the next version.
> 
> Hadley
> 
> On Tue, Jun 1, 2010 at 2:33 PM, arnaud Gaboury
>  wrote:
> > Maybe not the cleanest way, but I create a fake data frame with one
> row so
> > ddply() is happy!!
> >> if (nrow(futures)==0) futures<-data.frame(...)
> >
> >
> >
> >
> >
> >> -Original Message-
> >> From: Peter Ehlers [mailto:ehl...@ucalgary.ca]
> >> Sent: Tuesday, June 01, 2010 12:07 PM
> >> To: arnaud Gaboury
> >> Cc: 'Prof Brian Ripley'; r-help@r-project.org
> >> Subject: Re: [R] data frame manipulation with zero rows
> >>
> >> On 2010-06-01 1:53, arnaud Gaboury wrote:
> >> > Brian,
> >> >
> >> > If I do understand correctly, I must use in my function something
> >> else than
> >> > ddply() if I want to avoid any error each time my df has zero
> rows?
> >> > Am I correct?
> >> >
> >>
> >> You could define a function to handle the zero-rows case:
> >>
> >> f <- function(x){
> >>   if(nrow(x) < 1) out <- x[, c(1,3,2)]  # or whatever
> >>   else
> >>     out <- ddply(x, c("DESCRIPTION","SETTLEMENT"), summarise,
> >>                      POSITION=sum(QUANTITY))[,c(1,3,2)]
> >>   out
> >> }
> >> f(futures)
> >>
> >>   -Peter Ehlers
> >>
> >> >
> >> >
> >> >> -Original Message-
> >> >> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> >> >> Sent: Tuesday, June 01, 2010 9:47 AM
> >> >> To: arnaud Gaboury
> >> >> Subject: Re: [R] data frame manipulation with zero rows
> >> >>
> >> >> On Tue, 1 Jun 2010, arnaud Gaboury wrote:
> >> >>
> >> >>> Dear group,
> >> >>>
> >> >>> Here is the kind of data.frame I obtain every day with my
> function
> >> :
> >> >>>
> >> >>> futures<-
> >> >>> structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10",
> >> >>> "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE
> Aug/10",
> >> >>> "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11
> Jul/10",
> >> >>> "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10"
> >> >>> ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
> >> >>> 18407, 18408, 18406, 18407, 18407, 18407, 18407), class =
> "Date"),
> >> >>>     QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT
> =
> >> >>> c("373.2500",
> >> >>>     "373.2500", "373.2500", "373.2500", "373.2500", "90.7750",
> >> >>>     "90.7750", "14.9200", "14.9200", "14.9200", "14.9200",
> >> "14.9200"
> >> >>>     )), .Names = c("DESCRIPTION", "CREATED.DATE", "QUANTITY",
> >> >>> "SETTLEMENT"), row.names = c(NA, 12L), class = "data.frame")
> >> >>>
> >> >>> I need then to apply to the df this following code line :
> >> >>>
> >>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >> >> POSITION=
> >> >>> sum(QUANTITY))[,c(1,3,2)]
> >> >>>
> >> >>> It works perfectly in most of case, BUT I have a new problem: it
> >> can
> >> >>> sometime occurs that my df "futures" is empty, with zero rows.
> >> >>>
> >> >>>
> >> >>> futures<-
> >> >>> structure(list(DESCRIPTION = character(0), CREATED.DATE =
> >> >>> structure(numeric(0), class = "Date"),
> >> >>>     QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
> >> >>> c("DESCRIPTION",
> >> >>> "CREATED.DATE", "QUANTITY", "SETTLEMENT"), row.names =
> integer(0),
> >> >> class =
> >> >>> "data.frame")
> >> >>>
> >> >>> It is not the usual case, but it can happen. With this df, when
> I
> >> >> pass the
> >> >>> above mentione line, I get an error :
> >> >>>
> >>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >> >> POSITION=
> >> >>> sum(QUANTITY))[,c(1,3,2)]
> >> >>> Error in tapply(1:nrow(data), splitv, list) :
> >> >>>   arguments must have same length
> >> >>>
> >> >>>
> >> >>> How can I avoid this when my df is empty?
> >> >>
> >> >> Ask the author of the (missing) function ddply() to correct the
> >> error
> >> >> of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
> >> >>
> >> >> It's helpful to give example code, but much more helpful if you
> test
> >> >> it: yours cannot work without the function ddply() -- this is
> what
> >> >> 'self-contained' means in the footer here.
> >> >>
> >> >>
> >> >>>
> >> >>> Any help is appreciated
> >> >>>
> >> >>> __
> >> >>> R-help@r-project.org mailing list
> >> >>> https://stat.ethz.ch/mailman/listinfo/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 Appli

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Joris Meys
Hi Petr,

Matt may very well have been right. As I copied the dput from the mail, any
white space is converted to spaces apparently. Still, it might be possible
the white spaces in your original data are tabs or even newline characters.
You can check that easily with

grep("\t", as.character(becva$V1[1]))
grep("\n", as.character(becva$V1[1]))

Cheers
Joris



On Wed, Jun 2, 2010 at 3:54 PM, Petr PIKAL  wrote:

> Hi
>
> thanks. I am puzzled what was wrong. Now even
>
> sub(' +$', '', bbb[1])
>
> works. I am checking water throughput in nearby river and copying data
> from internet. So I wonder if there was some change recently as during
> floods they update it in about 10 minutes interval.
>
> Regards
> Petr
>
>
> jim holtman  napsal dne 02.06.2010 15:44:42:
>
> > You had the wrong case on 'w' and the wrong expression with
> > [:space:]';  see below
> >
> > > bbb <- c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00 ",
> > + "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> > + "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> > + "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> > + "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> > + "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> > + "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> > + "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> > + "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> > + "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> > + "27.05.10 05:00   ")
> > >  sub('\\W+$', '', bbb[1])
> > [1] "02.06.10 12:40"
> > > sub('[[:space:]]+$', '', bbb[1])
> > [1] "02.06.10 12:40"
> > >
> >
> >
> > On Wed, Jun 2, 2010 at 9:22 AM, Petr PIKAL 
> wrote:
> > > Hi
> > >
> > >> dput(bbb)
> > > c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
> > > "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> > > "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> > > "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> > > "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> > > "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> > > "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> > > "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> > > "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> > > "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> > > "27.05.10 05:00   ")
> > >>
> > >
> > > For simplicity I change the name and put it to single variable.
> > > I also reinstalled R to recent R-devel
> > >
> > >> sub('\\w+$', '', bbb[1])
> > > [1] "02.06.10 12:40   "
> > >> sub('[:space:]', '', bbb[1])
> > > [1] "02.06.10 1240   "
> > >>
> > >
> > > I also tried Matt's suggestion but it did not help.
> > >
> > > Regards
> > > Petr
> > >
> > > Joris Meys  napsal dne 02.06.2010 14:35:19:
> > >
> > >> Could you provide us with dput(becva$V1[1])?
> > >> Cheers
> > >> Joris
> > >
> > >> On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL 
> > > wrote:
> > >> Dear all
> > >>
> > >> I encountered strange problem with regexpr replacement
> > >>
> > >> I made this character object
> > >>
> > >> str <- "02.06.10 12:40 "
> > >>
> > >> > str(str)
> > >>  chr "02.06.10 12:40  "
> > >>
> > >> I read in an object which seems to be quite similar
> > >>
> > >> > str(as.character(becva$V1)[1])
> > >>  chr "02.06.10 12:40   "
> > >>
> > >> However I can not remove trailing spaces from it
> > >>
> > >> > sub(' +$', '', as.character(becva$V1[1]))
> > >>
> > >> [1] "02.06.10 12:40   "
> > >> > sub(' +$', '', str)
> > >> [1] "02.06.10 12:40"
> > >> >
> > >>
> > >> Do somebody have an idea what to do?
> > >>
> > >> $version.string
> > >> [1] "R version 2.12.0 Under development (unstable) (2010-04-25
> r51820)"
> > >>
> > >> on Windows
> > >>
> > >> Regards
> > >> Petr
> > >>
> > >> __
> > >> R-help@r-project.org mailing list
> > >> https://stat.ethz.ch/mailman/listinfo/r-help
> > >> PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > >> and provide commented, minimal, self-contained, reproducible code.
> > >>
> > >>
> > >>
> > >> --
> > >> Joris Meys
> > >> Statistical Consultant
> > >>
> > >> Ghent University
> > >> Faculty of Bioscience Engineering
> > >> Department of Applied mathematics, biometrics and process control
> > >>
> > >> Coupure Links 653
> > >> B-9000 Gent
> > >>
> > >> tel : +32 9 264 59 87
> > >> joris.m...@ugent.be
> > >> ---
> > >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> 

Re: [R] using the design matrix to correctly configure contrasts

2010-06-02 Thread Karl Brand

[Reposting to list]

Thank you Rich.

I still don't get it.

If i understand correctly- the MMC example on maize data outlines an 
issue with the multiple ties between group means. As a result of this, 
"user specified contrasts" needed specifying.


Its this part, understanding the design matrix (ie., the 'treatment 
contrast' for the ANOVA &/or lm design) so that one knows *how* to set 
up cunstom contrasts- the underlying logic- that i need to learn. Demystify.


In this maize example, if it is explained, regretfully i missed it. 
Perhaps i'm making somthing out of nothing, its self evident and i'm 
just complicating it. In that case a bucket of cold water is what i 
need. But maybe you have another example? Or an explicit tutorial 
covering this?


Unfortunatley the local stats here are thin on the ground and thus 
overworked. No time for "R-101" for troublsome biologists like me...


Back to the miaze example in case i missed 'it', and with sincere thanks 
for your suggestion,


karl



On 6/1/2010 6:03 PM, RICHARD M. HEIBERGER wrote:
>
> Please look at the maiz example, the last example in ?MMC in the HH 
package.

> Follow the example all the way to the end.  It illustrates a problem and
> then the resolution
> of the problem.
> install.packages("HH")  ## if you don't have it yet.
> library(HH)
> ?MMC
> Rich

--
Karl Brand 
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268


On 6/1/2010 6:03 PM, RICHARD M. HEIBERGER wrote:


Please look at the maiz example, the last example in ?MMC in the HH package.
Follow the example all the way to the end.  It illustrates a problem and
then the resolution
of the problem.
install.packages("HH")  ## if you don't have it yet.
library(HH)
?MMC
Rich


--
Karl Brand 
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Matt Shotwell
On Wed, 2010-06-02 at 09:22 -0400, Petr PIKAL wrote:
> Hi
> 
> > dput(bbb)
> c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ", 
> "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ", 
> "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ", 
> "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ", 
> "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ", 
> "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ", 
> "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ", 
> "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ", 
> "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ", 
> "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ", 
> "27.05.10 05:00   ")
> >
> 
> For simplicity I change the name and put it to single variable.
> I also reinstalled R to recent R-devel
> 
> > sub('\\w+$', '', bbb[1])

my first message had a typo, should have been with '\\s' rather than '\
\w'.

sub('\\s+$', '', bbb[1])

> [1] "02.06.10 12:40   "
> > sub('[:space:]', '', bbb[1])

this should be

sub('[[:space:]]+$', '', bbb[1])

that's why it stripped the ':' and not white space

> [1] "02.06.10 1240   "
> >
> 
> I also tried Matt's suggestion but it did not help. 
> 
> Regards
> Petr
> 
> Joris Meys  napsal dne 02.06.2010 14:35:19:
> 
> > Could you provide us with dput(becva$V1[1])?
> > Cheers
> > Joris
> 
> > On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL  
> wrote:
> > Dear all
> > 
> > I encountered strange problem with regexpr replacement
> > 
> > I made this character object
> > 
> > str <- "02.06.10 12:40 "
> > 
> > > str(str)
> >  chr "02.06.10 12:40  "
> > 
> > I read in an object which seems to be quite similar
> > 
> > > str(as.character(becva$V1)[1])
> >  chr "02.06.10 12:40   "
> > 
> > However I can not remove trailing spaces from it
> > 
> > > sub(' +$', '', as.character(becva$V1[1]))
> > 
> > [1] "02.06.10 12:40   "
> > > sub(' +$', '', str)
> > [1] "02.06.10 12:40"
> > >
> > 
> > Do somebody have an idea what to do?
> > 
> > $version.string
> > [1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"
> > 
> > on Windows
> > 
> > Regards
> > Petr
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> > 
> > 
> > -- 
> > Joris Meys
> > Statistical Consultant
> > 
> > Ghent University
> > Faculty of Bioscience Engineering 
> > Department of Applied mathematics, biometrics and process control
> > 
> > Coupure Links 653
> > B-9000 Gent
> > 
> > tel : +32 9 264 59 87
> > joris.m...@ugent.be 
> > ---
> > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi

thanks. I am puzzled what was wrong. Now even

sub(' +$', '', bbb[1])

works. I am checking water throughput in nearby river and copying data 
from internet. So I wonder if there was some change recently as during 
floods they update it in about 10 minutes interval.

Regards
Petr


jim holtman  napsal dne 02.06.2010 15:44:42:

> You had the wrong case on 'w' and the wrong expression with
> [:space:]';  see below
> 
> > bbb <- c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00 ",
> + "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> + "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> + "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> + "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> + "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> + "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> + "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> + "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> + "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> + "27.05.10 05:00   ")
> >  sub('\\W+$', '', bbb[1])
> [1] "02.06.10 12:40"
> > sub('[[:space:]]+$', '', bbb[1])
> [1] "02.06.10 12:40"
> >
> 
> 
> On Wed, Jun 2, 2010 at 9:22 AM, Petr PIKAL  
wrote:
> > Hi
> >
> >> dput(bbb)
> > c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
> > "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> > "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> > "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> > "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> > "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> > "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> > "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> > "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> > "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> > "27.05.10 05:00   ")
> >>
> >
> > For simplicity I change the name and put it to single variable.
> > I also reinstalled R to recent R-devel
> >
> >> sub('\\w+$', '', bbb[1])
> > [1] "02.06.10 12:40   "
> >> sub('[:space:]', '', bbb[1])
> > [1] "02.06.10 1240   "
> >>
> >
> > I also tried Matt's suggestion but it did not help.
> >
> > Regards
> > Petr
> >
> > Joris Meys  napsal dne 02.06.2010 14:35:19:
> >
> >> Could you provide us with dput(becva$V1[1])?
> >> Cheers
> >> Joris
> >
> >> On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL 
> > wrote:
> >> Dear all
> >>
> >> I encountered strange problem with regexpr replacement
> >>
> >> I made this character object
> >>
> >> str <- "02.06.10 12:40 "
> >>
> >> > str(str)
> >>  chr "02.06.10 12:40  "
> >>
> >> I read in an object which seems to be quite similar
> >>
> >> > str(as.character(becva$V1)[1])
> >>  chr "02.06.10 12:40   "
> >>
> >> However I can not remove trailing spaces from it
> >>
> >> > sub(' +$', '', as.character(becva$V1[1]))
> >>
> >> [1] "02.06.10 12:40   "
> >> > sub(' +$', '', str)
> >> [1] "02.06.10 12:40"
> >> >
> >>
> >> Do somebody have an idea what to do?
> >>
> >> $version.string
> >> [1] "R version 2.12.0 Under development (unstable) (2010-04-25 
r51820)"
> >>
> >> on Windows
> >>
> >> Regards
> >> Petr
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >>
> >>
> >> --
> >> Joris Meys
> >> Statistical Consultant
> >>
> >> Ghent University
> >> Faculty of Bioscience Engineering
> >> Department of Applied mathematics, biometrics and process control
> >>
> >> Coupure Links 653
> >> B-9000 Gent
> >>
> >> tel : +32 9 264 59 87
> >> joris.m...@ugent.be
> >> ---
> >> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> 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.


Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Joris Meys
sub("\\s+$", '', bbb,perl=T)

does it for me.


On Wed, Jun 2, 2010 at 3:22 PM, Petr PIKAL  wrote:

> Hi
>
> > dput(bbb)
> c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
> "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> "27.05.10 05:00   ")
> >
>
> For simplicity I change the name and put it to single variable.
> I also reinstalled R to recent R-devel
>
> > sub('\\w+$', '', bbb[1])
> [1] "02.06.10 12:40   "
> > sub('[:space:]', '', bbb[1])
> [1] "02.06.10 1240   "
> >
>
> I also tried Matt's suggestion but it did not help.
>
> Regards
> Petr
>
> Joris Meys  napsal dne 02.06.2010 14:35:19:
>
> > Could you provide us with dput(becva$V1[1])?
> > Cheers
> > Joris
>
> > On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL 
> wrote:
> > Dear all
> >
> > I encountered strange problem with regexpr replacement
> >
> > I made this character object
> >
> > str <- "02.06.10 12:40 "
> >
> > > str(str)
> >  chr "02.06.10 12:40  "
> >
> > I read in an object which seems to be quite similar
> >
> > > str(as.character(becva$V1)[1])
> >  chr "02.06.10 12:40   "
> >
> > However I can not remove trailing spaces from it
> >
> > > sub(' +$', '', as.character(becva$V1[1]))
> >
> > [1] "02.06.10 12:40   "
> > > sub(' +$', '', str)
> > [1] "02.06.10 12:40"
> > >
> >
> > Do somebody have an idea what to do?
> >
> > $version.string
> > [1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"
> >
> > on Windows
> >
> > Regards
> > Petr
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >
> > --
> > Joris Meys
> > Statistical Consultant
> >
> > Ghent University
> > Faculty of Bioscience Engineering
> > Department of Applied mathematics, biometrics and process control
> >
> > Coupure Links 653
> > B-9000 Gent
> >
> > tel : +32 9 264 59 87
> > joris.m...@ugent.be
> > ---
> > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>



-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

[[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] writing a matrix in a file

2010-06-02 Thread Sean Anderson

On 10-06-02 10:34 AM, amir wrote:

I want to write a matrix (n*m) in a file (Text file)  such that the file
will be as Result file (below).
I use the below command but it write all numbers in one column,


write(paste(matrixname),file="test.txt",append=TRUE)


how can I do this?
...
Matrix:
  [,1] [,2] [,3] [,4] [,5] [,6]
[1,]55   -1   -1   -1   -1
[2,]882765
[3,]668275


x <- matrix(1:12, nrow = 4)
sink("test.txt")
cat("Matrix:\n")
x
sink()

Also look at ?write.table

Sean

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regexpr mystery can not remove trailing spaces

2010-06-02 Thread jim holtman
You had the wrong case on 'w' and the wrong expression with
[:space:]';  see below

> bbb <- c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
+ "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
+ "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
+ "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
+ "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
+ "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
+ "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
+ "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
+ "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
+ "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
+ "27.05.10 05:00   ")
>  sub('\\W+$', '', bbb[1])
[1] "02.06.10 12:40"
> sub('[[:space:]]+$', '', bbb[1])
[1] "02.06.10 12:40"
>


On Wed, Jun 2, 2010 at 9:22 AM, Petr PIKAL  wrote:
> Hi
>
>> dput(bbb)
> c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ",
> "02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ",
> "02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ",
> "02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ",
> "02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ",
> "01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ",
> "01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ",
> "01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ",
> "01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ",
> "30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ",
> "27.05.10 05:00   ")
>>
>
> For simplicity I change the name and put it to single variable.
> I also reinstalled R to recent R-devel
>
>> sub('\\w+$', '', bbb[1])
> [1] "02.06.10 12:40   "
>> sub('[:space:]', '', bbb[1])
> [1] "02.06.10 1240   "
>>
>
> I also tried Matt's suggestion but it did not help.
>
> Regards
> Petr
>
> Joris Meys  napsal dne 02.06.2010 14:35:19:
>
>> Could you provide us with dput(becva$V1[1])?
>> Cheers
>> Joris
>
>> On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL 
> wrote:
>> Dear all
>>
>> I encountered strange problem with regexpr replacement
>>
>> I made this character object
>>
>> str <- "02.06.10 12:40     "
>>
>> > str(str)
>>  chr "02.06.10 12:40      "
>>
>> I read in an object which seems to be quite similar
>>
>> > str(as.character(becva$V1)[1])
>>  chr "02.06.10 12:40   "
>>
>> However I can not remove trailing spaces from it
>>
>> > sub(' +$', '', as.character(becva$V1[1]))
>>
>> [1] "02.06.10 12:40   "
>> > sub(' +$', '', str)
>> [1] "02.06.10 12:40"
>> >
>>
>> Do somebody have an idea what to do?
>>
>> $version.string
>> [1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"
>>
>> on Windows
>>
>> Regards
>> Petr
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>> --
>> Joris Meys
>> Statistical Consultant
>>
>> Ghent University
>> Faculty of Bioscience Engineering
>> Department of Applied mathematics, biometrics and process control
>>
>> Coupure Links 653
>> B-9000 Gent
>>
>> tel : +32 9 264 59 87
>> joris.m...@ugent.be
>> ---
>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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


Re: [R] writing a matrix in a file

2010-06-02 Thread Jorge Ivan Velez
Hi Amir,

Here is a suggestion:

write.table(yourmatrix, "mymatrix.txt", col.names = FALSE, row.names =
FALSE, sep = "\t", quote = FALSE)

After executing this, you will see a "mymatrix.txt" file in your working
directory. Here, typing getwd() in the R console may also help.
Do not forget to take a look at ?write.table.

HTH,
Jorge


On Wed, Jun 2, 2010 at 9:34 AM, amir <> wrote:

> Hi,
>
> I want to write a matrix (n*m) in a file (Text file)  such that the file
> will be as Result file (below).
> I use the below command but it write all numbers in one column,
>
> > write(paste(matrixname),file="test.txt",append=TRUE)
>
> how can I do this?
>
> Result file:
> 55   -1   -1   -1   -1
> 882765
> 668275
>
> Matrix:
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,]55   -1   -1   -1   -1
> [2,]882765
> [3,]668275
>
> Regards,
> Amir
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] writing a matrix in a file

2010-06-02 Thread jim holtman
try this:

> x <- matrix(1:25,5)
> x
 [,1] [,2] [,3] [,4] [,5]
[1,]16   11   16   21
[2,]27   12   17   22
[3,]38   13   18   23
[4,]49   14   19   24
[5,]5   10   15   20   25
> write.table(x, file='')
"V1" "V2" "V3" "V4" "V5"
"1" 1 6 11 16 21
"2" 2 7 12 17 22
"3" 3 8 13 18 23
"4" 4 9 14 19 24
"5" 5 10 15 20 25
> write.table(x, file='', row.names=FALSE, col.names=FALSE)
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25


On Wed, Jun 2, 2010 at 9:34 AM, amir  wrote:
> Hi,
>
> I want to write a matrix (n*m) in a file (Text file)  such that the file
> will be as Result file (below).
> I use the below command but it write all numbers in one column,
>
>> write(paste(matrixname),file="test.txt",append=TRUE)
>
> how can I do this?
>
> Result file:
> 5    5   -1   -1   -1   -1
> 8    8    2    7    6    5
> 6    6    8    2    7    5
>
> Matrix:
>     [,1] [,2] [,3] [,4] [,5] [,6]
> [1,]    5    5   -1   -1   -1   -1
> [2,]    8    8    2    7    6    5
> [3,]    6    6    8    2    7    5
>
> Regards,
> Amir
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Odp: charactor matrix convert to numeric matrix

2010-06-02 Thread Petr PIKAL
Hi

you have several options

apply(a, 2, as.numeric)

matrix(as.numeric(a),3,2)

b<-as.numeric(a)
dim(b)<-c(3,2)

Regards
Petr


r-help-boun...@r-project.org napsal dne 02.06.2010 14:15:25:

> Hello R experts,
> can you tell me a simple way to convert a charactor matrix to numeric 
matrix?
> if I use as.numeric, the matrix is converted to a vector.
> 
> a<-cbind(c("23","54","65"),c("1","2","3"))
> a
>  [,1] [,2]
> [1,] "23" "1" 
> [2,] "54" "2" 
> [3,] "65" "3" 
> 
>  as.numeric(a)
> [1] 23 54 65  1  2  3
> 
> thanks
> Jian
> 
> 
> 
> 
> 
> 
>[[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] charactor matrix convert to numeric matrix

2010-06-02 Thread Jorge Ivan Velez
Hi Jian,

Try

matrix(as.numeric(a), ncol = 2)

HTH,
Jorge


On Wed, Jun 2, 2010 at 8:15 AM, Yuan Jian <> wrote:

> Hello R experts,
> can you tell me a simple way to convert a charactor matrix to numeric
> matrix?
> if I use as.numeric, the matrix is converted to a vector.
>
> a<-cbind(c("23","54","65"),c("1","2","3"))
> a
>  [,1] [,2]
> [1,] "23" "1"
> [2,] "54" "2"
> [3,] "65" "3"
>
>  as.numeric(a)
> [1] 23 54 65  1  2  3
>
> thanks
> Jian
>
>
>
>
>
>
>[[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] charactor matrix convert to numeric matrix

2010-06-02 Thread jim holtman
try this:

> a<-cbind(c("23","54","65"),c("1","2","3"))
> a
 [,1] [,2]
[1,] "23" "1"
[2,] "54" "2"
[3,] "65" "3"
> mode(a) <- 'numeric'
> a
 [,1] [,2]
[1,]   231
[2,]   542
[3,]   653
>


On Wed, Jun 2, 2010 at 8:15 AM, Yuan Jian  wrote:
> Hello R experts,
> can you tell me a simple way to convert a charactor matrix to numeric matrix?
> if I use as.numeric, the matrix is converted to a vector.
>
> a<-cbind(c("23","54","65"),c("1","2","3"))
> a
>  [,1] [,2]
> [1,] "23" "1"
> [2,] "54" "2"
> [3,] "65" "3"
>
>  as.numeric(a)
> [1] 23 54 65  1  2  3
>
> thanks
> Jian
>
>
>
>
>
>
>        [[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] writing a matrix in a file

2010-06-02 Thread amir
Hi,

I want to write a matrix (n*m) in a file (Text file)  such that the file
will be as Result file (below).
I use the below command but it write all numbers in one column,

> write(paste(matrixname),file="test.txt",append=TRUE)

how can I do this?

Result file:
55   -1   -1   -1   -1
882765
668275

Matrix:
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]55   -1   -1   -1   -1
[2,]882765
[3,]668275

Regards,
Amir

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

2010-06-02 Thread Dries Bonte
Dear R-users,

I build already many contour graphs using the contour-procedure in R (akima 
library), after interpollating my data z on x,y (see e.g. graphs in this paper: 
http://www.biomedcentral.com/content/pdf/1471-2148-9-16.pdf).

Now, however, i experience unexpected and completely unsensible problems: after 
building the syntax, i can create the graphs and use the interp-command without 
any problems. However, after shutting down R and opening the saved syntax (that 
worked), i now get the error message that the 'interp.old' doesn't calculate 
due to collinearity in the data (which is not the case). So, i am now unable to 
create the graphs that i was used to build.

Has anyone got this problem before and, if yes, how was it solved?

Many thanks for the help,
Dries
[[alternative HTML version deleted]]

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


Re: [R] data frame manipulation with zero rows

2010-06-02 Thread Hadley Wickham
Hi Arnaud,

I've added this case to the set of test cases in plyr and it will be
fixed in the next version.

Hadley

On Tue, Jun 1, 2010 at 2:33 PM, arnaud Gaboury  wrote:
> Maybe not the cleanest way, but I create a fake data frame with one row so
> ddply() is happy!!
>> if (nrow(futures)==0) futures<-data.frame(...)
>
>
>
>
>
>> -Original Message-
>> From: Peter Ehlers [mailto:ehl...@ucalgary.ca]
>> Sent: Tuesday, June 01, 2010 12:07 PM
>> To: arnaud Gaboury
>> Cc: 'Prof Brian Ripley'; r-help@r-project.org
>> Subject: Re: [R] data frame manipulation with zero rows
>>
>> On 2010-06-01 1:53, arnaud Gaboury wrote:
>> > Brian,
>> >
>> > If I do understand correctly, I must use in my function something
>> else than
>> > ddply() if I want to avoid any error each time my df has zero rows?
>> > Am I correct?
>> >
>>
>> You could define a function to handle the zero-rows case:
>>
>> f <- function(x){
>>   if(nrow(x) < 1) out <- x[, c(1,3,2)]  # or whatever
>>   else
>>     out <- ddply(x, c("DESCRIPTION","SETTLEMENT"), summarise,
>>                      POSITION=sum(QUANTITY))[,c(1,3,2)]
>>   out
>> }
>> f(futures)
>>
>>   -Peter Ehlers
>>
>> >
>> >
>> >> -Original Message-
>> >> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
>> >> Sent: Tuesday, June 01, 2010 9:47 AM
>> >> To: arnaud Gaboury
>> >> Subject: Re: [R] data frame manipulation with zero rows
>> >>
>> >> On Tue, 1 Jun 2010, arnaud Gaboury wrote:
>> >>
>> >>> Dear group,
>> >>>
>> >>> Here is the kind of data.frame I obtain every day with my function
>> :
>> >>>
>> >>> futures<-
>> >>> structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10",
>> >>> "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10",
>> >>> "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10",
>> >>> "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10"
>> >>> ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
>> >>> 18407, 18408, 18406, 18407, 18407, 18407, 18407), class = "Date"),
>> >>>     QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
>> >>> c("373.2500",
>> >>>     "373.2500", "373.2500", "373.2500", "373.2500", "90.7750",
>> >>>     "90.7750", "14.9200", "14.9200", "14.9200", "14.9200",
>> "14.9200"
>> >>>     )), .Names = c("DESCRIPTION", "CREATED.DATE", "QUANTITY",
>> >>> "SETTLEMENT"), row.names = c(NA, 12L), class = "data.frame")
>> >>>
>> >>> I need then to apply to the df this following code line :
>> >>>
>>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
>> >> POSITION=
>> >>> sum(QUANTITY))[,c(1,3,2)]
>> >>>
>> >>> It works perfectly in most of case, BUT I have a new problem: it
>> can
>> >>> sometime occurs that my df "futures" is empty, with zero rows.
>> >>>
>> >>>
>> >>> futures<-
>> >>> structure(list(DESCRIPTION = character(0), CREATED.DATE =
>> >>> structure(numeric(0), class = "Date"),
>> >>>     QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
>> >>> c("DESCRIPTION",
>> >>> "CREATED.DATE", "QUANTITY", "SETTLEMENT"), row.names = integer(0),
>> >> class =
>> >>> "data.frame")
>> >>>
>> >>> It is not the usual case, but it can happen. With this df, when I
>> >> pass the
>> >>> above mentione line, I get an error :
>> >>>
>>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
>> >> POSITION=
>> >>> sum(QUANTITY))[,c(1,3,2)]
>> >>> Error in tapply(1:nrow(data), splitv, list) :
>> >>>   arguments must have same length
>> >>>
>> >>>
>> >>> How can I avoid this when my df is empty?
>> >>
>> >> Ask the author of the (missing) function ddply() to correct the
>> error
>> >> of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
>> >>
>> >> It's helpful to give example code, but much more helpful if you test
>> >> it: yours cannot work without the function ddply() -- this is what
>> >> 'self-contained' means in the footer here.
>> >>
>> >>
>> >>>
>> >>> Any help is appreciated
>> >>>
>> >>> __
>> >>> R-help@r-project.org mailing list
>> >>> https://stat.ethz.ch/mailman/listinfo/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, UK                Fax:  +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.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
h

[R] About Error Message in readSeries function from Rmetrics

2010-06-02 Thread JOSH C. CHIEN
Hi all R users,
I download market data from Yahoo Finance to save file in csv.
But, I can't load data set into R successfully. I don't why ?
Below is error message. 

> data <- readSeries("D:/data.csv",header=T,sep=",")
Error in midnightStandard2(charvec, format) : 
  'charvec' has non-NA entries of different number of characters

Does anyone know what happen with me ?
thanks a lot.
[[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] charactor matrix convert to numeric matrix

2010-06-02 Thread Yuan Jian
Hello R experts,
can you tell me a simple way to convert a charactor matrix to numeric matrix?
if I use as.numeric, the matrix is converted to a vector.

a<-cbind(c("23","54","65"),c("1","2","3"))
a
 [,1] [,2]
[1,] "23" "1" 
[2,] "54" "2" 
[3,] "65" "3" 

 as.numeric(a)
[1] 23 54 65  1  2  3

thanks
Jian





  
[[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] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi

> dput(bbb)
c("02.06.10 12:40   ", "02.06.10 12:00   ", "02.06.10 11:00   ", 
"02.06.10 10:00   ", "02.06.10 09:00   ", "02.06.10 08:00   ", 
"02.06.10 07:00   ", "02.06.10 06:00   ", "02.06.10 05:00   ", 
"02.06.10 04:00   ", "02.06.10 03:00   ", "02.06.10 02:00   ", 
"02.06.10 01:00   ", "02.06.10 00:00   ", "01.06.10 23:00   ", 
"01.06.10 22:00   ", "01.06.10 21:00   ", "01.06.10 20:00   ", 
"01.06.10 19:00   ", "01.06.10 18:00   ", "01.06.10 17:00   ", 
"01.06.10 16:00   ", "01.06.10 15:00   ", "01.06.10 14:00   ", 
"01.06.10 13:00   ", "01.06.10 05:00   ", "31.05.10 05:00   ", 
"30.05.10 05:00   ", "29.05.10 05:00   ", "28.05.10 05:00   ", 
"27.05.10 05:00   ")
>

For simplicity I change the name and put it to single variable.
I also reinstalled R to recent R-devel

> sub('\\w+$', '', bbb[1])
[1] "02.06.10 12:40   "
> sub('[:space:]', '', bbb[1])
[1] "02.06.10 1240   "
>

I also tried Matt's suggestion but it did not help. 

Regards
Petr

Joris Meys  napsal dne 02.06.2010 14:35:19:

> Could you provide us with dput(becva$V1[1])?
> Cheers
> Joris

> On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL  
wrote:
> Dear all
> 
> I encountered strange problem with regexpr replacement
> 
> I made this character object
> 
> str <- "02.06.10 12:40 "
> 
> > str(str)
>  chr "02.06.10 12:40  "
> 
> I read in an object which seems to be quite similar
> 
> > str(as.character(becva$V1)[1])
>  chr "02.06.10 12:40   "
> 
> However I can not remove trailing spaces from it
> 
> > sub(' +$', '', as.character(becva$V1[1]))
> 
> [1] "02.06.10 12:40   "
> > sub(' +$', '', str)
> [1] "02.06.10 12:40"
> >
> 
> Do somebody have an idea what to do?
> 
> $version.string
> [1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"
> 
> on Windows
> 
> Regards
> Petr
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> -- 
> Joris Meys
> Statistical Consultant
> 
> Ghent University
> Faculty of Bioscience Engineering 
> Department of Applied mathematics, biometrics and process control
> 
> Coupure Links 653
> B-9000 Gent
> 
> tel : +32 9 264 59 87
> joris.m...@ugent.be 
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


Re: [R] compute the associate vector of distances between leaves in a binary non-rooted tree

2010-06-02 Thread Joris Meys
Hi,

with a little hack you can use the function cophenetic.phylo from ape. You
just set all branch lengths to 1 :

require(ape)

>tree <- rtree(5,rooted=F)
>n <- length(tree$edge.length)
>tree$edge.length <- rep(1,n)
>cophenetic.phylo(tree)

   t3 t1 t2 t4 t5
t3  0  3  3  3  3
t1  3  0  2  4  4
t2  3  2  0  4  4
t4  3  4  4  0  2
t5  3  4  4  2  0

Cheers


On Wed, Jun 2, 2010 at 2:47 PM, Arnau Mir Torres  wrote:

> Hello.
>
> I'd like to compute the associate vector of distances between leaves in a
> binary non-rooted tree. The definition of a distance between two leaves in a
> binary non-rooted tree is the number of edges in the path joining the two
> leaves.
> I've tried the ape package but I'm unable to find this vector.
> For example, using rtree(5,rooted=F) I've obtained the following tree:
>
> $edge
> [,1] [,2]
> [1,]67
> [2,]71
> [3,]78
> [4,]82
> [5,]83
> [6,]64
> [7,]65
>
> $tip.label
> [1] "t4" "t3" "t2" "t1" "t5"
>
> $edge.length
> [1] 0.9126727 0.2765674 0.4996832 0.7904400 0.8508797 0.8174133 0.9027958
>
> $Nnode
> [1] 3
>
>
> My question is: how to compute the vector of distances between the 5
> leaves. This vector is in this case:
>
> v=(d(t1,t2),d(t1,t3),d(t1,t4),d(t1,t5),d(t2,t3),d(t2,t4),d(t2,t5),d(t3,t4),d(t3,t5),d(t4,t5))=(4,4,3,2,2,3,4,3,4,3).
>
>
> Thanks in advance,
>
> Arnau.
> 
> Arnau Mir Torres
> Edifici A. Turmeda
> Campus UIB
> Ctra. Valldemossa, km. 7,5
> 07122 Palma de Mca.
> tel: (+34) 971172987
> fax: (+34) 971173003
> email: arnau@uib.es
> URL: http://dmi.uib.es/~arnau 
> 
>
>
>
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

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

Coupure Links 653
B-9000 Gent

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

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

2010-06-02 Thread Erick Rocha Fonseca
Dear all,

I'm having difficulties installing a package on Windows. It has only R
data files, no code. I've built it on a Linux platform and installed it
there without problems. When I tried installing the .tar.gz on Windows,
via install.packages, I got the following errors:

Error in gzfile(file, "r") : unable to open connection 
In addition: Warning message:
1: In unzip(zipname, exdir = dest) :
  error 1 in extracting from zip file 
2: In gzfile(file, "r") :
  cannot open compressed file 'pkgname.tar.gz/DESCRIPTION', probable
reason 'No such file or directory'


After searching in the web, I tried installing the Rtools kit. The
problem with install.packages remains, but I managed to install it with
R CMD INSTALL. What could be wrong with install.packages? As far as I
understood, installing a package without source code shouldn't need the
resources in Rtools.

Thanks, 

Erick Fonseca

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


[R] compute the associate vector of distances between leaves in a binary non-rooted tree

2010-06-02 Thread Arnau Mir Torres
Hello.

I'd like to compute the associate vector of distances between leaves in a 
binary non-rooted tree. The definition of a distance between two leaves in a 
binary non-rooted tree is the number of edges in the path joining the two 
leaves.
I've tried the ape package but I'm unable to find this vector. 
For example, using rtree(5,rooted=F) I've obtained the following tree:

$edge
 [,1] [,2]
[1,]67
[2,]71
[3,]78
[4,]82
[5,]83
[6,]64
[7,]65

$tip.label
[1] "t4" "t3" "t2" "t1" "t5"

$edge.length
[1] 0.9126727 0.2765674 0.4996832 0.7904400 0.8508797 0.8174133 0.9027958

$Nnode
[1] 3


My question is: how to compute the vector of distances between the 5 leaves. 
This vector is in this case:
v=(d(t1,t2),d(t1,t3),d(t1,t4),d(t1,t5),d(t2,t3),d(t2,t4),d(t2,t5),d(t3,t4),d(t3,t5),d(t4,t5))=(4,4,3,2,2,3,4,3,4,3).


Thanks in advance,

Arnau.

Arnau Mir Torres
Edifici A. Turmeda
Campus UIB
Ctra. Valldemossa, km. 7,5
07122 Palma de Mca.
tel: (+34) 971172987
fax: (+34) 971173003
email: arnau@uib.es
URL: http://dmi.uib.es/~arnau









__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Matt Shotwell
On Wed, 2010-06-02 at 08:07 -0400, Petr PIKAL wrote:
> Dear all
> 
> I encountered strange problem with regexpr replacement
> 
> I made this character object
> 
> str <- "02.06.10 12:40 "
> 
> > str(str)
>  chr "02.06.10 12:40  "
> 
> I read in an object which seems to be quite similar
> 
> > str(as.character(becva$V1)[1])
>  chr "02.06.10 12:40   "
> 
> However I can not remove trailing spaces from it
> 
> > sub(' +$', '', as.character(becva$V1[1]))
> 
> [1] "02.06.10 12:40   "
> > sub(' +$', '', str)
> [1] "02.06.10 12:40"
> >
> 
> Do somebody have an idea what to do?

Could the white space in the string be a tab? If so, the space character
will not match. Try something that matches multiple white space, like

sub('\\w+$', '', as.character(becva$V1[1]))

or

sub('[[:blank:]]+$', '', as.character(becva$V1[1]))




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

> 
> $version.string
> [1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"
> 
> on Windows
> 
> Regards
> Petr
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


  1   2   >