Re: [R] Military Time Comparison

2012-02-26 Thread Edgar Alminar
Oh, haha -- sorry for the vagueness:

I was expecting to get the comparison to work. I also didn't mention that the 
dataset is much larger; I just wanted to give the first few rows. 

So, basically, I have a bunch of times in three columns, and I'm looking to 
compare them in which the command works correctly. 

Let's say, using the example below, that I want to get:

>> match2 = subset(match2, AEONTIME < INFTIME.x)

Well, with that exact syntax, it's not working because I'm getting back a 
dataset in which some AEONTIMEs are actually > INFTIME.x.

So, I feel like I'm just missing a piece of the syntax (i.e. as.date, 
as.character, but what works for time?)

I hope this helps. :-)

Thanks!


On Feb 26, 2012, at 9:32 PM, David Winsemius wrote:

> 
> On Feb 26, 2012, at 10:31 PM, Edgar Alminar wrote:
> 
>> Hello All,
>> I have this dataset:
>> 
>>   RID VISCODE  SCRNO RECNO AEWHEN   AEONDATE AEONTIME INFPOINT.x  
>> INFDATE.x INFTIME.x INFPOINT.y  INFDATE.y INFTIME.y
>> 1   100 w00 IGI1480069 4  2 09/15/2009 1118  1 
>> 09/15/2009   947 14 -4  1117
>> 2   100 w00 IGI1480069 8  2 09/15/2009 1132  1 
>> 09/15/2009   947 14 -4  1117
>> 3   100 w00 IGI1480069 5  2 09/15/2009 1125  1 
>> 09/15/2009   947 14 -4  1117
>> 
>> 
>> 
>> I have AEONTIME, INFTIME.x, and INFTIME.y, and they are all military times.
>> I'm trying to do a comparison like this:
>> 
>> match2 = subset(match2, AEONTIME < INFTIME.x)
>> 
>> But it's not working correctly.
> 
> Define what you expected. In the sample you offered none of those logical 
> comparisons would be true so you should get a dataframe with zero rows. (And 
> since you gave the result the same name, you have basically wiped out match2.)
> 
> 
>> How do I do this? :-)
> 
> Do what?
> 
> -- 
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 

Edgar Alminar
Clinical Operations
Alzheimer's Disease Cooperative Study
University of California, San Diego
9500 Gilman Drive, MC-0949
La Jolla, CA 92093-0949
Tel: (858) 622-8798
Fax: (858) 622-5876
Email: eaalmi...@ucsd.edu

Confidentiality Notice- This e-mail message from the Alz...{{dropped:11}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] large data sets of irregular time series

2012-02-26 Thread stathisan
Hi, I am trying to run several types of time series/statistical analysis on
large data sets of irregularly spaced time series. So far I have been
playing around with zoo, but for large data sets I run into memory problems.
Is there any package that offers support for such analysis? Or you think
bigmemory and ff packages would be the appropriate ones after some
manipulation of my time series data? Stuff that I am trying to do is fitting
VAR models, fitting univariate and multivariate GARCH models, construct
large correlation matrices (say 5000 time series each having 6000
observations) etc. 

--
View this message in context: 
http://r.789695.n4.nabble.com/large-data-sets-of-irregular-time-series-tp4423642p4423642.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] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread Vijayan Padmanabhan
Thank you.. I cant imagine that I missed the most obvious route from my 
attempt!

Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 




Uwe Ligges  
02/27/2012 12:57 PM

To
Vijayan Padmanabhan 
cc
"R. Michael Weylandt" , r-help@r-project.org
Subject
Re: [R] win zip archive of library(HH) for R2.12.0






I wonder why nobopdy suggested to run

install.packages("HH")

since the binary is in the 2.12 repository on CRAN:

CRAN-mirror/bin/windows/contrib/2.12/

Uwe Ligges



On 27.02.2012 07:30, Vijayan Padmanabhan wrote:
> Dear Michael
>
> I found an alternate way that was useful at least in this case.
> Trust someone would benefit from a similar approach in the RGroup when
> they face a similar problem as  mine by following this approach.
>
> I saved the tar.gz file of package HH, corresponding to the R version of
> mine in a local drive path and ran the following command at R Prompt..
> It works!
>
> install.packages("H:/RPackages/HH_2.1-32.tar.gz", repos = NULL,
> type="source")
>
> Thanks
>
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
>
>
>
> "R. Michael Weylandt"
> 02/27/2012 11:46 AM
>
> To
> Vijayan Padmanabhan
> cc
> r-help@r-project.org
> Subject
> Re: [R] win zip archive of library(HH) for R2.12.0
>
>
>
>
>
>
> I believe you'll have to build it yourself from the sources (in the
> tarball) - or perhaps find some kind soul who's willing to - the 
official
> repositories don't support a version that's about to be 18months out of
> date.
>
> Michael
>
> On Mon, Feb 27, 2012 at 1:12 AM, Vijayan 
Padmanabhan> wrote:
>
> Dear Michael
> I checked this link.. the archives shown here are all tar.gz versions.
> I am looking for a zip archive, to install on my windows XP installation
> of R 2.12.0.
> pl help if you have the link to windows archives.
>
> Thanks
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
>
>
>
> "R. Michael Weylandt"
> 02/27/2012 11:38 AM
>
>
> To
> Vijayan Padmanabhan
> cc
> r-help@r-project.org
> Subject
> Re: [R] win zip archive of library(HH) for R2.12.0
>
>
>
>
>
>
>
>
> Old sources are available here:
> http://cran.r-project.org/src/contrib/Archive/HH/
>
> You'll have to see which ones are compatible
>
> Michael
>
> On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
>   wrote:
>> Dear R Group
>> Can any body point me to a link from where I can get zip archive of the
>> package HH for R 2.12.0?
>>
>> Thanks&
>> Regards
>> Vijayan Padmanabhan
>>
>>
>> "What is expressed without proof can be denied without proof" - 
Euclide.
>>
>> Please visit us at www.itcportal.com
>>
> 
**
>> This Communication is for the exclusive use of the intended recipient
> (s) and shall
>> not attach any liability on the originator or ITC Ltd./its
> Subsidiaries/its Group
>> Companies. If you are the addressee, the contents of this email are
> intended for your use only and it shall not be forwarded to any third
> party, without first obtaining written authorisation from the originator
> or ITC Ltd./its Subsidiaries/its Group Companies. It may contain
> information which is confidential and legally privileged and the same
> shall not be used or dealt with by any third party in any manner
> whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its
> Group Companies.
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> Please visit us at www.itcportal.com
> 
**
> This Communication is for the exclusive use of the intended recipient 
(s)
> and shall
> not attach any liability on the originator or ITC Ltd./its
> Subsidiaries/its Group
> Companies. If you are the addressee, the contents of this email are
> intended for your use only and it shall not be forwarded to any third
> party, without first obtaining written authorisation from the originator
> or ITC Ltd./its Subsidiaries/its Group Companies. It may contain
> information which is confidential and legally privileged and the same
> shall not be used or dealt with by any third party in any manner
> whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its
> Group Companies.
>
>
> Please visit us at www.itcportal.com
> 
**
> This Communication is for the exclusive use of the intended recipient 
(s) and shall
> not attach any liability on the originator or ITC Ltd./its 
Subsidiaries/its Group
> Companies. If you are the addressee, the content

Re: [R] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread Uwe Ligges

I wonder why nobopdy suggested to run

install.packages("HH")

since the binary is in the 2.12 repository on CRAN:

CRAN-mirror/bin/windows/contrib/2.12/

Uwe Ligges



On 27.02.2012 07:30, Vijayan Padmanabhan wrote:

Dear Michael

I found an alternate way that was useful at least in this case.
Trust someone would benefit from a similar approach in the RGroup when
they face a similar problem as  mine by following this approach.

I saved the tar.gz file of package HH, corresponding to the R version of
mine in a local drive path and ran the following command at R Prompt..
It works!

install.packages("H:/RPackages/HH_2.1-32.tar.gz", repos = NULL,
type="source")

Thanks

Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide.




"R. Michael Weylandt"
02/27/2012 11:46 AM

To
Vijayan Padmanabhan
cc
r-help@r-project.org
Subject
Re: [R] win zip archive of library(HH) for R2.12.0






I believe you'll have to build it yourself from the sources (in the
tarball) - or perhaps find some kind soul who's willing to - the official
repositories don't support a version that's about to be 18months out of
date.

Michael

On Mon, Feb 27, 2012 at 1:12 AM, Vijayan Padmanabhan
wrote:


Dear Michael
I checked this link.. the archives shown here are all tar.gz versions.
I am looking for a zip archive, to install on my windows XP installation
of R 2.12.0.
pl help if you have the link to windows archives.

Thanks
Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide.




"R. Michael Weylandt"
02/27/2012 11:38 AM


To
Vijayan Padmanabhan
cc
r-help@r-project.org
Subject
Re: [R] win zip archive of library(HH) for R2.12.0








Old sources are available here:
http://cran.r-project.org/src/contrib/Archive/HH/

You'll have to see which ones are compatible

Michael

On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
  wrote:

Dear R Group
Can any body point me to a link from where I can get zip archive of the
package HH for R 2.12.0?

Thanks&
Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide.

Please visit us at www.itcportal.com


**

This Communication is for the exclusive use of the intended recipient

(s) and shall

not attach any liability on the originator or ITC Ltd./its

Subsidiaries/its Group

Companies. If you are the addressee, the contents of this email are

intended for your use only and it shall not be forwarded to any third
party, without first obtaining written authorisation from the originator
or ITC Ltd./its Subsidiaries/its Group Companies. It may contain
information which is confidential and legally privileged and the same
shall not be used or dealt with by any third party in any manner
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its
Group Companies.

[[alternative HTML version deleted]]

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

http://www.R-project.org/posting-guide.html

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


Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s)
and shall
not attach any liability on the originator or ITC Ltd./its
Subsidiaries/its Group
Companies. If you are the addressee, the contents of this email are
intended for your use only and it shall not be forwarded to any third
party, without first obtaining written authorisation from the originator
or ITC Ltd./its Subsidiaries/its Group Companies. It may contain
information which is confidential and legally privileged and the same
shall not be used or dealt with by any third party in any manner
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its
Group Companies.


Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
[[alternative HTML version deleted]]

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

Re: [R] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread Vijayan Padmanabhan
Dear Michael

I found an alternate way that was useful at least in this case.
Trust someone would benefit from a similar approach in the RGroup when 
they face a similar problem as  mine by following this approach.

I saved the tar.gz file of package HH, corresponding to the R version of 
mine in a local drive path and ran the following command at R Prompt..
It works!

install.packages("H:/RPackages/HH_2.1-32.tar.gz", repos = NULL, 
type="source") 

Thanks

Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 




"R. Michael Weylandt"  
02/27/2012 11:46 AM

To
Vijayan Padmanabhan 
cc
r-help@r-project.org
Subject
Re: [R] win zip archive of library(HH) for R2.12.0






I believe you'll have to build it yourself from the sources (in the 
tarball) - or perhaps find some kind soul who's willing to - the official 
repositories don't support a version that's about to be 18months out of 
date. 

Michael

On Mon, Feb 27, 2012 at 1:12 AM, Vijayan Padmanabhan  wrote:

Dear Michael 
I checked this link.. the archives shown here are all tar.gz versions. 
I am looking for a zip archive, to install on my windows XP installation 
of R 2.12.0. 
pl help if you have the link to windows archives. 

Thanks 
Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 




"R. Michael Weylandt"  
02/27/2012 11:38 AM 


