[R] how to make multiple curves in one plot

2010-11-01 Thread karena

hello, 

plot(running(-log10(results_chr_p$empi_p), fun=mean, width=41, font.axis=4,
by=1),type="l",cex=0.1, ylab="-Log(p)", ylim=c(0,5.0), xlab=" ", lwd=2)


this is my code to make a plot. The problem is, now I want to add one more
curve to the plot, which is for another variable in the data.frame
-log10(results_chr_p$p). My question is: how to make multiple lines in one
plot, especially when using the 'running' function in it??

thank you very much,

karena
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-make-multiple-curves-in-one-plot-tp3023135p3023135.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Using R for Production - Discussion

2010-11-01 Thread baptiste auguie
Hi,

Regarding your '10 commandments' in Q3, you may find useful tips in
"the R inferno" by Pat Burns.

HTH,

baptiste

On 2 November 2010 05:04, Santosh Srinivas  wrote:
> Hello Group,
>
> This is an open-ended question.
>
> Quite fascinated by the things I can do and the control I have on my
> activities since I started using R.
> I basically have been using this for analytical related work off my desktop.
> My experience has been quite good and most issues where I need to
> investigate and solve are typical items more related to data errors, format
> corruption, etc... not necessarily "R" Related.
>
> Complementing this with Python gives enough firepower to do lots of
> production (analytical related activities) on the cloud (from my research I
> see that every innovative technology provider seems to support Python ...
> google, amazon, etc).
>
> Question on using R for Production activities:
> Q1) Does anyone have experience of using R-scripts etc ... for production
> related activities. E.g. serving off a computational/ analytical /
> simulation environment from a webportal with the analytical processing done
> in R.
> I've seen that most useful things for normal (not rocket science) business
> (80-20 rule) can be done just as well in R in comparison with tools like
> SAS, Matlab, etc.
>
> Q2) I haven't tried the processing routines for much larger data-sets
> assuming "size" is not a constraint nowadays.
> I know that I should try out ... but any forewarnings would help. Is it
> likely that something that works for my "desktop" dataset is quite as likely
> to work when scaled up to a "cloud dataset"?
> Assuming that I do the clearing out of unused objects, not running into
> infinite loops, etc?
>
> i.e. is there any problem with the "fundamental architecture of R itself"?
> (like press articles often say)
>
>
> Q3) There are big fans of the SAS, Matlab, Mathworks environments out there
>  does anyone have a comparison of how R fares.
> >From my experience R is quite neat and low level ... so overheads should be
> quite low.
> Most slowness comes due to lack of knowledge (see my code ... like using the
> wrong structures, functions, loops, etc.) rather than something wrong with
> the way R itself is.
> Perhaps there is no "commercial" focus to enhance performance related issues
> but my guess is that it is just matter of time till the community evolves
> the language to score higher on that too.
> And perhaps develops documentation to assist the challenge users with
> "performance tips" (the ten commandments types)
>
> Q4) You must have heard about the latest comment from James Goodnight of SAS
> ... "We haven't noticed that a lot. Most of our companies need industrial
> strength software that has been tested, put through every possible scenario
> or failure to make sure everything works correctly."
> My "gut" is that random passionate geeks (playing part-time) do better
> testing than a military of professionals ... (but I've no empirical evidence
> here)
>
> I am not taking a side here (although I appreciate those who do!) .. but
> looking for an objective reasoning.
>
> Thanks,
> S
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] how to compare two datasets in R>?

2010-11-01 Thread Santosh Srinivas
Take a look at ?merge for doing such join operations. (I believe that should
help)
If you had provided a sample of your datasets using dput, I would have
checked that for you.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of song song
Sent: 02 November 2010 11:44
To: r-help@r-project.org
Subject: [R] how to compare two datasets in R>?

hi, everybody, my question is:

suppose I have two data sets, set A is large and have variables like ID,
Gender, Income.  Set B is small and suppose only has ID.

Now I want to get a subset from data set A which contains ID from Set B.

How to do this in R>?  Is there any commands to do this?

Thank you

[[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] how to compare two datasets in R>?

2010-11-01 Thread song song
hi, everybody, my question is:

suppose I have two data sets, set A is large and have variables like ID,
Gender, Income.  Set B is small and suppose only has ID.

Now I want to get a subset from data set A which contains ID from Set B.

How to do this in R>?  Is there any commands to do this?

Thank you

[[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] Need help with nlme code

2010-11-01 Thread Muhammad Yaseen
*Dear All,*
*
*
*I got a very simple for you. Please help me to come up with the R code in
nlme for the following SAS code:*
*
*
*{*
proc mixed data=spatvar;
   model yield = ;
   repeated / subject = intercept
  type= sp(sph)(row col);
   parms (0 to 10 by 2.5)
 (1 to 10 by 3  );
   run;

Note:
The INTERCEPT specification creates an effect that is constant across the
observations in the data set. This implies that all observations belong to
the same subject.
*}*
*
*
*I'm struggling how to use groupedData function from nlme to come up with
the right R code. Any suggestion and help will be highly appreciated. Thanks
*
 *
*
*Regards!*
*
*
*Yours Sincerely,*
*
*

-- 
*

Muhammad Yaseen
*

[[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] Strings from different locale

2010-11-01 Thread steven mosher
I'm doing some test processing of a cvs file that appears to use a different
locale
from my machine.

I get the following warning:

 input string 1 is invalid in this locale

My locale is US. Is this simply a matter of changing my locale to 'all;
locales?

I don't know what locale the string is in, is there a way to detect this or
translate

[[alternative HTML version deleted]]

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


Re: [R] how to make multiple curves in one plot

2010-11-01 Thread Remko Duursma

Dear Karena,


Please read the posting guide : your example cannot be reproduced because we
don't know in which package the 'running' function resides.

Generally speaking, use 'points' or 'lines' to add points or lines to the
current device.


greetings,
remko
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-make-multiple-curves-in-one-plot-tp3023135p3023169.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] arguments must have the same length

2010-11-01 Thread Michael Sumner
It's not night time everywhere.

The error message suggests that your arguments have different lengths,
and that this is required. Perhaps a function that takes two vector
arguments?

Please provide the code you are running, hopefully with a reproducible
example as per the posting guide.

BTW, please read the posting guide, and writing good questions does
take practice, but you'll find you often figure out the answer
yourself by working on a good question for R-help.

Cheers, Mike.

On Tue, Nov 2, 2010 at 3:11 PM, Shari Kay Hunter
 wrote:
> Hi, anyone up in the night working? Thanks for being there. I'm getting this
> error message "arguments must have the same length."
> Can't seem to straighten it out. Any suggestions? Thanks so much!
> PS I saw that someone asked a similar question, but I don't see that
> anyone had posted a reply...
>
> --
> Shari Kay Hunter
> 612-250-9252(cell)
>
>        [[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.
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@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] arguments must have the same length

2010-11-01 Thread Shari Kay Hunter
Hi, anyone up in the night working? Thanks for being there. I'm getting this
error message "arguments must have the same length."
Can't seem to straighten it out. Any suggestions? Thanks so much!
PS I saw that someone asked a similar question, but I don't see that
anyone had posted a reply...

-- 
Shari Kay Hunter
612-250-9252(cell)

[[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] Using R for Production - Discussion

2010-11-01 Thread Santosh Srinivas
Hello Group,

This is an open-ended question.

Quite fascinated by the things I can do and the control I have on my
activities since I started using R.
I basically have been using this for analytical related work off my desktop.
My experience has been quite good and most issues where I need to
investigate and solve are typical items more related to data errors, format
corruption, etc... not necessarily "R" Related.

Complementing this with Python gives enough firepower to do lots of
production (analytical related activities) on the cloud (from my research I
see that every innovative technology provider seems to support Python ...
google, amazon, etc).

Question on using R for Production activities:
Q1) Does anyone have experience of using R-scripts etc ... for production
related activities. E.g. serving off a computational/ analytical /
simulation environment from a webportal with the analytical processing done
in R.
I've seen that most useful things for normal (not rocket science) business
(80-20 rule) can be done just as well in R in comparison with tools like
SAS, Matlab, etc.

Q2) I haven't tried the processing routines for much larger data-sets
assuming "size" is not a constraint nowadays.
I know that I should try out ... but any forewarnings would help. Is it
likely that something that works for my "desktop" dataset is quite as likely
to work when scaled up to a "cloud dataset"?
Assuming that I do the clearing out of unused objects, not running into
infinite loops, etc?

i.e. is there any problem with the "fundamental architecture of R itself"?
(like press articles often say)


Q3) There are big fans of the SAS, Matlab, Mathworks environments out there
 does anyone have a comparison of how R fares.
>From my experience R is quite neat and low level ... so overheads should be
quite low.
Most slowness comes due to lack of knowledge (see my code ... like using the
wrong structures, functions, loops, etc.) rather than something wrong with
the way R itself is.
Perhaps there is no "commercial" focus to enhance performance related issues
but my guess is that it is just matter of time till the community evolves
the language to score higher on that too.
And perhaps develops documentation to assist the challenge users with
"performance tips" (the ten commandments types)

Q4) You must have heard about the latest comment from James Goodnight of SAS
... "We haven't noticed that a lot. Most of our companies need industrial
strength software that has been tested, put through every possible scenario
or failure to make sure everything works correctly."
My "gut" is that random passionate geeks (playing part-time) do better
testing than a military of professionals ... (but I've no empirical evidence
here)

I am not taking a side here (although I appreciate those who do!) .. but
looking for an objective reasoning.

Thanks,
S

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please help me about Monte Carlo Permutation

2010-11-01 Thread Chitra

yes,
and also plotting them.
Thanks.

2010/11/1 Łukasz Ręcławowicz [via R] <
ml-node+3022778-293096829-200...@n4.nabble.com
>

> 2010/10/29 Chitra <[hidden 
> email]>
>
>
> >
> >  I am sorry I got lost here.
>
>
> Me too. So you want to do a MC test for Pearson's product-moment
> correlation, right...?
>
>
> --
> Mi³ego dnia
>
> [[alternative HTML version deleted]]
>
>
> __
> [hidden email] mailing 
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
>  View message @
> http://r.789695.n4.nabble.com/Please-help-me-about-Monte-Carlo-Permutation-tp3017131p3022778.html
> To unsubscribe from Please help me about Monte Carlo Permutation, click
> here.
>
>
>


-- 
Chitra Bahadur Baniya (PhD)
Lecturer
Central Department of Botany
Tribhuvan University
Kirtipur
Kathmandu, Nepal

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Please-help-me-about-Monte-Carlo-Permutation-tp3017131p3023137.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] File Downloading Problem

2010-11-01 Thread Santosh Srinivas
Just for info  how did you guys figure out that useragent was the
problem?

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Duncan Temple Lang
Sent: 01 November 2010 22:34
To: r-help@r-project.org
Subject: Re: [R] File Downloading Problem


I got this working almost immediately with RCurl although with that
one has to specify any value for the useragent option, or the same error
occurs.

The issue is that R does not add an Accept entry to the HTTP request header.
It should add something like
   Accept: *.*

Using RCurl,
 u =
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"
 o = getURLContent(u, verbose = TRUE, useragent =
getOption("HTTPUserAgent"))

succeeds (but not if there is no useragent).


We could fix R's download.file() to send Accept: *.*,
or allow general headers to be specified either as an option for
all requests, or as a parameter of download.file() (or both).
Or we could have the makeUserAgent() function in utils be more customizable
through options, or allow the R user specify the function herself.
But while this would be good, the HTTP facilities in R are not
intended to be as general something like libcurl (and hence RCurl).

Unless there is a compelling reason to enhance R's internal facilities,
I suggest people use something like libcurl.  This approach also has
the advantage of having the data directly in memory and avoiding writing
it to disk and then reading it back in, e.g.

  library(Rcompression)
  z = zipArchive(o)
  names(z)
  read.csv(textConnection(z[[1]]))


  D.


On 11/1/10 8:27 AM, Santosh Srinivas wrote:
> It's strange and the internet connection is fine because I am able to get
> data from yahoo.
> This was working till just yesterday ... strange if the website is
creating
> issues with public access of basic data!
> 
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net] 
> Sent: 01 November 2010 20:48
> To: Duncan Murdoch
> Cc: Santosh Srinivas; 'Rhelp'
> Subject: Re: [R] File Downloading Problem
> 
> 
> On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:
> 
>> On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
>>> Nope Duncan ... no changes .. the same old way without a proxy ...  
>>> actually
>>> the download.file is being returned "403 forbidden" which is strange.
>>>
>>> These are just two lines that I am trying to run.
>>>
>>> sURL<-
>>>
>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>>> v.csv.zip"
>>> download.file(sURL,"test.zip")
>>>
>>> Put the same URL in a browser and it works fine.
>>
>> It doesn't work for me, so presumably there is some kind of security  
>> setting at the site (a cookie?), which allows your browser, but  
>> doesn't allow you to use R, or me to use anything.
> 
> Firefox in a Mac platform will download and unzip the file with no  
> security complaints and no cookie appears to be set when downloading,  
> but that code will not access the file, nor will my efforts to wrap  
> the URL in url() or unz() so it seems more likely that Santosh and I  
> do not understand the file opening processes that R supports.
> 
>  > con=
>
unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NO
> V/cm01NOV2010bhav.csv.zip 
> ", file="~/cm01NOV2010bhav.csv")
>  > test.df <-  read.csv(file=con)
> Error in open.connection(file, "rt") : cannot open the connection
> In addition: Warning message:
> In open.connection(file, "rt") :
>cannot open zip file
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip'
> 
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Underline only colnames in grid.table

2010-11-01 Thread Paul Murrell

Hi

On 29/10/2010 7:55 p.m., robbert blonk wrote:


Dear all,

I would like to underline only the colnames in a table as e.g.

grid.draw(tableGrob(head(iris, 10), name="test"))

I can imagine you should use grid.edit or so, bu I can't figure out
how...

Does anyone have a suggestion?


Unfortunately, grid.edit() won't help here because the table is all 
drawn on-the-fly ; the only thing you can see is the overall table grob.


You can see the viewports that are used to draw the table, but the 
downside there is that they do not have very useful names.


The following code draws the table, then looks into the viewport tree to 
get the name of the 12th table viewport (which is the first viewport on 
the second column), navigates down to that viewport, then draws a line 
along the bottom.


grid.table(head(iris, 10), name="test")
downViewport(current.vpTree()$children[[1]]$children[[12]]$name)
grid.segments(0, 0, 1, 0)

Not a very general solution, but may provide a one-off workaround.

Is that what you meant?

Paul


Thanks Robbert

windows xp R 2.10.1



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

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


Re: [R] question in using nlme and lme4 for unbalanced data

2010-11-01 Thread Ben Bolker
Chi Yuan  email.arizona.edu> writes
> 
> Hello:
>  I need some help about using mixed for model for unbalanced data. I
> have an two factorial random block design. It's a ecology
> experiment. My two factors are, guild removal and enfa removal. Both
> are two levels, 0 (no removal), 1 (removal). I have 5 blocks. But
> within each block, it's unbalanced at plot level because I have 5
> plots instead of 4 in each block. Within each block, I have 1 plot
> with only guild removal, 1 plot with only enfa removal, 1 plot for
> control with no removal, 2 plots for both guild and enfa removal. I am
> looking at how these treatment affect the enfa mortality rate. I
> decide to use mixed model to treat block as random effect. So I try
> both nlme and lme4. But I don't know whether they take the unbalanced
> data properly. So my question is, does lme in nlme and lmer in lme4
> take unbalanced data? How do I know it's analysis in a proper way?

  Didn't Bert Gunter and I already provide answers to this question
last week? Can you please clarify what about those answers you didn't
understand?

> Another question is about p values.
> I kind of heard the P value does not matter that much in the mixed
> model because it's not calculate properly. Is there any other way I can
>  tell whether the treatment has a effect not? I know AIC is for model
> comparison,
> do I report this in formal publication?

  It is indeed hard to compute p-values, but ... if you use AIC,
you are essentially making the same assumption as if you assumed
that the denominator degrees of freedom were infinite in an F test
(or if you used the likelihood ratio test).

[snip results]

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 in using nlme and lme4 for unbalanced data

2010-11-01 Thread Dennis Murphy
Hi:

On Mon, Nov 1, 2010 at 3:59 PM, Chi Yuan  wrote:

> Hello:
>  I need some help about using mixed for model for unbalanced data. I
> have an two factorial random block design. It's a ecology
> experiment. My two factors are, guild removal and enfa removal. Both
> are two levels, 0 (no removal), 1 (removal). I have 5 blocks. But
> within each block, it's unbalanced at plot level because I have 5
> plots instead of 4 in each block. Within each block, I have 1 plot
> with only guild removal, 1 plot with only enfa removal, 1 plot for
> control with no removal, 2 plots for both guild and enfa removal. I am
> looking at how these treatment affect the enfa mortality rate. I
> decide to use mixed model to treat block as random effect. So I try
> both nlme and lme4. But I don't know whether they take the unbalanced
> data properly. So my question is, does lme in nlme and lmer in lme4
> take unbalanced data? How do I know it's analysis in a proper way?
>

Unbalanced data is not a problem in either package. However, five blocks is
rather at the boundary of whether or not one can compute reliable variance
components and random effects. Given that the variance estimate of blocks in
your models was nearly zero, you're probably better off treating them as
fixed rather than random and analyzing the data with a fixed effects model
instead.

Another question is about p values.
> I kind of heard the P value does not matter that much in the mixed
> model because it's not calculate properly.


No. p-values are not calculated in lme4 (as I understand it) because,
especially in the case of severely unbalanced data, the true sampling
distributions of the test statistics in small to moderate samples are not
necessarily close to the asymptotic distributions used to compute the
corresponding p-values. It's the (sometimes gross) disparity between the
small-sample and asymptotic distributions that makes the reported p-values
based on the latter unreliable, not an inability to calculate the p-value
properly. I can assure you that Prof. Bates knows how to compute a p-value.

Is there any other way I can
>  tell whether the treatment has a effect not? I know AIC is for model
> comparison,
> do I report this in formal publication?
>

As mentioned above, I would suggest analyzing this as a fixed effects
problem. Since the imbalance is not too bad, and it is not unusual in field
experiments to have more control EUs than treatment EUs within each level of
treatment, a fixed effects analysis may be sufficient. It wouldn't hurt to
consult with a local statistician to discuss the options.

HTH,
Dennis


> Here is my code and the result for each method.
>  I first try nlme
>  library(nlme)
>
>  
> m=lme(enfa_mortality~guild_removal*enfa_removal,random=~1|block,data=com_summer)
>  It gave me the result as following
>  Linear mixed-effects model fit by REML
>  Data: com_summer
>  AIC  BIC   logLik
>  8.552254 14.81939 1.723873
>
> Random effects:
>  Formula: ~1 | block
>(Intercept)  Residual
> StdDev: 9.722548e-07 0.1880945
>
> Fixed effects: enfa_mortality ~ guild_removal * enfa_removal
>   Value Std.Error DF   t-value p-value
> (Intercept) 0.450 0.0841184 17  5.349603  0.0001
> guild_removal  -0.100 0.1189614 17 -0.840609  0.4122
> enfa_removal   -0.368 0.1189614 17 -3.093441  0.0066
> guild_removal:enfa_removal  0.197 0.1573711 17  1.251818  0.2276
>  Correlation:
>  (Intr) gld_rm enf_rm
> guild_removal  -0.707
> enfa_removal   -0.707  0.500
> guild_removal:enfa_removal  0.535 -0.756 -0.756
>
> Standardized Within-Group Residuals:
>  Min Q1Med Q3Max
> -1.7650706 -0.7017751  0.1594943  0.7974717  1.9139320
>
> Number of Observations: 25
> Number of Groups: 5
>
>
>  I then try lme4, it give similar result, but won't tell me the p value.
> library(lme4)
> m<-lmer(enfa_mortality ~ guild_removal*enfa_removal +(1|block),
> data=com_summer)
> here is the result
>  Linear mixed model fit by REML
> Formula: enfa_mortality ~ guild_removal * enfa_removal + (1 | block)
>  Data: com_summer
>  AIC   BIC logLik deviance REMLdev
>  8.552 15.87  1.724   -16.95  -3.448
> Random effects:
>  Groups   NameVariance Std.Dev.
>  block(Intercept) 0.00 0.0
>  Residual 0.035380 0.18809
> Number of obs: 25, groups: block, 5
>
> Fixed effects:
>  Estimate Std. Error t value
> (Intercept) 0.450000.08412   5.350
> guild_removal  -0.10.11896  -0.841
> enfa_removal   -0.368000.11896  -3.093
> guild_removal:enfa_removal  0.197000.15737   1.252
>
> Correlation of Fixed Effects:
>   (Intr) gld_rm enf_rm
> guild_remvl -0.707
> enfa_removl -0.707  0.500
> gld_rmvl:n_  0.535 -0.756 -0.756
>
>
> I really appreciate any suggestion!
> Thank you!
> --
> Chi Yuan
> Graduate Student
> Department of Eco