To
Vijayan Padmanabhan  
cc
r-help@r-project.org 
Subject
Re: [R] win zip archive of library(HH) for R2.12.0








Old sources are available here:
http://cran.r-project.org/src/contrib/Archive/HH/

You'll have to see which ones are compatible

Michael

On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
 wrote:
> Dear R Group
> Can any body point me to a link from where I can get zip archive of the
> package HH for R 2.12.0?
>
> Thanks &
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
> Please visit us at www.itcportal.com
> 
**
> This Communication is for the exclusive use of the intended recipient 
(s) and shall
> not attach any liability on the originator or ITC Ltd./its 
Subsidiaries/its Group
> Companies. If you are the addressee, the contents of this email are 
intended for your use only and it shall not be forwarded to any third 
party, without first obtaining written authorisation from the originator 
or ITC Ltd./its Subsidiaries/its Group Companies. It may contain 
information which is confidential and legally privileged and the same 
shall not be used or dealt with by any third party in any manner 
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its 
Group Companies.
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) 
and shall
not attach any liability on the originator or ITC Ltd./its 
Subsidiaries/its Group 
Companies. If you are the addressee, the contents of this email are 
intended for your use only and it shall not be forwarded to any third 
party, without first obtaining written authorisation from the originator 
or ITC Ltd./its Subsidiaries/its Group Companies. It may contain 
information which is confidential and legally privileged and the same 
shall not be used or dealt with by any third party in any manner 
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its 
Group Companies.


Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
[[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, reproducibl

Re: [R] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread R. Michael Weylandt
I believe you'll have to build it yourself from the sources (in the
tarball) - or perhaps find some kind soul who's willing to - the official
repositories don't support a version that's about to be 18months out of
date.

Michael

On Mon, Feb 27, 2012 at 1:12 AM, Vijayan Padmanabhan
wrote:

>
> Dear Michael
> I checked this link.. the archives shown here are all tar.gz versions.
> I am looking for a zip archive, to install on my windows XP installation
> of R 2.12.0.
> pl help if you have the link to windows archives.
>
> Thanks
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
>
>
>  *"R. Michael Weylandt" *
>
> 02/27/2012 11:38 AM
>   To
> Vijayan Padmanabhan 
> cc
> r-help@r-project.org
> Subject
> Re: [R] win zip archive of library(HH) for R2.12.0
>
>
>
>
> Old sources are available here:
> http://cran.r-project.org/src/contrib/Archive/HH/
>
> You'll have to see which ones are compatible
>
> Michael
>
> On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
>  wrote:
> > Dear R Group
> > Can any body point me to a link from where I can get zip archive of the
> > package HH for R 2.12.0?
> >
> > Thanks &
> > Regards
> > Vijayan Padmanabhan
> >
> >
> > "What is expressed without proof can be denied without proof" - Euclide.
> >
> > Please visit us at www.itcportal.com
> >
> **
> > This Communication is for the exclusive use of the intended recipient
> (s) and shall
> > not attach any liability on the originator or ITC Ltd./its
> Subsidiaries/its Group
> > Companies. If you are the addressee, the contents of this email are
> intended for your use only and it shall not be forwarded to any third
> party, without first obtaining written authorisation from the originator or
> ITC Ltd./its Subsidiaries/its Group Companies. It may contain information
> which is confidential and legally privileged and the same shall not be used
> or dealt with by any third party in any manner whatsoever without the
> specific consent of ITC Ltd./its Subsidiaries/its Group Companies.
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> Please visit us at www.itcportal.com
> **
> This Communication is for the exclusive use of the intended recipient (s) and 
> shall
> not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
> Group
> Companies. If you are the addressee, the contents of this email are intended 
> for your use only and it shall not be forwarded to any third party, without 
> first obtaining written authorisation from the originator or ITC Ltd./its 
> Subsidiaries/its Group Companies. It may contain information which is 
> confidential and legally privileged and the same shall not be used or dealt 
> with by any third party in any manner whatsoever without the specific consent 
> of ITC Ltd./its Subsidiaries/its Group Companies.
>
>

[[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] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread Vijayan Padmanabhan
Dear Michael
I checked this link.. the archives shown here are all tar.gz versions.
I am looking for a zip archive, to install on my windows XP installation 
of R 2.12.0.
pl help if you have the link to windows archives.

Thanks
Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 




"R. Michael Weylandt"  
02/27/2012 11:38 AM

To
Vijayan Padmanabhan 
cc
r-help@r-project.org
Subject
Re: [R] win zip archive of library(HH) for R2.12.0






Old sources are available here:
http://cran.r-project.org/src/contrib/Archive/HH/

You'll have to see which ones are compatible

Michael

On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
 wrote:
> Dear R Group
> Can any body point me to a link from where I can get zip archive of the
> package HH for R 2.12.0?
>
> Thanks &
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
> Please visit us at www.itcportal.com
> 
**
> This Communication is for the exclusive use of the intended recipient 
(s) and shall
> not attach any liability on the originator or ITC Ltd./its 
Subsidiaries/its Group
> Companies. If you are the addressee, the contents of this email are 
intended for your use only and it shall not be forwarded to any third 
party, without first obtaining written authorisation from the originator 
or ITC Ltd./its Subsidiaries/its Group Companies. It may contain 
information which is confidential and legally privileged and the same 
shall not be used or dealt with by any third party in any manner 
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its 
Group Companies.
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
[[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] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread R. Michael Weylandt
Old sources are available here:
http://cran.r-project.org/src/contrib/Archive/HH/

You'll have to see which ones are compatible

Michael

On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan
 wrote:
> Dear R Group
> Can any body point me to a link from where I can get zip archive of the
> package HH for R 2.12.0?
>
> Thanks &
> Regards
> Vijayan Padmanabhan
>
>
> "What is expressed without proof can be denied without proof" - Euclide.
>
> Please visit us at www.itcportal.com
> **
> This Communication is for the exclusive use of the intended recipient (s) and 
> shall
> not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
> Group
> Companies. If you are the addressee, the contents of this email are intended 
> for your use only and it shall not be forwarded to any third party, without 
> first obtaining written authorisation from the originator or ITC Ltd./its 
> Subsidiaries/its Group Companies. It may contain information which is 
> confidential and legally privileged and the same shall not be used or dealt 
> with by any third party in any manner whatsoever without the specific consent 
> of ITC Ltd./its Subsidiaries/its Group Companies.
>        [[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] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread Vijayan Padmanabhan
Dear R Group
Can any body point me to a link from where I can get zip archive of the 
package HH for R 2.12.0?

Thanks & 
Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 

Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
[[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] Suggestion on Model Def - reg in nlme

2012-02-26 Thread Vijayan Padmanabhan
Dear RGroup
I have a data of the type shown below:
I am trying to use lme function followed by post hoc test as given in the 
code below.
Am I right in my model definition, given the problem data structure. 

in the example, i have used column names of my data frame so that it is 
self explanatory.


library(reshape)
library(nlme)
library(multcomp)

df<-expand.grid(Subject=c("S1","S2","S3"),Arm=c("L","R"),Treatment=c("A","B","C"),Time=c("T0","T1","T2"))
df$Attr1<-rnorm(27,40,2.2)
df$Attr2<-rnorm(27,76,4.2)
df<-melt(df)
colnames(df)
head(df)

df<-subset(df,variable=="Attr1")
df<-droplevels(df)

model <- lme(value ~ Treatment*Arm*Time, random = ~1 | Subject,data =df)
print("R Formula Used - lme(value ~ Treatment*Arm*Time, random = ~1 | 
Subject)")
summary(model)
x<-anova(model)
print(x)
summary(glht(model,linfct=mcp(Time="Tukey")))
plot(summary(glht(model,linfct=mcp(Time="Tukey"))),cex.axis=0.6)


summary(glht(model,linfct=mcp(Treatment="Tukey")))
plot(summary(glht(model,linfct=mcp(Treatment="Tukey"))),cex.axis=0.6)



Regards
Vijayan Padmanabhan


"What is expressed without proof can be denied without proof" - Euclide. 

Please visit us at www.itcportal.com
**
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your use only and it shall not be forwarded to any third party, without 
first obtaining written authorisation from the originator or ITC Ltd./its 
Subsidiaries/its Group Companies. It may contain information which is 
confidential and legally privileged and the same shall not be used or dealt 
with by any third party in any manner whatsoever without the specific consent 
of ITC Ltd./its Subsidiaries/its Group Companies.
[[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] Military Time Comparison

2012-02-26 Thread David Winsemius


On Feb 26, 2012, at 10:31 PM, Edgar Alminar wrote:


Hello All,
I have this dataset:

   RID VISCODE  SCRNO RECNO AEWHEN   AEONDATE AEONTIME  
INFPOINT.x  INFDATE.x INFTIME.x INFPOINT.y  INFDATE.y INFTIME.y
1   100 w00 IGI1480069 4  2 09/15/2009 1118   
1 09/15/2009   947 14 -4  1117
2   100 w00 IGI1480069 8  2 09/15/2009 1132   
1 09/15/2009   947 14 -4  1117
3   100 w00 IGI1480069 5  2 09/15/2009 1125   
1 09/15/2009   947 14 -4  1117




I have AEONTIME, INFTIME.x, and INFTIME.y, and they are all military  
times.

I'm trying to do a comparison like this:

match2 = subset(match2, AEONTIME < INFTIME.x)

But it's not working correctly.


Define what you expected. In the sample you offered none of those  
logical comparisons would be true so you should get a dataframe with  
zero rows. (And since you gave the result the same name, you have  
basically wiped out match2.)




How do I do this? :-)


Do what?

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Military Time Comparison

2012-02-26 Thread Edgar Alminar
Hello All,
I have this dataset:

RID VISCODE  SCRNO RECNO AEWHEN   AEONDATE AEONTIME INFPOINT.x  
INFDATE.x INFTIME.x INFPOINT.y  INFDATE.y INFTIME.y
1   100 w00 IGI1480069 4  2 09/15/2009 1118  1 
09/15/2009   947 14 -4  1117
2   100 w00 IGI1480069 8  2 09/15/2009 1132  1 
09/15/2009   947 14 -4  1117
3   100 w00 IGI1480069 5  2 09/15/2009 1125  1 
09/15/2009   947 14 -4  1117



I have AEONTIME, INFTIME.x, and INFTIME.y, and they are all military times.
I'm trying to do a comparison like this: 

match2 = subset(match2, AEONTIME < INFTIME.x)

But it's not working correctly. How do I do this? :-)




THANKS!





Edgar Alminar
Clinical Operations
Alzheimer's Disease Cooperative Study
University of California, San Diego
9500 Gilman Drive, MC-0949
La Jolla, CA 92093-0949
Tel: (858) 622-8798
Fax: (858) 622-5876
Email: eaalmi...@ucsd.edu

Confidentiality Notice- This e-mail message from the Alz...{{dropped:11}}

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


Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Rui Barradas
Hello, again.

> Did anyone ever mention the 'countLines' function in R.utils.

No, I didn't know about it.
Thanks.

Rui Barradas




--
View this message in context: 
http://r.789695.n4.nabble.com/count-how-many-row-i-have-in-a-txt-file-in-a-directory-tp4422186p4423521.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] A new book "Guidebook to R Graphics Using Microsoft Windows (Wiley)"

2012-02-26 Thread 竹澤邦夫
Dear R-Users,

   A new book "Guidebook to R Graphics Using Microsoft Windows (Wiley)" is
out.

http://as.wiley.com/WileyCDA/WileyTitle/productCd-111802639X.html

http://www.amazon.com/Guidebook-Graphics-Using-Microsoft-Windows/dp/111802639X/ref=sr_1_1?ie=UTF8&qid=1330301212&sr=8-1

 E-mail: takez...@affrc.go.jp 
 * http://cse.naro.affrc.go.jp/takezawa/intro.html *

[[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 problem to extract animal associations

2012-02-26 Thread Ross Dwyer
Dear List,

I have been trying to extract associations from a matrix whereby individual 
locations are within a certain distance threshold from one another.

I have been able to extract those individuals where there is 'no interaction' 
(i.e. where these individuals are not within a specified distance threshold 
from another individual) and give these individuals a unique Group ID 
containing that one individual.

i.e.

   ID Group

1 ID1 1

2 ID3 2

3 ID4 3

4 ID5 4

5 ID7 5

6 ID8 6

7 ID9 7


What I need assistance with is allocating associations with a unique group id.
i.e. If we have interactions between  "ID2_ID6", "ID6_ID2", "ID6_ID10", 
"ID10_ID6" as in the example code...


   ID Group

1 ID1 1

2 ID3 2

3 ID4 3

4 ID5 4

5 ID7 5

6 ID8 6

7 ID9 7

##
8 ID2 8
9 ID6 8
10 ID10 8

##
The code also needs to robust enough to recognize instances where we have an 
interaction in a separate group...
i.e. "ID11_ID12" should be in a separate group (Group 9) as they don't interact 
with IDs 2, 6, or 10 (not in below code!)
11 ID11 9
12 ID12 9


I've been trying to figure this out but have drawn a blank. My example code can 
be found below.

Very best wishes,

Ross

Dr Ross Dwyer
Postdoctoral Research Fellow
University of Queensland



> ###
> require(stats)
> x <- sample(1:20,10)
> y <- sample(1:20,10)
> IDs <- sapply(1:10,function(i) paste("ID",i,sep=""))
> (DFid <- data.frame(x,y))
x  y
1   7 20
2   5  3
3  12  5
4   3 12
5  18 19
6   2  1
7  19 15
8  20 11
9  13 14
10  1  2
>
>
> (DMdist <- dist(DFid, method = "euclidean",
+diag = FALSE, upper = TRUE))
   1 2 3 4 5 6 7
 8 910
117.117243 15.811388  8.944272 11.045361 19.646883 13.00 
15.811388  8.485281 18.973666
2  17.1172437.280110  9.219544 20.615528  3.605551 18.439089 
17.00 13.601471  4.123106
3  15.811388  7.280110   11.401754 15.231546 10.770330 12.206556 
10.00  9.055385 11.401754
4   8.944272  9.219544 11.401754   16.552945 11.045361 16.278821 
17.029386 10.198039 10.198039
5  11.045361 20.615528 15.231546 16.552945   24.083189  4.123106  
8.246211  7.071068 24.041631
6  19.646883  3.605551 10.770330 11.045361 24.083189   22.022716 
20.591260 17.029386  1.414214
7  13.00 18.439089 12.206556 16.278821  4.123106 22.022716
4.123106  6.082763 22.203603
8  15.811388 17.00 10.00 17.029386  8.246211 20.591260  4.123106
7.615773 21.023796
9   8.485281 13.601471  9.055385 10.198039  7.071068 17.029386  6.082763  
7.615773   16.970563
10 18.973666  4.123106 11.401754 10.198039 24.041631  1.414214 22.203603 
21.023796 16.970563
>
> #Generate True/False matrix on those individuals < 4 units apart
> DMTF <- apply(as.matrix(DMdist), c(1,2), function(x) ifelse(x<=4,T,F))
> diag(DMTF)<- NA #replace diagonal with NA
> dimnames(DMTF) <- list(IDs, IDs) #add individual's name to matrix
>
> DMTF
   ID1   ID2   ID3   ID4   ID5   ID6   ID7   ID8   ID9  ID10
ID1 NA FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
ID2  FALSENA FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
ID3  FALSE FALSENA FALSE FALSE FALSE FALSE FALSE FALSE FALSE
ID4  FALSE FALSE FALSENA FALSE FALSE FALSE FALSE FALSE FALSE
ID5  FALSE FALSE FALSE FALSENA FALSE FALSE FALSE FALSE FALSE
ID6  FALSE  TRUE FALSE FALSE FALSENA FALSE FALSE FALSE  TRUE
ID7  FALSE FALSE FALSE FALSE FALSE FALSENA FALSE FALSE FALSE
ID8  FALSE FALSE FALSE FALSE FALSE FALSE FALSENA FALSE FALSE
ID9  FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSENA FALSE
ID10 FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSENA
>
> irow <- as.character(gl(length(IDs),length(IDs),labels=IDs))
> icol <-rep(IDs, length(IDs))
>
> AssocMatrix <- matrix(data=paste(irow,"_",icol,"_",sep=""),
+   nrow = length(IDs), ncol = length(IDs),
+   dimnames= list(IDs, IDs))
>
> AssocMatrix

 ID1 ID2 ID3 ID4 ID5 ID6 
ID7 ID8 ID9 ID10

ID1  "ID1_ID1_"  "ID2_ID1_"  "ID3_ID1_"  "ID4_ID1_"  "ID5_ID1_"  "ID6_ID1_"  
"ID7_ID1_"  "ID8_ID1_"  "ID9_ID1_"  "ID10_ID1_"

ID2  "ID1_ID2_"  "ID2_ID2_"  "ID3_ID2_"  "ID4_ID2_"  "ID5_ID2_"  "ID6_ID2_"  
"ID7_ID2_"  "ID8_ID2_"  "ID9_ID2_"  "ID10_ID2_"

ID3  "ID1_ID3_"  "ID2_ID3_"  "ID3_ID3_"  "ID4_ID3_"  "ID5_ID3_"  "ID6_ID3_"  
"ID7_ID3_"  "ID8_ID3_"  "ID9_ID3_"  "ID10_ID3_"

ID4  "ID1_ID4_"  "ID2_ID4_"  "ID3_ID4_"  "ID4_ID4_"  "ID5_ID4_"  "ID6_ID4_"  
"ID7_ID4_"  "ID8_ID4_"  "ID9_ID4_"  "ID10_ID4_"

ID5  "ID1_ID5_"  "ID2_ID5_"  "ID3_ID5_"  "ID4_ID5_"  "ID5_ID5_"  "ID6_ID5_"  
"ID7_ID5_"  "ID8_ID5_"  "ID9_ID5_"  "ID10_ID5_"

ID6  "ID1_ID6_"  "ID2_ID6_"  "ID3_ID6_"  "ID4_ID6_"  "ID5_ID6_"  "ID6_ID6_"  
"ID7_ID6_"  "ID8_ID6_"  "ID9_ID6_"  "ID10_ID6_"

ID7  "ID1_ID7_"  "ID2_ID7_"  "ID3_ID7_

Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread jim holtman
Did anyone ever mention the 'countLines' function in R.utils.

On Sun, Feb 26, 2012 at 5:55 PM, Hans Ekbrand  wrote:
>
> On Sun, Feb 26, 2012 at 09:39:46AM -0800, Rui Barradas wrote:
> > Hello,
> >
> > > The first step before to create a loop row-by-row is to know
> > > how many rows there are in the txt file without load in R to save
> > > memory
> > > problem.
> > >
> > > some people know the specific function?
> > >
> >
> > I don't believe there's a specific function.
>
> As stated, OP does not need to know the number of lines in the file to
> solve the problem. However, if you want to know that, I'd suggest the
> command wc rather than writing a function in R to accomplish this.
>
> wc is also part of GNU coreutils
>
> $ wc -l foo.csv
> 1138200 foo.csv
>
> > If you want to know how many rows are there in a txt file, try this
> > function.
> >
> > numTextFileLines <- function(filename, header=FALSE, sep=",",
> > nrows=5000){
> >       tc <- file(filename, open="rt")
> >       on.exit(close(tc))
> >       if(header){
> >               # cnames: column names (not used)
> >               cnames <- read.table(file=tc, sep=sep, nrows=1,
> > stringsAsFactors=FALSE)
> >               # cnames <- as.character(cnames)
> >       }
> >       n <- 0
> >       while(TRUE){
> >               x <- tryCatch(read.table(file=tc, sep=sep, nrows=nrows),
> > error=function(e)
> > e)
> >               if (any(grepl("no lines available", unclass(x
> >                       break
> >               if(nrow(x) < nrows){
> >                       n <- n + nrow(x)
> >                       break
> >               }
> >               n <- n + nrows
> >       }
> >       n
> > }
>
> But hey, programming R is fun, so why not?
>
> --
> Hans Ekbrand
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


[R] tm_map help

2012-02-26 Thread Sachinthaka Abeywardana
Hi all,

I am trying to do some text mining with twitter and I am getting the error:

Error in structure(names(sapply(possibleCompletions, "[", 1)), names = x) :
  'names' attribute [1] must be the same length as the vector [0]


When I use tm_map. Has anyone had/seen this error before? The code I
have is shown below and this error only occurs with #qantas, hashtags
like #asx, #obama work ok.


Appreciate any help.

Thanks,

Sachin


library(twitteR)
library(tm)
library(wordcloud)


hashTag<-function (hashTag, minFreq){

tweets<- searchTwitter(hashTag, n=200)
df <- do.call("rbind", lapply(tweets, as.data.frame))

myCorpus <- Corpus(VectorSource(df$text))
myCorpus <- tm_map(myCorpus, function(x) iconv(enc2utf8(x), sub = "byte"))
myCorpus <- tm_map(myCorpus, tolower)
myCorpus <- tm_map(myCorpus, removePunctuation)
myCorpus <- tm_map(myCorpus, removeNumbers)
myStopwords <- c(stopwords('english'), "available", "via")
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)

dictCorpus <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)

ERROR HAPPENS ON NEXT LINE##
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=dictCorpus)
myDtm <- TermDocumentMatrix(myCorpus, control = list(minWordLength = 1))

m <- as.matrix(myDtm)
v <- sort(rowSums(m), decreasing=TRUE)
myNames <- names(v)
d <- data.frame(word=myNames, freq=v)
wordcloud(d$word, d$freq, min.freq=minFreq)
list(freq=v, TextMatrix=myDtm)
}


qantas=hashTag("#qantas", 7)

[[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] fixed TkTable problem but I need to unistall/reinstall R....How do I manage that??

2012-02-26 Thread Eric P
Hello,

So I need some help. I have been trying to get biocondutor to work on
my computer that has Ubuntu 11.10 running on it and I found out that I
needed to install something called TkTable before I install R. So I
did that but now I have no idea how to properly uninstall/reinstall R,
and I cannot find any sort of help with that on this site or any
other. Help...Thanks

Eric

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


Re: [R] tapply for enormous (>2^31 row) matrices

2012-02-26 Thread Gabor Grothendieck
On Thu, Feb 23, 2012 at 11:39 AM, Matthew Keller  wrote:
> Thank you all very much for your help (on both the r-help and the
> bioconductor listserves).
>
> Benilton - I couldn't get sqldf to install on the server I'm using
> (error is: Error : package 'gsubfn' does not have a name space). I
> think this was a problem for R 2.13, and I'm trying to get the admin's
> to install a more up-to-date version. I know that I need to probably
> learn a modicum of SQL given the sizes of datasets I'm using now.

Right. See the troubleshooting section of the sqldf home page:
http://code.google.com/p/sqldf/#Troubleshooting

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] How to deal with missing values when using Random Forrest

2012-02-26 Thread Weidong Gu
Hi,

You can set na.action=na.roughfix which fills NAs with the mean or
mode of the missing variable.

Other option is to impute missing values using rfImpute, then run
randomForest on the complete data set.

Weidong Gu

On Sat, Feb 25, 2012 at 6:24 PM, kevin123  wrote:
> I am using the package Random Forrest to test and train a model,
> I aim to predict (LengthOfStay.days),:
>
>> library(randomForest)
>> model <- randomForest( LengthOfStay.days~.,data = training,
> + importance=TRUE,
> + keep.forest=TRUE
> + )
>
>
> *This is a small portion of the data frame:   *
>
> *data(training)*
>
> LengthOfStay.days CharlsonIndex.numeric DSFS.months
> 1                  0                   0.0         8.5
> 6                  0                   0.0         3.5
> 7                  0                   0.0         0.5
> 8                  0                   0.0         0.5
> 9                  0                   0.0         1.5
> 11                 0                   1.5         NaN
>
>
>
> *Error message*
>
> Error in na.fail.default(list(LengthOfStay.days = c(0, 0, 0, 0, 0, 0,  :
>  missing values in object,
>
> I would greatly appreciate any help
>
> Thanks
>
> Kevin
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-deal-with-missing-values-when-using-Random-Forrest-tp4421254p4421254.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] read separate columns from an Excel sheet

2012-02-26 Thread Gabor Grothendieck
On Sun, Feb 26, 2012 at 2:58 PM, Ivette  wrote:
> Hello,
>
> Lets suppose I have an Excel sheet with 9 columns of data. How to tell R to
> read for example column 1 and 7 of this sheet? I know only the usual code
> without specifying columns:
>
> library(gdata)
> a <- read.xls("file.xls", sheet=1)                # reads in the 1st sheet
>

Its pretty much the same as if you were using read.table, viz.

read.xls("file.xls")[c(1, 7])

or if you know that there are nc columns:

nc <- ...
read.xls("file.xls", colClasses = replace(rep("NULL", nc), c(1, 7), NA))

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
On Sun, Feb 26, 2012 at 09:39:46AM -0800, Rui Barradas wrote:
> Hello,
> 
> > The first step before to create a loop row-by-row is to know
> > how many rows there are in the txt file without load in R to save memory
> > problem.
> > 
> > some people know the specific function? 
> > 
> 
> I don't believe there's a specific function.

As stated, OP does not need to know the number of lines in the file to
solve the problem. However, if you want to know that, I'd suggest the
command wc rather than writing a function in R to accomplish this.

wc is also part of GNU coreutils

$ wc -l foo.csv
1138200 foo.csv

> If you want to know how many rows are there in a txt file, try this
> function.
> 
> numTextFileLines <- function(filename, header=FALSE, sep=",", nrows=5000){
>   tc <- file(filename, open="rt")
>   on.exit(close(tc))
>   if(header){
>   # cnames: column names (not used)
>   cnames <- read.table(file=tc, sep=sep, nrows=1, 
> stringsAsFactors=FALSE)
>   # cnames <- as.character(cnames)
>   }
>   n <- 0
>   while(TRUE){
>   x <- tryCatch(read.table(file=tc, sep=sep, nrows=nrows), 
> error=function(e)
> e)
>   if (any(grepl("no lines available", unclass(x
>   break
>   if(nrow(x) < nrows){
>   n <- n + nrow(x)
>   break
>   }
>   n <- n + nrows
>   }
>   n
> }

But hey, programming R is fun, so why not?

--
Hans Ekbrand

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read separate columns from an Excel sheet

2012-02-26 Thread Ivette
Hello,

Lets suppose I have an Excel sheet with 9 columns of data. How to tell R to
read for example column 1 and 7 of this sheet? I know only the usual code
without specifying columns:

library(gdata)
a <- read.xls("file.xls", sheet=1)# reads in the 1st sheet

Thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/read-separate-columns-from-an-Excel-sheet-tp4422812p4422812.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] Positive semidefinite correlation Matrix

2012-02-26 Thread stephanmi1

   Hello,
   I'm searching for a function that creates the nearest positive semidefinite
   correlation matrix.
   Up to now I was only able to find the function nearcor().
   Due to the fact, that a correlation matrix is only forced to be positive
   semidefinite,
   I prefer to find the nearest semidefinite one, and not the nearest positive
   definite correlation matrix like nearcor() is doing it.
   Is anyone aware of such a function?
   Thanks.
   With kind regards.
   Stephan

   Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE Mail App für iPhone
   und Android.
   [1]https://produkte.web.de/freemail_mobile_startseite/

References

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


Re: [R] loop for a large database

2012-02-26 Thread mari681
Thank you!!

MyTable has 21 millions rows and 15 columns, and the data is "character",
they are words.
When I tried the loop my computer crashed in the meaning that it freezed
(froze?) and didn't allow me to do anything. The morning after I forced it
off and rebooted.
:-)

Thank you so much, I'll try your suggestion.

--
View this message in context: 
http://r.789695.n4.nabble.com/loop-for-a-large-database-tp4422052p4422783.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] loop for a large database

2012-02-26 Thread mari681
SORRY!

The data in MyTable are tagsets of photos,  like this:

  V1 V2   V3  V4  V5   V6V7   V8
230green nailpolish   barrym   0   00 00
231   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
232green   saul  lecture   0   00 00
233green colorscores  market colores marakesh   mercado malu
234   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
235green   saul  lecture   0   00 00
236 portraitpetwhite   green catcanonsquare  eos

 V9   V10  V11  V12 V13 V14 V15
230   0 000   0   0   0
231 gowanuscanalconservancy 000   0   0   0
232   0 000   0   0   0
233   malugreen maroc souk marrocos   0   0   0
234 gowanuscanalconservancy 000   0   0   0
235   0 000   0   0   0
236  is  eyes mark   taiwan  ii mk2  5d


while data of MyVector is a list of tags (none of the columns in particular)
whose frequency in MyTable has to be computed. Like this:

[1] "life"  "wood"  "pink"  "house" "green" "fall" 



Thanks!!

Marianna


--
View this message in context: 
http://r.789695.n4.nabble.com/loop-for-a-large-database-tp4422052p4422776.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] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread Ivette
try setwd(choose.dir()) 

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-needed-Error-in-setwd-newdir-cannot-change-working-directory-tp4421698p4422749.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] Goodness of Fit for Copula

2012-02-26 Thread Ivette
x=your pseudo-observations in the interval [0,1]


--
View this message in context: 
http://r.789695.n4.nabble.com/Goodness-of-Fit-for-Copula-tp4174977p4422737.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] Min-Max Normalization for Class RasterStack?

2012-02-26 Thread Cornelius Senf
Is there a way to normalize each layer of a RasterStack between 0 and 1 
based on the minimum and maximum of each layer?


Thanks!

Cornelius

--
__
Cornelius Senf, Bsc.
Humboldt-University of Berlin
Geography Department
Geomatics Lab

www.hu-geomatics.de

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


Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Rui Barradas
Hello,

> The first step before to create a loop row-by-row is to know
> how many rows there are in the txt file without load in R to save memory
> problem.
> 
> some people know the specific function? 
> 

I don't believe there's a specific function.
If you want to know how many rows are there in a txt file, try this
function.

numTextFileLines <- function(filename, header=FALSE, sep=",", nrows=5000){
tc <- file(filename, open="rt")
on.exit(close(tc))
if(header){
# cnames: column names (not used)
cnames <- read.table(file=tc, sep=sep, nrows=1, 
stringsAsFactors=FALSE)
# cnames <- as.character(cnames)
}
n <- 0
while(TRUE){
x <- tryCatch(read.table(file=tc, sep=sep, nrows=nrows), 
error=function(e)
e)
if (any(grepl("no lines available", unclass(x
break
if(nrow(x) < nrows){
n <- n + nrow(x)
break
}
n <- n + nrows
}
n
}

# Make a data file
N <- 1e7 + 1
d <- data.frame(X=1:N, Y=sample(10, N, T), MyValue=rnorm(N))
write.table(d, file="test.txt", row.names=FALSE, sep=",")

# Count it's lines, but not the header, nrows=5k at a time
t1 <- system.time({
nlines <- numTextFileLines("test.txt", header=TRUE)
})
cat(" Lines read:", nlines, "\n", "Last block:", nlines %% 5000, "\n")

# Clean-up
unlink("test.txt")


> I have a large TXT (X,Y,MyValue) file in a directory and I wish to import
> row by row the txt in a loop to save only the data they are inside a
> buffer
> (using inside.owin of spatstat) and delete the rest. 

Maybe you don't need to count the number of rows on the file,
you could adapt the code above to process it in blocks.
Something like

# Start of the function code is the same
if (any(grepl("no lines available", unclass(x
break
# Process 'x', row-wise
apply(x, 1, MyFunction)
#
if(nrow(x) < nrows){
 ... etc ...

Hope this helps,
Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/count-how-many-row-i-have-in-a-txt-file-in-a-directory-tp4422186p4422549.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] svm with GRASS GIS

2012-02-26 Thread etiennebr
I usually use a rasterLayer object (from raster package) instead of a
SpatialGridDataFrame, but you probably just have to bind it to your data :
TL_training_2006_id.raw@data$prediction <- pred
This will create a band in which you have your predictions. raster package
doesn't handle the factors, so you have to use as.integer(), but it is
probably the same.

--
View this message in context: 
http://r.789695.n4.nabble.com/svm-with-GRASS-GIS-tp4388006p4422787.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] loop for a large database

2012-02-26 Thread chuck.01
Untested die to no data, but this should work with a loop

out=vector("list", length= length(MyVector))

for(i in 1 : length (MyVector))
  { 
 x <- data.frame (sum (MyTable ==MyVector[i])) 
 out[[i]] <- x
}
sum(do.call(rbind, out))

--
View this message in context: 
http://r.789695.n4.nabble.com/loop-for-a-large-database-tp4422052p4422584.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] Sweave Print xtable

2012-02-26 Thread Riccardo Romoli
Thanks for your replay!!! Problem solved!!

Best
Riccardo

2012/2/26 Yihui Xie 

> print(xtable(...), ..., table.placement = '')
>
> this is an xtable problem; see ?print.xtable
>
> Regards,
> Yihui
> --
> Yihui Xie 
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Sun, Feb 26, 2012 at 3:30 PM, Riccardo Romoli 
> wrote:
> > Hi, I'm working with Sweave and I have some trouble generating table.
> The R
> > code is:
> >
> > print(xtable(myTable, caption ="", label="tab:myTab",
> > digits=3), tabular.environment='tabular',  floating=TRUE,
> > caption.placement="top",size="\\scriptsize")
> >
> > and the resulting LaTeX table is:
> >
> > \begin{table}[ht]
> >  \begin{center}
> >\caption{Principal component analysis of soil dispersed in water}
> > \label{tab:myTab}
> > {\scriptsize
> > \begin{tabular}{rr}
> >  \hline
> > Table
> >   \hline
> > \end{tabular}
> > }
> > \end{center}
> > \end{table}
> >
> > So, how should I change in the R code to eliminate "[ht]" in the
> resulting
> > LaTeX table??
> >
> > Best
> >
> > Riccardo
> >
> >[[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] Sweave Print xtable

2012-02-26 Thread Yihui Xie
print(xtable(...), ..., table.placement = '')

this is an xtable problem; see ?print.xtable

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Sun, Feb 26, 2012 at 3:30 PM, Riccardo Romoli  wrote:
> Hi, I'm working with Sweave and I have some trouble generating table. The R
> code is:
>
> print(xtable(myTable, caption ="", label="tab:myTab",
> digits=3), tabular.environment='tabular',          floating=TRUE,
> caption.placement="top",size="\\scriptsize")
>
> and the resulting LaTeX table is:
>
> \begin{table}[ht]
>  \begin{center}
>    \caption{Principal component analysis of soil dispersed in water}
> \label{tab:myTab}
> {\scriptsize
> \begin{tabular}{rr}
>  \hline
> Table
>   \hline
> \end{tabular}
> }
> \end{center}
> \end{table}
>
> So, how should I change in the R code to eliminate "[ht]" in the resulting
> LaTeX table??
>
> Best
>
> Riccardo
>
>        [[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] Reading spss files into R - warnings

2012-02-26 Thread Steve Taylor
suppressWarnings() will get rid of them for you.

Note that in R a factor cannot have duplicate levels.  Compare the results with 
use.value.labels turned on or off, to see which you prefer.

I also get the "unknown type" warnings, but I ignore them as my data seems to 
arrive into R intact. 

Hope that helps.

cheers,
Steve

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Marion Wenty
Sent: Friday, 17 February 2012 1:00a
To: r-help@r-project.org
Subject: [R] Reading spss files into R - warnings

Hello people,

I have got a question concerning reading spss files into R:

I used the package foreign and the following command:

read.spss("C:/Eigene Dateien/myspssfile.sav",to.data.frame=T)

I have read two different files into R (several times) and always got the 
following two warning messages:

first file:

Warnmeldungen:1: In `levels<-`(`*tmp*`, value = if (nl == nL)
as.character(labels) else paste(labels,  :
  doppelt auftretende Faktorstufen werden nicht mehr zulässig sein2:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
paste(labels,  :
  doppelt auftretende Faktorstufen werden nicht mehr zulässig sein3:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
paste(labels,  :
  doppelt auftretende Faktorstufen werden nicht mehr zulässig sein4:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
paste(labels,  :
  doppelt auftretende Faktorstufen werden nicht mehr zulässig sein5:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
paste(labels,  :
  doppelt auftretende Faktorstufen werden nicht mehr zulässig sein


second file:


Warnmeldungen:

1:

 Unerkannter Datensatztyp 7, Untertyp 14 in Systemdatei vorgefunden2:

Unerkannter Datensatztyp 7, Untertyp 18 in Systemdatei vorgefunden



I couldn't find out how to get rid of these.


Does anyone know how to do this?


Thank you very much in advance,


Marion

[[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] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread Petr Savicky
On Sun, Feb 26, 2012 at 04:12:03PM -0500, ying chen wrote:
> 
> Hi, 
>  
> I am sorry about the format it showed up. I do not know what happened as now 
> it looks worse even on my own machine. I do not know what to do, I just add 
> "\n" to the end of each line and hope it will come out OK this time. The 
> packages A, B, C are not the real package names.  Basically I have  scriptA.R 
> that works from inside a directory with my data (/home/sean/Rtest/Data01). 
> Now I want to modify the script to make it run from the upper directory 
> (/home/sean/Rtest) because I have many data directories under /Rtest, such as 
> /home/sean/Rtest/Data01, /home/sean/Rtest/Data02, 
> /home/sean/Rtest/Data03,. I want to modify my script so that it will run 
> from /Rtest, and with the data directory name as arg passed to my R script. 
> My point is that when I put the scriptA.R in data directory such as Data01, 
> it works. Here are my scriptB.R script: 
>  
> ##scriptA.R# 
>  
> # load the necessary libraries 
> library("A");  # A fake package name 
> library("B");  # B fake package name 
> library("C");  # C fake package name 
> #data processing 
> #data processing 
> #data processing 
> # unload the libraries 
> detach("package:A");   
> detach("package:B"); 
> detach("package:C"); 
> q(); 
> ### 
> 
> But, when I tried to modify scriptA.R to scriptB.R to run it from the 
> directory just above Data directories, I got the error message. 
> 
> ###scriptB.R###
> 
> # retrieve args 
> args <- commandArgs(TRUE); 
> # store the current directory 
> initial.dir <- getwd(); 
> newdir <- paste(initial.dir,args,sep="/"); 
> outfilename <- paste(args,"out",sep="."); 
> # change to the new directory 
> setwd(newdir); 

Print the variable "newdir" to see, whether it contains, what you expect.

> # load the necessary libraries 
> library("A");  # A fake package name 
> library("B");  # B fake package name 
> library("C");  # C fake package name 

Loading libraries in this way does not depend on the working directory.

> # set the output file 
> sink(outfilename); 
> #data processing 
> #data processing 
> #data processing 
> # close the output file 
> sink(); 
> # unload the libraries 
> detach("package:A");  # 
> detach("package:B"); 
> detach("package:C"); 
> # change back to the original directory 
> setwd(initial.dir); 
> 
> ## 
> 
> I run the scriptB.R by 
> 
> sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R 
> 
> I got the error message: 
> 
> sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R 
> Attempting to load the environment ?package:R.utils? 
> Loading required package: R.methodsS3 
> R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See ?R.methodsS3 for 
> help. 
> Loading required package: utils 
> R.oo v1.8.3 (2011-11-01) successfully loaded. See ?R.oo for help. 
> 
> Attaching package: ?R.oo? 
> 
> The following object(s) are masked from ?package:R.methodsS3?: 
> 
>throw.default 
> 
> The following object(s) are masked from ?package:methods?: 
> 
>getClass, getClasses, getMethods 
> 
> The following object(s) are masked from ?package:base?: 
> 
>   attach, detach, environment, gc, load, save 
> 
> R.utils v1.9.11 (2012-01-17) successfully loaded. See ?R.utils for help. 
> 
> Attaching package: ?R.utils? 
> 
> The following object(s) are masked from ?package:utils?: 
> 
> timestamp 
> 
> The following object(s) are masked from ?package:base?: 
> 
> cat, commandArgs, getOption, inherits, isOpen, lapply, parse, 
> remove, warnings 
> 
> [1] "/home/sean/Rtest" 
> [1] "/home/sean/Rtest/NA"   "/home/sean/Rtest/TRUE" 
> [3] "/home/sean/Rtest/Data01" 
> [1] "NA.out"   "TRUE.out" "Data01.out" 
> Error in setwd(newdir) : cannot change working directory 
> Execution halted 

Try print(newdir) before setwd(newdir).

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread jim holtman
At this point you need to learn how to do some basic debugging of your
script.  Open a GUI window that you can copy/paste parts of your script and
execute it piece-meal.  Get to the point where you want to change your
working directory and do a 'getwd()' to see where you are.  It is obvious
from your error message that whatever directory you are giving as an
argument is not valid at the point you are executing the 'setwd' function.
At least put a 'print(getwd())' right before your setwd function call.

This is debugging 101 that you will have to learn so that you can develop
more complex scripts.

On Sun, Feb 26, 2012 at 4:12 PM, ying chen  wrote:

>
> Hi,
>
> I am sorry about the format it showed up. I do not know what happened as
> now it looks worse even on my own machine. I do not know what to do, I just
> add "\n" to the end of each line and hope it will come out OK this time.
> The packages A, B, C are not the real package names.  Basically I have
>  scriptA.R that works from inside a directory with my data
> (/home/sean/Rtest/Data01). Now I want to modify the script to make it run
> from the upper directory (/home/sean/Rtest) because I have many data
> directories under /Rtest, such as /home/sean/Rtest/Data01,
> /home/sean/Rtest/Data02, /home/sean/Rtest/Data03,. I want to modify my
> script so that it will run from /Rtest, and with the data directory name as
> arg passed to my R script. My point is that when I put the scriptA.R in
> data directory such as Data01, it works. Here are my scriptB.R script:
>
> ##scriptA.R#
>
> # load the necessary libraries
> library("A");  # A fake package name
> library("B");  # B fake package name
> library("C");  # C fake package name
> #data processing
> #data processing
> #data processing
> # unload the libraries
> detach("package:A");
> detach("package:B");
> detach("package:C");
> q();
> ###
>
> But, when I tried to modify scriptA.R to scriptB.R to run it from the
> directory just above Data directories, I got the error message.
>
> ###scriptB.R###
>
> # retrieve args
> args <- commandArgs(TRUE);
> # store the current directory
> initial.dir <- getwd();
> newdir <- paste(initial.dir,args,sep="/");
> outfilename <- paste(args,"out",sep=".");
> # change to the new directory
> setwd(newdir);
> # load the necessary libraries
> library("A");  # A fake package name
> library("B");  # B fake package name
> library("C");  # C fake package name
> # set the output file
> sink(outfilename);
> #data processing
> #data processing
> #data processing
> # close the output file
> sink();
> # unload the libraries
> detach("package:A");  #
> detach("package:B");
> detach("package:C");
> # change back to the original directory
> setwd(initial.dir);
>
> ##
>
> I run the scriptB.R by
>
> sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R
>
> I got the error message:
>
> sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R
>  Attempting to load the environment ‘package:R.utils’
> Loading required package: R.methodsS3
> R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See ?R.methodsS3 for
> help.
> Loading required package: utils
> R.oo v1.8.3 (2011-11-01) successfully loaded. See ?R.oo for help.
>
> Attaching package: ‘R.oo’
>
> The following object(s) are masked from ‘package:R.methodsS3’:
>
>   throw.default
>
> The following object(s) are masked from ‘package:methods’:
>
>   getClass, getClasses, getMethods
>
> The following object(s) are masked from ‘package:base’:
>
>  attach, detach, environment, gc, load, save
>
> R.utils v1.9.11 (2012-01-17) successfully loaded. See ?R.utils for help.
>
> Attaching package: ‘R.utils’
>
> The following object(s) are masked from ‘package:utils’:
>
>timestamp
>
> The following object(s) are masked from ‘package:base’:
>
>cat, commandArgs, getOption, inherits, isOpen, lapply, parse,
>remove, warnings
>
> [1] "/home/sean/Rtest"
> [1] "/home/sean/Rtest/NA"   "/home/sean/Rtest/TRUE"
> [3] "/home/sean/Rtest/Data01"
> [1] "NA.out"   "TRUE.out" "Data01.out"
> Error in setwd(newdir) : cannot change working directory
> Execution halted
>
> What did I do wrong? I think I have the right to read and write to the
> directories.
>
> One more question, is there anyway to modify this script to make it work
> on all data directories under /home/sean/Rtest by itself?
>
> Thanks a lot for the help!
>
> Ying
>
> sean@I7-3930K:~/Rtest$ ls -l
> total 56
> drwx-- 3 sean sean 4096 2012-02-25 20:39 Data01
> drwx-- 2 sean sean 4096 2012-02-25 20:28 Data02
> drwx-- 2 sean sean 4096 2012-02-26 07:41 Data03
> drwx-- 2 sean sean 4096 2012-02-25 21:18 Data04
> drwx-- 2 sean sean 4096 2012-02-25

[R] Sweave Print xtable

2012-02-26 Thread Riccardo Romoli
Hi, I'm working with Sweave and I have some trouble generating table. The R
code is:

print(xtable(myTable, caption ="", label="tab:myTab",
digits=3), tabular.environment='tabular',  floating=TRUE,
caption.placement="top",size="\\scriptsize")

and the resulting LaTeX table is:

\begin{table}[ht]
  \begin{center}
\caption{Principal component analysis of soil dispersed in water}
\label{tab:myTab}
{\scriptsize
\begin{tabular}{rr}
  \hline
Table
   \hline
\end{tabular}
}
\end{center}
\end{table}

So, how should I change in the R code to eliminate "[ht]" in the resulting
LaTeX table??

Best

Riccardo

[[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] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread Jeff Newmiller
Stop it with the "fake" code if you want help. In keeping with the posting 
guide, make one reproducible example that exhibits a real problem. For what it 
is worth, I don't have difficulty with setwd().
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

ying chen  wrote:

>
>
>
>
>
>Hi,
>I am sorry about the format it showed up. I do not know what happened
>as it looks fine when I read it using chrome on ubuntu 11.10 64bit. The
>packages A, B, C are not the real package names.  Basically I have 
>scriptA.R that works from inside a directory with my data
>(/home/sean/Rtest/Data01). Now I want to modify the script to make it
>run from the upper directory (/home/sean/Rtest) because I have many
>data directories under /Rtest, such as /home/sean/Rtest/Data01,
>/home/sean/Rtest/Data02, /home/sean/Rtest/Data03,. I want to modify
>my script so that it will run from /Rtest, and with the data directory
>name as arg passed to my R script. My point is that when I put the
>scriptA.R in data directory such as Data01, it works. Here are my
>scriptB.R script:
>##scriptA.R#
># load the necessary librarieslibrary("A");  # A fake package
>namelibrary("B");  # B fake package namelibrary("C");  # C fake package
>name#data processing#data processing   
>#data processing# unload the librariesdetach("package:A"); 
>detach("package:B");detach("package:C");q();###
>But, when I tried to modify scriptA.R to scriptB.R to run it from the
>directory just above Data directories, I got the error message.
>###scriptB.R###
># retrieve argsargs <- commandArgs(TRUE);# store the current
>directoryinitial.dir <- getwd();newdir <-
>paste(initial.dir,args,sep="/");outfilename <-
>paste(args,"out",sep=".");# change to the new directorysetwd(newdir);#
>load the necessary librarieslibrary("A");  # A fake package
>namelibrary("B");  # B fake package namelibrary("C");  # C fake package
>name# set the output filesink(outfilename);#data
>processing#data processing#data processing#
>close the output filesink();# unload the librariesdetach("package:A"); 
>#detach("package:B");detach("package:C");# change back to the original
>directorysetwd(initial.dir);
>##
>I run the scriptB.R by
>sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R
>I got the error message:
>sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.RAttempting to
>load the environment �package:R.utils�Loading required package:
>R.methodsS3R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See
>?R.methodsS3 for help.Loading required package: utilsR.oo v1.8.3
>(2011-11-01) successfully loaded. See ?R.oo for help.
>Attaching package: �R.oo�
>The following object(s) are masked from �package:R.methodsS3�:
>   throw.default
>The following object(s) are masked from �package:methods�:
>   getClass, getClasses, getMethods
>The following object(s) are masked from �package:base�:
>  attach, detach, environment, gc, load, save
>R.utils v1.9.11 (2012-01-17) successfully loaded. See ?R.utils for
>help.
>Attaching package: �R.utils�
>The following object(s) are masked from �package:utils�:
>timestamp
>The following object(s) are masked from �package:base�:
>cat, commandArgs, getOption, inherits, isOpen, lapply, parse,   
>remove, warnings
>[1] "/home/sean/Rtest"[1] "/home/sean/Rtest/NA"  
>"/home/sean/Rtest/TRUE"[3] "/home/sean/Rtest/Data01"[1] "NA.out"   
>"TRUE.out" "Data01.out"Error in setwd(newdir) : cannot change
>working directoryExecution halted
>What did I do wrong? I think I have the right to read and write to the
>directories.
>One more question, is there anyway to modify this script to make it
>work on all data directories under /home/sean/Rtest by itself?
>Thanks a lot for the help!
>Ying
>sean@I7-3930K:~/Rtest$ ls -ltotal 56drwx-- 3 sean sean 4096
>2012-02-25 20:39 Data01drwx-- 2 sean sean 4096 2012-02-25 20:28
>Data02drwx-- 2 sean sean 4096 2012-02-26 07:41 Data03drwx-- 2
>sean sean 4096 2012-02-25 21:18 Data04drwx-- 2 sean sean 4096
>2012-02-25 20:27 Data05-rw-r--r-- 1 sean sean  437 2012-02-26 15:28
>scriptA.R...
>> From: michael.weyla...@gmail.com
>> Date: Sun, 26 Feb 2012 12:48:57 -0500
>> Subject: Re: [R] Help needed! Error in setwd

Re: [R] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread ying chen

Hi, 
 
I am sorry about the format it showed up. I do not know what happened as now it 
looks worse even on my own machine. I do not know what to do, I just add "\n" 
to the end of each line and hope it will come out OK this time. The packages A, 
B, C are not the real package names.  Basically I have  scriptA.R that works 
from inside a directory with my data (/home/sean/Rtest/Data01). Now I want to 
modify the script to make it run from the upper directory (/home/sean/Rtest) 
because I have many data directories under /Rtest, such as 
/home/sean/Rtest/Data01, /home/sean/Rtest/Data02, /home/sean/Rtest/Data03,. 
I want to modify my script so that it will run from /Rtest, and with the data 
directory name as arg passed to my R script. My point is that when I put the 
scriptA.R in data directory such as Data01, it works. Here are my scriptB.R 
script: 
 
##scriptA.R# 
 
# load the necessary libraries 
library("A");  # A fake package name 
library("B");  # B fake package name 
library("C");  # C fake package name 
#data processing 
#data processing 
#data processing 
# unload the libraries 
detach("package:A");   
detach("package:B"); 
detach("package:C"); 
q(); 
### 

But, when I tried to modify scriptA.R to scriptB.R to run it from the directory 
just above Data directories, I got the error message. 

###scriptB.R###

# retrieve args 
args <- commandArgs(TRUE); 
# store the current directory 
initial.dir <- getwd(); 
newdir <- paste(initial.dir,args,sep="/"); 
outfilename <- paste(args,"out",sep="."); 
# change to the new directory 
setwd(newdir); 
# load the necessary libraries 
library("A");  # A fake package name 
library("B");  # B fake package name 
library("C");  # C fake package name 
# set the output file 
sink(outfilename); 
#data processing 
#data processing 
#data processing 
# close the output file 
sink(); 
# unload the libraries 
detach("package:A");  # 
detach("package:B"); 
detach("package:C"); 
# change back to the original directory 
setwd(initial.dir); 

## 

I run the scriptB.R by 

sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R 

I got the error message: 

sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R 
Attempting to load the environment ‘package:R.utils’ 
Loading required package: R.methodsS3 
R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See ?R.methodsS3 for help. 
Loading required package: utils 
R.oo v1.8.3 (2011-11-01) successfully loaded. See ?R.oo for help. 

Attaching package: ‘R.oo’ 

The following object(s) are masked from ‘package:R.methodsS3’: 

   throw.default 

The following object(s) are masked from ‘package:methods’: 

   getClass, getClasses, getMethods 

The following object(s) are masked from ‘package:base’: 

  attach, detach, environment, gc, load, save 

R.utils v1.9.11 (2012-01-17) successfully loaded. See ?R.utils for help. 

Attaching package: ‘R.utils’ 

The following object(s) are masked from ‘package:utils’: 

timestamp 

The following object(s) are masked from ‘package:base’: 

cat, commandArgs, getOption, inherits, isOpen, lapply, parse, 
remove, warnings 

[1] "/home/sean/Rtest" 
[1] "/home/sean/Rtest/NA"   "/home/sean/Rtest/TRUE" 
[3] "/home/sean/Rtest/Data01" 
[1] "NA.out"   "TRUE.out" "Data01.out" 
Error in setwd(newdir) : cannot change working directory 
Execution halted 

What did I do wrong? I think I have the right to read and write to the 
directories. 

One more question, is there anyway to modify this script to make it work on all 
data directories under /home/sean/Rtest by itself? 

Thanks a lot for the help! 

Ying 

sean@I7-3930K:~/Rtest$ ls -l 
total 56 
drwx-- 3 sean sean 4096 2012-02-25 20:39 Data01 
drwx-- 2 sean sean 4096 2012-02-25 20:28 Data02 
drwx-- 2 sean sean 4096 2012-02-26 07:41 Data03 
drwx-- 2 sean sean 4096 2012-02-25 21:18 Data04 
drwx-- 2 sean sean 4096 2012-02-25 20:27 Data05 
-rw-r--r-- 1 sean sean  437 2012-02-26 15:28 scriptA.R 
... 

From: ying_c...@live.com
To: michael.weyla...@gmail.com
Date: Sun, 26 Feb 2012 16:00:20 -0500
CC: r-help@r-project.org
Subject: Re: [R] Help needed! Error in setwd(newdir) : cannot change working 
directory






Hi,
I am sorry about the format it showed up. I do not know what happened as it 
looks fine when I read it using chrome on ubuntu 11.10 64bit. The packages A, 
B, C are not the real package names.  Basically I have  scriptA.R that works 
from inside a directory with my data (/home/sean/Rtest/Data01). Now I want to 
modify the script to make it run from the upper directory (/home/sean/Rtest) 
because I have many data directories under /Rtest, such as 
/home/sean/Rtest/Data01, /h

Re: [R] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
On Sun, Feb 26, 2012 at 05:06:42PM +0100, gianni lavaredo wrote:
> thanks Hans.
> 
> It's true your idea improve the speed in the analysis respect a row-by-row
> loop.
> 
> Sorry if I ask these questions to better understand and better performening
> my code:
> 
> 1) split command in GNU coreutils, $ split -l 100 testmem.csv
> i never use this command. Is it possibile to coding in R or it's an
> external command?

external. split is - as I wrote - part of GNU coreutils.

> do you have some links where i can study this command. Thanks

http://www.gnu.org/software/coreutils/

> 2) is it possible to work with txt file?

"txt file" is not a well defined concept, such a file could very well
be a csv file, see http://en.wikipedia.org/wiki/Comma-separated_values

?read.csv

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread ying chen





Hi,
I am sorry about the format it showed up. I do not know what happened as it 
looks fine when I read it using chrome on ubuntu 11.10 64bit. The packages A, 
B, C are not the real package names.  Basically I have  scriptA.R that works 
from inside a directory with my data (/home/sean/Rtest/Data01). Now I want to 
modify the script to make it run from the upper directory (/home/sean/Rtest) 
because I have many data directories under /Rtest, such as 
/home/sean/Rtest/Data01, /home/sean/Rtest/Data02, /home/sean/Rtest/Data03,. 
I want to modify my script so that it will run from /Rtest, and with the data 
directory name as arg passed to my R script. My point is that when I put the 
scriptA.R in data directory such as Data01, it works. Here are my scriptB.R 
script:
##scriptA.R#
# load the necessary librarieslibrary("A");  # A fake package namelibrary("B"); 
 # B fake package namelibrary("C");  # C fake package name#data 
processing#data processing#data processing# unload the 
librariesdetach("package:A");  
detach("package:B");detach("package:C");q();###
But, when I tried to modify scriptA.R to scriptB.R to run it from the directory 
just above Data directories, I got the error message.
###scriptB.R###
# retrieve argsargs <- commandArgs(TRUE);# store the current 
directoryinitial.dir <- getwd();newdir <- 
paste(initial.dir,args,sep="/");outfilename <- paste(args,"out",sep=".");# 
change to the new directorysetwd(newdir);# load the necessary 
librarieslibrary("A");  # A fake package namelibrary("B");  # B fake package 
namelibrary("C");  # C fake package name# set the output 
filesink(outfilename);#data processing#data 
processing#data processing# close the output filesink();# unload 
the librariesdetach("package:A");  #detach("package:B");detach("package:C");# 
change back to the original directorysetwd(initial.dir);
##
I run the scriptB.R by
sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.R
I got the error message:
sean@I7-3930K:~/Rtest$ R --slave --args Data01 < scriptB.RAttempting to load 
the environment ‘package:R.utils’Loading required package: 
R.methodsS3R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See 
?R.methodsS3 for help.Loading required package: utilsR.oo v1.8.3 (2011-11-01) 
successfully loaded. See ?R.oo for help.
Attaching package: ‘R.oo’
The following object(s) are masked from ‘package:R.methodsS3’:
   throw.default
The following object(s) are masked from ‘package:methods’:
   getClass, getClasses, getMethods
The following object(s) are masked from ‘package:base’:
  attach, detach, environment, gc, load, save
R.utils v1.9.11 (2012-01-17) successfully loaded. See ?R.utils for help.
Attaching package: ‘R.utils’
The following object(s) are masked from ‘package:utils’:
timestamp
The following object(s) are masked from ‘package:base’:
cat, commandArgs, getOption, inherits, isOpen, lapply, parse,remove, 
warnings
[1] "/home/sean/Rtest"[1] "/home/sean/Rtest/NA"   "/home/sean/Rtest/TRUE"   
 [3] "/home/sean/Rtest/Data01"[1] "NA.out"   "TRUE.out" 
"Data01.out"Error in setwd(newdir) : cannot change working directoryExecution 
halted
What did I do wrong? I think I have the right to read and write to the 
directories.
One more question, is there anyway to modify this script to make it work on all 
data directories under /home/sean/Rtest by itself?
Thanks a lot for the help!
Ying
sean@I7-3930K:~/Rtest$ ls -ltotal 56drwx-- 3 sean sean 4096 2012-02-25 
20:39 Data01drwx-- 2 sean sean 4096 2012-02-25 20:28 Data02drwx-- 2 
sean sean 4096 2012-02-26 07:41 Data03drwx-- 2 sean sean 4096 2012-02-25 
21:18 Data04drwx-- 2 sean sean 4096 2012-02-25 20:27 Data05-rw-r--r-- 1 
sean sean  437 2012-02-26 15:28 scriptA.R...
> From: michael.weyla...@gmail.com
> Date: Sun, 26 Feb 2012 12:48:57 -0500
> Subject: Re: [R] Help needed! Error in setwd(newdir) : cannot change working 
> directory
> To: ying_c...@live.com
> CC: r-help@r-project.org
> 
> This is a mess -- please resend in plain text.
> 
> Also, there are not, to my knowledge, packages (not libraries) called
> "A", "B", or "C" so your script doesn't even begin to look
> reproducible were it legible.
> 
> Do you have read/write access to the directories in question?
> 
> Michael
> 
> On Sat, Feb 25, 2012 at 11:25 PM, ying chen  wrote:
> >
> > Hi Guys,
> >
> > I am new to R and just trying to write a small script to automate a couple 
> > commands. But I run into the setwd(): cannot change working directory.
> > I googled a little bit and tried all fixes/suggestions with no success.
> > Basically I have a script that works from inside a directory with my data 
> > (/home/sean/Rt

Re: [R] loop for a large database

2012-02-26 Thread Petr Savicky
On Sun, Feb 26, 2012 at 04:13:49AM -0800, mari681 wrote:
> Yes, I am a newbie.
> 
> I have a data.frame (MyTable) of  1445846  rows and  15  columns with
> character data.
> And a character vector (MyVector) of 473491 elements.
> 
> I want simply to get a data.frame with the count of how many times each
> element of MyVector appears in MyTable.
> 
> I've tried a loop with : for (i in 1 : length (myvector))  sum (MyTable== i)
> 
> but it crashes my computer.

Hi.

Try first the following.

  out <- unclass(table(factor(MyTable[[1]], levels=myvector)))

The output should be a table of frequencies of the components
of "myvector" in the first column of "MyTable".

If this works for the data of the size, which you have,
then there are different possible ways how to compute
the frequencies in all columns. For example, concatenate
all columns to a single vector and apply the above to
this concatenation as follows.

  x <- c(as.matrix(MyTable))
  out <- unclass(table(factor(x, levels=myvector))) 

Here, "out" is a vector of the same length as "myvector"
and out[i] is the frequency of myvector[i] in "MyTable".

Hope this helps.

Petr Savicky.

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


Re: [R] loop for a large database

2012-02-26 Thread Petr Savicky
On Sun, Feb 26, 2012 at 04:13:49AM -0800, mari681 wrote:
> Yes, I am a newbie.
> 
> I have a data.frame (MyTable) of  1445846  rows and  15  columns with
> character data.
> And a character vector (MyVector) of 473491 elements.
> 
> I want simply to get a data.frame with the count of how many times each
> element of MyVector appears in MyTable.
> 
> I've tried a loop with : for (i in 1 : length (myvector))  sum (MyTable== i)
> 
> but it crashes my computer.

Hi.

As David pointed out, you probably want to compute 

  sum (MyTable== myvector[i])

and not sum (MyTable== i).

Also, i would expect storing the results somewhere, for example

  numOccur <- rep(NA, times=length(myvector))
  for (i in 1:length(myvector)) numOccur[i] <- sum(MyTable == myvector[i])

What do you see on the crashing computer? I would expect it to run for
a long time, but not crashing.

Try to run your code on a smaller part of the data to test efficiency
of different approaches.

How many different strings are in your data? If there is a lot of
repeated strings, then it may be better to first compute the
frequency table of them and search the strings from "myvector"
in this table and sum the frequencies.

Does your data frame consist of character vectors or from factors?
This may be seen by testing class(MyTable[[1]]).

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread R. Michael Weylandt
This is a mess -- please resend in plain text.

Also, there are not, to my knowledge, packages (not libraries) called
"A", "B", or "C" so your script doesn't even begin to look
reproducible were it legible.

Do you have read/write access to the directories in question?

Michael

On Sat, Feb 25, 2012 at 11:25 PM, ying chen  wrote:
>
> Hi Guys,
>
> I am new to R and just trying to write a small script to automate a couple 
> commands. But I run into the setwd(): cannot change working directory.
> I googled a little bit and tried all fixes/suggestions with no success.
> Basically I have a script that works from inside a directory with my data 
> (/home/sean/Rtest/Data01). Now I want to modify the script to make it run 
> from the upper directory (/home/sean/Rtest) because I have many data 
> directories under /Rtest, such as /home/sean/Rtest/Data01, 
> /home/sean/Rtest/Data02, /home/sean/Rtest/Data03,.
> I want to modify my script so that it will run from /Rtest, and with the data 
> directory name as arg passed to my R script. Here is my mytest02.R script:
>>># retrieve args>>args <- commandArgs(TRUE);>># store the current 
>>>directory>>initial.dir <- getwd();>>newdir <- 
>>>paste(initial.dir,args,sep="/");>>outfilename <- 
>>>paste(args,"out",sep=".");>># change to the new directory>>setwd(newdir);>># 
>>>load the necessary libraries>>library("A");  
>>>#>>library("B");>>library("C");>># set the output 
>>>file>>sink(outfilename);>>    #data processing>>    #data 
>>>processing>>    #data processing>># close the output 
>>>file>>sink();>># unload the libraries>>detach("package:A");  
>>>#>>detach("package:B");>>detach("package:C");>># change back to the original 
>>>directory>>setwd(initial.dir);
> Then I run the script by
>>>sean@I7-3930K:~/Rtest$ R --slave --args Data01 < mytest02.R
> I got the error message:
>>>sean@I7-3930K:~/Rtest$ R --slave --args Data01 < mytest02.R>>Attempting to 
>>>load the environment ‘package:R.utils’>>Loading required package: 
>>>R.methodsS3>>R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See 
>>>?R.methodsS3 for help.>>Loading required package: utils>>R.oo v1.8.3 
>>>(2011-11-01) successfully loaded. See ?R.oo for help.Attaching package: 
>>>‘R.oo’The following object(s) are masked from ‘package:R.methodsS3’:>> 
>   throw.defaultThe following object(s) are masked from 
>>>‘package:methods’:>> >>   getClass, getClasses, getMethodsThe following 
>>>object(s) are masked from ‘package:base’:>> >>   attach, detach, 
>>>environment, gc, load, saveR.utils v1.9.11 (2012-01-17) successfully 
>>>loaded. See ?R.utils for help.Attaching package: ‘R.utils’The 
>>>following object(s) are masked from ‘package:utils’:    timestampThe 
>>>following object(s) are masked from ‘package:base’:    cat, commandArgs, 
>>>getOption, inherits, isOpen, lapply, parse,>>    remove, warnings[1] 
>>>"/home/sean/Rtest">>[1] "/home/sean/Rtest/NA"       "/home/sean/Rtest/TRUE"  
>>>  >>[3] "/home/sean/Rtest/Data01">>[1] "NA.out"       "TRUE.out"     
>>>"Data01.out">>Error in setwd(newdir) : cannot change working 
>>>directory>>Execution halted
> What did I do wrong?
> One more question, is there anyway to modify this script to make it work on 
> all data directories under /home/sean/Rtest by itself?
> Thanks a lot for the help!
> Ying
>
>        [[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] NaN's in class 'performance; [package "ROCR"]

2012-02-26 Thread Chet Seligman
Thanks Uwe.
I definitely want to replace the NaN, unless someone has a better idea.
I have a couple of lists of label-value pairs that come from a randomForest
object.
I plot a series of precision- recall curves (not really curves but
zig-zags) from  x and y lists that came from multiple randomForest runs.
I want to make the comparison between the runs clearer than just plotting
the zig-zags on top of each other, so I tried a curve smoother like lowess.
Lowess doesn't like NaN's.
Replacing the first one in the list with something that is just after it,
lets the smoother work and doesn't really change the comparison between the
runs.

2012/2/25 Uwe Ligges 

>
>
> On 24.02.2012 17:41, Chet Seligman wrote:
>
>> The first item in @ y.values is a NaN
>> Slot "y.values":
>> [[1]]
>>   [1]   NaN 1.000
>>
>> How do replace it with 1.00 or otherwise get rid of it?
>>
>
>
> I wonder if you really want to do that,m but if so, you can replace it by:
>
> object@y.values[[1]][1] <- 1
>
> Uwe Ligges
>
>
>
>
>  Chet
>>
>>[[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] loop for a large database

2012-02-26 Thread David Winsemius


On Feb 26, 2012, at 7:13 AM, mari681 wrote:


Yes, I am a newbie.

I have a data.frame (MyTable) of  1445846  rows and  15  columns with
character data.
And a character vector (MyVector) of 473491 elements.

I want simply to get a data.frame with the count of how many times  
each

element of MyVector appears in MyTable.

I've tried a loop with : for (i in 1 : length (myvector))  sum  
(MyTable== i)


In that instance "i" is a number and probably would not be matching  
something that was a character vector.




but it crashes my computer.

I've also tried something like

x <- 1 : length (MyVector)
apply (MyTable , 1 , function(x) {sum (MyTable ==x)}

but doesn't work.
Any idea?

Thank you. Any suggestion is super welcome.


Since you never offered the requested information about your objects,  
this is guesswork. If MyVector is one of the 15 columns in MyTable  
then this will have good chance:


table(MyTable$MyVector)

If on the other hand they are separate and you want to ignore the  
elements not in MyVector, then assign the value of a table operation  
and then use match() to pick out the tabulated values


In the future, please al least offer the results of str(MyTable).

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Gia to R forum

2012-02-26 Thread Alaios
 apply(( DataForFrequency > threshold), 1, sum)), 
FrequencyBins=ncol(DataForFrequency))



num [1:292256, 1:403] -106 -108 -110 -110 -112 ...

[[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] Line-by-line profiling, a la Matlab

2012-02-26 Thread Martin
Hi,
I was wondering if there is a function or package for R that can be used
for "line-by-line" profiling, and yields an output similar to Matlab's
profiler?

For those of you that are not familiar with the Matlab profiler, it shows
you how much time each line in the code took to run. Moreover, if the
function/s included in that line are not "built-in", you can click on them
and see the time it took to run each line within that function.

Is there anything similar in R? I've tried Rprof and the profr package, but
they have not been very helpful.

Thank you very much in advance.

[[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] strucchange breakpoints (Bai and Perron, 1998, 2003)

2012-02-26 Thread Achim Zeileis


On Sun, 26 Feb 2012, buehlerman wrote:


If I try the breakpoints() function (strucchange package) with a minimum
segment size = the number of regressors, there appears the following error
message:
"minimum segment size must be greater than the number of regressors"

According to the documentation:
"breakpoints implements the algorithm described in Bai & Perron (2003) for
simultaneous estimation of multiple breakpoints."

Bai & Perron (2003) assumed: minimum segment size >= number of regressors
(and not >).
What is the reason for this deviation?


It was introduced to make the results numerically more stable. Typically, 
neither of the restrictions will be appropriate in practice and larger 
minimal segment sizes should be used. For example, for a regression with 
an intercept and a slope, I would typically use at least h = 10 (and not h 
= 2 or h = 3) so that the parameters estimators are meaningful on each 
resulting segment.



--
View this message in context: 
http://r.789695.n4.nabble.com/strucchange-breakpoints-Bai-and-Perron-1998-2003-tp4422361p4422361.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] question about user written function (newb question)

2012-02-26 Thread Gabor Grothendieck
On Sun, Feb 26, 2012 at 9:06 AM, knavero  wrote:
> Quick newb question about R relating to the line of code below:
>
> rawCool = read.zoo("cooling.txt", FUN = as.chron, format = "%m/%d/%Y %H:%M",
> sep = "\t", aggregate = function(x) tail(x, 1))
>
> I'm wondering what the specifics are for the argument where it has
> "aggregate = function(x) tail(x, 1)". I understand that it removes the last
> row of duplicates/aggregates in the zoo series. I'm confused as to why
> "tail(x, 1)", a built in function in the utils package, requires the coder
> to treat it as a user written function thus defining the assignment, in this
> case an argument, with "function(x)". Why can't the coder just write
> "tail(x, 1)" instead? Also, with the argument 'x', within tail, I'm assuming
> it's looking at all columns simultaneously within the zoo series? Is that
> correct to say? Thanks.

1.  tail(x, 1) is not a function.  Its the operation of executing the
function tail with the values x and 1.  Even if x existed it would be
an error since aggregate= requires a function, not a value.   One
could have written aggregate = tail except that the default is 6
elements whereas we want 1.

One could write this where tail1 is defined to be the same as tail
except its hard coded to use the last element of x only:

tail1 <- function(x) tail(x, 1)
read.zoo(...whatever..., aggregate = tail1)

2.  aggregate= ultimately calls aggregate in the core of R and that
works by looking at the columns one by one.   For a particular column
it splits it into groups (in the case of aggregate.zoo the groups are
defined by rows having the same times) and then for each group
applying the indicated function.

See ?read.zoo and the vignette("zoo-read") for more.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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.


[R] strucchange breakpoints (Bai and Perron, 1998, 2003)

2012-02-26 Thread buehlerman
If I try the breakpoints() function (strucchange package) with a minimum
segment size = the number of regressors, there appears the following error
message:
"minimum segment size must be greater than the number of regressors"

According to the documentation:
"breakpoints implements the algorithm described in Bai & Perron (2003) for
simultaneous estimation of multiple breakpoints."

Bai & Perron (2003) assumed: minimum segment size >= number of regressors
(and not >).
What is the reason for this deviation?

--
View this message in context: 
http://r.789695.n4.nabble.com/strucchange-breakpoints-Bai-and-Perron-1998-2003-tp4422361p4422361.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] count how many row i have in a txt file in a directory

2012-02-26 Thread Hans Ekbrand
On Sun, Feb 26, 2012 at 03:03:58PM +0100, gianni lavaredo wrote:
> Dear Researchers,
> 
> I have a large TXT (X,Y,MyValue) file in a directory and I wish to import
> row by row the txt in a loop to save only the data they are inside a buffer
> (using inside.owin of spatstat) and delete the rest. The first step before
> to create a loop row-by-row is to know how many rows there are in the txt
> file without load in R to save memory problem.
> 
> some people know the specific function?

If the number of rows are many that even only three variables per row
will cause memory problems, then looping the file row-by-row will take
a very long time.

I would - instead of looping row-by-row - split the text file into
chunks small enough for a chunk to be read into R, and operated on
within R, without memory problems.

I create a test file of 10.000.000 rows

my.words <- replicate(1, paste(LETTERS[sample.int(28, 10)], sep = "", 
collapse = ""))
my.df <- data.frame(x=rnorm(1000), y=rnorm(1000), my.val=rep(my.words, 
1000))
write.csv(my.df, file = "testmem.csv")

Split the file into smaller chunks, say 1.000.000 rows. I use the
split command in GNU coreutils,

$ split -l 100 testmem.csv

Loop through the cunks.

for(file.name in c("xaa", "xab" ...){
  chunk <- read.csv(file = file.name)
  [ match and add all the interesting rows to an object ]
}

Here's an example that for each chunk prints its third row.

for(file.name in c("xaa", "xab")){
  chunk <- read.csv(file = file.name)
  print(chunk[3,])
}

With a chunk of 1.000.000 rows, R needed about 250 MB RAM to process this loop.

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


Re: [R] question about user written function (newb question)

2012-02-26 Thread R. Michael Weylandt
Short answer to a very good question: one has to use "function(x)
tail(x, 1)"  syntax to avoid using the default tail(x, 6). There are
some other ways to achieve the same thing, but I think this syntax is
generally preferred for its clarity.

Other question: yes I believe so.

Michael

On Sun, Feb 26, 2012 at 9:06 AM, knavero  wrote:
> Quick newb question about R relating to the line of code below:
>
> rawCool = read.zoo("cooling.txt", FUN = as.chron, format = "%m/%d/%Y %H:%M",
> sep = "\t", aggregate = function(x) tail(x, 1))
>
> I'm wondering what the specifics are for the argument where it has
> "aggregate = function(x) tail(x, 1)". I understand that it removes the last
> row of duplicates/aggregates in the zoo series. I'm confused as to why
> "tail(x, 1)", a built in function in the utils package, requires the coder
> to treat it as a user written function thus defining the assignment, in this
> case an argument, with "function(x)". Why can't the coder just write
> "tail(x, 1)" instead? Also, with the argument 'x', within tail, I'm assuming
> it's looking at all columns simultaneously within the zoo series? Is that
> correct to say? Thanks.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/question-about-user-written-function-newb-question-tp4422187p4422187.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] svm with GRASS GIS

2012-02-26 Thread giuseppe calamita
Dear Ethienne, thanks a lot for your help.
We finally manage to perform the svm classification in this  way:

library(spgrass6) ; G <- gmeta6()

TL_training_2006_id.raw<-readRAST6("TL_training_2006_id") #  classes
training area 

B1_B2_B3_train.raw<-readRAST6(c("AST_L1B_2008_05_2009_area_giusta_1_training","AST_L1B_2008_05_2009_area_giusta_2_training","AST_L1B_2008_05_2009_area_giusta_3N_training"))
#bands training area 

B1_B2_B3_compl.raw<-readRAST6(c("AST_L1B_2008_05_2009_area_giusta_1","AST_L1B_2008_05_2009_area_giusta_2","AST_L1B_2008_05_2009_area_giusta_3N"))
#bands, complete data

#transform classes from numeric to factor
is.numeric(TL_training_2006_id.raw@data$TL_training_2006_id) #TRUE
class(TL_training_2006_id.raw@data$TL_training_2006_id) #numeric
TL_training_2006_id.raw@data$TL_training_2006_id <-
as.factor(TL_training_2006_id.raw@data$TL_training_2006_id)


# create NA mask using complete.cases()
TL_training_2006_id.na_mask <- complete.cases(TL_training_2006_id.raw@data)
B1_B2_B3_train.na_mask <-complete.cases(B1_B2_B3_train.raw@data)
B1_B2_B3_compl.na_mask <-complete.cases(B1_B2_B3_compl.raw@data)


# get values based on na_mask
TL_training_2006_id <-
TL_training_2006_id.raw@data[TL_training_2006_id.na_mask, ] 
B1_B2_B3_train <- B1_B2_B3_train.raw@data[B1_B2_B3_train.na_mask, ]
B1_B2_B3_compl <- B1_B2_B3_compl.raw@data[B1_B2_B3_compl.na_mask, ]


# create SVM model
library(e1071)
x <- B1_B2_B3_train
y <- TL_training_2006_id
model_ASTER <- svm(x,y)

#predict 
pred <- predict(model_ASTER, B1_B2_B3_compl.raw@data)
#same as:
pred <- predict(model_ASTER, B1_B2_B3_compl.raw@data[B1_B2_B3_compl.na_mask,
], locations=coordinates(utm_wgs84))

#now the issue is that the "pred" object is
 str(pred)
 Factor w/ 4 levels "2","3","4","5": 3 3 3 3 3 3 3 3 3 3 ...
 - attr(*, "names")= chr [1:920591] "24389" "24390" "24391" "25729" ...

that is, it contains the predicted(classified) values but it is not an S4
object SGDF

Do you have any advice on how to tranform it back in SGDF having the
coordinates(B1_B2_B3_compl.raw)?

Thankyou ! 

Giuseppe

--
View this message in context: 
http://r.789695.n4.nabble.com/svm-with-GRASS-GIS-tp4388006p4422281.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] question about user written function (newb question)

2012-02-26 Thread knavero
Quick newb question about R relating to the line of code below:

rawCool = read.zoo("cooling.txt", FUN = as.chron, format = "%m/%d/%Y %H:%M",
sep = "\t", aggregate = function(x) tail(x, 1))

I'm wondering what the specifics are for the argument where it has
"aggregate = function(x) tail(x, 1)". I understand that it removes the last
row of duplicates/aggregates in the zoo series. I'm confused as to why
"tail(x, 1)", a built in function in the utils package, requires the coder
to treat it as a user written function thus defining the assignment, in this
case an argument, with "function(x)". Why can't the coder just write
"tail(x, 1)" instead? Also, with the argument 'x', within tail, I'm assuming
it's looking at all columns simultaneously within the zoo series? Is that
correct to say? Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/question-about-user-written-function-newb-question-tp4422187p4422187.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] loop for a large database

2012-02-26 Thread mari681
Yes, I am a newbie.

I have a data.frame (MyTable) of  1445846  rows and  15  columns with
character data.
And a character vector (MyVector) of 473491 elements.

I want simply to get a data.frame with the count of how many times each
element of MyVector appears in MyTable.

I've tried a loop with : for (i in 1 : length (myvector))  sum (MyTable== i)

but it crashes my computer.

I've also tried something like   

x <- 1 : length (MyVector)
apply (MyTable , 1 , function(x) {sum (MyTable ==x)}

but doesn't work.
Any idea?

Thank you. Any suggestion is super welcome.

Marianna



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-for-a-large-database-tp4422052p4422052.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] count how many row i have in a txt file in a directory

2012-02-26 Thread gianni lavaredo
Dear Researchers,

I have a large TXT (X,Y,MyValue) file in a directory and I wish to import
row by row the txt in a loop to save only the data they are inside a buffer
(using inside.owin of spatstat) and delete the rest. The first step before
to create a loop row-by-row is to know how many rows there are in the txt
file without load in R to save memory problem.

some people know the specific function?

thanks in advance for all suggestions
Gianni

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