Re: [R] Determining a basal correct count

2010-11-01 Thread David Herzberg
Phil, when I run:

apply(x,1,function(x)if(!any(x==1)) 0 else 
rle(x[which(x==1)[1]:length(x)])$lengths[1])

on my data set it returns:

ERROR: length(x)])$lengths[1]

Any thoughts?

-Original Message-
From: Phil Spector [mailto:spec...@stat.berkeley.edu] 
Sent: Thursday, October 28, 2010 4:59 PM
To: David Herzberg
Cc: r-help@r-project.org
Subject: Re: [R] Determining a basal correct count

David -
I think changing

apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1])

to

apply(x,1,function(x)if(!any(x==1)) 0 else 
rle(x[which(x==1)[1]:length(x)])$lengths[1])

solves the problem.
 - Phil


On Thu, 28 Oct 2010, David Herzberg wrote:

> Thank you Phil - I'll give this a try. I do have some empty rows, so 
> I'll have to deal with that eventually.
> 
> Dave
> 
> Sent via DROID X
> 
> 
> -Original message-
>   From: Phil Spector 
>   To: David Herzberg 
>   Cc: "r-help@r-project.org" 
>   Sent: Thu, Oct 28, 2010 23:39:34 GMT+00:00
>   Subject: Re: [R] Determining a basal correct count
> 
> David -
>     I *think*
> 
>    apply(x,1,function(x)rle(x[which(x==1)[1]:length(x)])$lengths[1])
> 
> gives you what you want, but without a reproducible example it's hard 
> to say.  It will fail if there are no 1s in a given row.
> 
>  - Phil Spector
>   Statistical Computing 
> Facility
>   Department of Statistics
>   UC Berkeley
>   spec...@stat.berkeley.edu
> 
> 
> On Thu, 28 Oct 2010, David Herzberg wrote:
> 
> > Here's another interesting problem: if you recall I have a data 
> > frame
> (LCvars1) that consists of about 1500 cases (rows) of data from kids 
> who took a test of listening comprehension. The columns are their 
> scores (1 = correct, 0 = incorrect,  . = missing) on 140 test items. 
> The items are numbered sequentially and are ordered by increasing 
> difficulty as you go from left to right across the columns.
> >
> > I used the following (thanks to Peter Ehlers for this solution):
> >
> > First1ItemNo <- as.vector(
> >  apply(
> >  LCvars1, 1, match, x=1
> >  ))
> >
> > to make R go through the columns from left to right and record into 
> > a
> vector the column number of the first '1' response for each case.
> >
> > Now, for each case (row), I want R to START with the column that
> contains the first '1' response, and continue to the right and count 
> the number of consecutive columns containing '1' responses. At the next '0'
> or '.', I want R to record the count of consecutive '1's, and the skip 
> to the next row and begin the process anew.
> >
> > Thanks in advance for your help,
> >
> > David S. Herzberg, Ph.D.
> > Vice President, Research and Development Western Psychological 
> > Services
> > 12031 Wilshire Blvd.
> > Los Angeles, CA 90025-1251
> > Phone: (310)478-2061 x144
> > FAX: (310)478-7838
> > email: dav...@wpspublish.com
> >
> >
> >
> >    [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
>
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 3:40 PM, Louis Plough  wrote:
> Hi,
> I am simply looking for the function that will allow you to look at the top
> 20 lines of a long dataset?
>
> LP

Try this:

head(iris)
head(iris, 20)
View(iris)


-- 
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] question in using nlme and lme4 for unbalanced data

2010-11-01 Thread Chi Yuan
Hello:
 I need some help about using mixed for model for unbalanced data. I
have an two factorial random block design. It's a ecology
experiment. My two factors are, guild removal and enfa removal. Both
are two levels, 0 (no removal), 1 (removal). I have 5 blocks. But
within each block, it's unbalanced at plot level because I have 5
plots instead of 4 in each block. Within each block, I have 1 plot
with only guild removal, 1 plot with only enfa removal, 1 plot for
control with no removal, 2 plots for both guild and enfa removal. I am
looking at how these treatment affect the enfa mortality rate. I
decide to use mixed model to treat block as random effect. So I try
both nlme and lme4. But I don't know whether they take the unbalanced
data properly. So my question is, does lme in nlme and lmer in lme4
take unbalanced data? How do I know it's analysis in a proper way?
Another question is about p values.
I kind of heard the P value does not matter that much in the mixed
model because it's not calculate properly. Is there any other way I can
 tell whether the treatment has a effect not? I know AIC is for model
comparison,
do I report this in formal publication?

Here is my code and the result for each method.
 I first try nlme
 library(nlme)
 
m=lme(enfa_mortality~guild_removal*enfa_removal,random=~1|block,data=com_summer)
 It gave me the result as following
 Linear mixed-effects model fit by REML
 Data: com_summer
  AIC  BIC   logLik
 8.552254 14.81939 1.723873

Random effects:
 Formula: ~1 | block
(Intercept)  Residual
StdDev: 9.722548e-07 0.1880945

Fixed effects: enfa_mortality ~ guild_removal * enfa_removal
   Value Std.Error DF   t-value p-value
(Intercept) 0.450 0.0841184 17  5.349603  0.0001
guild_removal  -0.100 0.1189614 17 -0.840609  0.4122
enfa_removal   -0.368 0.1189614 17 -3.093441  0.0066
guild_removal:enfa_removal  0.197 0.1573711 17  1.251818  0.2276
 Correlation:
  (Intr) gld_rm enf_rm
guild_removal  -0.707
enfa_removal   -0.707  0.500
guild_removal:enfa_removal  0.535 -0.756 -0.756

Standardized Within-Group Residuals:
  Min Q1Med Q3Max
-1.7650706 -0.7017751  0.1594943  0.7974717  1.9139320

Number of Observations: 25
Number of Groups: 5


 I then try lme4, it give similar result, but won't tell me the p value.
library(lme4)
m<-lmer(enfa_mortality ~ guild_removal*enfa_removal +(1|block), data=com_summer)
here is the result
 Linear mixed model fit by REML
Formula: enfa_mortality ~ guild_removal * enfa_removal + (1 | block)
  Data: com_summer
  AIC   BIC logLik deviance REMLdev
 8.552 15.87  1.724   -16.95  -3.448
Random effects:
 Groups   NameVariance Std.Dev.
 block(Intercept) 0.00 0.0
 Residual 0.035380 0.18809
Number of obs: 25, groups: block, 5

Fixed effects:
  Estimate Std. Error t value
(Intercept) 0.450000.08412   5.350
guild_removal  -0.10.11896  -0.841
enfa_removal   -0.368000.11896  -3.093
guild_removal:enfa_removal  0.197000.15737   1.252

Correlation of Fixed Effects:
   (Intr) gld_rm enf_rm
guild_remvl -0.707
enfa_removl -0.707  0.500
gld_rmvl:n_  0.535 -0.756 -0.756


I really appreciate any suggestion!
Thank you!
-- 
Chi Yuan
Graduate Student
Department of Ecology and Evolutionary Biology
University of Arizona
Room 106 Bioscience West
lab phone: 520-621-1889
Email:cy...@email.arizona.edu
Website: http://www.u.arizona.edu/~cyuan/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] spliting first 10 words in a string

2010-11-01 Thread David Winsemius


On Nov 1, 2010, at 5:52 PM, Phil Spector wrote:


 -
  Does this example do what you want?

mysentences = c('Here is a sentence that has a bunch of words in  
it','Here is another sentence that also has a bunch of words','I  
have yet another sentence and it also has a whole bunch of words')
data.frame(mysentences,do.call(rbind,lapply(strsplit(mysentences,'  
+'),'[',1:10)))
 
mysentences   X1   X2
1 Here is a sentence that has a bunch of words in it  
Here   is
2Here is another sentence that also has a bunch of words  
Here   is
3 I have yet another sentence and it also has a whole bunch of  
wordsI have

  X3   X4   X5   X6  X7X8X9   X10
1   a sentence that  has   a bunchof words
2 another sentence that also has a bunchof
3 yet  another sentence  and  it  also   has a


Matevž;

Be on the alert for what the data.frame function does with character  
vectors. Unless you forbid it from doing so it will convert any  
character vector to a factor. (A major source of confusion for R- 
newbies.) In the above version you could prevent this in Phil's  
solution by:


data.frame(mysentences,do.call(rbind,lapply(strsplit(mysentences,'  
+'),'[',1:10)), stringsAsFactors=FALSE)


Or if cbind were applied to my solution at the end of this email:

cbind(worddf, t(sapply(strsplit(worddf$words, " "), "[", 1:10) ) ,  
stringsAsFactors=FALSE)
> str( cbind(worddf, t(sapply(strsplit(worddf$words, " "), "[",  
1:10) ) , stringsAsFactors=FALSE) )

'data.frame':   3 obs. of  11 variables:
 $ words: chr  "I have a columnn with text that has quite a few words  
in it." "I would like to split these words in separate columns" "but  
just first ten words in the string. Is that possible in R?"

 $ 1: chr  "I" "I" "but"
 $ 2: chr  "have" "would" "just"
 $ 3: chr  "a" "like" "first"
 $ 4: chr  "columnn" "to" "ten"
 $ 5: chr  "with" "split" "words"
 $ 6: chr  "text" "these" "in"
 $ 7: chr  "that" "words" "the"
 $ 8: chr  "has" "in" "string."
 $ 9: chr  "quite" "separate" "Is"
 $ 10   : chr  "a" "columns" "that"

cbind.data.frame is a method that would be invoked for that operation.  
This result has the disadvantage that the column names will need to be  
enclosed in quotes to access them with the "$" function since they  
start with numerals.


(Or you could just deal with the factor type.)

--
David.



- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Mon, 1 Nov 2010, Matevž Pavlič wrote:

...I would like i.e. split this sentence from field Opis in  
data.frame :


Opis : "I have a sentense with ten words", so that it would conver  
to something like this :


Opis : "I have a sentense with then words"; Column1 : "I";  
Column2 : "have"; Column3 : "a"; Column4 : "sentense"; Column5:  
"with"; Column6 :"ten";column7:"words"


or in data.frame something like this (as I understand) :

data.frame':   xx obs. of  12 variables:
$ Opis : factor :"I have a sentense with then words";
$ Column1 : factor  "I";
$ Column2 : factor "have";
$ Column3 : factor "a";
$ Column4 : factor "sentense";
$ Column5: factor "with";
$ Column6 : factor "ten";
$ Column7: factor"words"

Hope that explains it better, I am still having some troubles  
understanding R and all..

m


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
] On Behalf Of Matevž Pavlič

Sent: Monday, November 01, 2010 10:34 PM
To: David Winsemius
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string

Hi,

I am sorry, will try to be more exact from now on...

I have a data.frame  with a field called Opis. IT contains  
sentenses that I would like to split in words or fields in  
data.frame...when I say columns I mean as in Excel table. I would  
like to split "Opis" into ten fields from the first ten words in  
Opis field.

Here is an example of my data.frame.

'data.frame':   22928 obs. of  12 variables:
$ VrtinaID: int  1 1 1 1 2 2 2 2 2 2 ...
$ ZapStev : int  1 2 3 4 1 2 3 4 5 6 ...
$ GlobinaOd   : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
$ GlobinaDo   : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
$ Opis: Factor w/ 12754 levels "","(MIVKA) DROBEN  
MELJAST PESEK, GOST, SIVORJAV",..: 2060 11588 2477 11660 7539 3182  
7884 9123 2500 4756 ...
$ ACklasifikacija : Factor w/ 290 levels "","(CL)","(CL)/(SC)",..:  
154 125 101 101 NA 106 125 80 106 101 ...

$ GeolNastOd  : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
$ GeolNastDo  : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
$ GeolNastOpis: Factor w/ 113 levels "","B. M. 

[R] multicore package: help

2010-11-01 Thread Fahim M
I have matrices as below:

a <- matrix(c(1:10, 11, 12), 3,4)
aa <- data.frame(a)

b <- matrix(c(10:20, 21), 4,3)
bb <- data.frame(b)
...
and many more matrices.

st = list(aa,bb, . )

mclapply(st, FUN, mc.cores=6); #this function apply the function to the
elements of the list 'aa', 'bb'...etc


FUN = function(st)
 {
 Is there a way/function to know the index of st(the list) currently
processed by this function as these matrices  are processed in the order of
availability of processors?
for example, if matrix bb is being processed then the index that I want is
2.
 ...
 ...
 ...

 }

[[alternative HTML version deleted]]

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


Re: [R] spliting first 10 words in a string

2010-11-01 Thread Phil Spector

Matevž -
   Does this example do what you want?


mysentences = c('Here is a sentence that has a bunch of words in it','Here is 
another sentence that also has a bunch of words','I have yet another sentence 
and it also has a whole bunch of words')
data.frame(mysentences,do.call(rbind,lapply(strsplit(mysentences,' 
+'),'[',1:10)))

 mysentences   X1   X2
1 Here is a sentence that has a bunch of words in it Here   is
2Here is another sentence that also has a bunch of words Here   is
3 I have yet another sentence and it also has a whole bunch of wordsI have
   X3   X4   X5   X6  X7X8X9   X10
1   a sentence that  has   a bunchof words
2 another sentence that also has a bunchof
3 yet  another sentence  and  it  also   has a

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Mon, 1 Nov 2010, Matevž Pavlič wrote:


...I would like i.e. split this sentence from field Opis in data.frame :

Opis : "I have a sentense with ten words", so that it would conver to something 
like this :

Opis : "I have a sentense with then words"; Column1 : "I"; Column2 : "have"; Column3 : "a"; Column4 : 
"sentense"; Column5: "with"; Column6 :"ten";column7:"words"

or in data.frame something like this (as I understand) :

data.frame':   xx obs. of  12 variables:
$ Opis : factor :"I have a sentense with then words";
$ Column1 : factor  "I";
$ Column2 : factor "have";
$ Column3 : factor "a";
$ Column4 : factor "sentense";
$ Column5: factor "with";
$ Column6 : factor "ten";
$ Column7: factor"words"

Hope that explains it better, I am still having some troubles understanding R 
and all..
m


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Matevž Pavlič
Sent: Monday, November 01, 2010 10:34 PM
To: David Winsemius
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string

Hi,

I am sorry, will try to be more exact from now on...

I have a data.frame  with a field called Opis. IT contains sentenses that I would like to 
split in words or fields in data.frame...when I say columns I mean as in Excel table. I 
would like to split "Opis" into ten fields from the first ten words in Opis 
field.
Here is an example of my data.frame.

'data.frame':   22928 obs. of  12 variables:
$ VrtinaID: int  1 1 1 1 2 2 2 2 2 2 ...
$ ZapStev : int  1 2 3 4 1 2 3 4 5 6 ...
$ GlobinaOd   : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
$ GlobinaDo   : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
$ Opis: Factor w/ 12754 levels "","(MIVKA) DROBEN MELJAST PESEK, GOST, 
SIVORJAV",..: 2060 11588 2477 11660 7539 3182 7884 9123 2500 4756 ...
$ ACklasifikacija : Factor w/ 290 levels "","(CL)","(CL)/(SC)",..: 154 125 101 
101 NA 106 125 80 106 101 ...
$ GeolNastOd  : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
$ GeolNastDo  : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
$ GeolNastOpis: Factor w/ 113 levels "","B. M. S.",..: 56 53 53 53 56 53 53 
53 53 53 ...
$ NacinVrtanjaOd  : num  0e+00 1e+09 1e+09 1e+09 0e+00 ...
$ NacinVrtanjaDo  : num  1.1e+01 1.0e+09 1.0e+09 1.0e+09 1.0e+01 ...
$ NacinVrtanjaOpis: Factor w/ 43 levels "","H. N.","IZKOP",..: 26 1 1 1 26 1 1 
1 1 1 ...

Hope that explains better...
Thank you, m

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Monday, November 01, 2010 10:13 PM
To: Matevž Pavlič
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string


On Nov 1, 2010, at 4:39 PM, Matevž Pavlič wrote:


Hi all,



I have a columnn with text that has quite a few words in it. I would
like to split these words in separate columns, but just first ten
words in the string. Is that possible in R?




Not sure what a column means to you. It's not a precisely defined R
type or class. (And you are requested to offered a concrete example
rather than making us guess.)

>words <-"I have a columnn with text that has quite a few words in
it. I would like to split these words in separate columns, but just
first ten words in the string. Is that possible in R?"

> strsplit(words, " ")[[1]][1:10]
 [1] "I"   "have""a"   "columnn" "with""text"
"that""has" "quite"   "a"


Or if in a dataframe:

> words <-c("I have a columnn with text that has quite a few words in
it.",   "I would like to split these words in separate columns", "but
just first ten words in the string. Is that possible in R?")
> worddf <- data.frame(words=words)

> t(sapply(strsplit(worddf$words, " "), "[", 1:10) )
 [,1]  [,2][,3][,4]  [,5][,6][,7][,
8] 

Re: [R] spliting first 10 words in a string

2010-11-01 Thread Matevž Pavlič
...I would like i.e. split this sentence from field Opis in data.frame :

Opis : "I have a sentense with ten words", so that it would conver to something 
like this :

Opis : "I have a sentense with then words"; Column1 : "I"; Column2 : "have"; 
Column3 : "a"; Column4 : "sentense"; Column5: "with"; Column6 
:"ten";column7:"words" 

or in data.frame something like this (as I understand) :

data.frame':   xx obs. of  12 variables:
$ Opis : factor :"I have a sentense with then words"; 
$ Column1 : factor  "I"; 
$ Column2 : factor "have"; 
$ Column3 : factor "a";
$ Column4 : factor "sentense"; 
$ Column5: factor "with";
$ Column6 : factor "ten";
$ Column7: factor"words" 

Hope that explains it better, I am still having some troubles understanding R 
and all..
m


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Matevž Pavlič
Sent: Monday, November 01, 2010 10:34 PM
To: David Winsemius
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string

Hi, 

I am sorry, will try to be more exact from now on...

I have a data.frame  with a field called Opis. IT contains sentenses that I 
would like to split in words or fields in data.frame...when I say columns I 
mean as in Excel table. I would like to split "Opis" into ten fields from the 
first ten words in Opis field.
Here is an example of my data.frame. 

'data.frame':   22928 obs. of  12 variables:
 $ VrtinaID: int  1 1 1 1 2 2 2 2 2 2 ...
 $ ZapStev : int  1 2 3 4 1 2 3 4 5 6 ...
 $ GlobinaOd   : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
 $ GlobinaDo   : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
 $ Opis: Factor w/ 12754 levels "","(MIVKA) DROBEN MELJAST PESEK, 
GOST, SIVORJAV",..: 2060 11588 2477 11660 7539 3182 7884 9123 2500 4756 ...
 $ ACklasifikacija : Factor w/ 290 levels "","(CL)","(CL)/(SC)",..: 154 125 101 
101 NA 106 125 80 106 101 ...
 $ GeolNastOd  : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
 $ GeolNastDo  : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
 $ GeolNastOpis: Factor w/ 113 levels "","B. M. S.",..: 56 53 53 53 56 53 
53 53 53 53 ...
 $ NacinVrtanjaOd  : num  0e+00 1e+09 1e+09 1e+09 0e+00 ...
 $ NacinVrtanjaDo  : num  1.1e+01 1.0e+09 1.0e+09 1.0e+09 1.0e+01 ...
 $ NacinVrtanjaOpis: Factor w/ 43 levels "","H. N.","IZKOP",..: 26 1 1 1 26 1 1 
1 1 1 ...

Hope that explains better...
Thank you, m

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Monday, November 01, 2010 10:13 PM
To: Matevž Pavlič
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string


On Nov 1, 2010, at 4:39 PM, Matevž Pavlič wrote:

> Hi all,
>
>
>
> I have a columnn with text that has quite a few words in it. I would 
> like to split these words in separate columns, but just first ten 
> words in the string. Is that possible in R?
>
>

Not sure what a column means to you. It's not a precisely defined R  
type or class. (And you are requested to offered a concrete example  
rather than making us guess.)

 >words <-"I have a columnn with text that has quite a few words in  
it. I would like to split these words in separate columns, but just  
first ten words in the string. Is that possible in R?"

 > strsplit(words, " ")[[1]][1:10]
  [1] "I"   "have""a"   "columnn" "with""text" 
"that""has" "quite"   "a"


Or if in a dataframe:

 > words <-c("I have a columnn with text that has quite a few words in  
it.",   "I would like to split these words in separate columns", "but  
just first ten words in the string. Is that possible in R?")
 > worddf <- data.frame(words=words)

 > t(sapply(strsplit(worddf$words, " "), "[", 1:10) )
  [,1]  [,2][,3][,4]  [,5][,6][,7][, 
8]  [,9]   [,10]
[1,] "I"   "have"  "a" "columnn" "with"  "text"  "that"  "has"  
"quite""a"
[2,] "I"   "would" "like"  "to"  "split" "these" "words" "in"   
"separate" "columns"
[3,] "but" "just"  "first" "ten" "words" "in""the"   "string."  
"Is"   "that"


-- 
David Winsemius, MD
West Hartford, CT

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


Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Felipe Carrillo
is this what you want?

head(yourdataset,20)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA



- Original Message 
> From: Louis Plough 
> To: r-help@r-project.org
> Sent: Mon, November 1, 2010 12:40:19 PM
> Subject: [R] how to view the top 20 lines in a long dataset
> 
> Hi,
> I am simply looking for the function that will allow you to look at the top
> 20 lines of a long dataset?
> 
> LP
> 
> 
> On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough  wrote:
> 
> > Hi,
> > I am trying to generate all possible permutations (choose 2) of a vector,
> > b, for example--using 'combn' the combinations in only one direction are
> > generated...
> >
> > > b<-c(.1,.2,.3)
> > > combn(b,2)
> >      [,1] [,2] [,3]
> > [1,]  0.1  0.1  0.2
> > [2,]  0.2  0.3  0.3
> >
> >                        [1,] 0.1  0.2  0.3  0.2  0.3  0.3        These
> > should also be there.
> >                        [2,] 0.1  0.2  0.3  0.1  0.1  0.2
> >
> > Is there another R function that can do this??
> >
> > Thanks,
> > Louis
> >
> 
>     [[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] spliting first 10 words in a string

2010-11-01 Thread Matevž Pavlič
Hi, 

I am sorry, will try to be more exact from now on...

I have a data.frame  with a field called Opis. IT contains sentenses that I 
would like to split in words or fields in data.frame...when I say columns I 
mean as in Excel table. I would like to split "Opis" into ten fields from the 
first ten words in Opis field.
Here is an example of my data.frame. 

'data.frame':   22928 obs. of  12 variables:
 $ VrtinaID: int  1 1 1 1 2 2 2 2 2 2 ...
 $ ZapStev : int  1 2 3 4 1 2 3 4 5 6 ...
 $ GlobinaOd   : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
 $ GlobinaDo   : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
 $ Opis: Factor w/ 12754 levels "","(MIVKA) DROBEN MELJAST PESEK, 
GOST, SIVORJAV",..: 2060 11588 2477 11660 7539 3182 7884 9123 2500 4756 ...
 $ ACklasifikacija : Factor w/ 290 levels "","(CL)","(CL)/(SC)",..: 154 125 101 
101 NA 106 125 80 106 101 ...
 $ GeolNastOd  : num  0 0.8 9.2 10.1 0 0.9 2.6 4.9 6.8 7.3 ...
 $ GeolNastDo  : num  0.8 9.2 10.1 11 0.9 2.6 4.9 6.8 7.3 8.2 ...
 $ GeolNastOpis: Factor w/ 113 levels "","B. M. S.",..: 56 53 53 53 56 53 
53 53 53 53 ...
 $ NacinVrtanjaOd  : num  0e+00 1e+09 1e+09 1e+09 0e+00 ...
 $ NacinVrtanjaDo  : num  1.1e+01 1.0e+09 1.0e+09 1.0e+09 1.0e+01 ...
 $ NacinVrtanjaOpis: Factor w/ 43 levels "","H. N.","IZKOP",..: 26 1 1 1 26 1 1 
1 1 1 ...

Hope that explains better...
Thank you, m

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Monday, November 01, 2010 10:13 PM
To: Matevž Pavlič
Cc: r-help@r-project.org
Subject: Re: [R] spliting first 10 words in a string


On Nov 1, 2010, at 4:39 PM, Matevž Pavlič wrote:

> Hi all,
>
>
>
> I have a columnn with text that has quite a few words in it. I would 
> like to split these words in separate columns, but just first ten 
> words in the string. Is that possible in R?
>
>

Not sure what a column means to you. It's not a precisely defined R  
type or class. (And you are requested to offered a concrete example  
rather than making us guess.)

 >words <-"I have a columnn with text that has quite a few words in  
it. I would like to split these words in separate columns, but just  
first ten words in the string. Is that possible in R?"

 > strsplit(words, " ")[[1]][1:10]
  [1] "I"   "have""a"   "columnn" "with""text" 
"that""has" "quite"   "a"


Or if in a dataframe:

 > words <-c("I have a columnn with text that has quite a few words in  
it.",   "I would like to split these words in separate columns", "but  
just first ten words in the string. Is that possible in R?")
 > worddf <- data.frame(words=words)

 > t(sapply(strsplit(worddf$words, " "), "[", 1:10) )
  [,1]  [,2][,3][,4]  [,5][,6][,7][, 
8]  [,9]   [,10]
[1,] "I"   "have"  "a" "columnn" "with"  "text"  "that"  "has"  
"quite""a"
[2,] "I"   "would" "like"  "to"  "split" "these" "words" "in"   
"separate" "columns"
[3,] "but" "just"  "first" "ten" "words" "in""the"   "string."  
"Is"   "that"


-- 
David Winsemius, MD
West Hartford, CT

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


[R] Error message in fit.mult.impute (Hmisc package)

2010-11-01 Thread Kim Fernandes
Hello,

I would like to use the aregImpute and fit.mult.impute to impute missing
values for my dataset and then conduct logistic regression analyses on the
data, taking into account that we imputed values.  I have no problems
imputing the values using aregImpute, but I am getting an error at the
fit.mult.impute stage.

Here is some sample code (I actually have more observations and variables to
impute, but the error can be duplicated using the code below).

#
library(Hmisc)
library(Design)
ds <- structure(list(use_statins1 = c(1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L,
1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, NA, 1L, 0L, 0L, 0L,
0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L,
1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, NA, 1L, 0L, 0L, 0L, 1L, 0L, 1L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L), use_nsaids =
structure(c(2L,
2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, NA, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L,
2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L,
2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L,
2L, 2L, 2L), .Label = c("No", "Yes"), class = "factor")), .Names =
c("use_statins1",
"use_nsaids"), row.names = c(NA, 100L), class = "data.frame")

> gm <- aregImpute(formula = ~ use_statins1 + use_nsaids,data=ds,n.impute=5)
Iteration 8
> fmi=fit.mult.impute(use_statins1~ use_nsaids, fitter=lrm, xtrans = gm,
data = ds)
Error in if (object$family$family %in% c("poisson", "binomial")) 1 else if
(df.r >  :
  argument is of length zero
#

It is this error in the last line that I am not sure why I am getting.  Any
help would be greatly appreciated.

Thanks,

Kim

[[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] foreloop? aggregating time series data into groups

2010-11-01 Thread jim holtman
you can use na.locf in the zoo package:

> require(zoo)
> x<-c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
> # replace zeros with NA
> x[x == 0] <- NA
> x
 [1] NA  2 NA  1 NA NA NA NA  1 NA  1 NA NA NA  2  1 NA NA NA  2 NA NA NA  1
> na.locf(x, fromLast = TRUE)
 [1] 2 2 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 2 2 2 1 1 1 1
>


On Mon, Nov 1, 2010 at 3:34 PM, blurg  wrote:
>
> I have a data set similar to the set below where 1 and 2 indicate test
> results and 0 indicates time points in between where there are no test
> results.  I would like to allocate the time points leading up to a test
> result with the value of the test result.
>
> What I have:     What I want:
> 1                     1
> 0                     1
> 0                     1
> 0                     1
> 1                     1
> 0                     2
> 0                     2
> 2                     2
> 0                     1
> 0                     1
> 1                     1
> 0                     2
> 2                     2
>
> I have attempted methods creating a data.frame of the the breaks/changes in
> of values to from 0 to 1 or to 2.
> x<-c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
> x1 <- which(diff(x) == 1)
> x2 <- which(diff(x) == 2)
>
> What ever the solution, I can't be entered by hand due to the size of the
> dataset (>10 million and change). Any ideas?  This is my first time posting
> to this forum and I am relatively new to R, so please don't flame me to
> hard.  Desperate times call for desperate measures.  Thanks.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/foreloop-aggregating-time-series-data-into-groups-tp3022667p3022667.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] spliting first 10 words in a string

2010-11-01 Thread David Winsemius


On Nov 1, 2010, at 4:39 PM, Matevž Pavlič wrote:


Hi all,



I have a columnn with text that has quite a few words in it. I would  
like to split these words in separate columns, but just first ten  
words in the string. Is that possible in R?





Not sure what a column means to you. It's not a precisely defined R  
type or class. (And you are requested to offered a concrete example  
rather than making us guess.)


>words <-"I have a columnn with text that has quite a few words in  
it. I would like to split these words in separate columns, but just  
first ten words in the string. Is that possible in R?"


> strsplit(words, " ")[[1]][1:10]
 [1] "I"   "have""a"   "columnn" "with""text" 
"that""has" "quite"   "a"



Or if in a dataframe:

> words <-c("I have a columnn with text that has quite a few words in  
it.",   "I would like to split these words in separate columns", "but  
just first ten words in the string. Is that possible in R?")

> worddf <- data.frame(words=words)

> t(sapply(strsplit(worddf$words, " "), "[", 1:10) )
 [,1]  [,2][,3][,4]  [,5][,6][,7][, 
8]  [,9]   [,10]
[1,] "I"   "have"  "a" "columnn" "with"  "text"  "that"  "has"  
"quite""a"
[2,] "I"   "would" "like"  "to"  "split" "these" "words" "in"   
"separate" "columns"
[3,] "but" "just"  "first" "ten" "words" "in""the"   "string."  
"Is"   "that"



--
David Winsemius, MD
West Hartford, CT

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


[R] RODBC - odbcConnectExcel2007 headers issue

2010-11-01 Thread Thomas Parr
Apologies if this is already answered elsewhere, but I could not find the
answer searching the archives.

I am trying to bring my data in from an .xlsx file.  The data of interest is
an n x m array, but it is preceded with ~2 columns and 30 rows of
instrumental "information." An abbreviated example (cols denoted with  ","
for this example:
Subject , 01
wavelength, 400
(30 more rows of similar metadata data)
10, 11   ,23 ,34,54  (60 more columns of similar data)
1  , 65   ,61 ,43,21
12 ,14   ,78 ,23,23
(90 rows of similar data

I have put together a script that can read the data in with the "xlsx"
package, but this package runs a little slow compared to RODBC.  Since I
will be processing hundreds to thousands of files, I would like a faster
option.  RODBC seems to be it, but I am having trouble telling it not to
take the first row of "data" as a header/column name.

Here is my present command
rawspectrum <- odbcConnectExcel2007("directory path/filename.xlsx", readOnly
= TRUE)
editspectrum <- sqlFetch(rawspectrum,"Sheet1", as.is=TRUE, colnames = FALSE,
rownames = FALSE, nullstring="")
odbcClose(rawspectrum)

If I ran this on the above fake data I would get something like:
 Subject , 01   ,F1,F2   ,F3
1   wavelength, 400
2   10, 11   ,23 ,34,54
3   1  , 65   ,61 ,43,21
4   12 ,14   ,78 ,23,23

When I want to see
1 Subject , 01
2   wavelength, 400
3   10, 11   ,23 ,34,54
4   1  , 65   ,61 ,43,21
5   12 ,14   ,78 ,23,23

For the moment, yes the files have to be in xlsx (unfortunately) and yes
they need to (and will always) have the "metadata" (again unfortunately).
 If the xlsx package is the only option given the awkward data format just
let me know.

[[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] foreloop? aggregating time series data into groups

2010-11-01 Thread Joshua Wiley
Hi,

Welcome to R and the help list!

On Mon, Nov 1, 2010 at 12:34 PM, blurg  wrote:
>
> I have a data set similar to the set below where 1 and 2 indicate test
> results and 0 indicates time points in between where there are no test
> results.  I would like to allocate the time points leading up to a test
> result with the value of the test result.
>
> What I have:     What I want:
> 1                     1
> 0                     1
> 0                     1
> 0                     1
> 1                     1
> 0                     2
> 0                     2
> 2                     2
> 0                     1
> 0                     1
> 1                     1
> 0                     2
> 2                     2
>
> I have attempted methods creating a data.frame of the the breaks/changes in
> of values to from 0 to 1 or to 2.
> x<-c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
> x1 <- which(diff(x) == 1)
> x2 <- which(diff(x) == 2)

## Functions that *I think* does what you want
myfun <- function(x) {
  dat <- rle(x)
  i <- which(dat$values == 0)
  dat$lengths[i + 1] <- with(dat, lengths[i + 1] + lengths[i])
  return(with(dat, rep(values[-i], lengths[-i])))
}

## Three test pieces of data
x <- c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
y <- c(1,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
z <- c(1,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,0)

## your example, works
myfun(x)
## test case 2 (begins with a number), works
myfun(y)
## test case 3 (ends with 0), fails
myfun(z)

So, if things work how I think they do, that function should do what
you need as long as the last value is not 0, which kind of makes sense
because what value would be assigned anyways?

Side note, I created a sample vector with 10 million elements, and it
took about 9 seconds to run it through my function.

@list members, I welcome someone checking my work, I'm uneasy about a
couple aspects generalizing properly.

>
> What ever the solution, I can't be entered by hand due to the size of the
> dataset (>10 million and change). Any ideas?  This is my first time posting
> to this forum and I am relatively new to R, so please don't flame me to
> hard.

Although this list can certainly be tough at times, for your peace of
mind you pretty much did everything right as far as I am concerned.
You described your problem, included a small set of sample data that
was easily read into R (for future reference say you have a more
complex object that is not as easy to create, dput() will save you and
us trouble), and even showed what you tried to do.

Finally, in your explanation you gave both sample data AND desired
outcome.  This gives us a "gold standard" to test our code against,
rather than hoping our results match what your described you want.  I
am always thrilled when I'm not left re-reading a paragraph long,
English explanation that can be shown nicely with a few numbers.

> Desperate times call for desperate measures.

and assuming you have put forth some effort trying to solve it
yourself and took the time to help us answer your question (as you
clearly did here), the help list should not be a desperate measure :)

Cheers,

Josh

  Thanks.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/foreloop-aggregating-time-series-data-into-groups-tp3022667p3022667.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] Please help me about Monte Carlo Permutation

2010-11-01 Thread Łukasz Ręcławowicz
2010/10/29 Chitra 

>
>  I am sorry I got lost here.


Me too. So you want to do a MC test for Pearson's product-moment
correlation, right...?


-- 
Mi³ego dnia

[[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] spliting first 10 words in a string

2010-11-01 Thread Matevž Pavlič
Hi all, 

 

I have a columnn with text that has quite a few words in it. I would like to 
split these words in separate columns, but just first ten words in the string. 
Is that possible in R?

 

Thank you, m

 


[[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] 32-bit packages on 64-bit Windows

2010-11-01 Thread Lee Hachadoorian
Thanks very much for the information. I also see that
http://cran.r-project.org/bin/windows/contrib/2.12/ReadMe has
information on some of the packages I'm interested in.

Thanks for the help,
--Lee

On Mon, Nov 1, 2010 at 1:48 PM, Duncan Murdoch  wrote:
> On 01/11/2010 1:40 PM, Lee Hachadoorian wrote:
>>
>> Are 32-bit precompiled packages supposed to work on 32-bit R installed
>> on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run
>> 32-bit or 64-bit R?) implies that they will work, but I am having
>> trouble getting certain packages to work. Before I spend more time on
>> it or start asking questions about specific packages, I would like to
>> know I'm not trying to do something impossible.
>
>
> Yes, but be sure they were compiled for R 2.12.0.  The location of DLLs has
> changed, as well as the other usual minor internal changes that come with a
> new version.
>
> Duncan Murdoch
>



-- 
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] foreloop? aggregating time series data into groups

2010-11-01 Thread David Winsemius


On Nov 1, 2010, at 3:34 PM, blurg wrote:



I have a data set similar to the set below where 1 and 2 indicate test
results and 0 indicates time points in between where there are no test
results.  I would like to allocate the time points leading up to a  
test

result with the value of the test result.

What I have: What I want:
1 1
0 1
0 1
0 1
1 1
0 2
0 2
2 2
0 1
0 1
1 1
0 2
2 2

I have attempted methods creating a data.frame of the the breaks/ 
changes in

of values to from 0 to 1 or to 2.
x<-c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
x1 <- which(diff(x) == 1)
x2 <- which(diff(x) == 2)


Not sure how long you longest run of zeros is but repeate applications  
of htis method n-such times will fill in in the backward direction:


> xna <- x
> xna[xna==0] <- NA
> xna[which(is.na(xna))] <- xna[which(is.na(xna))+1]
> xna
 [1]  2  2  1  1 NA NA NA  1  1  1  1 NA NA  2  2  1 NA NA  2  2 NA  
NA  1  1

> xna[which(is.na(xna))] <- xna[which(is.na(xna))+1]
> xna
 [1]  2  2  1  1 NA NA  1  1  1  1  1 NA  2  2  2  1 NA  2  2  2 NA   
1  1  1

> xna[which(is.na(xna))] <- xna[which(is.na(xna))+1]
> xna[which(is.na(xna))] <- xna[which(is.na(xna))+1]
> xna[which(is.na(xna))] <- xna[which(is.na(xna))+1]
> xna
 [1] 2 2 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 2 2 2 1 1 1 1

I'm not sure that conversion to NA is needed. The indexing with  
which(x==0) and which(x==0+1 might work as well. Yep... that work's too:


> x
 [1] 0 2 0 1 0 0 0 0 1 0 1 0 0 0 2 1 0 0 0 2 0 0 0 1
> x[which(x==0)] <- x[which(x==0)+1]
> x
 [1] 2 2 1 1 0 0 0 1 1 1 1 0 0 2 2 1 0 0 2 2 0 0 1 1
> x[which(x==0)] <- x[which(x==0)+1]
> x[which(x==0)] <- x[which(x==0)+1]
> x[which(x==0)] <- x[which(x==0)+1]
> x
 [1] 2 2 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 2 2 2 1 1 1 1


--
David




What ever the solution, I can't be entered by hand due to the size  
of the
dataset (>10 million and change). Any ideas?  This is my first time  
posting
to this forum and I am relatively new to R, so please don't flame me  
to

hard.  Desperate times call for desperate measures.  Thanks.
--



David Winsemius, MD
West Hartford, CT

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


[R] Extract node names from BinaryTree in package party

2010-11-01 Thread Sven Garbade
Hi there,

I need to extract the variable names from all nodes (except the
terminal nodes) from a ctree object, e.g.

library(party)
mammoct <- ctree(ME ~ ., data = mammoexp)
plot(mammoct)

how can I extract the varnames from node   1 (SYMPT) and node 3 (PB)
from the fitted object "mammoct"?

Many Thanks, Sven

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] foreloop? aggregating time series data into groups

2010-11-01 Thread blurg

I have a data set similar to the set below where 1 and 2 indicate test
results and 0 indicates time points in between where there are no test
results.  I would like to allocate the time points leading up to a test
result with the value of the test result. 

What I have: What I want:
1 1
0 1
0 1
0 1
1 1
0 2
0 2
2 2
0 1
0 1
1 1
0 2
2 2

I have attempted methods creating a data.frame of the the breaks/changes in
of values to from 0 to 1 or to 2.
x<-c(0,2,0,1,0,0,0,0,1,0,1,0,0,0,2,1,0,0,0,2,0,0,0,1)
x1 <- which(diff(x) == 1) 
x2 <- which(diff(x) == 2)

What ever the solution, I can't be entered by hand due to the size of the
dataset (>10 million and change). Any ideas?  This is my first time posting
to this forum and I am relatively new to R, so please don't flame me to
hard.  Desperate times call for desperate measures.  Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/foreloop-aggregating-time-series-data-into-groups-tp3022667p3022667.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Søren Højsgaard
See ?head
Regards
Søren


Fra: r-help-boun...@r-project.org [r-help-boun...@r-project.org] På vegne 
af Louis Plough [lplo...@usc.edu]
Sendt: 1. november 2010 20:40
Til: r-help@r-project.org
Emne: [R]  how to view the top 20 lines in a long dataset

Hi,
I am simply looking for the function that will allow you to look at the top
20 lines of a long dataset?

LP


On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough  wrote:

> Hi,
> I am trying to generate all possible permutations (choose 2) of a vector,
> b, for example--using 'combn' the combinations in only one direction are
> generated...
>
> > b<-c(.1,.2,.3)
> > combn(b,2)
>  [,1] [,2] [,3]
> [1,]  0.1  0.1  0.2
> [2,]  0.2  0.3  0.3
>
> [1,] 0.1  0.2  0.3  0.2  0.3  0.3These
> should also be there.
> [2,] 0.1  0.2  0.3  0.1  0.1  0.2
>
> Is there another R function that can do this??
>
> Thanks,
> Louis
>

[[alternative HTML version deleted]]

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


Re: [R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Erik Iverson

?head or just

df[1:20, ]

Louis Plough wrote:

Hi,
I am simply looking for the function that will allow you to look at the top
20 lines of a long dataset?

LP


On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough  wrote:


Hi,
I am trying to generate all possible permutations (choose 2) of a vector,
b, for example--using 'combn' the combinations in only one direction are
generated...


b<-c(.1,.2,.3)
combn(b,2)

 [,1] [,2] [,3]
[1,]  0.1  0.1  0.2
[2,]  0.2  0.3  0.3

[1,] 0.1  0.2  0.3  0.2  0.3  0.3These
should also be there.
[2,] 0.1  0.2  0.3  0.1  0.1  0.2

Is there another R function that can do this??

Thanks,
Louis



[[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] Plots inside a Plot

2010-11-01 Thread D Kelly O'Day

here's a second example using basic R graphics. I update this chart daily.

http://processtrends.com/images/RClimate_UAH_Ch5_latest.png link 

http://r.789695.n4.nabble.com/file/n3022678/RClimate_UAH_Ch5_latest.png 

Here's what ?par says about par(fig)

fig
A numerical vector of the form c(x1, x2, y1, y2) which gives the (NDC)
coordinates of the figure region in the display region of the device. If you
set this, unlike S, you start a new plot, so to add to an existing plot use
new=TRUE as well.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plots-inside-a-Plot-tp3021988p3022678.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to view the top 20 lines in a long dataset

2010-11-01 Thread Louis Plough
Hi,
I am simply looking for the function that will allow you to look at the top
20 lines of a long dataset?

LP


On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough  wrote:

> Hi,
> I am trying to generate all possible permutations (choose 2) of a vector,
> b, for example--using 'combn' the combinations in only one direction are
> generated...
>
> > b<-c(.1,.2,.3)
> > combn(b,2)
>  [,1] [,2] [,3]
> [1,]  0.1  0.1  0.2
> [2,]  0.2  0.3  0.3
>
> [1,] 0.1  0.2  0.3  0.2  0.3  0.3These
> should also be there.
> [2,] 0.1  0.2  0.3  0.1  0.1  0.2
>
> Is there another R function that can do this??
>
> Thanks,
> Louis
>

[[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] Mean and individual growth curve trajectories

2010-11-01 Thread Dennis Murphy
Hi:

Here's another version of the plot using ggplot2:

g <- ggplot(sleepstudy, aes(x = Days, y = Reaction, group = Subject, colour
= Subject))
g + geom_line(size = 1) + geom_smooth(aes(group = 1), size = 2) + theme_bw()

To get rid of the legend, if you so desire, use
g + geom_line(size = 1) +
 geom_smooth(aes(group = 1), size = 2) + theme_bw() +
 opts(legend.position = 'none')

By default, geom_smooth() uses a loess curve for smoothing; use method =
'lm' outside the aes() call to get a least squares line instead. If you
don't want the useful confidence limits on the smooth :), add se = FALSE to
the geom_smooth() argument list.

I tend to like size = 1 for lines, but the default size produces thinner
lines, if that's what you prefer.

HTH,
Dennis

On Sun, Oct 31, 2010 at 7:01 PM, jlwoodard  wrote:

>
> I'm trying to understand how to plot individual growth curve trajectories,
> with the overall mean trajectory superimposed (preferably in a slightly
> thicker line, maybe in black) over the individual trajectories.  Using the
> sleepstudy data in lme4, here is the code I have so far:
>
> library(lme4)
> library(lattice)
> xyplot(Reaction ~ Days, data = sleepstudy, group = Subject, type = 'l')
>
> This plot produces the individual growth curves nicely, but I'd like to be
> able to plot the mean for each day (averaged over subjects) on top of this
> graph.
>
> Many thanks in advance for any help/suggestions.
>
> John
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Mean-and-individual-growth-curve-trajectories-tp3021672p3021672.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.
>

[[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] transforming a dataset for association analysis RESHAPE2

2010-11-01 Thread Dennis Murphy
Hi:

xtabs() also works in this case:

> dat <- read.table(textConnection('Subject   Item Score
+ "Subject 1" "Item 1" 1
+ "Subject 1" "Item 2" 0
+ "Subject 1" "Item 3" 1
+ "Subject 2" "Item 1" 1
+ "Subject 2" "Item 2" 1
+ "Subject 2" "Item 3" 0'), header=TRUE)
> closeAllConnections()
>
> acast(dat, Subject~Item)
Using Score as value column: use value_var to override.
  Item 1 Item 2 Item 3
Subject 1  1  0  1
Subject 2  1  1  0
> xtabs(Score ~ Subject + Item, data = dat)
   Item
Subject Item 1 Item 2 Item 3
  Subject 1  1  0  1
  Subject 2  1  1  0
> df <- data.frame(Subject=
+   c("Subject 1","Subject 1","Subject 1","Subject 1",
+ "Subject 2","Subject 2","Subject 2","Subject 2"),
+ Item   =
+   c("Item 1","Item 2","Item 3","Item 4",
+ "Item 1","Item 2","Item 3","Item 4"),
+ Score  = c(1,0,1,1,1,1,0,0))
> xtabs(Score ~ Subject + Item, data = df)
   Item
Subject Item 1 Item 2 Item 3 Item 4
  Subject 1  1  0  1  1
  Subject 2  1  1  0  0

HTH,
Dennis

On Mon, Nov 1, 2010 at 7:39 AM, Ajay Ohri  wrote:

> I get the following message when using the reshape2 package line
>
> > tDat.m<- melt(Dataset)
> Using Item, Subject as id variables
> > tDatCast<- acast(tDat.m,Subject~Item)
> Aggregation function missing: defaulting to length
>
>
> Note Problem Statement-
>
> convert dataframe
>
>
> Subject   Item Score
> 1 Subject 1 Item 1 1
> 2 Subject 1 Item 2 0
> 3 Subject 1 Item 3 1
> 4 Subject 2 Item 1 1
> 5 Subject 2 Item 2 1
> 6 Subject 2 Item 3 0
>
> to
>
>
>  Subject Item 1 Item 2 Item 3 Item 4
> 1 Subject 1  1  0  1  1
> 5 Subject 2  1  1  0  0
>
> Note- when I tried using the "wide" method the resultant vector went out of
> memory- its a dataset appox 100,000 lines
>
>
>
> Websites-
> http://decisionstats.com
> http://dudeofdata.com
>
>
> Linkedin- www.linkedin.com/in/ajayohri
>
>
>
>
> On Sat, Oct 30, 2010 at 5:41 PM, Rainer Hurling  wrote:
>
> > On 30.10.2010 13:50 (UTC+1), Santosh Srinivas wrote:
> >
> >> A more usable problem input would definitely help ... use dput to send a
> >> reproducible sample to the group
> >>
> >> Think the below should solve your problem
> >>
> >>  read.csv("Book1.csv")
> >>>
> >> Subject   Item Score
> >> 1 Subject 1 Item 1 1
> >> 2 Subject 1 Item 2 0
> >> 3 Subject 1 Item 3 1
> >> 4 Subject 2 Item 1 1
> >> 5 Subject 2 Item 2 1
> >> 6 Subject 2 Item 3 0
> >>
> >>  library("reshape2")
> >>> tDat.m<- melt(tDat)
> >>>
> >>
> >>  tDatCast<- acast(tDat.m,Subject~Item)
> >>> tDatCast
> >>>
> >>   Item 1 Item 2 Item 3
> >> Subject 1  1  0  1
> >> Subject 2  1  1  0
> >>
> >
> >
> > # Or without using package reshape2, only function reshape from stats:
> >
> > df <- data.frame(Subject=
> >   c("Subject 1","Subject 1","Subject 1","Subject 1",
> > "Subject 2","Subject 2","Subject 2","Subject 2"),
> > Item   =
> >   c("Item 1","Item 2","Item 3","Item 4",
> > "Item 1","Item 2","Item 3","Item 4"),
> > Score  = c(1,0,1,1,1,1,0,0))
> >
> > df.wide <- reshape(df, idvar="Subject", timevar="Item", direction="wide")
> > names(df.wide) <- c("Subject",unique(as.character(df$Item)))
> >
> > df.wide
> >Subject Item 1 Item 2 Item 3 Item 4
> > 1 Subject 1  1  0  1  1
> > 5 Subject 2  1  1  0  0
> >
> >
> >
> >  -Original Message-
> >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org
> ]
> >> On
> >> Behalf Of Ajay Ohri
> >> Sent: 30 October 2010 16:27
> >> To: Rhelp
> >> Subject: [R] transforming a dataset for association analysis
> >>
> >> Hi
> >>
> >> I would like to transform  a data frame like
> >>
> >> SubjectItem   Score
> >> Subject 1 Item 1 1
> >> Subject 1 Item 2 0
> >> Subject 1 Item 3 1
> >> Subject 2 Item 1 1
> >> Subject 2 Item 2 1
> >> Subject 2 Item 3 0
> >> 
> >> *to *
> >>
> >> Subject  Item1   Item2   Item3 .Item N
> >> Subject1   1  0   1
> >> Subject2   1  10
> >> 
> >> SubjectP..
> >>
> >> Apologize for the simple nature of my query but I am stuck. How can I do
> >> this transformation?
> >>
> >> Regards
> >>
> >> Ajay
> >>
> >>
> >>
> >> Websites-
> >> http://decisionstats.com
> >> http://dudeofdata.com
> >>
> >>
> >> Linkedin- www.linkedin.com/in/ajayohri
> >>
> >>
> >>
> >>
> >> On Sat, Oct 30, 2010 at 2:39 PM, Alaios  wrote:
> >>
> >>  Hello everyone.
> >>> I have written quite a big function that at the end correctly returns
> the
> >>> values
> >>> I want. I found a rare exception that I want to cover also. The easier
> >>> for
> >>> me
> >>> would be to write something like that
> >>>
> >>>
> >>> functi

Re: [R] How to stop showing messages while loading package?

2010-11-01 Thread Erik Iverson

Simply read the ?library help page, where you'll find under Details:

 To suppress messages during the loading of packages use
 ‘suppressPackageStartupMessages’: this will suppress all messages
 from R itself but not necessarily all those from package authors.


Christofer Bogaso wrote:

Hi, is there any way to stop showing all messages which sometimes come while
loading a packages? For example let say I want to load fBasics package. So I
get following notices:


library(fBasics)

Loading required package: MASS
Loading required package: timeDate
Loading required package: timeSeries
Attaching package: 'timeSeries'
The following object(s) are masked from 'package:zoo':
time<-

Attaching package: 'fBasics'
The following object(s) are masked from 'package:base':
norm
I want to stop all above information to be shown. Would really aprreciate if
somebody points any.

Thanks and regards,

[[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] How to stop showing messages while loading package?

2010-11-01 Thread Christofer Bogaso
Hi, is there any way to stop showing all messages which sometimes come while
loading a packages? For example let say I want to load fBasics package. So I
get following notices:

> library(fBasics)
Loading required package: MASS
Loading required package: timeDate
Loading required package: timeSeries
Attaching package: 'timeSeries'
The following object(s) are masked from 'package:zoo':
time<-

Attaching package: 'fBasics'
The following object(s) are masked from 'package:base':
norm
I want to stop all above information to be shown. Would really aprreciate if
somebody points any.

Thanks and regards,

[[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] Function not working

2010-11-01 Thread Duncan Murdoch

On 01/11/2010 12:56 PM, Thomas Parr wrote:

Below is the (really basic) script I am creating to call a function that
sets the working directory, determines the number of files it will need to
process in that directory, and creates a mask.  A "for" loop will eventually
be added that will loop through the files (arrays) in that directory
performing a baseline/zero correction and apply the mask - that will
probably be a later plea for help. It is being designed for a specific
idiot-proof purpose (obviously it found an idiot) which is why you just have
to input the directory.

This function was working fine on my x64 2.12.0 build of R on my home
computer, but when I brought to work and started fiddling with the script on
my x32 2.12.0 it didn't work. It sources without a problem, and I can call
it without getting an error message, but all it seems willing to do is set
the working directory.  Entering "n", "mat" or "mask" after that to make
sure it ran results in "Error: object 'mat' not found."  I have copied and
pasted the text into a new script, tried it with "\\" and with "/". Rebooted
R, sourced from the command line and from the menu...  None of the functions
I am using are exclusive to x64 or a package (that I know of).  I need to
know why it was working on one computer and not the other because, in final
form, it will be transported and used on different systems by people with
minimal understanding of R.
I think it wasn't working on your x64 computer, but you happened to have 
existing variables named n, mat and mask, and you mistakenly thought 
your function was setting them.




The call would look something like: EEMCORR("C:\\Documents and
Settings\\User\\Desktop\\folder\\subfolder") or wherever they put the data
arrays.

EEMCORR<- function(location){

#set working directory, find number of files in directory
setwd(location)
n<- (length(list.files(getwd(-1

#mask
mat<-matrix(0, 20,20)
mat[upper.tri(mat)]<-"ZZ"
mask<- rbind((cbind(matrix(0,20,20),mat)),matrix(0,100,40))
}



This function has local variables n, mat and mask, but never changes the 
values of global ones.  Generally functions that have such global side 
effects are a bad idea, but if you are sure you want to do it, use n <<- 
..., mat <<- ..., etc.  The <<- "superassignment" operator makes the 
assignment in a parent or global environment.


Duncan Murdoch


Thanks for your keen eyes

Thomas

[[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] Function not working

2010-11-01 Thread Thomas Parr
Below is the (really basic) script I am creating to call a function that
sets the working directory, determines the number of files it will need to
process in that directory, and creates a mask.  A "for" loop will eventually
be added that will loop through the files (arrays) in that directory
performing a baseline/zero correction and apply the mask - that will
probably be a later plea for help. It is being designed for a specific
idiot-proof purpose (obviously it found an idiot) which is why you just have
to input the directory.

This function was working fine on my x64 2.12.0 build of R on my home
computer, but when I brought to work and started fiddling with the script on
my x32 2.12.0 it didn't work. It sources without a problem, and I can call
it without getting an error message, but all it seems willing to do is set
the working directory.  Entering "n", "mat" or "mask" after that to make
sure it ran results in "Error: object 'mat' not found."  I have copied and
pasted the text into a new script, tried it with "\\" and with "/". Rebooted
R, sourced from the command line and from the menu...  None of the functions
I am using are exclusive to x64 or a package (that I know of).  I need to
know why it was working on one computer and not the other because, in final
form, it will be transported and used on different systems by people with
minimal understanding of R.

The call would look something like: EEMCORR("C:\\Documents and
Settings\\User\\Desktop\\folder\\subfolder") or wherever they put the data
arrays.

EEMCORR <- function(location){

#set working directory, find number of files in directory
setwd(location)
n <- (length(list.files(getwd(-1

#mask
mat<-matrix(0, 20,20)
mat[upper.tri(mat)]<-"ZZ"
mask<- rbind((cbind(matrix(0,20,20),mat)),matrix(0,100,40))
}

Thanks for your keen eyes

Thomas

[[alternative HTML version deleted]]

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


Re: [R] how to get all possible combinations including the diagonal using "combn"

2010-11-01 Thread Marc Schwartz
On Nov 1, 2010, at 12:46 PM, Louis Plough wrote:

> Hi,
> I am trying to generate all possible permutations (choose 2) of a vector, b,
> for example--using 'combn' the combinations in only one direction are
> generated...
> 
>> b<-c(.1,.2,.3)
>> combn(b,2)
> [,1] [,2] [,3]
> [1,]  0.1  0.1  0.2
> [2,]  0.2  0.3  0.3
> 
>[1,] 0.1  0.2  0.3  0.2  0.3  0.3These
> should also be there.
>[2,] 0.1  0.2  0.3  0.1  0.1  0.2
> 
> Is there another R function that can do this??
> 
> Thanks,
> Louis


See ?expand.grid

b <- c(.1, .2, .3)

> expand.grid(b, b)
  Var1 Var2
1  0.1  0.1
2  0.2  0.1
3  0.3  0.1
4  0.1  0.2
5  0.2  0.2
6  0.3  0.2
7  0.1  0.3
8  0.2  0.3
9  0.3  0.3

HTH,

Marc Schwartz

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


Re: [R] 32-bit packages on 64-bit Windows

2010-11-01 Thread Duncan Murdoch

On 01/11/2010 1:40 PM, Lee Hachadoorian wrote:

Are 32-bit precompiled packages supposed to work on 32-bit R installed
on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run
32-bit or 64-bit R?) implies that they will work, but I am having
trouble getting certain packages to work. Before I spend more time on
it or start asking questions about specific packages, I would like to
know I'm not trying to do something impossible.



Yes, but be sure they were compiled for R 2.12.0.  The location of DLLs 
has changed, as well as the other usual minor internal changes that come 
with a new version.


Duncan Murdoch

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


[R] how to get all possible combinations including the diagonal using "combn"

2010-11-01 Thread Louis Plough
Hi,
I am trying to generate all possible permutations (choose 2) of a vector, b,
for example--using 'combn' the combinations in only one direction are
generated...

> b<-c(.1,.2,.3)
> combn(b,2)
 [,1] [,2] [,3]
[1,]  0.1  0.1  0.2
[2,]  0.2  0.3  0.3

[1,] 0.1  0.2  0.3  0.2  0.3  0.3These
should also be there.
[2,] 0.1  0.2  0.3  0.1  0.1  0.2

Is there another R function that can do this??

Thanks,
Louis

[[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] 32-bit packages on 64-bit Windows

2010-11-01 Thread Uwe Ligges
Yes, 32-bit precompiled packages work with 32-bit R binaries on 64-bit 
Windows.


Best,
Uwe Ligges




On 01.11.2010 18:40, Lee Hachadoorian wrote:

Are 32-bit precompiled packages supposed to work on 32-bit R installed
on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run
32-bit or 64-bit R?) implies that they will work, but I am having
trouble getting certain packages to work. Before I spend more time on
it or start asking questions about specific packages, I would like to
know I'm not trying to do something impossible.

Thanks,
--Lee

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 32-bit packages on 64-bit Windows

2010-11-01 Thread Lee Hachadoorian
Are 32-bit precompiled packages supposed to work on 32-bit R installed
on 64-bit Windows? I *think* the Windows R FAQ (2.28 Should I run
32-bit or 64-bit R?) implies that they will work, but I am having
trouble getting certain packages to work. Before I spend more time on
it or start asking questions about specific packages, I would like to
know I'm not trying to do something impossible.

Thanks,
--Lee

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

2010-11-01 Thread Santosh Srinivas
Thanks Duncan and Alex.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Duncan Temple Lang
Sent: 01 November 2010 22:34
To: r-help@r-project.org
Subject: Re: [R] File Downloading Problem


I got this working almost immediately with RCurl although with that
one has to specify any value for the useragent option, or the same error
occurs.

The issue is that R does not add an Accept entry to the HTTP request header.
It should add something like
   Accept: *.*

Using RCurl,
 u =
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"
 o = getURLContent(u, verbose = TRUE, useragent =
getOption("HTTPUserAgent"))

succeeds (but not if there is no useragent).


We could fix R's download.file() to send Accept: *.*,
or allow general headers to be specified either as an option for
all requests, or as a parameter of download.file() (or both).
Or we could have the makeUserAgent() function in utils be more customizable
through options, or allow the R user specify the function herself.
But while this would be good, the HTTP facilities in R are not
intended to be as general something like libcurl (and hence RCurl).

Unless there is a compelling reason to enhance R's internal facilities,
I suggest people use something like libcurl.  This approach also has
the advantage of having the data directly in memory and avoiding writing
it to disk and then reading it back in, e.g.

  library(Rcompression)
  z = zipArchive(o)
  names(z)
  read.csv(textConnection(z[[1]]))


  D.


On 11/1/10 8:27 AM, Santosh Srinivas wrote:
> It's strange and the internet connection is fine because I am able to get
> data from yahoo.
> This was working till just yesterday ... strange if the website is
creating
> issues with public access of basic data!
> 
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net] 
> Sent: 01 November 2010 20:48
> To: Duncan Murdoch
> Cc: Santosh Srinivas; 'Rhelp'
> Subject: Re: [R] File Downloading Problem
> 
> 
> On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:
> 
>> On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
>>> Nope Duncan ... no changes .. the same old way without a proxy ...  
>>> actually
>>> the download.file is being returned "403 forbidden" which is strange.
>>>
>>> These are just two lines that I am trying to run.
>>>
>>> sURL<-
>>>
>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>>> v.csv.zip"
>>> download.file(sURL,"test.zip")
>>>
>>> Put the same URL in a browser and it works fine.
>>
>> It doesn't work for me, so presumably there is some kind of security  
>> setting at the site (a cookie?), which allows your browser, but  
>> doesn't allow you to use R, or me to use anything.
> 
> Firefox in a Mac platform will download and unzip the file with no  
> security complaints and no cookie appears to be set when downloading,  
> but that code will not access the file, nor will my efforts to wrap  
> the URL in url() or unz() so it seems more likely that Santosh and I  
> do not understand the file opening processes that R supports.
> 
>  > con=
>
unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NO
> V/cm01NOV2010bhav.csv.zip 
> ", file="~/cm01NOV2010bhav.csv")
>  > test.df <-  read.csv(file=con)
> Error in open.connection(file, "rt") : cannot open the connection
> In addition: Warning message:
> In open.connection(file, "rt") :
>cannot open zip file
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip'
> 
> 
>

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

2010-11-01 Thread Alexander Salim
Hi all,

 

Issue: I merged two zoo objects (a regular and an irregular). After the
merge I used the function 'na.approx' to have also values in the resolution
of the regular time series.

 

Problem: After approximation some rows at the beginning or at the end of the
zoo objects disappear due to the 'na.approx' algorithm. Now I just want to
have all the rows of the regular time series with the approximated values of
the irregular time series back. Because some rows disappear I wasn't able to
program a code which works properly for 'all' circumstances. I also tried to
work with the 'index' function. Didn't work out so far.

 

Thank you for your help.

 

Regards,

Alex

 

***

funLm <- function(gauge, orange){

 

gauge <- zoo(gauge$Precipitation, order.by = gauge$Time)

 

tstart <- ISOdatetime(year=2009, month=5, day=1, hour = 0, min = 0, sec = 0,
tz = "UTC")

tend <- ISOdatetime(year=2009, month=5, day=31, hour = 23, min = 59, sec =
59, tz = "UTC")

orangeMai <- window(orange, start=tstart, end=tend) 

gaugeMai <- window(gauge, start=tstart, end=tend)

 

mergeGaugeOrange <- merge.zoo(gaugeMai, orangeMai)

 

smoothing <- na.approx(mergeGaugeOrange)

 

na.index <- which(is.na(mergeGaugeOrange$orangeMai))

na.index <- if(na.index[1] != 1){na.index-(na.index[1]-1)}

 

regularZoo <- smoothing[c(na.index)]

 

rain.lm <- lm(orangeMai ~ gaugeMai, data=regularZoo)

 

par(mfrow=c(2,2))

plot(rain.lm)

 

}

***


[[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] File Downloading Problem

2010-11-01 Thread Duncan Temple Lang

I got this working almost immediately with RCurl although with that
one has to specify any value for the useragent option, or the same error occurs.

The issue is that R does not add an Accept entry to the HTTP request header.
It should add something like
   Accept: *.*

Using RCurl,
 u = 
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip";
 o = getURLContent(u, verbose = TRUE, useragent = getOption("HTTPUserAgent"))

succeeds (but not if there is no useragent).


We could fix R's download.file() to send Accept: *.*,
or allow general headers to be specified either as an option for
all requests, or as a parameter of download.file() (or both).
Or we could have the makeUserAgent() function in utils be more customizable
through options, or allow the R user specify the function herself.
But while this would be good, the HTTP facilities in R are not
intended to be as general something like libcurl (and hence RCurl).

Unless there is a compelling reason to enhance R's internal facilities,
I suggest people use something like libcurl.  This approach also has
the advantage of having the data directly in memory and avoiding writing
it to disk and then reading it back in, e.g.

  library(Rcompression)
  z = zipArchive(o)
  names(z)
  read.csv(textConnection(z[[1]]))


  D.


On 11/1/10 8:27 AM, Santosh Srinivas wrote:
> It's strange and the internet connection is fine because I am able to get
> data from yahoo.
> This was working till just yesterday ... strange if the website is creating
> issues with public access of basic data!
> 
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net] 
> Sent: 01 November 2010 20:48
> To: Duncan Murdoch
> Cc: Santosh Srinivas; 'Rhelp'
> Subject: Re: [R] File Downloading Problem
> 
> 
> On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:
> 
>> On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
>>> Nope Duncan ... no changes .. the same old way without a proxy ...  
>>> actually
>>> the download.file is being returned "403 forbidden" which is strange.
>>>
>>> These are just two lines that I am trying to run.
>>>
>>> sURL<-
>>>
> "http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>>> v.csv.zip"
>>> download.file(sURL,"test.zip")
>>>
>>> Put the same URL in a browser and it works fine.
>>
>> It doesn't work for me, so presumably there is some kind of security  
>> setting at the site (a cookie?), which allows your browser, but  
>> doesn't allow you to use R, or me to use anything.
> 
> Firefox in a Mac platform will download and unzip the file with no  
> security complaints and no cookie appears to be set when downloading,  
> but that code will not access the file, nor will my efforts to wrap  
> the URL in url() or unz() so it seems more likely that Santosh and I  
> do not understand the file opening processes that R supports.
> 
>  > con=
> unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NO
> V/cm01NOV2010bhav.csv.zip 
> ", file="~/cm01NOV2010bhav.csv")
>  > test.df <-  read.csv(file=con)
> Error in open.connection(file, "rt") : cannot open the connection
> In addition: Warning message:
> In open.connection(file, "rt") :
>cannot open zip file
> 'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip'
> 
> 
>

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

2010-11-01 Thread Alex Gutteridge
On Mon, 1 Nov 2010 20:57:47 +0530, "Santosh Srinivas"
 wrote:
> It's strange and the internet connection is fine because I am able to
get
> data from yahoo.
> This was working till just yesterday ... strange if the website is
creating
> issues with public access of basic data!
> 

It's checking your HTTP UserAgent header. Spoof it for access:

> options(HTTPUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6;
en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12")
> sURL =
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip";
> download.file(sURL,"test")
trying URL
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip'
Content type 'application/zip' length 43124 bytes (42 Kb)
opened URL
==
downloaded 42 Kb

-- 
Alex Gutteridge

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sqldf hanging on macintosh - works on windows

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 12:10 PM, Marc Schwartz  wrote:
> On Nov 1, 2010, at 10:55 AM, Gabor Grothendieck wrote:
>
>> On Mon, Nov 1, 2010 at 10:55 AM, GL  wrote:
>>>
>>>

 library(sqldf)
>>> Loading required package: DBI
>>> Loading required package: RSQLite
>>> Loading required package: RSQLite.extfuns
>>> Loading required package: gsubfn
>>> Loading required package: proto
>>> Loading required package: chron
 debug(sqldf)
   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
 "df.possible.combos"
>>> +     left join "df.aggregate" using (Hour, Date)')
>>> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
>> ...
>>> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
>>> Browse[2]>
>>> Loading required package: tcltk
>>> Loading Tcl/Tk interface ...
>>> +
>>
>> There is something wrong with tcltk on your system.  You can tell it
>> not to use tcltk by setting the appropriate option as discussed in
>> sqldf FAQ #5:
>>
>> http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.
>
>
> GL,
>
> If you installed R using the OSX binary from CRAN, it does not include 
> tcl/tk. You need to install the separate tcltk package that Simon has put 
> together and is available from:
>
>  http://cran.us.r-project.org/bin/macosx/tools/
>
> You also need to have X11 installed, which is available from the OSX DVD in 
> the Optional Installs section.
>
> HTH,
>
> Marc Schwartz
>
>
>

Note that sqldf can work without tcltk, as well.  The gsubfn package
does check for tcltk and and sets the engine to "R" rather than
"tcltk" if

capabilities()[["tcltk"]]

is FALSE.  There may be a bug in R or a problem with the installation.

-- 
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] Plots inside a Plot

2010-11-01 Thread Bert Gunter
Petr is correct,I believe,  but see also ?layout for a (newer and)
more flexible approach to splitting the screen into a non-matricial
arrangement to overlay several plots.

?split.screen can also do this, but is somewhat clumsier to use imo.

Cheers,
Bert

On Mon, Nov 1, 2010 at 4:27 AM, Petr PIKAL  wrote:
> Hi
>
> I remember that I did it also in base graphics but it took me some time to
> find out how and it was a long time ago so.
>
> If I remember it correctly it was some combination of graphic parameters
> to set user coordinates and do not overwrite the first plot by setting
> par(new=TRUE)
>
> Regards
> Petr
>
>
>
>
> r-help-boun...@r-project.org napsal dne 01.11.2010 12:10:18:
>
>> Not in R base graphics, but you can do easily with the grid package.
>>
>> Best,
>> Uwe Ligges
>>
>>
>> On 01.11.2010 11:59, Knut Krueger wrote:
>> > hi,
>> >
>> > is it possible to draw a plot inside another plot f.e in the upper
> right
>> > corner. I do not mean the possbility
>> > par(mfrow = c(2,2).
>> >
>> >
>> > Kind Regards
>> > Knut
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 save this result in a vector

2010-11-01 Thread Changbin Du
Thanks, Erich!



On Mon, Nov 1, 2010 at 4:55 AM, Erich Neuwirth
wrote:

> My guess is that what you want probably is best done by using ecdf.
> You might want to look it up in the docs.
>
> 1-ecdf(test)(x)
> Will give you the percentage of values in test larger than x.
>
>
> On 11/1/2010 2:24 AM, Changbin Du wrote:
> > Thanks Joshua! Yes, i is not going up sequentially  by 1, as i here is
> the
> > raw number of reads for each DNA base. Thanks so much for the great help!
> >
> >
> > On Sun, Oct 31, 2010 at 6:03 PM, Joshua Wiley  >wrote:
> >
> >> On Sun, Oct 31, 2010 at 5:44 PM, Joshua Wiley 
> >> wrote:
> >> 
> >>> #cover is a vector
> >>> cover_per <- function(cover) {
> >>>  ## create a vector to store the results of your for loop
> >>>  output <- vector("numeric", length(min(cover):max(cover)))
> >>>  for (i in min(cover):max(cover)) {
> >>>## rather than print()ing the output, assign it to an object
> >>>output[i] <- 100*sum(ifelse(cover >= i, 1, 0))/length(cover)
> >>>  }
> >>>  ## have the return value from the function be
> >>>  ## the object 'output'
> >>>  return(output)
> >>> }
> >>
> >> I did not catch that i was not necessarily starting at 1 going
> >> sequentially up, so that would have to be done manually (or use cumsum
> >> per David rather than the function you wrote).
> >>
> >> cover_per2 <- function(cover) {
> >>   output <- vector("numeric", length(min(cover):max(cover)))
> >>   j <- 1
> >>   for (i in min(cover):max(cover)) {
> >> output[j] <- 100*sum(ifelse(cover >= i, 1, 0))/length(cover)
> >>j <- j + 1
> >>  }
> >>  return(output)
> >> }
> >>
> >> Josh
> >>
> >
> >
> >
>
>


-- 
Sincerely,
Changbin
--

Changbin Du
DOE Joint Genome Institute
Bldg 400 Rm 457
2800 Mitchell Dr
Walnut Creet, CA 94598
Phone: 925-927-2856

[[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] Seek some help on Statistics

2010-11-01 Thread Ron Michael
Hi friends, I would really appreciate if somebody helps me give 
better understanding on subject matter.
Suppose I have a set of Integrated variables (say max order is 1). I understand 
there may be some cases when there could be some linear combinations which are 
stationary and this phenomena is called as co-integration.
Now suppose I have a vector of Random walks (which is also integrated of order 
1 each), where error terms are not necessarily independent but of 
course uncorrelated over time i.e. error terms are WN. Here my question is 
still can we find some linear combinations (like co-integrated variables) which 
are stationary? And if not, why this is not.
Please forgive me if my question seems very naive. However 
although intuitively I feel that no such linear relationships exist for RWs, 
however I find hard to explain to 2nd person.
Any help please?
Thanks


[[alternative HTML version deleted]]

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


Re: [R] Plots inside a Plot

2010-11-01 Thread Uwe Ligges



On 01.11.2010 12:20, Barry Rowlingson wrote:

On Mon, Nov 1, 2010 at 11:10 AM, Uwe Ligges
  wrote:

Not in R base graphics, but you can do easily with the grid package.


  You can do anything in R base graphics! Sometimes it's been done for
you, sometimes you just have to draw the whole thing yourself using
lines().

  In this case, someone has already done it for you. subplot() in package Hmisc:

  >  require(Hmisc)
  >  plot( 11:20, sample(51:60) )
  >  subplot( hist(rnorm(100)), 15, 55)

Barry


Actually, it only works if your subplot does not contain "sub"plots 
itself. Try:


 plot( 11:20, sample(51:60) )
 subplot(pairs(iris), 15, 55)

and find it won't work.
So my corrected answer is: "In general not in R base graphics." ;-)

Best wishes,
Uwe

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


Re: [R] Error message when creating a dataframe

2010-11-01 Thread Erik Iverson

I suggest using the most recent version of R (2.12.0 I believe)
and providing a reproducible example, showing us exactly how you
are creating this data.frame (assuming it still exhibits the
behavior).

--Erik

ANJAN PURKAYASTHA wrote:

Hi,
I'm creating a data frame of 24 columns and 45101 rows.
Here is the error I get:
R(147,0xa04d8720) malloc: *** mmap(size=184320) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Any idea of what I can do to trouble-shoot?
Attached is the session  info:
R version 2.11.1 (2010-05-31)
i386-apple-darwin9.8.0

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

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



Thanks in advance,
Anjan




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


[R] Error message when creating a dataframe

2010-11-01 Thread ANJAN PURKAYASTHA
Hi,
I'm creating a data frame of 24 columns and 45101 rows.
Here is the error I get:
R(147,0xa04d8720) malloc: *** mmap(size=184320) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Any idea of what I can do to trouble-shoot?
Attached is the session  info:
R version 2.11.1 (2010-05-31)
i386-apple-darwin9.8.0

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

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



Thanks in advance,
Anjan


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

[[alternative HTML version deleted]]

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


Re: [R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread Marc Schwartz
On Nov 1, 2010, at 10:55 AM, Gabor Grothendieck wrote:

> On Mon, Nov 1, 2010 at 10:55 AM, GL  wrote:
>> 
>> 
>>> 
>>> library(sqldf)
>> Loading required package: DBI
>> Loading required package: RSQLite
>> Loading required package: RSQLite.extfuns
>> Loading required package: gsubfn
>> Loading required package: proto
>> Loading required package: chron
>>> debug(sqldf)
>>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>>> "df.possible.combos"
>> + left join "df.aggregate" using (Hour, Date)')
>> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
> ...
>> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
>> Browse[2]>
>> Loading required package: tcltk
>> Loading Tcl/Tk interface ...
>> +
> 
> There is something wrong with tcltk on your system.  You can tell it
> not to use tcltk by setting the appropriate option as discussed in
> sqldf FAQ #5:
> 
> http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.


GL,

If you installed R using the OSX binary from CRAN, it does not include tcl/tk. 
You need to install the separate tcltk package that Simon has put together and 
is available from:

  http://cran.us.r-project.org/bin/macosx/tools/

You also need to have X11 installed, which is available from the OSX DVD in the 
Optional Installs section.

HTH,

Marc Schwartz

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


Re: [R] transfer string to expression

2010-11-01 Thread Bert Gunter
If it's not already clear, perhaps this slight variation might help
explain what's happening:

b0<-1
b1<-1
x<-1
str2expr<-function(y){eval(parse(text=y))}  ## Note change from "x" to "y" here
test1<-"b0+b1*sqrt(x)"
str2expr(test1)

Cheers,
Bert

On Sun, Oct 31, 2010 at 1:58 PM, Duncan Murdoch
 wrote:
> On 31/10/2010 4:47 PM, Wu Gong wrote:
>>
>> Hi Duncan:
>>
>> I'm curious about the environment setting. ?eval says:
>>
>> "If envir is not specified, then the default is parent.frame() (the
>> environment where the call to eval was made). "
>>
>> So what's the difference between set envir=parent.frame() or not?
>
> If you pass parent.frame() as an argument, it will be one level up: it's the
> parent of the function that calls eval.  If you leave it at the default,
> it's the parent of eval, i.e. the function that calls it.
>
> Duncan Murdoch
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics

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

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 11:14 AM, Salim Alexander (salimale)
 wrote:
> Hi all,
>
> Issue: I merged two zoo objects (a regular and an irregular). After the merge 
> I used the function 'na.approx' to have also values in the resolution of the 
> regular time series.
>
> Problem: After approximation some rows at the beginning or at the end of the 
> zoo objects disappear due to the 'na.approx' algorithm. Now I just want to 
> have all the rows of the regular time series with the approximated values of 
> the irregular time series back. Because some rows disappear I wasn't able to 
> program a code which works properly for 'all' circumstances. I also tried to 
> work with the 'index' function. Didn't work out so far.
>
> Thank you for your help.
>
> Regards,
> Alex

Note the last line to every message to r-help asking for minimal
reproducible code.   Without that one cannot be sure what the problem
is but note the na.rm= argument on na.approx.zoo .

-- 
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] sqldf hanging on macintosh - works on windows

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 10:55 AM, GL  wrote:
>
>
>>
>> library(sqldf)
> Loading required package: DBI
> Loading required package: RSQLite
> Loading required package: RSQLite.extfuns
> Loading required package: gsubfn
> Loading required package: proto
> Loading required package: chron
>> debug(sqldf)
>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>> "df.possible.combos"
> +     left join "df.aggregate" using (Hour, Date)')
> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
...
> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
> Browse[2]>
> Loading required package: tcltk
> Loading Tcl/Tk interface ...
> +

There is something wrong with tcltk on your system.  You can tell it
not to use tcltk by setting the appropriate option as discussed in
sqldf FAQ #5:

http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.

-- 
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] Plots inside a Plot

2010-11-01 Thread D Kelly O'Day

Here's a quick example I posted on my blog.

http://chartsgraphs.wordpress.com/2009/05/06/r-lets-you-put-chart-inside-chart/
link 

Hope it helps.

http://r.789695.n4.nabble.com/file/n3022363/chart_inside_chart.png 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plots-inside-a-Plot-tp3021988p3022363.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] Post-processing of approximated irregular time series

2010-11-01 Thread Salim Alexander (salimale)
Hi all,

Issue: I merged two zoo objects (a regular and an irregular). After the merge I 
used the function 'na.approx' to have also values in the resolution of the 
regular time series.

Problem: After approximation some rows at the beginning or at the end of the 
zoo objects disappear due to the 'na.approx' algorithm. Now I just want to have 
all the rows of the regular time series with the approximated values of the 
irregular time series back. Because some rows disappear I wasn't able to 
program a code which works properly for 'all' circumstances. I also tried to 
work with the 'index' function. Didn't work out so far.

Thank you for your help.

Regards,
Alex

[[alternative HTML version deleted]]

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


[R] R's text mining package VSM support

2010-11-01 Thread Shivani Rao
I have been using R's text mining package and its really a great tool. I
have not found retrieval support or maybe there are functionalities I am
missing.
How can a simple VSM model be implemented using the R's text mining package?

Your help is appreciated.

-- 
Research Scholar,
School of Electrical and Computer Engineering
Purdue University
West Lafayette IN
web.ics.purdue.edu/~sgrao

[[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] ggplot map bounds

2010-11-01 Thread Adrienne Wootten
Oh this is excellent, Thanks!
Adrienne

On Mon, Nov 1, 2010 at 11:25 AM, Ista Zahn wrote:

> Hi Adrienne,
> I think
>
> usamap + xlim(c(-85, -75)) + ylim(c(33,37))
>
> will do what you want.
>
> Best,
> Ista
>
> On Mon, Nov 1, 2010 at 10:52 AM, Adrienne Wootten 
> wrote:
> > To all,
> >
> > I'm working with code below to produce a map with station data plotted in
> > points, but right now I'm having trouble with the mapping portion of this
> > code
> >
> >
> > states <- data.frame(map("state", plot=FALSE,xlim=
> > c(-85,-75),ylim=c(33,37))[c("x","y")])
> > usamap<- ggplot(states)+geom_path(aes(x,y))
> > usamap
> >
> > When I plot this the problem is that the bounds of the plot is from 31N
> to
> > 38N and 90W to 75W.  The problem is that I only need the bounds of the
> plot
> > to be from 33N to 37N and 85W to 75W.  The way this is now, if I try to
> > subset the states object, I get a garbled mess of lines.  The rest of the
> > code provides what I'm trying to do with the attached data.
> >
> >
> > usamap + geom_point(data=obsmeans,aes(x=lon,y=lat,colour =
> month_1),size=5)
> > +
> >
> scale_colour_gradientn(data=obsmeans,colour=rev(rainbow(17)),breaks=seq(5,21,by=1),limits=c(5,21))
> >
> >
> > Any ideas for how I can fix this map would be appreciated!
> >
> > Adrienne
> >
> > --
> > Adrienne Wootten
> > Graduate Research Assistant
> > State Climate Office of North Carolina
> > Department of Marine, Earth and Atmospheric Sciences
> > North Carolina State University
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
>
>
> --
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
>



-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University

[[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] File Downloading Problem

2010-11-01 Thread Santosh Srinivas
It's strange and the internet connection is fine because I am able to get
data from yahoo.
This was working till just yesterday ... strange if the website is creating
issues with public access of basic data!

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: 01 November 2010 20:48
To: Duncan Murdoch
Cc: Santosh Srinivas; 'Rhelp'
Subject: Re: [R] File Downloading Problem


On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:

> On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
>> Nope Duncan ... no changes .. the same old way without a proxy ...  
>> actually
>> the download.file is being returned "403 forbidden" which is strange.
>>
>> These are just two lines that I am trying to run.
>>
>> sURL<-
>>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> v.csv.zip"
>> download.file(sURL,"test.zip")
>>
>> Put the same URL in a browser and it works fine.
>
> It doesn't work for me, so presumably there is some kind of security  
> setting at the site (a cookie?), which allows your browser, but  
> doesn't allow you to use R, or me to use anything.

Firefox in a Mac platform will download and unzip the file with no  
security complaints and no cookie appears to be set when downloading,  
but that code will not access the file, nor will my efforts to wrap  
the URL in url() or unz() so it seems more likely that Santosh and I  
do not understand the file opening processes that R supports.

 > con=
unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NO
V/cm01NOV2010bhav.csv.zip 
", file="~/cm01NOV2010bhav.csv")
 > test.df <-  read.csv(file=con)
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
   cannot open zip file
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip'



-- 
David.


>
> Duncan Murdoch
>
>> -Original Message-
>> From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
>> Sent: 01 November 2010 19:04
>> To: Santosh Srinivas
>> Cc: 'Rhelp'
>> Subject: Re: [R] File Downloading Problem
>>
>> On 01/11/2010 9:22 AM, Santosh Srinivas wrote:
>> >  Dear Group,
>> >
>> >  My code stopped working ... used to work till last week!
>> >
>> >  sURL<-
>> >
>>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> >  v.csv.zip"
>> >
>> >  >   download.file(sURL,"test.zip")
>> >  trying URL
>> >
>>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> >  v.csv.zip'
>> >  Error in download.file(sURL, "test.zip") :
>> > cannot open URL
>> >
>>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>> >  v.csv.zip'
>> >  In addition: Warning message:
>> >  In download.file(sURL, "test.zip") :
>> > cannot open: HTTP status was '403 Forbidden'
>> >
>> >  I put the same URL in  a browser and it works just fine.
>>
>>
>> Are you using a proxy?  If you've recently updated R, you may have  
>> told
>> it not to use the proxy.  You can test this by running
>>
>> setInternet2(TRUE)
>>
>> (which will use a proxy if one is defined in Internet Explorer) and
>> repeating the download.file() call.  You can make Internet2 the  
>> default
>> by putting --internet2 on the command line when you start R.
>>
>> Duncan Murdoch
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

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


Re: [R] ggplot map bounds

2010-11-01 Thread Ista Zahn
Hi Adrienne,
I think

usamap + xlim(c(-85, -75)) + ylim(c(33,37))

will do what you want.

Best,
Ista

On Mon, Nov 1, 2010 at 10:52 AM, Adrienne Wootten  wrote:
> To all,
>
> I'm working with code below to produce a map with station data plotted in
> points, but right now I'm having trouble with the mapping portion of this
> code
>
>
> states <- data.frame(map("state", plot=FALSE,xlim=
> c(-85,-75),ylim=c(33,37))[c("x","y")])
> usamap<- ggplot(states)+geom_path(aes(x,y))
> usamap
>
> When I plot this the problem is that the bounds of the plot is from 31N to
> 38N and 90W to 75W.  The problem is that I only need the bounds of the plot
> to be from 33N to 37N and 85W to 75W.  The way this is now, if I try to
> subset the states object, I get a garbled mess of lines.  The rest of the
> code provides what I'm trying to do with the attached data.
>
>
> usamap + geom_point(data=obsmeans,aes(x=lon,y=lat,colour = month_1),size=5)
> +
> scale_colour_gradientn(data=obsmeans,colour=rev(rainbow(17)),breaks=seq(5,21,by=1),limits=c(5,21))
>
>
> Any ideas for how I can fix this map would be appreciated!
>
> Adrienne
>
> --
> Adrienne Wootten
> Graduate Research Assistant
> State Climate Office of North Carolina
> Department of Marine, Earth and Atmospheric Sciences
> North Carolina State University
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] File Downloading Problem

2010-11-01 Thread David Winsemius


On Nov 1, 2010, at 10:41 AM, Duncan Murdoch wrote:


On 01/11/2010 10:37 AM, Santosh Srinivas wrote:
Nope Duncan ... no changes .. the same old way without a proxy ...  
actually

the download.file is being returned "403 forbidden" which is strange.

These are just two lines that I am trying to run.

sURL<-
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"
download.file(sURL,"test.zip")

Put the same URL in a browser and it works fine.


It doesn't work for me, so presumably there is some kind of security  
setting at the site (a cookie?), which allows your browser, but  
doesn't allow you to use R, or me to use anything.


Firefox in a Mac platform will download and unzip the file with no  
security complaints and no cookie appears to be set when downloading,  
but that code will not access the file, nor will my efforts to wrap  
the URL in url() or unz() so it seems more likely that Santosh and I  
do not understand the file opening processes that R supports.


> con= unz(description="http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip 
", file="~/cm01NOV2010bhav.csv")

> test.df <-  read.csv(file=con)
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
  cannot open zip file 
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bhav.csv.zip'



--
David.




Duncan Murdoch


-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Sent: 01 November 2010 19:04
To: Santosh Srinivas
Cc: 'Rhelp'
Subject: Re: [R] File Downloading Problem

On 01/11/2010 9:22 AM, Santosh Srinivas wrote:
>  Dear Group,
>
>  My code stopped working ... used to work till last week!
>
>  sURL<-
>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip"
>
>  >   download.file(sURL,"test.zip")
>  trying URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip'
>  Error in download.file(sURL, "test.zip") :
> cannot open URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip'
>  In addition: Warning message:
>  In download.file(sURL, "test.zip") :
> cannot open: HTTP status was '403 Forbidden'
>
>  I put the same URL in  a browser and it works just fine.


Are you using a proxy?  If you've recently updated R, you may have  
told

it not to use the proxy.  You can test this by running

setInternet2(TRUE)

(which will use a proxy if one is defined in Internet Explorer) and
repeating the download.file() call.  You can make Internet2 the  
default

by putting --internet2 on the command line when you start R.

Duncan Murdoch



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


David Winsemius, MD
West Hartford, CT

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


Re: [R] transforming a dataset for association analysis RESHAPE2

2010-11-01 Thread Ista Zahn
Hi Ajay,
I'm not sure what the problem is, and I don't think your description
is enough to reproduce it. This works fine for me


library(reshape2)

dat <- read.table(textConnection('Subject   Item Score
"Subject 1" "Item 1" 1
"Subject 1" "Item 2" 0
"Subject 1" "Item 3" 1
"Subject 2" "Item 1" 1
"Subject 2" "Item 2" 1
"Subject 2" "Item 3" 0'), header=TRUE)
closeAllConnections()

acast(dat, Subject~Item)

sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
 [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8
 [7] LC_PAPER=en_US.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] reshape2_1.0  ggplot2_0.8.8 proto_0.3-8   reshape_0.8.3 plyr_1.2.1

loaded via a namespace (and not attached):
[1] stringr_0.4  tools_2.12.0

-Ista

On Mon, Nov 1, 2010 at 10:39 AM, Ajay Ohri  wrote:
> I get the following message when using the reshape2 package line
>
>> tDat.m<- melt(Dataset)
> Using Item, Subject as id variables
>> tDatCast<- acast(tDat.m,Subject~Item)
> Aggregation function missing: defaulting to length
>
>
> Note Problem Statement-
>
> convert dataframe
>
>
> Subject   Item Score
> 1 Subject 1 Item 1     1
> 2 Subject 1 Item 2     0
> 3 Subject 1 Item 3     1
> 4 Subject 2 Item 1     1
> 5 Subject 2 Item 2     1
> 6 Subject 2 Item 3     0
>
> to
>
>
>  Subject Item 1 Item 2 Item 3 Item 4
> 1 Subject 1      1      0      1      1
> 5 Subject 2      1      1      0      0
>
> Note- when I tried using the "wide" method the resultant vector went out of
> memory- its a dataset appox 100,000 lines
>
>
>
> Websites-
> http://decisionstats.com
> http://dudeofdata.com
>
>
> Linkedin- www.linkedin.com/in/ajayohri
>
>
>
>
> On Sat, Oct 30, 2010 at 5:41 PM, Rainer Hurling  wrote:
>
>> On 30.10.2010 13:50 (UTC+1), Santosh Srinivas wrote:
>>
>>> A more usable problem input would definitely help ... use dput to send a
>>> reproducible sample to the group
>>>
>>> Think the below should solve your problem
>>>
>>>  read.csv("Book1.csv")

>>>     Subject   Item Score
>>> 1 Subject 1 Item 1     1
>>> 2 Subject 1 Item 2     0
>>> 3 Subject 1 Item 3     1
>>> 4 Subject 2 Item 1     1
>>> 5 Subject 2 Item 2     1
>>> 6 Subject 2 Item 3     0
>>>
>>>  library("reshape2")
 tDat.m<- melt(tDat)

>>>
>>>  tDatCast<- acast(tDat.m,Subject~Item)
 tDatCast

>>>           Item 1 Item 2 Item 3
>>> Subject 1      1      0      1
>>> Subject 2      1      1      0
>>>
>>
>>
>> # Or without using package reshape2, only function reshape from stats:
>>
>> df <- data.frame(Subject=
>>                   c("Subject 1","Subject 1","Subject 1","Subject 1",
>>                     "Subject 2","Subject 2","Subject 2","Subject 2"),
>>                 Item   =
>>                   c("Item 1","Item 2","Item 3","Item 4",
>>                     "Item 1","Item 2","Item 3","Item 4"),
>>                 Score  = c(1,0,1,1,1,1,0,0))
>>
>> df.wide <- reshape(df, idvar="Subject", timevar="Item", direction="wide")
>> names(df.wide) <- c("Subject",unique(as.character(df$Item)))
>>
>> df.wide
>>    Subject Item 1 Item 2 Item 3 Item 4
>> 1 Subject 1      1      0      1      1
>> 5 Subject 2      1      1      0      0
>>
>>
>>
>>  -Original Message-
>>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>>> On
>>> Behalf Of Ajay Ohri
>>> Sent: 30 October 2010 16:27
>>> To: Rhelp
>>> Subject: [R] transforming a dataset for association analysis
>>>
>>> Hi
>>>
>>> I would like to transform  a data frame like
>>>
>>> Subject    Item   Score
>>> Subject 1 Item 1 1
>>> Subject 1 Item 2 0
>>> Subject 1 Item 3 1
>>> Subject 2 Item 1 1
>>> Subject 2 Item 2 1
>>> Subject 2 Item 3 0
>>> 
>>> *to *
>>>
>>> Subject      Item1   Item2   Item3 .Item N
>>> Subject1       1          0       1
>>> Subject2       1          1        0
>>> 
>>> SubjectP..
>>>
>>> Apologize for the simple nature of my query but I am stuck. How can I do
>>> this transformation?
>>>
>>> Regards
>>>
>>> Ajay
>>>
>>>
>>>
>>> Websites-
>>> http://decisionstats.com
>>> http://dudeofdata.com
>>>
>>>
>>> Linkedin- www.linkedin.com/in/ajayohri
>>>
>>>
>>>
>>>
>>> On Sat, Oct 30, 2010 at 2:39 PM, Alaios  wrote:
>>>
>>>  Hello everyone.
 I have written quite a big function that at the end correctly returns the
 values
 I want. I found a rare exception that I want to cover also. The easier
 for
 me
 would be to write something like that


 function(){

  if (rare exception happened)
      return that value

  # The comes the code for normal execution
  # ...
  # ...
  return value # Normal values to return

 }


 Wo

Re: [R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL


> 
> library(sqldf)
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: chron
> debug(sqldf)  
>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
> "df.possible.combos"
+ left join "df.aggregate" using (Hour, Date)')
debugging in: sqldf("select Date, Hour, x as RoomsInUse from
\"df.possible.combos\"\nleft join \"df.aggregate\" using (Hour, Date)")
debug: {
as.POSIXct.character <- function(x) structure(as.numeric(x), 
class = c("POSIXt", "POSIXct"))
as.Date.character <- function(x) structure(as.numeric(x), 
class = "Date")
as.Date.numeric <- function(x, origin = "1970-01-01", ...)
base::as.Date.numeric(x, 
origin = origin, ...)
as.dates.character <- function(x) structure(as.numeric(x), 
class = c("dates", "times"))
as.times.character <- function(x) structure(as.numeric(x), 
class = "times")
overwrite <- FALSE
request.open <- missing(x) && is.null(connection)
request.close <- missing(x) && !is.null(connection)
request.con <- !missing(x) && !is.null(connection)
request.nocon <- !missing(x) && is.null(connection)
dfnames <- fileobjs <- character(0)
if (request.close || request.nocon) {
on.exit({
dbPreExists <- attr(connection, "dbPreExists")
dbname <- attr(connection, "dbname")
if (!missing(dbname) && !is.null(dbname) && dbname == 
":memory:") {
dbDisconnect(connection)
} else if (!dbPreExists && drv == "sqlite") {
dbDisconnect(connection)
file.remove(dbname)
} else {
for (nam in dfnames) dbRemoveTable(connection, 
  nam)
for (fo in fileobjs) dbRemoveTable(connection, 
  fo)
dbDisconnect(connection)
}
})
if (request.close) {
if (identical(connection, getOption("sqldf.connection"))) 
options(sqldf.connection = NULL)
return()
}
}
if (request.open || request.nocon) {
if (is.null(drv)) {
drv <- if ("package:RpgSQL" %in% search()) {
"pgSQL"
}
else if ("package:RMySQL" %in% search()) {
"MySQL"
}
else if ("package:RH2" %in% search()) {
"H2"
}
else "SQLite"
}
drv <- tolower(drv)
if (drv == "mysql") {
m <- dbDriver("MySQL")
connection <- if (missing(dbname) || dbname == ":memory:") {
dbConnect(m)
}
else dbConnect(m, dbname = dbname)
dbPreExists <- TRUE
}
else if (drv == "pgsql") {
m <- dbDriver("pgSQL")
if (missing(dbname) || is.null(dbname)) {
dbname <- getOption("RpgSQL.dbname")
if (is.null(dbname)) 
  dbname <- "test"
}
connection <- dbConnect(m, dbname = dbname)
dbPreExists <- TRUE
}
else if (drv == "h2") {
m <- H2()
if (missing(dbname) || is.null(dbname)) 
dbname <- ":memory:"
dbPreExists <- dbname != ":memory:" && file.exists(dbname)
connection <- if (missing(dbname) || dbname == ":memory:") {
dbConnect(m, "jdbc:h2:mem:", "sa", "")
}
else {
jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
dbConnect(m, jdbc.string)
}
}
else {
m <- dbDriver("SQLite")
if (missing(dbname)) 
dbname <- ":memory:"
dbPreExists <- dbname != ":memory:" && file.exists(dbname)
if (is.null(getOption("sqldf.dll"))) {
dll <- Sys.which("libspatialite-1.dll")
if (dll != "") 
  options(sqldf.dll = dll)
else options(sqldf.dll = FALSE)
}
dll <- getOption("sqldf.dll")
if (length(dll) != 1 || identical(dll, FALSE) || 
nchar(dll) == 0) {
dll <- FALSE
}
else {
if (dll == basename(dll)) 
  dll <- Sys.which(dll)
}
options(sqldf.dll = dll)
if (!identical(dll, FALSE)) {
connection <- dbConnect(m, dbname = dbname,
loadable.extensions = TRUE)
s <- sprintf("select load_extension('%s')", dll)
dbGetQuery(connection, s)
}
else connection <- dbConnect(m, dbname = dbname)
init_extensions(connection)
}
attr(connection, "dbPreExists") <- dbPreExists
if (missing(dbname) && drv == "sqlite") 
d

[R] ggplot map bounds

2010-11-01 Thread Adrienne Wootten
To all,

I'm working with code below to produce a map with station data plotted in
points, but right now I'm having trouble with the mapping portion of this
code


states <- data.frame(map("state", plot=FALSE,xlim=
c(-85,-75),ylim=c(33,37))[c("x","y")])
usamap<- ggplot(states)+geom_path(aes(x,y))
usamap

When I plot this the problem is that the bounds of the plot is from 31N to
38N and 90W to 75W.  The problem is that I only need the bounds of the plot
to be from 33N to 37N and 85W to 75W.  The way this is now, if I try to
subset the states object, I get a garbled mess of lines.  The rest of the
code provides what I'm trying to do with the attached data.


usamap + geom_point(data=obsmeans,aes(x=lon,y=lat,colour = month_1),size=5)
+
scale_colour_gradientn(data=obsmeans,colour=rev(rainbow(17)),breaks=seq(5,21,by=1),limits=c(5,21))


Any ideas for how I can fix this map would be appreciated!

Adrienne

-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sqldf hanging on macintosh - works on windows

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 10:32 AM, GL  wrote:
>
> added library(RH2)
>
> Still get message:
>
> Loading required package: tcltk
> Loading Tcl/Tk interface
> +
>
> directly after sqldf statement
>
>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>> "df.possible.combos"
> +     left join "df.aggregate" using (Hour, Date)')
>
> There is no progress spinner. If I hit  I get a ">"
>
> At that point I start to enter any command (just summary, for instance), I
> get the progress spinner, the
> "try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)
> " message in the bottom ribbon, and the system apparently hangs.

I don't have a Mac but if you wish to pursue it try this:

library(sqldf)
debug(sqldf)
sqldf(...whatever...)
# now step through it by repeatedly pressing Enter and send me the
console output of the session

-- 
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] R 2.12.0 does not open in Tinn-R 2.3.5.2

2010-11-01 Thread Meyerink

Just another tip on how to change the path (it took me some time find out
how: the Tinn-R help is not correct on this one):

options/applications/R (click the tab)

Gerdien Meyerink


elpape wrote:
> 
> Found the problem. Have to change the path in Tinn-R
> 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-2-12-0-does-not-open-in-Tinn-R-2-3-5-2-tp3007070p3022254.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] biglm: how it handles large data set?

2010-11-01 Thread Mike Marchywka







> Date: Sun, 31 Oct 2010 00:22:12 -0700
> From: tim@netzero.net
> To: r-help@r-project.org
> Subject: [R] biglm: how it handles large data set?
>
>
>
> I am trying to figure out why 'biglm' can handle large data set...
>
> According to the R document - "biglm creates a linear model object that uses
> only p^2 memory for p variables. It can be updated with more data using
> update. This allows linear regression on data sets larger than memory."

I'm not sure anyone answered the question but let me make some
comments having done something similar with non-R code before and motivate
my earlier comments about "streaming" data into a stats widget.
Probably this creates a matrix of some sort with various moments/ 
sums-of-powers
of the data like IIRC what the stats books call "computing formulas."
Each new data point simply adds to the matrix
elements, it needn't be stored by itself- in the simple case of finding 
an average for example each data point just ads to N and a sum and 
you divide the two when finished. So, anyway, up to the limits
of the floating point implementation( when each new "y^n" is too small to 
add a non-zero delta to the current sum LOL) , you can keep updating the matrix
elements with very large data sets and your memory requirement is just
due to matrix elements not number of data points. Finally you invert
the matrix to get your "answer." The ordere you quote seem about
right IIRC as I tried to fit some image related data to a polynomial.
You can probably just write the equations yourself, rearrange terms to
express as sums over past data, and see that your coefficients come from
the matrix inverse. 


>
> After reading the source code below, I still could not figure out how
> 'update' implements the algorithm...
>
> Thanks for any light shed upon this ...
>
> > biglm::biglm
>
> function (formula, data, weights = NULL, sandwich = FALSE)
> {
> tt <- terms(formula)
> if (!is.null(weights)) {
> if (!inherits(weights, "formula"))
> stop("`weights' must be a formula")
> w <- model.frame(weights, data)[[1]]
> }
> else w <- NULL
> mf <- model.frame(tt, data)
> mm <- model.matrix(tt, mf)
> qr <- bigqr.init(NCOL(mm))
> qr <- update(qr, mm, model.response(mf), w)
> rval <- list(call = sys.call(), qr = qr, assign = attr(mm,
> "assign"), terms = tt, n = NROW(mm), names = colnames(mm),
> weights = weights)
> if (sandwich) {
> p <- ncol(mm)
> n <- nrow(mm)
> xyqr <- bigqr.init(p * (p + 1))
> xx <- matrix(nrow = n, ncol = p * (p + 1))
> xx[, 1:p] <- mm * model.response(mf)
> for (i in 1:p) xx[, p * i + (1:p)] <- mm * mm[, i]
> xyqr <- update(xyqr, xx, rep(0, n), w * w)
> rval$sandwich <- list(xy = xyqr)
> }
> rval$df.resid <- rval$n - length(qr$D)
> class(rval) <- "biglm"
> rval
> }
> 
> ---
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/biglm-how-it-handles-large-data-set-tp3020890p3020890.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] number of items to replace is not a multiple of replacement length

2010-11-01 Thread Mipam Bruining
Hello,

I just wanted to say that I just stumbled upon the solution by accident!
After your comment on lists I searched for some more information on vectors,
lists and matrices. I read that using double ['s instead of singles drops
the names of the dimensions used.
I then gave
parameterList[aCounter, 3] <<- blaah
instead of
parameterList[[aCounter, 3]] <<- blaah
a quick try and voila!

In hindsight I guess I was just thinking to much in python style where
matrices dont have dimension naming. (python being the language in which I
first learned to program and quite similar to R)

But thanks for your help anyway!

Mipam Bruining

2010/11/1 Ivan Calandra 

> Hi,
>
> Not sure what the problem is, but you have weird data structures. I mean,
> having lists within matrices is possible (I've learned it last week!), but
> it is really confusing.
>
> You didn't provide every object like the complete parameterList and
> aCounter, but the only difference I see in
>
> aParameterValue <- as.matrix(parameterList[[aCounter,3]])
> ...
> blaah <<- aParameterValue
> ...
> parameterList[aCounter, 3] <<- blaah
> between the original parameterList[[aCounter,3]] and the new one is that
> your aParameterValue, and therefore blaah, is a matrix, and a weird one,
> that you try to assign into a non-matrix object.
>
> Have you tried without as.matrix()? What about storing everything in a list
> and using indexing?
>
> HTH,
> Ivan
>
>
> Le 11/1/2010 14:43, Mipam Bruining a écrit :
>
>> Hello,
>>
>> here are the results from using dput() on the objects in question.
>>
>> >dput(blaah)
>> structure(list("Insert single selection box title here", "Insert slider
>> bar title here",
>>"SingleSelect", "Slider", 1, 50, list("Option a", "Option b",
>>"Option c"), list(0, 100)), .Dim = c(2L, 4L), .Dimnames = list(
>>c("exampleSingleSelect", "exampleSlider"), NULL))
>>
>> >dput(parameterList[aCounter, 3])
>> list(structure(list("Insert single selection box title here",
>>"Insert slider bar title here", "SingleSelect", "Slider",
>>1, 0, list("Option a", "Option b", "Option c"), list(0, 100)), .Dim =
>> c(2L,
>> 4L), .Dimnames = list(c("exampleSingleSelect", "exampleSlider"
>> ), NULL)))
>>
>>
>> The matrix parameterList was constructed as followed:
>>
>> 
>> exampleSlider = list("Insert slider bar title here", "Slider", 0,
>> list(0,100))
>> exampleSingleSelect = list("Insert single selection box title here",
>> "SingleSelect", 1,
>> list("Option a", "Option b", "Option c"))
>>
>> parameterList = rbind(list("more advanced options", "Button",
>> rbind(exampleSingleSelect,exampleSlider ), " ")
>> ...
>> aParameterValue <- as.matrix(parameterList[[aCounter,3]])
>> ...
>> blaah <<- aParameterValue
>> ...
>> parameterList[aCounter, 3] <<- blaah
>>
>> 
>>
>> As a side note: The ... represents various other lines. The construction
>> parameterList <<- blaah <<- aParameterValue is an ad-hoc solution to using
>> global and local variables that I will try to smooth over once it works as
>> it is now. To be more specific, the value aParameterValue is a local
>> variable that is created in a subfunction which is called upon once for each
>> row in parameterList, each time the user presses a button in the created
>> tcltk window.
>> The blaah variable is a global variable that solves the problem of tlctk
>> buttons not being able to receive the returned values from the function it
>> calls and parameterList somehow not being able to be updated correctly
>> within this function.
>>
>> I hope anyone can make sense of this story :S
>>
>> Mipam Bruining
>>
>>
>> 2010/11/1 Ivan Calandra > ivan.calan...@uni-hamburg.de>>
>>
>>
>>Hi,
>>
>>I think you _*should*_ provide more:
>>- the objects you have, such as parameterList and blaah: copy the
>>output from dput(object) in your next e-mail
>>- the _*relevant*_ code for how you've built them
>>
>>I guess you will get more and better answers if you give a clear
>>and complete description of your problem.
>>
>>Ivan
>>
>>Le 11/1/2010 12:55, Mipam Bruining a écrit :
>>
>>Hey all,
>>
>>I am writing a function in which I will have a matrix of 4
>>columns and a
>>variable amount of rows.
>>The first to columns will always contain be of the Character
>>type, the third
>>and fourth columns
>>can be a variation of data types, usually characters and
>>integers, but
>>sometimes lists or matrices.
>>
>>At one point the code makes, for each row, a copy of that row,
>>then it makes
>>some adjustments
>>to the values in the third column, and then it overwrites the
>>original
>>matrix row with the copy. It is here
>>that I get the error from my subject title, "number of items
>>to replace is
>>not a multiple of replacement length".
>>This is strange because the items to replace in this instance
>>seem to me and
>> 

Re: [R] File Downloading Problem

2010-11-01 Thread Duncan Murdoch

On 01/11/2010 10:37 AM, Santosh Srinivas wrote:

Nope Duncan ... no changes .. the same old way without a proxy ... actually
the download.file is being returned "403 forbidden" which is strange.

These are just two lines that I am trying to run.

sURL<-
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"
download.file(sURL,"test.zip")

Put the same URL in a browser and it works fine.


It doesn't work for me, so presumably there is some kind of security 
setting at the site (a cookie?), which allows your browser, but doesn't 
allow you to use R, or me to use anything.


Duncan Murdoch


-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Sent: 01 November 2010 19:04
To: Santosh Srinivas
Cc: 'Rhelp'
Subject: Re: [R] File Downloading Problem

On 01/11/2010 9:22 AM, Santosh Srinivas wrote:
>  Dear Group,
>
>  My code stopped working ... used to work till last week!
>
>  sURL<-
>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip"
>
>  >   download.file(sURL,"test.zip")
>  trying URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip'
>  Error in download.file(sURL, "test.zip") :
> cannot open URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
>  v.csv.zip'
>  In addition: Warning message:
>  In download.file(sURL, "test.zip") :
> cannot open: HTTP status was '403 Forbidden'
>
>  I put the same URL in  a browser and it works just fine.


Are you using a proxy?  If you've recently updated R, you may have told
it not to use the proxy.  You can test this by running

setInternet2(TRUE)

(which will use a proxy if one is defined in Internet Explorer) and
repeating the download.file() call.  You can make Internet2 the default
by putting --internet2 on the command line when you start R.

Duncan Murdoch



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


Re: [R] transforming a dataset for association analysis RESHAPE2

2010-11-01 Thread Ajay Ohri
I get the following message when using the reshape2 package line

> tDat.m<- melt(Dataset)
Using Item, Subject as id variables
> tDatCast<- acast(tDat.m,Subject~Item)
Aggregation function missing: defaulting to length


Note Problem Statement-

convert dataframe


Subject   Item Score
1 Subject 1 Item 1 1
2 Subject 1 Item 2 0
3 Subject 1 Item 3 1
4 Subject 2 Item 1 1
5 Subject 2 Item 2 1
6 Subject 2 Item 3 0

to


  Subject Item 1 Item 2 Item 3 Item 4
1 Subject 1  1  0  1  1
5 Subject 2  1  1  0  0

Note- when I tried using the "wide" method the resultant vector went out of
memory- its a dataset appox 100,000 lines



Websites-
http://decisionstats.com
http://dudeofdata.com


Linkedin- www.linkedin.com/in/ajayohri




On Sat, Oct 30, 2010 at 5:41 PM, Rainer Hurling  wrote:

> On 30.10.2010 13:50 (UTC+1), Santosh Srinivas wrote:
>
>> A more usable problem input would definitely help ... use dput to send a
>> reproducible sample to the group
>>
>> Think the below should solve your problem
>>
>>  read.csv("Book1.csv")
>>>
>> Subject   Item Score
>> 1 Subject 1 Item 1 1
>> 2 Subject 1 Item 2 0
>> 3 Subject 1 Item 3 1
>> 4 Subject 2 Item 1 1
>> 5 Subject 2 Item 2 1
>> 6 Subject 2 Item 3 0
>>
>>  library("reshape2")
>>> tDat.m<- melt(tDat)
>>>
>>
>>  tDatCast<- acast(tDat.m,Subject~Item)
>>> tDatCast
>>>
>>   Item 1 Item 2 Item 3
>> Subject 1  1  0  1
>> Subject 2  1  1  0
>>
>
>
> # Or without using package reshape2, only function reshape from stats:
>
> df <- data.frame(Subject=
>   c("Subject 1","Subject 1","Subject 1","Subject 1",
> "Subject 2","Subject 2","Subject 2","Subject 2"),
> Item   =
>   c("Item 1","Item 2","Item 3","Item 4",
> "Item 1","Item 2","Item 3","Item 4"),
> Score  = c(1,0,1,1,1,1,0,0))
>
> df.wide <- reshape(df, idvar="Subject", timevar="Item", direction="wide")
> names(df.wide) <- c("Subject",unique(as.character(df$Item)))
>
> df.wide
>Subject Item 1 Item 2 Item 3 Item 4
> 1 Subject 1  1  0  1  1
> 5 Subject 2  1  1  0  0
>
>
>
>  -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>> On
>> Behalf Of Ajay Ohri
>> Sent: 30 October 2010 16:27
>> To: Rhelp
>> Subject: [R] transforming a dataset for association analysis
>>
>> Hi
>>
>> I would like to transform  a data frame like
>>
>> SubjectItem   Score
>> Subject 1 Item 1 1
>> Subject 1 Item 2 0
>> Subject 1 Item 3 1
>> Subject 2 Item 1 1
>> Subject 2 Item 2 1
>> Subject 2 Item 3 0
>> 
>> *to *
>>
>> Subject  Item1   Item2   Item3 .Item N
>> Subject1   1  0   1
>> Subject2   1  10
>> 
>> SubjectP..
>>
>> Apologize for the simple nature of my query but I am stuck. How can I do
>> this transformation?
>>
>> Regards
>>
>> Ajay
>>
>>
>>
>> Websites-
>> http://decisionstats.com
>> http://dudeofdata.com
>>
>>
>> Linkedin- www.linkedin.com/in/ajayohri
>>
>>
>>
>>
>> On Sat, Oct 30, 2010 at 2:39 PM, Alaios  wrote:
>>
>>  Hello everyone.
>>> I have written quite a big function that at the end correctly returns the
>>> values
>>> I want. I found a rare exception that I want to cover also. The easier
>>> for
>>> me
>>> would be to write something like that
>>>
>>>
>>> function(){
>>>
>>>  if (rare exception happened)
>>>  return that value
>>>
>>>  # The comes the code for normal execution
>>>  # ...
>>>  # ...
>>>  return value # Normal values to return
>>>
>>> }
>>>
>>>
>>> Would that be feasible with R or two returns statements are not accepted?
>>>
>>> Regards
>>> Alex
>>>
>>

[[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] File Downloading Problem

2010-11-01 Thread Santosh Srinivas
Nope Duncan ... no changes .. the same old way without a proxy ... actually
the download.file is being returned "403 forbidden" which is strange.

These are just two lines that I am trying to run.

sURL<-
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"
download.file(sURL,"test.zip")

Put the same URL in a browser and it works fine.

-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] 
Sent: 01 November 2010 19:04
To: Santosh Srinivas
Cc: 'Rhelp'
Subject: Re: [R] File Downloading Problem

On 01/11/2010 9:22 AM, Santosh Srinivas wrote:
> Dear Group,
>
> My code stopped working ... used to work till last week!
>
> sURL<-
>
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip"
>
> >  download.file(sURL,"test.zip")
> trying URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip'
> Error in download.file(sURL, "test.zip") :
>cannot open URL
>
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
> v.csv.zip'
> In addition: Warning message:
> In download.file(sURL, "test.zip") :
>cannot open: HTTP status was '403 Forbidden'
>
> I put the same URL in  a browser and it works just fine.


Are you using a proxy?  If you've recently updated R, you may have told 
it not to use the proxy.  You can test this by running

setInternet2(TRUE)

(which will use a proxy if one is defined in Internet Explorer) and 
repeating the download.file() call.  You can make Internet2 the default 
by putting --internet2 on the command line when you start R.

Duncan Murdoch

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


Re: [R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL

added library(RH2)

Still get message:

Loading required package: tcltk
Loading Tcl/Tk interface
+

directly after sqldf statement 

>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
> "df.possible.combos"
+ left join "df.aggregate" using (Hour, Date)')

There is no progress spinner. If I hit  I get a ">"

At that point I start to enter any command (just summary, for instance), I
get the progress spinner, the
"try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)
" message in the bottom ribbon, and the system apparently hangs. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sqldf-hanging-on-macintosh-works-on-windows-tp3022193p3022233.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] sqldf hanging on macintosh - works on windows

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 9:59 AM, GL  wrote:
>
> Have a long script that runs fine on windows (32 bit). When I try to run in
> on two different macs (64 bit), however, it hangs with identical behavior.
>
> I start with:
> library(sqldf)
>
> This results in messages:
> Loading required package: DBI
> Loading required package: RSQLite
> Loading required package: RSQLite.extfuns
> Loading required package: gsubfn
> Loading required package: proto
> Loading required package: chron
>
> I then read some data, etc.
>
> I execute the following:
>
> #merge raw data and all possible combinations
>  df.final <- sqldf('select Date, Hour, x as RoomsInUse from
> "df.possible.combos"
>    left join "df.aggregate" using (Hour, Date)')
>
> I receive the messages:
> Loading required package: tcltk
> Loading Tcl/Tk interface ...
> +
>
> Then I get into some kind of loop. Message at bottom ribbon says:
>
> executing:
> try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)
>

That is not a line that appears in the sqldf source code.  Try these
suggestions anyways:

http://permalink.gmane.org/gmane.comp.lang.r.general/209443


-- 
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] write.csv changes the format of the date

2010-11-01 Thread jim holtman
works fine on 2.11.1 Windows:

> x <- structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010",
+ class = "factor")), .Names = "Last_Successful_Run", class = "data.frame",
+ row.names = c(NA,
+ -1L))
> x
  Last_Successful_Run
1  30/10/2010
> str(x)
'data.frame':   1 obs. of  1 variable:
 $ Last_Successful_Run: Factor w/ 1 level "30/10/2010": 1
> write.csv(x, file='x.csv')
> z <- read.csv('x.csv')
> z
  X Last_Successful_Run
1 1  30/10/2010
>

Your data is a 'factor' so it should not be doing any date conversion.

On Mon, Nov 1, 2010 at 9:14 AM, Santosh Srinivas
 wrote:
> Dear Group,
>
> Why does write.csv modify the date format when it write to a file.
>
> I have the following variable Param_Dat:
>
> dput(Param_Dat)
> structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010",
> class = "factor")), .Names = "Last_Successful_Run", class = "data.frame",
> row.names = c(NA,
> -1L))
>
>
> When I do:
> write.csv(Param_Dat,"Param.csv",quote=F,row.names=F)
>
> The format of the info in the file is:
> Last_Successful_Run
> 31OCT2010
>
> I want to retain the dd/mm/ format ...
>
> Please advise.
>
> 
> --
> Thanks R-Helpers. Yes, this is a silly question and it will not be repeated!
> :-)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] Possible memory leak in loop.

2010-11-01 Thread Jonathan P Daily
Thank you, I will give that a try.
--
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
 - Jubal Early, Firefly



From:
jim holtman 
To:
Jonathan P Daily 
Cc:
r-help@r-project.org
Date:
11/01/2010 09:48 AM
Subject:
Re: [R] Possible memory leak in loop.



If you are running on Windows, you might want to use 'perfmon' to look
at the memory usage of the process over time.  You might also want to
put calls to memory.size in your looping code to see if there are
things you are doing in the code that might temporarily use a lot of
space and maybe fragment memory.

On Mon, Nov 1, 2010 at 8:35 AM, Jonathan P Daily  wrote:
> I was trying to use memory.size() to determine whether a code loop I am
> executing created a memory leak, since one replicate of the simulation
> takes 670.98 seconds according to proc.time(), while 5 replicates takes
> 170762 seconds. So I set it up as:
>
> memA <- memory.size()
>
> looping code...
>
> memB <- memory.size()
>
> memA returns as 9.3, and memB returns 11.3. I'm not familiar with
> fluctuation patterns in RAM usage (if there are any). Does anyone with
> more experience know if this is indicative of a memory leak?
>
> Thanks,
>Jon
> --
> Jonathan P. Daily
> Technician - USGS Leetown Science Center
> 11649 Leetown Road
> Kearneysville WV, 25430
> (304) 724-4480
> "Is the room still a room when its empty? Does the room,
>  the thing itself have purpose? Or do we, what's the word... imbue it."
> - Jubal Early, Firefly
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?



[[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] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL

Have a long script that runs fine on windows (32 bit). When I try to run in
on two different macs (64 bit), however, it hangs with identical behavior.

I start with:
library(sqldf)

This results in messages:
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: chron

I then read some data, etc.

I execute the following:

#merge raw data and all possible combinations
  df.final <- sqldf('select Date, Hour, x as RoomsInUse from
"df.possible.combos"
left join "df.aggregate" using (Hour, Date)')

I receive the messages:
Loading required package: tcltk
Loading Tcl/Tk interface ... 
+ 

Then I get into some kind of loop. Message at bottom ribbon says:

executing:
try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)

On the pc implementation it runs flawlessly, and quickly. 

Truly appreciate any ideas.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/sqldf-hanging-on-macintosh-works-on-windows-tp3022193p3022193.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] write.csv changes the format of the date

2010-11-01 Thread Santosh Srinivas
Hi David, Its strange ... when I run this separately it works ... but I when
I do in my function it changes the format.
I just opened it using Notepad.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: 01 November 2010 19:15
To: Santosh Srinivas
Cc: 'Rhelp'
Subject: Re: [R] write.csv changes the format of the date


On Nov 1, 2010, at 9:14 AM, Santosh Srinivas wrote:

> Dear Group,
>
> Why does write.csv modify the date format when it write to a file.
>
> I have the following variable Param_Dat:
>
> dput(Param_Dat)
> structure(list(Last_Successful_Run = structure(1L, .Label =  
> "30/10/2010",
> class = "factor")), .Names = "Last_Successful_Run", class =  
> "data.frame",
> row.names = c(NA,
> -1L))
>
>
> When I do:
> write.csv(Param_Dat,"Param.csv",quote=F,row.names=F)
>
> The format of the info in the file is:
> Last_Successful_Run
> 31OCT2010

Unable to reproduce. When I execute that code I get this file:
Last_Successful_Run
30/10/2010

I'm guessing you are viewing that file with something other than a  
plain text editor.

>
> I want to retain the dd/mm/ format ...
>
> Please advise.


--
David Winsemius, MD
West Hartford, CT

 > sessionInfo()
R version 2.11.1 Patched (2010-06-14 r52281)
x86_64-apple-darwin9.8.0

locale:
[1] en_US/en_US/en_US/C/en_US/en_US

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

other attached packages:
[1] Hmisc_3.8-1 survival_2.35-8 dismo_0.5-6 rJava_0.8-7
[5] raster_1.5-16   sp_0.9-72   sos_1.2-9   brew_0.1-1
[9] lattice_0.18-8

loaded via a namespace (and not attached):
[1] cluster_1.12.3 grid_2.11.1tools_2.11.1

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


[R] contiguity matrix (queens case)

2010-11-01 Thread Gary Nobles

i have a grid of points at regular intervals (taken from a raster).

I want to create a listw matrix based on a queens case senario, like this

1 1 1
1 1 1
1 1 1

and also like this

1  1  1  1  1
1  1  1  1  1
1  1  1  1  1
1  1  1  1  1
1  1  1  1  1

and so on


I want it to work with localG from package spdep:
localG(x, listw, zero.policy=NULL, spChk=NULL)

I can use nb2listw, I also want the matrix to use the observation value so
the Gstar optioon, I quote:

If the neighbours member of listw has a "self.included" attribute set to
TRUE, the Gstar variant, including
the self-weight wii > 0, is calculated and returned. The returned vector
will have a "gstari"
attribute set to TRUE. Self-weights can be included by using the
include.self function in the
spweights package before converting the neighbour list to a spatial weights
list with nb2listw as
shown below in the example.

Any help is much appreciated, I am slowly getting there!

Thanks

Gary
-- 
View this message in context: 
http://r.789695.n4.nabble.com/contiguity-matrix-queens-case-tp3022184p3022184.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] Possible memory leak in loop.

2010-11-01 Thread jim holtman
If you are running on Windows, you might want to use 'perfmon' to look
at the memory usage of the process over time.  You might also want to
put calls to memory.size in your looping code to see if there are
things you are doing in the code that might temporarily use a lot of
space and maybe fragment memory.

On Mon, Nov 1, 2010 at 8:35 AM, Jonathan P Daily  wrote:
> I was trying to use memory.size() to determine whether a code loop I am
> executing created a memory leak, since one replicate of the simulation
> takes 670.98 seconds according to proc.time(), while 5 replicates takes
> 170762 seconds. So I set it up as:
>
> memA <- memory.size()
>
> looping code...
>
> memB <- memory.size()
>
> memA returns as 9.3, and memB returns 11.3. I'm not familiar with
> fluctuation patterns in RAM usage (if there are any). Does anyone with
> more experience know if this is indicative of a memory leak?
>
> Thanks,
>        Jon
> --
> Jonathan P. Daily
> Technician - USGS Leetown Science Center
> 11649 Leetown Road
> Kearneysville WV, 25430
> (304) 724-4480
> "Is the room still a room when its empty? Does the room,
>  the thing itself have purpose? Or do we, what's the word... imbue it."
>     - Jubal Early, Firefly
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] connecting points into a smooth curve

2010-11-01 Thread Gavin Simpson
On Sun, 2010-10-31 at 23:18 -0700, tooblue wrote:
> If I have, say, five scatter points and want to connect them together into a
> smooth curve.
> I did plot(x,y,type="l"), but the graph is five segments connecting with
> each other, but not a smooth curve. 
> I wonder if there is a line type that is a curve. Thanks!

?spline would be one way of joining up the point with smooth curve
passing through the 5 observations. However, as several other have
noted, you need to explain how you want the smooth curve to pass through
the observations.

Here's an example:

x <- 1:5
y <- rnorm(5)
ylim <- with(sp, range(y))
plot(x,y, ylim = ylim)
lines(sp, col = "red")

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sqldf error only on Unix not Windows

2010-11-01 Thread Gabor Grothendieck
On Mon, Nov 1, 2010 at 9:28 AM, Alex Bryant  wrote:
> Hello Group,
>
>                I am having trouble with the sqldf package on unix.  The same 
> code works fine on windows.
>
> Silly Example script:
>
> # Load the package
> library(sqldf)
>
> # Use the titanic data set
>
> data(women)
> colnames(women)
> head(women)
>
> sqldf('select height, count(*) from women where height is not null group by 
> weight')
>

Some things to try:

-  try adding dbname = tempfile() argument to your sqldf statement and
see if that makes any difference

- try it with the H2 database rather than sqlite (or with PostgreSQL)
  To use it with H2 make sure you have Java and the CRAN package, RH2,
installed.
  RH2 includes the H2 database itself so you don't need to install that.
  Then issue this line in R any time before your first sqldf call
 library(RH2)
  sqldf will notice it and automatically use the H2 database instead of sqlite

- try it with R 2.11

-- 
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] write.csv changes the format of the date

2010-11-01 Thread David Winsemius


On Nov 1, 2010, at 9:14 AM, Santosh Srinivas wrote:


Dear Group,

Why does write.csv modify the date format when it write to a file.

I have the following variable Param_Dat:

dput(Param_Dat)
structure(list(Last_Successful_Run = structure(1L, .Label =  
"30/10/2010",
class = "factor")), .Names = "Last_Successful_Run", class =  
"data.frame",

row.names = c(NA,
-1L))


When I do:
write.csv(Param_Dat,"Param.csv",quote=F,row.names=F)

The format of the info in the file is:
Last_Successful_Run
31OCT2010


Unable to reproduce. When I execute that code I get this file:
Last_Successful_Run
30/10/2010

I'm guessing you are viewing that file with something other than a  
plain text editor.




I want to retain the dd/mm/ format ...

Please advise.



--
David Winsemius, MD
West Hartford, CT

> sessionInfo()
R version 2.11.1 Patched (2010-06-14 r52281)
x86_64-apple-darwin9.8.0

locale:
[1] en_US/en_US/en_US/C/en_US/en_US

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

other attached packages:
[1] Hmisc_3.8-1 survival_2.35-8 dismo_0.5-6 rJava_0.8-7
[5] raster_1.5-16   sp_0.9-72   sos_1.2-9   brew_0.1-1
[9] lattice_0.18-8

loaded via a namespace (and not attached):
[1] cluster_1.12.3 grid_2.11.1tools_2.11.1

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


Re: [R] number of items to replace is not a multiple of replacement length

2010-11-01 Thread Mipam Bruining
Hello,

here are the results from using dput() on the objects in question.

>dput(blaah)
structure(list("Insert single selection box title here", "Insert slider bar
title here",
"SingleSelect", "Slider", 1, 50, list("Option a", "Option b",
"Option c"), list(0, 100)), .Dim = c(2L, 4L), .Dimnames = list(
c("exampleSingleSelect", "exampleSlider"), NULL))

>dput(parameterList[aCounter, 3])
list(structure(list("Insert single selection box title here",
"Insert slider bar title here", "SingleSelect", "Slider",
1, 0, list("Option a", "Option b", "Option c"), list(0, 100)), .Dim =
c(2L,
4L), .Dimnames = list(c("exampleSingleSelect", "exampleSlider"
), NULL)))


The matrix parameterList was constructed as followed:


exampleSlider = list("Insert slider bar title here", "Slider", 0,
list(0,100))
exampleSingleSelect = list("Insert single selection box title here",
"SingleSelect", 1,
list("Option a", "Option b", "Option c"))

parameterList = rbind(list("more advanced options", "Button",
rbind(exampleSingleSelect,exampleSlider ), " ")
...
aParameterValue <- as.matrix(parameterList[[aCounter,3]])
...
blaah <<- aParameterValue
...
parameterList[aCounter, 3] <<- blaah



As a side note: The ... represents various other lines. The
construction parameterList <<- blaah <<- aParameterValue is an ad-hoc
solution to using global and local variables that I will try to smooth over
once it works as it is now. To be more specific, the value aParameterValue
is a local variable that is created in a subfunction which is called upon
once for each row in parameterList, each time the user presses a button in
the created tcltk window.
The blaah variable is a global variable that solves the problem of tlctk
buttons not being able to receive the returned values from the function it
calls and parameterList somehow not being able to be updated correctly
within this function.

I hope anyone can make sense of this story :S

Mipam Bruining


2010/11/1 Ivan Calandra 

> Hi,
>
> I think you _*should*_ provide more:
> - the objects you have, such as parameterList and blaah: copy the output
> from dput(object) in your next e-mail
> - the _*relevant*_ code for how you've built them
>
> I guess you will get more and better answers if you give a clear and
> complete description of your problem.
>
> Ivan
>
> Le 11/1/2010 12:55, Mipam Bruining a écrit :
>
>> Hey all,
>>
>> I am writing a function in which I will have a matrix of 4 columns and a
>> variable amount of rows.
>> The first to columns will always contain be of the Character type, the
>> third
>> and fourth columns
>> can be a variation of data types, usually characters and integers, but
>> sometimes lists or matrices.
>>
>> At one point the code makes, for each row, a copy of that row, then it
>> makes
>> some adjustments
>> to the values in the third column, and then it overwrites the original
>> matrix row with the copy. It is here
>> that I get the error from my subject title, "number of items to replace is
>> not a multiple of replacement length".
>> This is strange because the items to replace in this instance seem to me
>> and
>> should be an exact copy of the
>> replacement, save that the number 0 in this particular instance is to be
>> replaced with the number 58.
>>
>> If I print the variables in question I get this: (added some tabs to
>> allign
>> the columns for readability)
>>
>>  print(parameterList[aCounter, 3])
>>>
>> [[1]]
>>   [,1]
>>  [,2]   [,3][,4]
>> exampleSingleSelect   "Insert single selection box title here"
>> "SingleSelect"  1List,3
>> exampleSlider "Insert slider bar title here"
>> "Slider"0   List,2
>>
>>  print(blaah)
>>>
>>  [,1]
>>  [,2]   [,3]   [,4]
>> exampleSingleSelect  "Insert single selection box title here"
>> "SingleSelect"
>> 1List,3
>> exampleSlider"Insert slider bar title here"
>>  "Slider"   58   List,2
>>
>>
>> The command that caused the error is this:
>>
>>  parameterList[aCounter, 3]<<- blaah
>>>
>>
>> I hope I've given enough information for someone else to be able to make
>> sense of it all. If not I'd be happy to supply additional code
>> or info on how the script works, but I think that most of it would be
>> irrelevant and complicated.
>>
>>  Many thanks in advance,
>> Mipam Bruining
>>
>>[[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.
>>
>>
> --
> Ivan CALANDRA
> PhD Student
> University of Hamburg
> Biozentrum Grindel und Zoologisches Museum
> Abt. Säugetiere
> Martin-Luther-King-Platz 3
> D-20146 Hamburg, GERMANY
> +49(0)40 42838 6231
> ivan.calan...@uni-hamburg.de
>

Re: [R] R shp(ESRI) point patterns and marks

2010-11-01 Thread Gary Nobles

All fixed:

I scaned in the data from x.txt and y.txt

then:

P<-ppp(x,y,c(...),c(...), marks=m)


-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-shp-ESRI-point-patterns-and-marks-tp3017683p3022165.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] File Downloading Problem

2010-11-01 Thread Duncan Murdoch

On 01/11/2010 9:22 AM, Santosh Srinivas wrote:

Dear Group,

My code stopped working ... used to work till last week!

sURL<-
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"

>  download.file(sURL,"test.zip")
trying URL
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip'
Error in download.file(sURL, "test.zip") :
   cannot open URL
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip'
In addition: Warning message:
In download.file(sURL, "test.zip") :
   cannot open: HTTP status was '403 Forbidden'

I put the same URL in  a browser and it works just fine.



Are you using a proxy?  If you've recently updated R, you may have told 
it not to use the proxy.  You can test this by running


setInternet2(TRUE)

(which will use a proxy if one is defined in Internet Explorer) and 
repeating the download.file() call.  You can make Internet2 the default 
by putting --internet2 on the command line when you start R.


Duncan Murdoch

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


[R] sqldf error only on Unix not Windows

2010-11-01 Thread Alex Bryant
Hello Group,

I am having trouble with the sqldf package on unix.  The same 
code works fine on windows.

Silly Example script:

# Load the package
library(sqldf)

# Use the titanic data set

data(women)
colnames(women)
head(women)

sqldf('select height, count(*) from women where height is not null group by 
weight')

Unix Output and error:

bash-3.00$ R --vanilla  # Load the package
> library(sqldf)
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Loading required package: chron
>
>
> # Use the titanic data set
>
> data(women)
> colnames(women)
[1] "height" "weight"
> head(women)
  height weight
1 58115
2 59117
3 60120
4 61123
5 62126
6 63129
>
> sqldf('select height, count(*) from women where height is not null group by 
> weight')
Error in sqliteFetch(rs, n = -1, ...) :
  RSQLite driver: (RS_SQLite_fetch: failed first step: SQL logic error or 
missing database)
Calls: sqldf ... dbGetQuery -> sqliteQuickSQL -> sqliteFetch -> .Call
Error in !dbPreExists : invalid argument type
Calls: sqldf ... dbGetQuery -> sqliteQuickSQL -> sqliteFetch -> .Call
Execution halted
Warning message:
RS-DBI driver warning: (closing pending result sets before closing this 
connection)


Box:
Solaris: SunOS icsun7 5.10 Generic_118822-25 sun4u sparc SUNW,Sun-Fire-280R



I am unable to find any hits on the generated errors which makes me think 
either something is really wrong (resource issues or something) or this is not 
a common use of sqldf??  Is there a better package I should be using?

Thank you very much for your help,

 Alex Bryant
Software Development
Integrated Clinical Systems, Inc.
908-996-7208



Confidentiality Note: This e-mail, and any attachment to...{{dropped:13}}

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

2010-11-01 Thread Santosh Srinivas
Dear Group,

My code stopped working ... used to work till last week!

sURL <-
"http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip"

> download.file(sURL,"test.zip")
trying URL
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip'
Error in download.file(sURL, "test.zip") : 
  cannot open URL
'http://www.nseindia.com/content/historical/EQUITIES/2010/NOV/cm01NOV2010bha
v.csv.zip'
In addition: Warning message:
In download.file(sURL, "test.zip") :
  cannot open: HTTP status was '403 Forbidden'

I put the same URL in  a browser and it works just fine.

Any idea why?

Thanks,
S

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: connecting points into a smooth curve

2010-11-01 Thread Mike Marchywka


 >
> >
> > Doing much of anything meaningful with 5 points would probably require a
> model
> > as the other
> > poster suggested- your model would need to be solved depending on its
> particulars.
> >
> > You sometimes see these kinds of wild interpolation issues with the
> drawing
> > programs and free-form input "smoothing" where it tries to fit a smooth
> curve
> > to your mouse moves.
>
> And of course in Excel graphs you can find something like "smooth"
> connection to points. Therefore the method depends on what the OP means by
> smooth curve.
>

I think some of these let you manually set various parameters too to make
it look right - if the OP follows my advice,tries to define smooth in terms
of something data-relevant probably related to properties of derivatives, 
he will probably get to a point
where he can have more parameters than data and can set these things
to suite his imagination or artistic inclinations :)

> Regards
> Petr
>




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


[R] write.csv changes the format of the date

2010-11-01 Thread Santosh Srinivas
Dear Group,

Why does write.csv modify the date format when it write to a file.

I have the following variable Param_Dat:

dput(Param_Dat)
structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010",
class = "factor")), .Names = "Last_Successful_Run", class = "data.frame",
row.names = c(NA, 
-1L))


When I do:
write.csv(Param_Dat,"Param.csv",quote=F,row.names=F)

The format of the info in the file is:
Last_Successful_Run
31OCT2010

I want to retain the dd/mm/ format ...

Please advise.


--
Thanks R-Helpers. Yes, this is a silly question and it will not be repeated!
:-)

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


  1   2   >