Re: [R] read a text file with variable number of spaces

2011-03-03 Thread Gerrit Eichner

Hello, Gregory,

for your first data set see

?read.table

and for you second

?read.fwf

may help solving your problem.

Hth  --  Gerrit


On Thu, 3 Mar 2011, Gregory Ryslik wrote:


Hi,


I seem to be having somewhat of an unusual data input problem with some 
of the data sets I'm working with and want to run a simulation on.


in the first data set I'm looking at, I have a text file where the 
spacing between columns varies. I've attached a snippet. Is there a way 
to read this into R? Basically, I want to ignore all the spaces to make 
new columns. In a slightly different case, I have a long sequence of 
nucleotides (the letters are always either g,a,t,c). Is there a way to 
get each letter into it's own column so that I can then use it as a data 
set?


I'm kind of loathe to program a java/C program to do this if I don't 
have to and was wondering if a way in R exists for this.


Thanks!
Greg

Case1:
ACE2_YEAST  0.42  0.37  0.59  0.20  0.50  0.00  0.52  0.29  NUC
ACH1_YEAST  0.40  0.42  0.57  0.35  0.50  0.00  0.53  0.25  CYT
ACON_YEAST  0.60  0.40  0.52  0.46  0.50  0.00  0.53  0.22  MIT
ACR1_YEAST  0.66  0.55  0.45  0.19  0.50  0.00  0.46  0.22  MIT
ACT_YEAST   0.46  0.44  0.52  0.11  0.50  0.00  0.50  0.22  CYT
ACT2_YEAST  0.47  0.39  0.50  0.11  0.50  0.00  0.49  0.40  CYT
ACT3_YEAST  0.58  0.47  0.54  0.11  0.50  0.00  0.51  0.26  NUC
ACT5_YEAST  0.50  0.34  0.55  0.21  0.50  0.00  0.49  0.22  NUC

Case2:
gtacagtacgtacgtacgatcgatctagcatgcatgcatgcatgcta
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Creating a weighted sample - Help

2011-03-03 Thread Daniel Nordlund
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of P Ehlers
> Sent: Wednesday, March 02, 2011 10:29 PM
> To: LouiseS
> Cc: r-help@r-project.org
> Subject: Re: [R] Creating a weighted sample - Help
> 
> LouiseS wrote:
> > Hi
> >
> > I'm new to R and most things I want to do I can do but I'm stuck on how
> to
> > weight a sample.  I have had a look through the post but I can't find
> > anything that addresses my specific problem.  I am wanting to scale up a
> > sample which has been taken based on a single variable (perf) which has
> 4
> > attributes H,I, J and K.  The make up of the sample is shown below:-
> >
> > Perf Factored Count (A) Raw Count (B)   Factor (A/B)
> > H  5,945   2,924
> 2.033174
> > I  1,305   2,436
> 0.535714
> > J  2,000   2,092
> 0.956023
> > K   7501,225
> 0.612245
> >
> >
> > I then want to produce all further analysis based on this factored
> sample.
> > I can produce a weighted sample in SAS using the weight function which I
> > have shown below
> >
> > wt=0;
> > if perf='H' then wt=2.033174;
> > if perf='I ' then wt=0.535714;
> > if perf='J ' then wt=0.956023;
> > if perf='K ' then wt=0.612245;
> >
> > proc freq data=DD.new;
> > tables resdstat;
> > weight wt;
> > run;
> >
> > Does anyone know how to reproduce this in R?
> 
> I don't know what you mean by "all further analysis",
> but if you want weighted mean, variance, quantile, have
> a look at ?wtd.mean in the Hmisc package. Just use your
> A/B values in a weights vector.
> 
> Peter Ehlers
> 

You haven't told us how you obtained these data that you want to weight, but if 
you used some kind of non-SRS sampling plan (e.g. stratified, or cluster 
sample) then you should look at the survey package.

Dan

Daniel Nordlund
Bothell, WA USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.POSIXct show milliseconds with format

2011-03-03 Thread rivercode
Hi,

Trying to create a POSIXct index for an xts object that will display the
POSIXct index as HH:MM:SS.MMM.

First of all, I am trying to get the as.POSIXct to work with format...

> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST",
> format="%H:%M:%OS3")
[1] NA

Why is this returning NA ?

I can get Hours and Minutes...but only with the format as %H %M. 

> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST", format="%H
> %M")
[1] "2011-03-02 20:11:00 EST"

BUT if I do it with format="%H:%M" I also get an NA:
> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST",
> format="%H:%M")
[1] NA

What am I not understanding ?

Is it possible to create a POSIXct index for xts (or zoo) that will display
(eg. with head(my_xts_object) ) the index in format HH:MM:SS.MMM so I can
see the milliseconds.

Thanks,
Chris




--
View this message in context: 
http://r.789695.n4.nabble.com/as-POSIXct-show-milliseconds-with-format-tp3332733p3332733.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] What am I doing wrong with this loop ?

2011-03-03 Thread Scott Chamberlain
The "y" object within the loop returns a list and you are trying to put the 
first row of the 2nd column of the list (which refers to a vector of length 1 
to i) into the object z, which is vector. I am not sure at all what you are 
trying to end up with. 

Scott
On Wednesday, March 2, 2011 at 9:19 PM, eric wrote: 
> What is wrong with this loop ? I am getting an error saying incorrect number
> of dimensions y[i,2]
> 
> x <- as.data.frame(runif(2000, 12, 38))
> z <-numeric(length(x))
> y <- as.data.frame(z)
> for(i in 1:length(x)) {
>  y <- ifelse(i < 500, as.data.frame(lowess(x[1:i,1], f=1/9)) ,
> as.data.frame(lowess(x[(i-499):i,1], f=1/9))) 
>  z[i] <-y[i,2]
> }
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/What-am-I-doing-wrong-with-this-loop-tp3332703p3332703.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.


[R] Import/convert PMML to R model

2011-03-03 Thread Raji
Hi R-helpers,

 I have saved my kmeansModel as a pmml using the PMML package in R using the
following commands.

library(pmml)
pmml(kmeansModel)

I have to import this saved pmml model and save it in a kmeansModel again.
Can you please let me know the R commands to do that?

Thanks,
Raji

--
View this message in context: 
http://r.789695.n4.nabble.com/Import-convert-PMML-to-R-model-tp3332772p3332772.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] Reproducibility issue in gbm (32 vs 64 bit)

2011-03-03 Thread Patrick Connolly
On Sat, 26-Feb-2011 at 08:46AM -0800, Ridgeway, Greg wrote:

|> I have heard about this before happening on other
|> platforms. Frankly I'm not positive how this happens. My best guess
|> is that there's a tiny bit of numeric instability in the 9+ decimal
|> place so that on a given iteration a one variable choice at random
|> looks better than the other. Any other ideas?  Greg

I played around with this some time ago and noticed that it happens
only when there's perfect or very nearly perfect correlation.  I even
tried a third variable and it was ignored almost completely.  I
concluded it's highly unlikely to cause a problem since real data
wouldn't have perfectly correlated variables -- or if they did, they'd
be easy enough to detect.



|> 
|> - Original Message -
|> From: Joshua Wiley 
|> To: Axel Urbiz 
|> Cc: R-help@r-project.org ; Ridgeway, Greg
|> Sent: Fri Feb 25 22:16:02 2011
|> Subject: Re: [R] Reproducibility issue in gbm (32 vs 64 bit)
|> 
|> Hi Axel,
|> 
|> I do not have a nice explanation why the results differ off the top of
|> my head.  I can say I can replicate what you get on 32/64 (both
|> Windows 7) bit with the development version of R and gbm_1.6-3.1.
|> 
|> Here is an even simpler example that shows the difference:
|> 
|> gbmfit <- gbm(1:50 ~ I(50:1) + I(60:11), distribution = "gaussian")
|> summary(gbmfit)
|> 
|> I copied that package maintainer.
|> 
|> Cheers,
|> 
|> Josh
|> 
|> On Fri, Feb 25, 2011 at 7:29 PM, Axel Urbiz  wrote:
|> > Dear List,
|> >
|> > The gbm package on Win 7 produces different results for the
|> > relative importance of input variables in R 32-bit relative to R 64-bit. 
Any
|> > idea why? Any idea which one is correct?
|> >
|> > Based on this example, it looks like the relative importance of 2 perfectly
|> > correlated predictors is "diluted" by half in 32-bit, whereas in 64-bit, 
one
|> > of these predictors gets all the importance and the other gets none. I 
found
|> > this interesting.
|> >
|> > ### Sample code
|> >
|> > library(gbm)
|> > set.seed(12345)
|> > xc=matrix(rnorm(100*20),100,20)
|> > y=sample(1:2,100,replace=TRUE)
|> > xc[,2] <- xc[,1]
|> > gbmfit <- gbm(y~xc[,1]+xc[,2] +xc[,3], distribution="gaussian")
|> > summary(gbmfit)
|> >
|> > ### Results on R 2.12.0 (32-bit)
|> >
|> >      var  rel.inf
|> > 1 xc[, 3] 49.76143
|> > 2 xc[, 1] 27.27432
|> > 3 xc[, 2] 22.96425
|> >>
|> > ### Results on R 2.12.0 (64-bit)
|> >> summary(gbmfit)
|> >      var  rel.inf
|> > 1 xc[, 1] 50.23857
|> > 2 xc[, 3] 49.76143
|> > 3 xc[, 2]  0.0
|> >
|> > Thanks,
|> > Axel.
|> >
|> >        [[alternative HTML version deleted]]
|> >
|> > __
|> > R-help@r-project.org mailing list
|> > https://stat.ethz.ch/mailman/listinfo/r-help
|> > PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
|> > and provide commented, minimal, self-contained, reproducible code.
|> >
|> 
|> 
|> 
|> -- 
|> Joshua Wiley
|> Ph.D. Student, Health Psychology
|> University of California, Los Angeles
|> http://www.joshuawiley.com/
|> 
|> __
|> 
|> This email message is for the sole use of the intended recipient(s) and
|> may contain confidential information. Any unauthorized review, use,
|> disclosure or distribution is prohibited. If you are not the intended
|> recipient, please contact the sender by reply email and destroy all copies
|> of the original message.
|> __
|> R-help@r-project.org mailing list
|> https://stat.ethz.ch/mailman/listinfo/r-help
|> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
|> and provide commented, minimal, self-contained, reproducible code.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] Contingency table in R

2011-03-03 Thread Jim Lemon

On 03/03/2011 01:13 AM, Laura Clasemann wrote:


Hi,

I have a table in R with data I needed and need to create a contingency table 
out of it. The table I have so far looks like this:


Binger
r
DietType No Yes
   Dangerous  15  12
   Healthy52   9
   None  134  24
   Unhealthy  72  23

These are the error messages that I keep getting whenever I try to get a 
contingency table. I'm not sure why it won't work for me, any help would be 
appreciated!

nametable<-table(excat,recat)

Error in table(excat, recat) : object 'excat' not found


Hi Laura,
The above looks like a contingency table, but I suspect that it is in a 
format that is not recognized as such by R. If I read in the above, less 
the top two lines ("Binger" and "r"), I get a data frame.


lc.df<-read.table("lc.dat",header=TRUE)
lc.df
   DietType  No Yes
1 Dangerous  15  12
2   Healthy  52   9
3  None 134  24
4 Unhealthy  72  23

If I then try to run a chi-square test on the numeric columns of the 
data frame,


chisq.test(lc.df[,2:3])

Pearson's Chi-squared test

data:  lc.df[, 2:3]
X-squared = 14.5011, df = 3, p-value = 0.002297

I get the expected result. If the table in your message is something 
like a table in a word processing document or a text file, R doesn't 
know what it is. If it is indeed an R object (which I doubt) it probably 
isn't named "excat" (or "recat" for that matter). That may be what is 
causing the error message.


A final point is that you probably want your table arranged in order of 
the presumed healthiness of the diet, i.e.


Healthy
None
Unhealthy
Dangerous

because I think you are trying to discover whether bingers are more 
likely to report less healthy diets.


Jim

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


[R] R usage survey

2011-03-03 Thread Harsh
Hi R users,
I request members of the R community to consider filling a short survey
regarding the use of R.
The survey can be found at http://goo.gl/jw1ig

Please accept my apologies for posting here for a non-technical reason.

The data collected will be suitably analyzed and I'll post a link to the
results in the coming weeks.

Thank you all for your interest and for sharing your R usage information.

Regards,
Harsh Singhal

[[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] as.POSIXct show milliseconds with format

2011-03-03 Thread Gabor Grothendieck
On Wed, Mar 2, 2011 at 11:04 PM, rivercode  wrote:
> Hi,
>
> Trying to create a POSIXct index for an xts object that will display the
> POSIXct index as HH:MM:SS.MMM.
>
> First of all, I am trying to get the as.POSIXct to work with format...
>
>> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST",
>> format="%H:%M:%OS3")
> [1] NA
>
> Why is this returning NA ?
>
> I can get Hours and Minutes...but only with the format as %H %M.
>
>> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST", format="%H
>> %M")
> [1] "2011-03-02 20:11:00 EST"
>
> BUT if I do it with format="%H:%M" I also get an NA:
>> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST",
>> format="%H:%M")
> [1] NA
>
> What am I not understanding ?
>
> Is it possible to create a POSIXct index for xts (or zoo) that will display
> (eg. with head(my_xts_object) ) the index in format HH:MM:SS.MMM so I can
> see the milliseconds.
>

options(digits.secs = 3)

will cause 3 digits to be displayed.

Another thing you could do with zoo is that you could define your own
class that displays any way you like.  Here we have defined just
enough methods of a "mytime" class. This takes advantage of the fact
that zoo does not work with hard coded index classes but rather any
index class with sufficient methods will work with zoo:


library(zoo)

as.mytime <- function(x, ...) UseMethod("as.mytime")

as.mytime.character <- function(x, ...) {
x <- as.POSIXct(paste("1970-01-01", x), ...)
structure(x, class = c("mytime", class(x)))
}

as.mytime.POSIXt <- function(x, ...) {
structure(x, class = c("mytime", setdiff(class(x), "mytime")))
}

as.character.mytime <-
format.mytime <- function(x, format = "%H:%M:%OS3", ...) {
format.POSIXct(x, format = format, ...)
}

print.mytime <- function(x, ...) {
print(format(x), ...)
}

Ops.mytime <- function (e1, e2) {
as.mytime(NextMethod(.Generic))
}

z <- zooreg(1:15, start = as.mytime("13:14:15.100"), frequency = 10)
head(z)

The last line produces:

> head(z)
13:14:15.100 13:14:15.200 13:14:15.300 13:14:15.400 13:14:15.500 13:14:15.600
   123456

-- 
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] Multivariate Granger Causality Tests

2011-03-03 Thread hazzard
Dear Community,

For my masters thesis I need to perform a multivariate granger causality
test. I have found a code for bivariate testing on this page
(http://www.econ.uiuc.edu/~econ472/granger.R.txt), which I think would not
be useful for the multivariate case. Does anybody know a code for a
multivariate granger causality test. Thank you in advance.

Best Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Multivariate-Granger-Causality-Tests-tp3332968p3332968.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] Developing a web crawler

2011-03-03 Thread antujsrv
Hi,

I wish to develop a web crawler in R. I have been using the functionalities
available under the RCurl package.
I am able to extract the html content of the site but i don't know how to go
about analyzing the html formatted document.
I wish to know the frequency of a word in the document. I am only acquainted
with analyzing data sets.
So how should i go about analyzing data that is not available in table
format.

Few chunks of code that i wrote:
w <-
getURL("http://www.amazon.com/Kindle-Wireless-Reader-Wifi-Graphite/dp/B003DZ1Y8Q/ref=dp_reviewsanchor#FullQuotes";)
write.table(w,"test.txt")
t <- readLines(w) 

readLines also didnt prove out to be of any help.

Any help would be highly appreciated. Thanks in advance.


--
View this message in context: 
http://r.789695.n4.nabble.com/Developing-a-web-crawler-tp3332993p3332993.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] Applying function to multiple data

2011-03-03 Thread Akshata Rao
Dear R helpers,

I know R language at a preliminary level. This is my first post to this R
forum. I have recently learned the use of function and have been successful
in writing few on my own. However I am not able to figure out how to apply
the function to multiple sets of data.

# MY QUERY

Suppose I am having following data.frame

df = data.frame(k = c(1:8), ratings = c("A", "B", "C", "D", "E", "F", "G",
"H"),
default_frequency =
c(0.00229,0.01296,0.01794,0.04303,0.04641,0.06630,0.06862,0.06936))

# ---

DP = function(k, ODF, ratings)

{

n   <-  length(ODF)
tot_klnODF<-  sum(k*log(ODF))
tot_k <-  sum(k)
tot_lnODF <-  sum(log(ODF))
tot_k2   <-  sum(k^2)
slope<-  exp((n * tot_klnODF - tot_k * tot_lnODF)/(n * tot_k2 -
tot_k^2))
intercept   <-  exp((tot_lnODF - log(slope)* tot_k)/n)
IPD   <-  intercept * slope^k

return(data.frame(ratings = ratings, default_probability = round(IPD, digits
= 4)))

}

result = DP(k = df$k, ODF = df$default_frequency, ratings = df$ratings)

#


The above code fetches me following result. However, I am dealing with only
one set of data here as defined in 'df'.

> result

  ratings default_probability
1   A  0.0061
2   B  0.0094
3   C  0.0145
4   D  0.0222
5   E  0.0342
6   F  0.0527
7   G  0.0810
8   H  0.1247


# MY PROBLEM

Suppose I have data as given below

Classk  rating  default_frequency
Bank1 A0.00229
   2 B 0.01296
   3 C 0.01794
   4 D 0.04303
   5 E 0.04641
   6 F 0.06630
  7 G 0.06862
  8 H 0.06936
Corporate1 A 0.00101
  2 B 0.01433
  3 C 0.02711
  4 D 0.03701
  5 E 0.04313
  6 F 0.05600
  7 G 0.06041
  8 H 0.07112
Sovereign1 A 0.00210
  2 B 0.01014
  3 C 0.02001
  4 D 0.04312
  5 E 0.05114
  6 F 0.06801
  7 G 0.06997
  8 H 0.07404

So I need to use the function "DP" defined above to generate three sets of
results viz. for Bank, Corporate, Sovereign and save each of these results
as diffrent csv files say as bank.csv, corporate.csv etc. Again please note
that there could be say 'm' number of classes. I was trying to use the apply
function but things are not working for me. I will really apprecaite the
guidenace. I hope I am able to put up my query in a neat manner.

Regards and thanking you all in advance.

Akshata Rao

[[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] more boa plots questions

2011-03-03 Thread emj83
Can anyone help?
Thanks in advance Emma

--
View this message in context: 
http://r.789695.n4.nabble.com/more-boa-plots-questions-tp3330312p016.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] Greek character and R

2011-03-03 Thread Filoche
Dear R users.

In a loop, I set the title of my graph with :

mytitle = expression(paste(delta^13,'C Station ', i)
title(mytitle)

However, instead of using value of i, it will literally use "i" character.

Any one know the way to concatenate the value of i to the mathematical
expression?

With regards,
Phil



--
View this message in context: 
http://r.789695.n4.nabble.com/Greek-character-and-R-tp304p304.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] Creating a weighted sample - Help

2011-03-03 Thread LouiseS
Hi

Thanks for responses.  The sample I have taken is a random sample from H, I,
J and K.  The further analysis I want to do is all around bad debt rates so
it could be (H/H+I)*100 = Bad rate percentage also population stability
calculations that are all related to credit scoring.  I want to be able to
report back on any variable that I have in my data set based on my factored
counts (A) of 10,000 - so every calculation is based on 10,000 account in
the correct proportions.

Does his help?

Thanks once again
Louise

--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-a-weighted-sample-Help-tp3331842p311.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] vector("integer", length) : vector size specified is too large

2011-03-03 Thread Robert Guldemond
Good day to the R community,

 

I am interested to run the plot.count() function in the "untb" package.

My script is as follows:-

 

> library(untb)

> Community1 <- 

> structure(c(371,167,119,78,74,53,50,31,28,25,20,19,19,17,13,12,12,10,

> 9,9,8,8,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,3,3,3,2,2,2,2,2,2,2,1,1,1,1,1,

> 1,1,1,1,1,1,1,1), .Dim = 60, .Dimnames =
list(c("Spp.80","Spp.111","Spp.129",

>
"Spp.101","Spp.40","Spp.11","Spp.14","Spp.128","Spp.58","Spp.103","Spp.112",

> "Spp.50","Spp.115","Spp.31","Spp.86","Spp.92","Spp.108","Spp.79","Spp.81",

> "Spp.110","Spp.75","Spp.83","Spp.30","Spp.62","Spp.63","Spp.76","Spp.27",

> "Spp.87","Spp.102","Spp.121","Spp.22","Spp.33","Spp.67","Spp.109","Spp.1",

> "Spp.10","Spp.18","Spp.12","Spp.47","Spp.114","Spp.8","Spp.42","Spp.65",

>
"Spp.69","Spp.100","Spp.106","Spp.130","Spp.38","Spp.43","Spp.56","Spp.82",

>
"Spp.93","Spp.95","Spp.107","Spp.116","Spp.117","Spp.118","Spp.119","Spp.136
",

> "Spp.144")), class = c("count", "table"))

> Community1

> summary(unphi(phi(Community1)))

> plot.count(Community1,uncertainty=TRUE,expectation=TRUE,theta=NULL,n=10)

 

When I run this I get the following message:-

 

Error in vector("integer", length) : vector size specified is too large

In addition: Warning message:

In parts(J) : NAs introduced by coercion

 

Does anyone have any ideas for me why I get these error messages and what I
should

do to overcome this challenge?

 

Thank you in advance

 

Rob Guldemond

 

~~
Research Scientist
Conservation Ecology Research Unit
Department of Zoology and Entomology
University of Pretoria
Pretoria
0002
South Africa
tel: (+27) 12 420 3231
fax: (+27) 12 420 4523
cell: (+27) 83 770 9694
rguldem...@zoology.up.ac.za
  http://www.ceru.up.ac.za

~~ 


[[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] Developing a web crawler

2011-03-03 Thread rex.dwyer
Perl seems like a 10x better choice for the task, but try looking at the 
examples in ?strsplit to get started.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of antujsrv
Sent: Thursday, March 03, 2011 4:23 AM
To: r-help@r-project.org
Subject: [R] Developing a web crawler

Hi,

I wish to develop a web crawler in R. I have been using the functionalities
available under the RCurl package.
I am able to extract the html content of the site but i don't know how to go
about analyzing the html formatted document.
I wish to know the frequency of a word in the document. I am only acquainted
with analyzing data sets.
So how should i go about analyzing data that is not available in table
format.

Few chunks of code that i wrote:
w <-
getURL("http://www.amazon.com/Kindle-Wireless-Reader-Wifi-Graphite/dp/B003DZ1Y8Q/ref=dp_reviewsanchor#FullQuotes";)
write.table(w,"test.txt")
t <- readLines(w)

readLines also didnt prove out to be of any help.

Any help would be highly appreciated. Thanks in advance.


--
View this message in context: 
http://r.789695.n4.nabble.com/Developing-a-web-crawler-tp3332993p3332993.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.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] m out of n bootstrap

2011-03-03 Thread James Shaw
Can anyone confirm the formula for the m out of n bootstrap variance
estimator?  rq.boot applies a deflation factor directly to the
bootstrap estimates.  Presumably, the SE of the estimate of interest
is then taken to be the SD of the deflated estimates.  I have read
Bickel's and others' papers on this subject but have not seen an
explicit formula provided for the m out n variance estimator.

-- 
James W. Shaw, Ph.D., Pharm.D., M.P.H.
Assistant Professor
Department of Pharmacy Administration
College of Pharmacy
University of Illinois at Chicago
833 South Wood Street, M/C 871, Room 266
Chicago, IL 60612
Tel.: 312-355-5666
Fax: 312-996-0868
Mobile Tel.: 215-852-3045

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


Re: [R] Developing a web crawler

2011-03-03 Thread Alexy Khrabrov

On Mar 3, 2011, at 4:22 AM, antujsrv wrote:
> 
> I wish to develop a web crawler in R.

As Rex said, there are faster languages, but R string processing got better due 
to the stringr package (R Journal 2010-2).  When Hadley is done with it, it 
will be like having it all in R!

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


Re: [R] Greek character and R

2011-03-03 Thread rex.dwyer
mytitle = parse(text=paste("expression(paste(delta^13,'C Station ',",i,"))"))
title(mytitle)

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Filoche
Sent: Thursday, March 03, 2011 8:16 AM
To: r-help@r-project.org
Subject: [R] Greek character and R

Dear R users.

In a loop, I set the title of my graph with :

mytitle = expression(paste(delta^13,'C Station ', i)
title(mytitle)

However, instead of using value of i, it will literally use "i" character.

Any one know the way to concatenate the value of i to the mathematical
expression?

With regards,
Phil



--
View this message in context: 
http://r.789695.n4.nabble.com/Greek-character-and-R-tp304p304.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.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 usage survey

2011-03-03 Thread rex.dwyer
Harsh, "Suitably analyzed" for whose purposes?  One man's "suitable" is 
another's "outrageous". That's why people want to see the gowns at the Oscars.  
Under what auspices are you conducting this survey?  What do you intend to do 
with it?  You don't give any assurance that the results you post won't have 
personally identifiable information. I don't get the impression that you know 
much about survey design.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Harsh
Sent: Thursday, March 03, 2011 5:53 AM
To: r-help@r-project.org
Subject: [R] R usage survey

Hi R users,
I request members of the R community to consider filling a short survey
regarding the use of R.
The survey can be found at http://goo.gl/jw1ig

Please accept my apologies for posting here for a non-technical reason.

The data collected will be suitably analyzed and I'll post a link to the
results in the coming weeks.

Thank you all for your interest and for sharing your R usage information.

Regards,
Harsh Singhal

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




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multivariate Granger Causality Tests

2011-03-03 Thread Pfaff, Bernhard Dr.
Dear Hazzard I. Petzev,

you might find causality() in the package vars useful.

Best,
Bernhard 

> -Ursprüngliche Nachricht-
> Von: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Im Auftrag von hazzard
> Gesendet: Donnerstag, 3. März 2011 10:07
> An: r-help@r-project.org
> Betreff: [R] Multivariate Granger Causality Tests
> 
> Dear Community,
> 
> For my masters thesis I need to perform a multivariate 
> granger causality test. I have found a code for bivariate 
> testing on this page 
> (http://www.econ.uiuc.edu/~econ472/granger.R.txt), which I 
> think would not be useful for the multivariate case. Does 
> anybody know a code for a multivariate granger causality 
> test. Thank you in advance.
> 
> Best Regards
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Multivariate-Granger-Causality-T
ests-tp3332968p3332968.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.
> 
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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

2011-03-03 Thread Kenn Konstabel
Dear all,

I've used RODBC a lot to read in files created in MS excel and access but
found a strange problem today: a variable in my data file contained both
numbers and text; sqlFetch would set text within a row of numbers to NA; but
if first 5 or 6 rows would be text then all numbers would be read in as NA.

con<-odbcConnectExcel("xample.xls")   #the file is attached or at
http://psych.ut.ee/~nek/ajutine/xample.xls
sqlFetch(con, "TT$")
# ID_NO Setting_ID
#1   NA NA
#2  122  12203
# 3  1220001  12203
#etc

Whereas the same file saved as csv reads in correctly as:

read.csv("xample.csv")
# ID_NO Setting_ID
#1b  a
#2  122  12203
#3  1220001  12203
#4  1220002  12202
#5  1220003  12202
#etc

Can anyone explain why it would behave like this?

#just in case:
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] RODBC_1.3-2

loaded via a namespace (and not attached):
[1] iterators_1.0.3 tools_2.12.1



Thanks in advance,
Kenn

Kenn Konstabel
Department of Chronic Diseases
National Institute for Health Development
Hiiu 42
Tallinn, Estonia
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] sqlFetch (RODBC) question

2011-03-03 Thread Ista Zahn
Hi Kenn,
This is discussed in the package vignette, section 7.

Best,
Ista
On Thu, Mar 3, 2011 at 2:55 PM, Kenn Konstabel  wrote:
> Dear all,
>
> I've used RODBC a lot to read in files created in MS excel and access but
> found a strange problem today: a variable in my data file contained both
> numbers and text; sqlFetch would set text within a row of numbers to NA; but
> if first 5 or 6 rows would be text then all numbers would be read in as NA.
>
> con<-odbcConnectExcel("xample.xls")   #the file is attached or at
> http://psych.ut.ee/~nek/ajutine/xample.xls
> sqlFetch(con, "TT$")
> #     ID_NO Setting_ID
> #1       NA         NA
> #2  122      12203
> # 3  1220001      12203
> #etc
>
> Whereas the same file saved as csv reads in correctly as:
>
> read.csv("xample.csv")
> #     ID_NO Setting_ID
> #1        b          a
> #2  122      12203
> #3  1220001      12203
> #4  1220002      12202
> #5  1220003      12202
> #etc
>
> Can anyone explain why it would behave like this?
>
> #just in case:
>> sessionInfo()
> R version 2.12.1 (2010-12-16)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252
> [2] LC_CTYPE=English_United Kingdom.1252
> [3] LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] RODBC_1.3-2
>
> loaded via a namespace (and not attached):
> [1] iterators_1.0.3 tools_2.12.1
>
>
>
> Thanks in advance,
> Kenn
>
> Kenn Konstabel
> Department of Chronic Diseases
> National Institute for Health Development
> Hiiu 42
> Tallinn, Estonia
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


[R] Ordering several histograms

2011-03-03 Thread djbirdnerd
Hallo everyone,

I want to evaluate the change of the distribution for several size classes.
How can i order these separate histograms with the same y-axis along a
common x-axis according to their size classes. It would like it to look a
bit like this
(http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109) without
the quantile regression. I can produce the separate histograms, but have no
clue how to merge them. i can put them next to each with separate x- and
y-axes. 

Much obliged,

Kenneth



--
View this message in context: 
http://r.789695.n4.nabble.com/Ordering-several-histograms-tp382p382.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] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Dear all,
I am a newbie in R and could not find help on this problem. I am trying to
plot an histogram with probabilities in the y axis. This is the code I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
xlab="Média", ylab="Probabilidade")
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")

The problem is that I am getting greater than 1 probabilities in the Y axis?
Is there a way to correct this?
Many thanks in advance.
Joao

--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.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] Developing a web crawler / R "webkit" or something similar?

2011-03-03 Thread Mike Marchywka







> Date: Thu, 3 Mar 2011 01:22:44 -0800
> From: antuj...@gmail.com
> To: r-help@r-project.org
> Subject: [R] Developing a web crawler
>
> Hi,
>
> I wish to develop a web crawler in R. I have been using the functionalities
> available under the RCurl package.
> I am able to extract the html content of the site but i don't know how to go

In general this can be a big effort but there may be things in 
text processing packages you could adapt to execute html and javascript.
However, I guess what I'd be looking for is something like a "webkit"
package or other open source browser with or without an "R" interface.
This actually may be an ideal solution for a lot of things as you get
all the content handlers of at least some browser. 


Now that you mention it, I wonder if there are browser plugins to handle
"R" content ( I'd have to give this some thought, put a script up as
a web page with mime type "test/R" and have it execute it in R. )



> about analyzing the html formatted document.
> I wish to know the frequency of a word in the document. I am only acquainted
> with analyzing data sets.
> So how should i go about analyzing data that is not available in table
> format.
>
> Few chunks of code that i wrote:
> w <-
> getURL("http://www.amazon.com/Kindle-Wireless-Reader-Wifi-Graphite/dp/B003DZ1Y8Q/ref=dp_reviewsanchor#FullQuotes";)
> write.table(w,"test.txt")
> t <- readLines(w)
>
> readLines also didnt prove out to be of any help.
>
> Any help would be highly appreciated. Thanks in advance.
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Developing-a-web-crawler-tp3332993p3332993.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] R usage survey

2011-03-03 Thread Harsh
Hi Rex and useRs,

The purpose of the survey has been mentioned on the survey link goo.gl/jw1ig
but I will also reproduce it here.
- Geographical distribution of R users
- Application areas where R is being used
- Supporting technology being used along with R
- Academic background distribution of R users

The potential personally identifiable information such as name and employer
name are optional fields. Actually all the fields in the survey are
optional.

Some of the analysis output(s) could be along the lines of :-
- Usage statistics of various R packages
- Distribution of R users across countries/cities
- Mapping various applications to packages
- Text Mining of the responses to create informative word clouds

Personally, I am excited about the kind of data I will receive through this
survey and the various insights that could be derived. As already mentioned,
the results will be shared with the community.

Thank you Rex for raising an important point. It is indeed necessary for me
to personally assure the user community that the results will be shared in a
manner that will not contain any personally identifiable information.

Those who wish to gain access to the raw data will be provided with all the
fields but not the name and employer name fields.

Just out of curiosity : It is possible to get name, employer name, location,
usage information and academic background details when searching for R users
on LinkedIn and the many R related groups there.
Does this also provide potential opportunities for misuse and "outrageous"
analyses, since almost anyone can get onto LinkedIn and access user profiles
?

Thank you for your interest and support.
Regards,
Harsh












On Thu, Mar 3, 2011 at 8:02 PM,  wrote:

> Harsh, "Suitably analyzed" for whose purposes?  One man's "suitable" is
> another's "outrageous". That's why people want to see the gowns at the
> Oscars.  Under what auspices are you conducting this survey?  What do you
> intend to do with it?  You don't give any assurance that the results you
> post won't have personally identifiable information. I don't get the
> impression that you know much about survey design.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Harsh
> Sent: Thursday, March 03, 2011 5:53 AM
> To: r-help@r-project.org
> Subject: [R] R usage survey
>
> Hi R users,
> I request members of the R community to consider filling a short survey
> regarding the use of R.
> The survey can be found at http://goo.gl/jw1ig
>
> Please accept my apologies for posting here for a non-technical reason.
>
> The data collected will be suitably analyzed and I'll post a link to the
> results in the coming weeks.
>
> Thank you all for your interest and for sharing your R usage information.
>
> Regards,
> Harsh Singhal
>
> [[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.
>
>
>
>
> message may contain confidential information. If you are not the designated
> recipient, please notify the sender immediately, and delete the original and
> any copies. Any use of the message by you is prohibited.
>
>

[[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] Zero truncated Poisson distribution & R2WinBUGS

2011-03-03 Thread Timothée
Hi,
I have a very similar problem...
In some sites, counts data>0
In the other sites, counts = 0
I already applied zero inflated models with the zero-trick (Martin et al
2005 in Ecology letters), but I would like to use truncated distributions
(Poisson and negative binomial) to model my counts in order to estimate the
number of sites where no counts but presence.
The problem is that I can't manage to write the likelihood of such truncated
distributions.
Did you get any valuable answers to your post ?
Would you mind to share with me how you succeeded (if so) ?
Thank you very much
Timothée

--
View this message in context: 
http://r.789695.n4.nabble.com/Zero-truncated-Poisson-distribution-R2WinBUGS-tp3043121p406.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] Greek character and R

2011-03-03 Thread Filoche
Hi and ty for the answer.

However, it's not working. It will print "expression(d13C Station 1)".

Thank for any help,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Greek-character-and-R-tp304p467.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] Applying function to multiple data

2011-03-03 Thread Ivan Calandra

Hi,

It might not be the best approach, but here is what I would do.

##

1) If you have your data in 3 different data.frames:

#create a named list where each element is one of your data.frame
list_df <- vector(mode="list", length=3)
names(list_df) <- c("Bank", "Corporate", "Sovereign")

list_df[[1]] <- data.frame(k = c(1:8), ratings = c("A", "B", "C", "D", 
"E", "F", "G","H"), default_frequency = 
c(0.00229,0.01296,0.01794,0.04303,0.04641,0.06630,0.06862,0.06936))
list_df[[2]] <- data.frame(k = c(1:8), ratings = c("A", "B", "C", "D", 
"E", "F", "G","H"), default_frequency = 
c(0.00101,0.01433,0.02711,0.03701,0.04313,0.05600,0.06041,0.07112))
list_df[[3]] <- data.frame(k = c(1:8), ratings = c("A", "B", "C", "D", 
"E", "F", "G","H"), default_frequency = 
c(0.00210,0.01014,0.02001,0.04312,0.05114,0.06801,0.06997,0.07404))


#apply your function DP to each element of the list, i.e. to each 
data.frame:
out1 <- lapply(list_df, FUN=function(x) DP(k=x$k, 
ODF=x$default_frequency, ratings=x$ratings))


##

2) If you have your data in a single data.frame, as it looks from your 
example, I would first fill all the cells, so that it looks like this:


df2 <- structure(list(Class = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), 
.Label = c("Bank", "Corporate", "Sovereign"), class = "factor"), k = 
c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L), rating = structure(c(1L, 2L, 3L, 4L, 5L, 
6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L), .Label = c("A", "B", "C", "D", "E", "F", "G", "H"), class = 
"factor"), default_frequency = c(0.00229, 0.01296, 0.01794, 0.04303, 
0.04641, 0.0663, 0.06862, 0.06936, 0.00101, 0.01433, 0.02711, 0.03701, 
0.04313, 0.056, 0.06041, 0.07112, 0.0021, 0.01014, 0.02001, 0.04312, 
0.05114, 0.06801, 0.06997, 0.07404)), .Names = c("Class", "k", 
"ratings", "default_frequency"), class = "data.frame", row.names = c(NA, 
-24L))


#then split by Class:
list_df2 <- split(df2, df2$Class)
#and apply as before:
out2 <- lapply(list_df2, FUN=function(x) DP(k=x$k, 
ODF=x$default_frequency, ratings=x$ratings))


#or in one step using plyr:
library(plyr)
out3 <- dlply(.data=df2, .variables="Class", .fun=function(x) DP(k=x$k, 
ODF=x$default_frequency, ratings=x$ratings))



##

3) all solutions give the same results:

all.equal(out1, out2, check.attributes=FALSE)
[1] TRUE
all.equal(out1, out3, check.attributes=FALSE)
[1] TRUE
all.equal(out2, out3, check.attributes=FALSE)
[1] TRUE


HTH,
Ivan




Le 3/3/2011 11:06, Akshata Rao a écrit :

Dear R helpers,

I know R language at a preliminary level. This is my first post to this R
forum. I have recently learned the use of function and have been successful
in writing few on my own. However I am not able to figure out how to apply
the function to multiple sets of data.

# MY QUERY

Suppose I am having following data.frame

df = data.frame(k = c(1:8), ratings = c("A", "B", "C", "D", "E", "F", "G",
"H"),
default_frequency =
c(0.00229,0.01296,0.01794,0.04303,0.04641,0.06630,0.06862,0.06936))

# ---

DP = function(k, ODF, ratings)

{

n<-  length(ODF)
tot_klnODF<-  sum(k*log(ODF))
tot_k<-  sum(k)
tot_lnODF<-  sum(log(ODF))
tot_k2<-  sum(k^2)
slope<-  exp((n * tot_klnODF - tot_k * tot_lnODF)/(n * tot_k2 -
tot_k^2))
intercept<-  exp((tot_lnODF - log(slope)* tot_k)/n)
IPD<-  intercept * slope^k

return(data.frame(ratings = ratings, default_probability = round(IPD, digits
= 4)))

}

result = DP(k = df$k, ODF = df$default_frequency, ratings = df$ratings)

#


The above code fetches me following result. However, I am dealing with only
one set of data here as defined in 'df'.


result

   ratings default_probability
1   A  0.0061
2   B  0.0094
3   C  0.0145
4   D  0.0222
5   E  0.0342
6   F  0.0527
7   G  0.0810
8   H  0.1247


# MY PROBLEM

Suppose I have data as given below

Classk  rating  default_frequency
Bank1 A0.00229
2 B 0.01296
3 C 0.01794
4 D 0.04303
5 E 0.04641
6 F 0.06630
   7 G 0.06862
   8 H 0.06936
Corporate1 A 0.00101
   2 B 0.01433
   3 C 0.02711
   4 D 0.03701
   5 E 0.04313
   6 F 0.05600
   7 G 0.0604

Re: [R] Greek character and R

2011-03-03 Thread Duncan Murdoch

On 11-03-03 8:15 AM, Filoche wrote:

Dear R users.

In a loop, I set the title of my graph with :

mytitle = expression(paste(delta^13,'C Station ', i)
title(mytitle)

However, instead of using value of i, it will literally use "i" character.

Any one know the way to concatenate the value of i to the mathematical
expression?



Use

mytitle <- substitute(paste(delta^13,'C Station ', ival), list(ival=i))

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] Greek character and R

2011-03-03 Thread rex.dwyer
Eval it.  This works at my house:

plot(0)
title(eval(parse(text=paste("expression(paste(delta^13,'C Station ',",i,"))"

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Filoche
Sent: Thursday, March 03, 2011 9:39 AM
To: r-help@r-project.org
Subject: Re: [R] Greek character and R

Hi and ty for the answer.

However, it's not working. It will print "expression(d13C Station 1)".

Thank for any help,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Greek-character-and-R-tp304p467.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.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 usage survey

2011-03-03 Thread rex.dwyer

Just out of curiosity : It is possible to get name, employer name, location, 
usage information and academic background details when searching for R users on 
LinkedIn and the many R related groups there.
Does this also provide potential opportunities for misuse and "outrageous"  
analyses, since almost anyone can get onto LinkedIn and access user profiles ?
[Dwyer Rex USRE] That's a no-brainer: YES!

On Thu, Mar 3, 2011 at 8:02 PM, 
mailto:rex.dw...@syngenta.com>> wrote:
Harsh, "Suitably analyzed" for whose purposes?  One man's "suitable" is 
another's "outrageous". That's why people want to see the gowns at the Oscars.  
Under what auspices are you conducting this survey?  What do you intend to do 
with it?  You don't give any assurance that the results you post won't have 
personally identifiable information. I don't get the impression that you know 
much about survey design.

-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On 
Behalf Of Harsh
Sent: Thursday, March 03, 2011 5:53 AM
To: r-help@r-project.org
Subject: [R] R usage survey

Hi R users,
I request members of the R community to consider filling a short survey
regarding the use of R.
The survey can be found at http://goo.gl/jw1ig

Please accept my apologies for posting here for a non-technical reason.

The data collected will be suitably analyzed and I'll post a link to the
results in the coming weeks.

Thank you all for your interest and for sharing your R usage information.

Regards,
Harsh Singhal
   [[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.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited.




message may contain confidential information. If you are not the designated 
recipient, please notify the sender immediately, and delete the original and 
any copies. Any use of the message by you is prohibited. 

[[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] Probabilities greather than 1 in HIST

2011-03-03 Thread Jonathan P Daily
If you read ?hist, you will answer your own question.

The issue in your code is the parameter prob = T, which does nothing. By 
default, hist reports density.
--
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

r-help-boun...@r-project.org wrote on 03/03/2011 09:03:21 AM:

> [image removed] 
> 
> [R] Probabilities greather than 1 in HIST
> 
> jpmaroco 
> 
> to:
> 
> r-help
> 
> 03/03/2011 10:13 AM
> 
> Sent by:
> 
> r-help-boun...@r-project.org
> 
> Dear all,
> I am a newbie in R and could not find help on this problem. I am trying 
to
> plot an histogram with probabilities in the y axis. This is the code I 
am
> using:
> 
> #TLC uniform
> n=30
> mi=1; mx=6
> nrep=1000
> xbar=rep(0,nrep)
> for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
> hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
> xlab="Média", ylab="Probabilidade")
> curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")
> 
> The problem is that I am getting greater than 1 probabilities in the Y 
axis?
> Is there a way to correct this?
> Many thanks in advance.
> Joao
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/
> Probabilities-greather-than-1-in-HIST-tp388p388.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.

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


Re: [R] Greek character and R

2011-03-03 Thread William Dunlap


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
> Sent: Thursday, March 03, 2011 7:30 AM
> To: Filoche
> Cc: r-help@r-project.org
> Subject: Re: [R] Greek character and R
> 
> On 11-03-03 8:15 AM, Filoche wrote:
> > Dear R users.
> >
> > In a loop, I set the title of my graph with :
> >
> > mytitle = expression(paste(delta^13,'C Station ', i)
> > title(mytitle)
> >
> > However, instead of using value of i, it will literally use 
> "i" character.
> >
> > Any one know the way to concatenate the value of i to the 
> mathematical
> > expression?
> >
> 
> Use
> 
> mytitle <- substitute(paste(delta^13,'C Station ', ival),
list(ival=i))

Or use bquote():
  mytitle <- bquote(paste(delta^13,'C Station ', .(i)))

Note that the original could not have worked since 'i' and 'delta'
appeared in the same manner and you only wanted i replaced by it
value.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Analytical Hierarchical Process (AHP) in R?

2011-03-03 Thread Rainer M Krug
Hi

Does anybody know anything about an implementation of an AHP in R or
any other open source tool?

I googled but could not find anything

Thanks,

Rainer


-- 
NEW GERMAN FAX NUMBER!!!

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

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

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

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Course***Advanced Statistical Modeling in R by XLSolutions Corp

2011-03-03 Thread Sue Turner
Our New York City course: Advanced Statistical Modelling in R/S-PLUS

is coming up on  March 14-15 

http://www.xlsolutions-corp.com/coursedetail.asp?id=13

by  XLSolutions Corp

Email   s...@xlsolutions-corp.com

Regards - 

Sue Turner 
Senior Account Manager 
XLSolutions Corporation 
North American Division 
1700 7th Ave 
Suite 2100 
Seattle, WA 98101 
Phone: 206-686-1578 
Email: sue at xlsolutions-corp.com 
web: www.xlsolutions-corp.com/rcourses 

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:


Dear all,
I am a newbie in R and could not find help on this problem. I am  
trying to
plot an histogram with probabilities in the y axis. This is the code  
I am

using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
xlab="Média", ylab="Probabilidade")
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")

The problem is that I am getting greater than 1 probabilities in the  
Y axis?

Is there a way to correct this?


Despite the argument name, which I agree suggests that probabilities  
will be plotted, what is really described in the help page is that  
densities will be plotted, and densities may be greater than 1. You  
can suppress plotting of the y-axis, calculate the probabilities for  
each of the groups returned by hist,  and then use the axes function.


> xhist <- hist(xbar,breaks="Sturges",plot=FALSE)
> yhist <- xhist$counts/sum(xhist$counts)
> yhist
 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001




Many thanks in advance.
Joao

--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Pairwise T-Tests and Dunnett's Test (possibly using multcomp)

2011-03-03 Thread Paul Miller
Hi Josh,
 
Thanks for your reply. You're right about letting R's method dispatch system 
choose the method for summary and inserting more spaces in the code. I was just 
messing around with the code in the former case and forgot to change it back. 
As far as not having enough whitespace goes, I've been learning using The R 
Book and this may have caused me to learn some bad habits. I actually like The 
R Book a lot and have been able to learn a great deal from it. I've seen a few 
people comment about the lack of whitespace in the code though, and so this is 
something I'll need to change.
 
Your comment about editing the contrast matrix is interesting. I tried it out 
with my own code with the few moments I had this morning (see below). One thing 
I noticed immediately is that altering the contrast matrix, and then running 
the model, and then running Dunnett's test using multcomp doesn't work 
correctly. That is, the reference level for Dunnett's test is still "HI." If 
you use relevel though, the reference level for Dunnett's test is correct.
 
I haven't had time to investigate this yet. I get the impression though that 
editing the contract matrix is somewhat like using the "ref=" option in SAS 
procedures in that the change in the reference parameter doesn't (necessarily) 
carry over into subsequent analyses. That was one of the things I thought was 
so great about relevel. You set the reference level once and it stays set until 
you decide to change it.
 
Anyway, this was very interesting and informative.
 
Thanks for your help.
 
Paul
 
connection <- textConnection("
101 LO 21  104 LO 18
106 LO 19  110 LO  .
112 LO 28  116 LO 22
120 LO 30  121 LO 27
124 LO 28  125 LO 19
130 LO 23  136 LO 22
137 LO 20  141 LO 19
143 LO 26  148 LO 35
152 LO  .  103 HI 16
105 HI 21  109 HI 31
111 HI 25  113 HI 23
119 HI 25  123 HI 18
127 HI 20  128 HI 18
131 HI 16  135 HI 24
138 HI 22  140 HI 21
142 HI 16  146 HI 33
150 HI 21  151 HI 17
102 PB 22  107 PB 26
108 PB 29  114 PB 19
115 PB  .  117 PB 33
118 PB 37  122 PB 25
126 PB 28  129 PB 26
132 PB  .  133 PB 31
134 PB 27  139 PB 30
144 PB 25  145 PB 22
147 PB 36  149 PB 32
")
 
gad <- data.frame(scan(connection,
   list(patno=0, dosegrp="", hama=0), na.strings="."))
 
 ANOVA 
 
#gad$dosegrp <- relevel(gad$dosegrp, 3)
#contrasts(gad$dosegrp) <- contr.treatment(n = 3, base = 3)
model1 <- aov(hama ~ dosegrp, data = gad)
summary(model1)
 
 Dunnett's Test 
 
library(multcomp)
cht <- glht(model1, linfct = mcp(dosegrp = "Dunnett"))
summary(cht, test = univariate())



[[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] Recodifying a factor due to results in lm

2011-03-03 Thread agent dunham
Dear community, 

I'm doing a lm. In the independent variables I've got a categorical one.
Here is its histogram: 
http://r.789695.n4.nabble.com/file/n638/altitude.png 

I did this regression:

lmeo2.52f <- lm(dat82$IncAltuDom ~ dat82$hdom2+log(dat82$CV)+ dat82$CA+
dat82$FCC+ factor(dat82$IdAltitud))

I obtain: 


Coefficients:
 Estimate Std. Error t value Pr(>|t|)
(Intercept)   8.782220.94619   9.282 3.72e-15 ***
dat82$hdom2  -0.308590.03875  -7.963 2.73e-12 ***
log(dat82$CV)-0.429430.24568  -1.748   0.0835 .  
dat82$CA -2.981572.29904  -1.297   0.1977
dat82$FCC 0.023000.01067   2.156   0.0335 *  
factor(dat82$IdAltitud)1 -0.121420.40361  -0.301   0.7642
factor(dat82$IdAltitud)2  0.243410.43451   0.560   0.5766
factor(dat82$IdAltitud)3 -0.649040.47114  -1.378   0.1714
factor(dat82$IdAltitud)4 -1.143340.67509  -1.694   0.0935 .  
factor(dat82$IdAltitud)5 -2.132510.82463  -2.586   0.0112 *  


I thought I need to recodify my factor, 

q1 How can I do it?

q2 Apologies I'm pretty newbie with this, ... I don't know how to interpret
the regression when factors ... The factors created by  default, compare the
1st factor with the other 5?  ... but what does it mean??? is it good in my
case ??

Thanks in advance, u...@host.com


--
View this message in context: 
http://r.789695.n4.nabble.com/Recodifying-a-factor-due-to-results-in-lm-tp638p638.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] Ordering several histograms

2011-03-03 Thread Scott Chamberlain
You could get close with the ggplot2 package using the function facet_grid or 
facet_wrap, but each histogram would be on a separate x-axis

Scott
On Thursday, March 3, 2011 at 8:00 AM, djbirdnerd wrote: 
> Hallo everyone,
> 
> I want to evaluate the change of the distribution for several size classes.
> How can i order these separate histograms with the same y-axis along a
> common x-axis according to their size classes. It would like it to look a
> bit like this
> (http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109) without
> the quantile regression. I can produce the separate histograms, but have no
> clue how to merge them. i can put them next to each with separate x- and
> y-axes. 
> 
> Much obliged,
> 
> Kenneth
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Ordering-several-histograms-tp382p382.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.


[R] Error in model.frame.default

2011-03-03 Thread Heike Schmitz

Dear R- Community,

to learn i reanalysed some data provided and analysed by Zuur et. al. in 
their book "Mixed effect models and Extensions in Ecology with R". When 
i run the last command i get a warning message i dont understand.



Loyn<- read.table(file = "loyn.txt",header = TRUE)
Loyn$L.AREA<- log10(Loyn$AREA)
fGRAZE <-factor(Loyn$GRAZE)

M0<- lm(ABUND~ L.AREA + fGRAZE, data = Loyn)
summary(M0)

plot(x = Loyn$L.AREA, y = Loyn$ABUND,
xlab = "Log transformed AREA",
ylab = "Bird Abundance")

D1<- data.frame(L.AREA= Loyn$L.AREA[Loyn$GRAZE==1], fGraze = "1")
P1<- predict(M0,newdata = D1)

Warning message:
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev 
= object$xlevels) :

  variable lengths differ (found for 'fGRAZE')
In addition: Warning message:
'newdata' had 13 rows but variable(s) found have 56 rows

I hope anyone has an idea.
Thank you in advance.
Heike

--
Heike Schmitz- Diaspero
Population Ecology and Evolutionary Ecology Lab, FB2
University of Bremen
Leobener Strasse, Nw2, Room B4050
D-28359 Bremen
Germany
fon ++49-421-218-62937
email: heike.schm...@uni-bremen.de

http://www.popecol.uni-bremen.de

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


Re: [R] Multivariate Granger Causality Tests

2011-03-03 Thread Frank Harrell
Beware that causality can only be inferred using information that extends far
beyond the data at hand.

Frank

-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Multivariate-Granger-Causality-Tests-tp3332968p652.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] Developing a web crawler

2011-03-03 Thread Stefan Th. Gries
Hi

The book whose companion website is here

deals with many of the things you need for a web crawler, and
assignment "other 5" on that site
()
is a web crawler.

Best,
STG
--
Stefan Th. Gries
---
University of California, Santa Barbara
http://www.linguistics.ucsb.edu/faculty/stgries

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


Re: [R] Zero truncated Poisson distribution & R2WinBUGS

2011-03-03 Thread Achim Zeileis

On Thu, 3 Mar 2011, Timothée wrote:


Hi,
I have a very similar problem...
In some sites, counts data>0
In the other sites, counts = 0
I already applied zero inflated models with the zero-trick (Martin et al
2005 in Ecology letters), but I would like to use truncated distributions
(Poisson and negative binomial) to model my counts in order to estimate the
number of sites where no counts but presence.
The problem is that I can't manage to write the likelihood of such truncated
distributions.


If you're looking for a maximum likelihood regression model (without 
random effects), then the "countreg" package on R-Forge may be helpful for 
you.


The package is not yet on CRAN because we are planning to add more 
functionality, but the code is well tested. It's the same code-base 
underlying zeroinfl() and hurdle() in "pscl".


hth,
Z


Did you get any valuable answers to your post ?
Would you mind to share with me how you succeeded (if so) ?
Thank you very much
Timothée

--
View this message in context: 
http://r.789695.n4.nabble.com/Zero-truncated-Poisson-distribution-R2WinBUGS-tp3043121p406.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] Greek character and R

2011-03-03 Thread Eik Vettorazzi
or even without using 'paste'

plot(1,1,main=bquote(delta^13~'C Station'~.(i)))


Am 03.03.2011 16:45, schrieb William Dunlap:
> 
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com  
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org 
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
>> Sent: Thursday, March 03, 2011 7:30 AM
>> To: Filoche
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Greek character and R
>>
>> On 11-03-03 8:15 AM, Filoche wrote:
>>> Dear R users.
>>>
>>> In a loop, I set the title of my graph with :
>>>
>>> mytitle = expression(paste(delta^13,'C Station ', i)
>>> title(mytitle)
>>>
>>> However, instead of using value of i, it will literally use 
>> "i" character.
>>>
>>> Any one know the way to concatenate the value of i to the 
>> mathematical
>>> expression?
>>>
>>
>> Use
>>
>> mytitle <- substitute(paste(delta^13,'C Station ', ival),
> list(ival=i))
> 
> Or use bquote():
>   mytitle <- bquote(paste(delta^13,'C Station ', .(i)))
> 
> Note that the original could not have worked since 'i' and 'delta'
> appeared in the same manner and you only wanted i replaced by it
> value.
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com 
> 
>>
>> 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-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative frequencies? If I 
use

>plot(xhist,yhist)

I get absolute frequencies in the Y axis.

Best,

Joao

 

From: David Winsemius [via R] 
[mailto:ml-node+619-1272092771-215...@n4.nabble.com] 
Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST

 


On Mar 3, 2011, at 8:03 AM, jpmaroco wrote: 


> Dear all, 
> I am a newbie in R and could not find help on this problem. I am   
> trying to 
> plot an histogram with probabilities in the y axis. This is the code   
> I am 
> using: 
> 
> #TLC uniform 
> n=30 
> mi=1; mx=6 
> nrep=1000 
> xbar=rep(0,nrep) 
> for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))} 
> hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n), 
> xlab="Média", ylab="Probabilidade") 
> curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red") 
> 
> The problem is that I am getting greater than 1 probabilities in the   
> Y axis? 
> Is there a way to correct this? 


Despite the argument name, which I agree suggests that probabilities   
will be plotted, what is really described in the help page is that   
densities will be plotted, and densities may be greater than 1. You   
can suppress plotting of the y-axis, calculate the probabilities for   
each of the groups returned by hist,  and then use the axes function. 

 > xhist <- hist(xbar,breaks="Sturges",plot=FALSE) 
 > yhist <- xhist$counts/sum(xhist$counts) 
 > yhist 
  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001 




> Many thanks in advance. 
> Joao 
> 
> -- 
> View this message in context: 
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
>  
> 
>  
> Sent from the R help mailing list archive at Nabble.com. 
> [[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. 


David Winsemius, MD 
Heritage Laboratories 
West Hartford, CT 

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



  _  

If you reply to this email, your message will be added to the discussion below:

http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
 

To unsubscribe from Probabilities greather than 1 in HIST, click here 

 . 



--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.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.


[R] Calling a function to store values

2011-03-03 Thread kparamas
Hi,

I am calling a function with different arguments to read different files and
want the results to be stored in
different matrices.

Ex:
cData1 = NULL
cData2 = NULL

readData = function(cData, start, end)
{


   cData = //reads from the file
}

I am calling the functions using
readData(cData1,1,3)
readData(cData2,4,7)

But After running the code, cData1 and cData2 are not getting updated.
Is there a way in R to do this?

--
View this message in context: 
http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.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] Calling a function to store values

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:12 AM, kparamas wrote:


Hi,

I am calling a function with different arguments to read different  
files and

want the results to be stored in
different matrices.

Ex:
cData1 = NULL
cData2 = NULL

readData = function(cData, start, end)
{


  cData = //reads from the file
}

I am calling the functions using
readData(cData1,1,3)
readData(cData2,4,7)

But After running the code, cData1 and cData2 are not getting updated.
Is there a way in R to do this?
You need to assign the results of the function to an R object in the  
global environment. At the moment calling readData() only creates the  
cData object in the environment of the function which then disappears  
after function completion.


Try :

cdata_1_1_3 <- readData(cData1,1,3)
cdata_2_4_7 <- readData(cData2,4,7)



--
View this message in context: 
http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:


Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative  
frequencies? If I use



plot(xhist,yhist)


I get absolute frequencies in the Y axis.


I do not know of any simple setting to do what you want only within  
hist.


I explained that you need to suppress the y axis ( read help(par) for  
how to do that, possibly with xaxt="n"), calculate the values you  
desire, then add axis labeling at the locations on the density scale  
but with the probabilities you get from the calculations I illustrated.




Best,

Joao



From: David Winsemius [via R] [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
]

Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST




On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:



Dear all,
I am a newbie in R and could not find help on this problem. I am
trying to
plot an histogram with probabilities in the y axis. This is the code
I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
xlab="Média", ylab="Probabilidade")
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")

The problem is that I am getting greater than 1 probabilities in the
Y axis?
Is there a way to correct this?



Despite the argument name, which I agree suggests that probabilities
will be plotted, what is really described in the help page is that
densities will be plotted, and densities may be greater than 1. You
can suppress plotting of the y-axis, calculate the probabilities for
each of the groups returned by hist,  and then use the axes function.


xhist <- hist(xbar,breaks="Sturges",plot=FALSE)
yhist <- xhist$counts/sum(xhist$counts)
yhist

 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001





Many thanks in advance.
Joao

--
View this message in context: http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html 
 

Sent from the R help mailing list archive at Nabble.com.
[[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.



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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



 _

If you reply to this email, your message will be added to the  
discussion below:


http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

To unsubscribe from Probabilities greather than 1 in HIST, click  
here  .




--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:


Dear David,

Thanks for your prompt reply.

I see your point. But how can I get a histogram with relative  
frequencies? If I use



plot(xhist,yhist)


I get absolute frequencies in the Y axis.


In my earlier reply I meant to type yaxt="n".

--
David.


Best,

Joao



From: David Winsemius [via R] [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
]

Sent: quinta-feira, 3 de Março de 2011 16:01
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST




On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:



Dear all,
I am a newbie in R and could not find help on this problem. I am
trying to
plot an histogram with probabilities in the y axis. This is the code
I am
using:

#TLC uniform
n=30
mi=1; mx=6
nrep=1000
xbar=rep(0,nrep)
for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
xlab="Média", ylab="Probabilidade")
curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")

The problem is that I am getting greater than 1 probabilities in the
Y axis?
Is there a way to correct this?



Despite the argument name, which I agree suggests that probabilities
will be plotted, what is really described in the help page is that
densities will be plotted, and densities may be greater than 1. You
can suppress plotting of the y-axis, calculate the probabilities for
each of the groups returned by hist,  and then use the axes function.


xhist <- hist(xbar,breaks="Sturges",plot=FALSE)
yhist <- xhist$counts/sum(xhist$counts)
yhist

 [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001





Many thanks in advance.
Joao

--
View this message in context: http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html 
 

Sent from the R help mailing list archive at Nabble.com.
[[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.



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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



 _

If you reply to this email, your message will be added to the  
discussion below:


http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html

To unsubscribe from Probabilities greather than 1 in HIST, click  
here  .




--
View this message in context: 
http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread Martyn Byng
Hi,

Does

xx = rnorm(100)
hist(xx,freq=FALSE)
curve(dnorm,add=TRUE)

give you what you want?

Martyn
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of David Winsemius
Sent: 03 March 2011 17:00
To: jpmaroco
Cc: r-help@r-project.org
Subject: Re: [R] Probabilities greather than 1 in HIST


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote:

> Dear David,
>
> Thanks for your prompt reply.
>
> I see your point. But how can I get a histogram with relative  
> frequencies? If I use
>
>> plot(xhist,yhist)
>
> I get absolute frequencies in the Y axis.

In my earlier reply I meant to type yaxt="n".

-- 
David.
>
> Best,
>
> Joao
>
>
>
> From: David Winsemius [via R] 
> [mailto:ml-node+619-1272092771-215...@n4.nabble.com 
> ]
> Sent: quinta-feira, 3 de Março de 2011 16:01
> To: jpmaroco
> Subject: Re: Probabilities greather than 1 in HIST
>
>
>
>
> On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:
>
>
>> Dear all,
>> I am a newbie in R and could not find help on this problem. I am
>> trying to
>> plot an histogram with probabilities in the y axis. This is the code
>> I am
>> using:
>>
>> #TLC uniform
>> n=30
>> mi=1; mx=6
>> nrep=1000
>> xbar=rep(0,nrep)
>> for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
>> hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
>> xlab="Média", ylab="Probabilidade")
>> curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")
>>
>> The problem is that I am getting greater than 1 probabilities in the
>> Y axis?
>> Is there a way to correct this?
>
>
> Despite the argument name, which I agree suggests that probabilities
> will be plotted, what is really described in the help page is that
> densities will be plotted, and densities may be greater than 1. You
> can suppress plotting of the y-axis, calculate the probabilities for
> each of the groups returned by hist,  and then use the axes function.
>
>> xhist <- hist(xbar,breaks="Sturges",plot=FALSE)
>> yhist <- xhist$counts/sum(xhist$counts)
>> yhist
>  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001
>
>
>
>
>> Many thanks in advance.
>> Joao
>>
>> -- 
>> View this message in context: 
>> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
>>  
>>  
>> >  
>> >
>> Sent from the R help mailing list archive at Nabble.com.
>> [[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.
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> __
> [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.
>
>
>
>  _
>
> If you reply to this email, your message will be added to the  
> discussion below:
>
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
>
> To unsubscribe from Probabilities greather than 1 in HIST, click  
> here 
>   
> > .
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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


Re: [R] Error in model.frame.default

2011-03-03 Thread Dennis Murphy
Hi:

You need the second variable in D1 to be named fGRAZE - the variable names
in the newdata data frame (D1) have to be the same as the variable names on
the RHS of the model formula, in this case L.AREA and fGRAZE.

HTH,
Dennis

On Thu, Mar 3, 2011 at 7:43 AM, Heike Schmitz wrote:

> Dear R- Community,
>
> to learn i reanalysed some data provided and analysed by Zuur et. al. in
> their book "Mixed effect models and Extensions in Ecology with R". When i
> run the last command i get a warning message i dont understand.
>
>
> Loyn<- read.table(file = "loyn.txt",header = TRUE)
> Loyn$L.AREA<- log10(Loyn$AREA)
> fGRAZE <-factor(Loyn$GRAZE)
>
> M0<- lm(ABUND~ L.AREA + fGRAZE, data = Loyn)
> summary(M0)
>
> plot(x = Loyn$L.AREA, y = Loyn$ABUND,
>xlab = "Log transformed AREA",
>ylab = "Bird Abundance")
>
> D1<- data.frame(L.AREA= Loyn$L.AREA[Loyn$GRAZE==1], fGraze = "1")
> P1<- predict(M0,newdata = D1)
>
> Warning message:
> Error in model.frame.default(Terms, newdata, na.action = na.action, xlev =
> object$xlevels) :
>  variable lengths differ (found for 'fGRAZE')
> In addition: Warning message:
> 'newdata' had 13 rows but variable(s) found have 56 rows
>
> I hope anyone has an idea.
> Thank you in advance.
> Heike
>
> --
> Heike Schmitz- Diaspero
> Population Ecology and Evolutionary Ecology Lab, FB2
> University of Bremen
> Leobener Strasse, Nw2, Room B4050
> D-28359 Bremen
> Germany
> fon ++49-421-218-62937
> email: heike.schm...@uni-bremen.de
>
> http://www.popecol.uni-bremen.de
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] lattice custom axis function -- right side margins

2011-03-03 Thread Timothy W. Hilton
Dear R help list,

I have a plot with two different vertical scales that I want to display
on either side of the plot.  It's quite similar to the
Fahrenheit-Centigrade example in the examples section of the
documentation for axis.default.  

The right-side axis is clipped off, though, and I haven't been able to
figure out anything with viewport() and clipping or trellis.par.set to
fix that...  Any help greatly appreciated!  Minimal example below.

I would also like to add a label to the right-side vertical axis similar
to the "sill..." label on the left.  Bonus points if anyone can throw
that in...

Many thanks,
Tim

--

Timothy W. Hilton
PhD Candidate, Department of Meteorology
The Pennsylvania State University
503 Walker Building, University Park, PA   16802
hil...@meteo.psu.edu

--
code to produce the plot with right-side labels clipped off



example_data <-
structure(list(year = structure(c(4L, 2L, 2L, 7L, 2L, 2L, 4L, 
2L, 2L, 2L, 2L, 2L, 2L, 1L, 4L, 4L, 2L, 7L, 3L, 2L, 5L), .Label = c("2000", 
"2001", "2002", "2003", "2004", "2005", "2006"), class = "factor"), 
var = structure(c(2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 2L, 
2L, 2L, 2L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("NEE.model", 
"NEE.model.res", "NEE.obs"), class = "factor"), par_set = structure(c(6L, 
1L, 3L, 6L, 7L, 2L, 7L, 5L, 1L, 6L, 3L, 4L, 1L, 1L, 4L, 1L, 
7L, 5L, 9L, 9L, 9L), .Label = c("all.all", "all.ann", "all.mon", 
"pft.all", "pft.ann", "pft.mon", "site.all", "site.ann", 
"site.mon"), class = "factor"), sigmasq = c(11430.2595455547, 
12118.5387166954, 12982.4722525337, 16366.3059675243, 16650.2206047512, 
19730.2121989498, 19958.3416187217, 20491.4117984889, 20647.8829877428, 
21389.0300281264, 21413.7674128747, 21445.7255788782, 22002.8026436862, 
22042.9802472953, 22201.0461487030, 22340.9959465200, 24782.8974616218, 
27207.1283451608, 59450.6758048182, 94725.119215293, 694716.769010273
)), .Names = c("year", "var", "par_set", "sigmasq"), row.names = c(94L, 
8L, 20L, 43L, 44L, 68L, 100L, 86L, 2L, 92L, 74L, 80L, 62L, 1L, 
82L, 64L, 98L, 37L, 57L, 56L, 59L), class = "data.frame")

sigsq2sig <- function(sigmasq) sqrt(2 * sigmasq)
sig2sigsq <- function(sig) 0.5 * (sig)^2

# axis method to add a std deviation axis to the right side of a sill plot 
axis.sigmasq <- function(side, ...) {
  switch(side,
 left = {
   ylim <- current.panel.limits()$ylim
   pretty_sigmasq <- pretty(ylim)
   panel.axis(side = side, outside = TRUE,
  at = pretty_sigmasq, labels = pretty_sigmasq)
 },
 right = {
   ylim <- current.panel.limits()$ylim
   pretty_sigmasq <- pretty(ylim)
   pos_sigmasq <- pretty_sigmasq[pretty_sigmasq >= 0]
   pretty_sigma <- pretty(sigsq2sig(pos_sigmasq))
   panel.axis(side = side, outside = TRUE,
  at = sig2sigsq(pretty_sigma),
  labels = pretty_sigma)
 },
 axis.default(side = side, ...))
}

my_plot <- function(best.fits, ...) {

  y.main.label <- expression(sill~group("[", group("(", mu*mol~s^-1~m^-2 
,")")^2, "]"))
  #plot the parameter values, one per year
  plt <- xyplot(sigmasq~interaction(var, par_set),
data=best.fits,
groups=year,
axis = axis.sigmasq,
scales=list(x=list(rot=45)),
xlab=list(label="NEE measure"),
ylab=list(label=y.main.label),
...)
  return(plt)
}

print(my_plot(example_data))

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


Re: [R] lattice custom axis function -- right side margins

2011-03-03 Thread Richard M. Heiberger
print(my_plot(example_data, ylab.right=expression(e==mc^2)),
position=c(0,0,.95,1))

You will need a recent R version for the ylab.right argument.

On Thu, Mar 3, 2011 at 12:52 PM, Timothy W. Hilton wrote:

> Dear R help list,
>

[[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] Probabilities greather than 1 in HIST

2011-03-03 Thread Dennis Murphy
Hi:

Here's an example:

x <- rnorm(300)
hist(x, breaks = 15, yaxt = 'n', ylab = 'Relative frequency')
axis(2, at = seq(0, 50, by = 10), labels = round(seq(0, 50, by =
10)/length(x), 3))

HTH,
Dennis

On Thu, Mar 3, 2011 at 8:29 AM, jpmaroco  wrote:

> Dear David,
>
> Thanks for your prompt reply.
>
> I see your point. But how can I get a histogram with relative frequencies?
> If I use
>
> >plot(xhist,yhist)
>
> I get absolute frequencies in the Y axis.
>
> Best,
>
> Joao
>
>
>
> From: David Winsemius [via R] [mailto:
> ml-node+619-1272092771-215...@n4.nabble.com]
> Sent: quinta-feira, 3 de Março de 2011 16:01
> To: jpmaroco
> Subject: Re: Probabilities greather than 1 in HIST
>
>
>
>
> On Mar 3, 2011, at 8:03 AM, jpmaroco wrote:
>
>
> > Dear all,
> > I am a newbie in R and could not find help on this problem. I am
> > trying to
> > plot an histogram with probabilities in the y axis. This is the code
> > I am
> > using:
> >
> > #TLC uniform
> > n=30
> > mi=1; mx=6
> > nrep=1000
> > xbar=rep(0,nrep)
> > for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}
> > hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n),
> > xlab="Média", ylab="Probabilidade")
> > curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")
> >
> > The problem is that I am getting greater than 1 probabilities in the
> > Y axis?
> > Is there a way to correct this?
>
>
> Despite the argument name, which I agree suggests that probabilities
> will be plotted, what is really described in the help page is that
> densities will be plotted, and densities may be greater than 1. You
> can suppress plotting of the y-axis, calculate the probabilities for
> each of the groups returned by hist,  and then use the axes function.
>
>  > xhist <- hist(xbar,breaks="Sturges",plot=FALSE)
>  > yhist <- xhist$counts/sum(xhist$counts)
>  > yhist
>  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001
>
>
>
>
> > Many thanks in advance.
> > Joao
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html<
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html?by-user=t
> >
> > Sent from the R help mailing list archive at Nabble.com.
> > [[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.
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> __
> [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.
>
>
>
>   _
>
> If you reply to this email, your message will be added to the discussion
> below:
>
>
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
>
> To unsubscribe from Probabilities greather than 1 in HIST, click here <
> http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=388&code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==>
> .
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.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.
>
>

[[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] lattice custom axis function -- right side margins

2011-03-03 Thread Timothy W. Hilton
Many thanks, Richard -- the position argument does exactly what I
needed.  I'm not having any luck with the ylab.right argument.  My R and
lattice are up to date (below); is there something else I should check?  

Thanks for the help,
Tim

> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

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 

other attached packages:
[1] lattice_0.19-17

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

On Thu, Mar 2011, 03 at 01:05:49PM -0500, Richard M. Heiberger wrote:
> print(my_plot(example_data, ylab.right=expression(e==mc^2)),
> position=c(0,0,.95,1))
> 
> You will need a recent R version for the ylab.right argument.
> 
> On Thu, Mar 3, 2011 at 12:52 PM, Timothy W. Hilton 
> wrote:
> 
> > Dear R help list,
> >

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

2011-03-03 Thread fenerbahce sampiyon
-- 
"Gul dusununen gul bahcesi, diken dusunen dikenlik olur"Mevlana

[[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] Creating a weighted sample - Help

2011-03-03 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of LouiseS
> Sent: Thursday, March 03, 2011 5:21 AM
> To: r-help@r-project.org
> Subject: Re: [R] Creating a weighted sample - Help
> 
> Hi
> 
> Thanks for responses.  The sample I have taken is a random sample from
> H, I,
> J and K.  The further analysis I want to do is all around bad debt
> rates so
> it could be (H/H+I)*100 = Bad rate percentage also population stability
> calculations that are all related to credit scoring.  I want to be able
> to
> report back on any variable that I have in my data set based on my
> factored
> counts (A) of 10,000 - so every calculation is based on 10,000 account
> in
> the correct proportions.
> 
> Does his help?
> 
> Thanks once again
> Louise
> 

Louise,

It appears that you have done a stratified random sample of four types of 
accounts and have oversampled the less frequent account types.  You definitely 
should consider doing your analyses using the survey package (or similar 
package) that appropriately accounts for the sampling variability.  Otherwise, 
your variances / standard errors are going to be incorrect.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


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


Re: [R] Problem on flexmix when trying to apply signature developed in one model to a new sample

2011-03-03 Thread Bettina Gruen

Jon,

if I did understand you correctly the problem is that you did not 
specify the newdata argument in posterior() correctly. You need to 
specify it in way such that evaluating the formula uses the correct 
object. If you have a matrix as dependent variable, you have to use a 
list which contains an object with the name of the dependent variable 
which contains the data you want to use for determining the a-posteriori 
probabilities. The same holds for clusters().


Have a look at the following code:

library("flexmix")
library("mvtnorm")
set.seed(123)
BM <- rbind(rmvnorm(100, rep(0, 2)),
rmvnorm(100, rep(5, 2)))
ex2 <- flexmix(BM ~ 1, k = 2, model = FLXMCmvnorm(diagonal = FALSE))
print(ex2)
plotEll(ex2, BM)

Data2 <- data.frame(var1 = BM[c(1:5, 101:105), 1],
var2 = BM[c(1:5, 101:105), 2])
BM2 <- list(BM = cbind(Data2$var1, Data2$var2))
ProbMCI <- posterior(ex2, BM2)

HTH,
Bettina

On 03/01/2011 05:34 PM, Jon Toledo wrote:


Problem on flexmix when trying to apply signature developed in one model to a 
new sample.
Dear
R Users, R Core Team,



I have a problem when trying to know the
classification of the tested cases using two variables with the function  of 
flexmix:



After importing the database and creating
a matrix:

BM<-cbind(Data$var1,Data$var2)



I see that the best model has 2 groups and
use:



ex2
<- flexmix(BM~1, k=2, model=FLXMCmvnorm(diagonal=FALSE))

print(ex2)

plotEll(ex2, BM)



Then I want to test to which group one
subset of patients belongs, so I import a smaller sample of the previous data:

BM2<-data.frame (Data2$var1,Data2$var2)



However when I test the results I get are
from the complete training sample I used in ex2 and not from the new sample
BM2.



ProbMCI<-posterior(ex2, BM2)



And if I do the following I get double the
number of entered cases (I think because I entered 2 variables):

BM2<-cbind (Data2$var1,Data2$var2)

p<-posterior(ex2)[BMMCI,]

max.col(p)



(The same with clusters(ex2)[BM2])



In the future I would like to test the
result of this mixture also in new samples.



Thank you in advance
[[alternative HTML version deleted]]

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

   



--
---
Bettina Grün
Institut für Angewandte Statistik / IFAS
Johannes Kepler Universität Linz
Altenbergerstraße 69
4040 Linz, Austria

Tel: +43 732 2468-5889
Fax: +43 732 2468-9846
E-Mail: bettina.gr...@jku.at
www.ifas.jku.at

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plot, y-axis, uneven scale???

2011-03-03 Thread yan liu
Hello,

I have a question about the y-axis of plots.  Actually I had about 60
values.  About 80 percent of these values are less than 0.2, then the other
20 percent values are more than 4,max is 10.  So when I plot these values
together, the y-axis's range will go 0 to 10, and my major values (80%
values <0.2) will be pressed around 0 on the bottom, while other several
dots will scatter in the major part of the plot area.

Does anyone know how to assign the y-axis with uneven (jumping) ticks with
same width, like 0, 0.1, 1, 10,100 with the same width between?

Thanks a lot!

Yan

[[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] Regression with many independent variables

2011-03-03 Thread Greg Snow
What you might need to do is create a character string with your formula in it 
(looping through pairs of variables and using paste or sprint) then convert 
that to a formula using the as.formula function.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: Matthew Douglas [mailto:matt.dougla...@gmail.com]
> Sent: Thursday, March 03, 2011 2:09 PM
> To: Greg Snow
> Cc: r-help@r-project.org
> Subject: Re: [R] Regression with many independent variables
> 
> Thanks greg,
> 
>  that formula was exactly what I was looking for. Except now when I
> run it on my data I get the following error:
> 
> "Error in model.matrix.default(mt, mf, contrasts) : cannot allocate
> vector of length 2043479998"
> 
> I know there are probably many 2-way interactions that are zero so I
> thought I could save space by removing these. Is there some way that
> can just delete all the two way interactions that are zero and keep
> the columns that have non-zero entries? I think that will
> significantly cut down the memory needed. Or is there just another way
> to get around this?
> 
> thanks,
> Matt
> 
> On Tue, Mar 1, 2011 at 3:56 PM, Greg Snow  wrote:
> > You can use ^2 to get all 2 way interactions and ^3 to get all 3 way
> interactions, e.g.:
> >
> > lm(Sepal.Width ~ (. - Sepal.Length)^2, data=iris)
> >
> > The lm.fit function is what actually does the fitting, so you could
> go directly there, but then you lose the benefits of using . and ^.
>  The Matrix package has ways of dealing with sparse matricies, but I
> don't know if  that would help here or not.
> >
> > You could also just create x'x and x'y matricies directly since the
> variables are 0/1 then use solve.  A lot depends on what you are doing
> and what questions you are trying to answer.
> >
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.s...@imail.org
> > 801.408.8111
> >
> >
> >> -Original Message-
> >> From: Matthew Douglas [mailto:matt.dougla...@gmail.com]
> >> Sent: Tuesday, March 01, 2011 1:09 PM
> >> To: Greg Snow
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] Regression with many independent variables
> >>
> >> Hi Greg,
> >>
> >> Thanks for the help, it works perfectly. To answer your question,
> >> there are 339 independent variables but only 10 will be used at one
> >> time . So at any given line of the data set there will be 10 non
> zero
> >> entries for the independent variables and the rest will be zeros.
> >>
> >> One more question:
> >>
> >> 1. I still want to find a way to look at the interactions of the
> >> independent variables.
> >>
> >> the regression would look like this:
> >>
> >> y = b12*X1X2 + b23*X2X3 +...+ bk-1k*Xk-1Xk
> >>
> >> so I think the regression in R would look like this:
> >>
> >> lm(MARGIN, P235:P236+P236:P237+,weights = Poss, data = adj0708),
> >>
> >> my problem is that since I have technically 339 independent
> variables,
> >> when I do this regression I would have 339 Choose 2 = approx 57000
> >> independent variables (a vast majority will be 0s though) so I dont
> >> want to have to write all of these out. Is there a way to do this
> >> quickly in R?
> >>
> >> Also just a curious question that I cant seem to find to online:
> >> is there a more efficient model other than lm() that is better for
> >> very sparse data sets like mine?
> >>
> >> Thanks,
> >> Matt
> >>
> >>
> >> On Mon, Feb 28, 2011 at 4:30 PM, Greg Snow 
> wrote:
> >> > Don't put the name of the dataset in the formula, use the data
> >> argument to lm to provide that.  A single period (".") on the right
> >> hand side of the formula will represent all the columns in the data
> set
> >> that are not on the left hand side (you can then use "-" to remove
> any
> >> other columns that you don't want included on the RHS).
> >> >
> >> > For example:
> >> >
> >> >> lm(Sepal.Width ~ . - Sepal.Length, data=iris)
> >> >
> >> > Call:
> >> > lm(formula = Sepal.Width ~ . - Sepal.Length, data = iris)
> >> >
> >> > Coefficients:
> >> >      (Intercept)       Petal.Length        Petal.Width
> >>  Speciesversicolor
> >> >           3.0485             0.1547             0.6234
>  -
> >> 1.7641
> >> >  Speciesvirginica
> >> >          -2.1964
> >> >
> >> >
> >> > But, are you sure that a regression model with 339 predictors will
> be
> >> meaningful?
> >> >
> >> > --
> >> > Gregory (Greg) L. Snow Ph.D.
> >> > Statistical Data Center
> >> > Intermountain Healthcare
> >> > greg.s...@imail.org
> >> > 801.408.8111
> >> >
> >> >
> >> >> -Original Message-
> >> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> >> >> project.org] On Behalf Of Matthew Douglas
> >> >> Sent: Monday, February 28, 2011 1:32 PM
> >> >> To: r-help@r-project.org
> >> >> Subject: [R] Regression with many independent variables
> >> >>
> >> >> Hi,
> >> >>
> >> >> I am trying use lm() on some data, the code works fine b

Re: [R] plot, y-axis, uneven scale???

2011-03-03 Thread Greg Snow
You probably want to use the gap.plot function in the plotrix package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of yan liu
> Sent: Thursday, March 03, 2011 2:09 PM
> To: r-help@r-project.org
> Subject: [R] plot, y-axis, uneven scale???
> 
> Hello,
> 
> I have a question about the y-axis of plots.  Actually I had about 60
> values.  About 80 percent of these values are less than 0.2, then the
> other
> 20 percent values are more than 4,max is 10.  So when I plot these
> values
> together, the y-axis's range will go 0 to 10, and my major values (80%
> values <0.2) will be pressed around 0 on the bottom, while other
> several
> dots will scatter in the major part of the plot area.
> 
> Does anyone know how to assign the y-axis with uneven (jumping) ticks
> with
> same width, like 0, 0.1, 1, 10,100 with the same width between?
> 
> Thanks a lot!
> 
> Yan
> 
>   [[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] lattice: How to increase space between ticks and labels of z-axis?

2011-03-03 Thread Marius Hofert
Dear expeRts,

How can I increase the space between the ticks and the labels in the wireframe 
plot
below? I tried some variations with par.settings=list(..) but it just didn't 
work.

Many thanks,

Marius



library(lattice)

u <- seq(0, 1, length.out=20)
grid <- expand.grid(x=u, y=u)
z <- apply(grid, 1, function(x) 1/(x[1]*x[2]+0.0001))

wireframe(z~grid[,1]*grid[,2], aspect=1, scales=list(col=1, arrows=FALSE))
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plot, y-axis, uneven scale???

2011-03-03 Thread Gabor Grothendieck
On Thu, Mar 3, 2011 at 4:09 PM, yan liu  wrote:
> Hello,
>
> I have a question about the y-axis of plots.  Actually I had about 60
> values.  About 80 percent of these values are less than 0.2, then the other
> 20 percent values are more than 4,max is 10.  So when I plot these values
> together, the y-axis's range will go 0 to 10, and my major values (80%
> values <0.2) will be pressed around 0 on the bottom, while other several
> dots will scatter in the major part of the plot area.
>
> Does anyone know how to assign the y-axis with uneven (jumping) ticks with
> same width, like 0, 0.1, 1, 10,100 with the same width between?
>
> Thanks a lot!
>
> Yan

See the log= argument to plot (its actually listed under
?plot.default).  Also eaxis in sfsmisc.

-- 
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] 'merge' function creating duplicate columns names in the output

2011-03-03 Thread jim holtman
The "merge" command is creating duplicate column names in a dataframe
that is the result of the merge.  The following is the 'merge'
command:

x <- merge(invType
, allocSlots
, by.x = 'index'
, by.y = 'indx'
, all.x = TRUE
)

The 'invType' dataframe was the result of a previous merge and has the
following column names that are probably causing the problem:
height.x
height.y
height

> str(invType)
'data.frame':   2219 obs. of  30 variables:
 $ loc : chr  "F0AA63" "F0AA65" "F0AA73" "F0AA75" ...
 $ KLN : int  3569383 3515513 3565497 3555138 3565162 3555001
3565139 3555886 3565796 3556647 ...
 $ comm: int  451 57 560 40 560 39 560 40 560 46 ...
 $ case: num  7.70e+09 1.00e+12 3.00e+12 1.00e+12 1.11e+09 ...
 $ desc: chr  "PGPR RTC BONELESS WINGS" "GRTN POT CRNCH FISH
FILET" "TYSON CORNISH HENS TWN PK" "GGNT RSTD POT GRLC HERB" ...
 $ height.x: num  7.2 12.6 11 7.8 6.8 10.1 11.2 10 11 10.5 ...
 $ length  : num  14.5 15.8 20 15.6 22.2 15 20.2 15 17 19.8 ...
 $ weight  : num  11 16.3 39 11 35.6 6.5 36 4 30 12.5 ...
 $ width   : num  9.7 9.2 14.3 8 15.2 7.5 13.2 8.5 13 10 ...
 $ high: int  5 2 3 3 4 3 3 3 3 3 ...
 $ pqty: int  65 26 18 45 20 45 21 39 24 30 ...
 $ boh : int  4372 58 1199 51 836 116 64 312 371 389 ...
 $ awm : num  694 44.3 53.8 35 0.8 ...
 $ cubes   : num  0.586 1.06 1.821 0.563 1.328 ...
 $ pallet  : num  42 31.2 39 29.4 33.2 36.3 39.6 36 39 37.5 ...
 $ adm : num  99.143 6.329 7.686 5 0.114 ...
 $ tie : num  13 13 6 15 5 15 7 13 8 10 ...
 $ origComm: int  457 57 547 40 541 39 552 40 552 46 ...
 $ days: num  0.656 6.162 2.342 11.998 216.853 ...
 $ class   : chr  "single" "double" "single" "double" ...
 $ top.x   : logi  TRUE TRUE FALSE TRUE FALSE TRUE ...
 $ comm_ord: Factor w/ 30 levels "37A","38A","43A",..: 25 5 23 15 23 8
23 15 23 16 ...
 $ type.x  : int  2 2 2 2 2 2 2 2 2 2 ...
 $ height.y: num  47 47 47 47 47 47 47 47 47 47 ...
 $ top.y   : logi  FALSE TRUE FALSE TRUE FALSE TRUE ...
 $ noChange: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ type.y  : int  2 2 2 2 2 2 2 2 2 2 ...
 $ depth   : num  48 48 48 48 48 48 48 48 48 48 ...
 $ height  : num  47 47 47 47 47 47 47 47 47 47 ...
 $ index   : int  1 2 3 4 5 6 7 8 9 10 ...


Now the "allocSlots" dataframe also has a column name 'height'

> str(allocSlots)
'data.frame':   2462 obs. of  6 variables:
 $ loc   : chr  "F1AA02" "F1AA12" "F1AA22" "F1AA32" ...
 $ height: num  72 72 72 72 72 72 72 72 72 72 ...
 $ depth : num  48 48 48 48 48 48 48 48 48 48 ...
 $ bay   : chr  "F1AA0" "F1AA0" "F1AA2" "F1AA2" ...
 $ indx  : int  1675 1617 1386 1096 1077 963 816 471 275 259 ...
 $ type  : int  1 1 1 1 1 1 1 1 1 1 ...


Here is the result of the 'merge': (notice that there are now two
'height.x' and 'height.y' columns in the dataframe:

> str(x)
'data.frame':   2219 obs. of  35 variables:
 $ index   : int  1 2 3 4 5 6 7 8 9 10 ...
 $ loc.x   : chr  "F0AA63" "F0AA65" "F0AA73" "F0AA75" ...
 $ KLN : int  3569383 3515513 3565497 3555138 3565162 3555001
3565139 3555886 3565796 3556647 ...
 $ comm: int  451 57 560 40 560 39 560 40 560 46 ...
 $ case: num  7.70e+09 1.00e+12 3.00e+12 1.00e+12 1.11e+09 ...
 $ desc: chr  "PGPR RTC BONELESS WINGS" "GRTN POT CRNCH FISH
FILET" "TYSON CORNISH HENS TWN PK" "GGNT RSTD POT GRLC HERB" ...
 $ height.x: num  7.2 12.6 11 7.8 6.8 10.1 11.2 10 11 10.5 ...
 $ length  : num  14.5 15.8 20 15.6 22.2 15 20.2 15 17 19.8 ...
 $ weight  : num  11 16.3 39 11 35.6 6.5 36 4 30 12.5 ...
 $ width   : num  9.7 9.2 14.3 8 15.2 7.5 13.2 8.5 13 10 ...
 $ high: int  5 2 3 3 4 3 3 3 3 3 ...
 $ pqty: int  65 26 18 45 20 45 21 39 24 30 ...
 $ boh : int  4372 58 1199 51 836 116 64 312 371 389 ...
 $ awm : num  694 44.3 53.8 35 0.8 ...
 $ cubes   : num  0.586 1.06 1.821 0.563 1.328 ...
 $ pallet  : num  42 31.2 39 29.4 33.2 36.3 39.6 36 39 37.5 ...
 $ adm : num  99.143 6.329 7.686 5 0.114 ...
 $ tie : num  13 13 6 15 5 15 7 13 8 10 ...
 $ origComm: int  457 57 547 40 541 39 552 40 552 46 ...
 $ days: num  0.656 6.162 2.342 11.998 216.853 ...
 $ class   : chr  "single" "double" "single" "double" ...
 $ top.x   : logi  TRUE TRUE FALSE TRUE FALSE TRUE ...
 $ comm_ord: Factor w/ 30 levels "37A","38A","43A",..: 25 5 23 15 23 8
23 15 23 16 ...
 $ type.x  : int  2 2 2 2 2 2 2 2 2 2 ...
 $ height.y: num  47 47 47 47 47 47 47 47 47 47 ...
 $ top.y   : logi  FALSE TRUE FALSE TRUE FALSE TRUE ...
 $ noChange: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ type.y  : int  2 2 2 2 2 2 2 2 2 2 ...
 $ depth.x : num  48 48 48 48 48 48 48 48 48 48 ...
 $ height.x: num  47 47 47 47 47 47 47 47 47 47 ...
 $ loc.y   : chr  "F1KC22" "F1BM34" "F1HC73" "F1FJ65" ...
 $ height.y: num  72 44 72 44 72 44 72 44 72 72 ...
 $ depth.y : num  48 48 48 48 48 48 48 48 48 48 ...
 $ bay : chr  "F1KC2" "F1BM2" "F1HC7" "F1FJ5" ...
 $ type: int  1 2 1 2 1 2 1 2 1 1 ...


My workaround is to change one of the "height" to something else to
avoid the problem, but someone el

Re: [R] Calling a function to store values

2011-03-03 Thread David Winsemius

On Mar 3, 2011, at 1:49 PM, Kumaraguru Paramasivam wrote:

> Hi,
>
> I tried this approach.
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
> Its still not working. The result I get is NULL.

Then the function (which you have not provided) is faulty, but there  
is not way we can debug a function we cannot see.

-- 
David.

>
> Thanks,
> Kumar
>
> On Thu, Mar 3, 2011 at 9:50 AM, David Winsemius  > wrote:
>
> On Mar 3, 2011, at 10:12 AM, kparamas wrote:
>
> Hi,
>
> I am calling a function with different arguments to read different  
> files and
> want the results to be stored in
> different matrices.
>
> Ex:
> cData1 = NULL
> cData2 = NULL
>
> readData = function(cData, start, end)
> {
>
> 
>  cData = //reads from the file
> }
>
> I am calling the functions using
> readData(cData1,1,3)
> readData(cData2,4,7)
>
> But After running the code, cData1 and cData2 are not getting updated.
> Is there a way in R to do this?
> You need to assign the results of the function to an R object in the  
> global environment. At the moment calling readData() only creates  
> the cData object in the environment of the function which then  
> disappears after function completion.
>
> Try :
>
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.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.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>
>
>
> -- 
> Thanks 'n' Regards,
> Kumaraguru

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[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] Ordering several histograms

2011-03-03 Thread csrabak

Em 3/3/2011 12:00, djbirdnerd escreveu:

Hallo everyone,

I want to evaluate the change of the distribution for several size classes.
How can i order these separate histograms with the same y-axis along a
common x-axis according to their size classes. It would like it to look a
bit like this
(http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109) without
the quantile regression. I can produce the separate histograms, but have no
clue how to merge them. i can put them next to each with separate x- and
y-axes.

Much obliged,


Kenneth,

Have tried to adapt the R code which is published in the link you did post?

--
Cesar Rabak

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Scatter plot with multiple data sets

2011-03-03 Thread Jorseff
Hi, I have multiple (6) data sets which I would like to plot together on one
scatter graph. The reason they are all separate is that I require a
different symbol to be plotted for each set. Could somebody advise on how to
do this?

Many thanks,

Joe

--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-with-multiple-data-sets-tp3334096p3334096.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] Ploting Histogram with Y axis is percentage of sample for each bin

2011-03-03 Thread leinwand
I'm trying to do something very simple...

I wan to plot a histogram where the y axis represent the percentage of the
total sample that each bin represents. 

I know how to plot a histogram with the counts and density... but can't find
anything that gives me perenct of sample on the y axis. 

Any help is appriciated

Below is the script I'm working with

par(mfrow=c(1,2))
hist(ISIS$ASH_BA1K_ISIS[ISIS$Pest_Status=="-1"], main="Ash BA 1K Negative
Detection",  xlab="ASH BA 1K")
lines(density(ISIS$ASH_BA1K_ISIS), col="blue")
hist(ISIS$ASH_BA1K_ISIS[ISIS$Pest_Status=="1"], main="Ash BA 1K Positive
Detection", xlab="Ash BA 1K")
lines(density(ISIS$ASH_BA1K_ISIS), col="red")


--
View this message in context: 
http://r.789695.n4.nabble.com/Ploting-Histogram-with-Y-axis-is-percentage-of-sample-for-each-bin-tp961p961.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] Developing a web crawler / R "webkit" or something similar? [off topic]

2011-03-03 Thread Matt Shotwell

On 03/03/2011 08:07 AM, Mike Marchywka wrote:









Date: Thu, 3 Mar 2011 01:22:44 -0800
From: antuj...@gmail.com
To: r-help@r-project.org
Subject: [R] Developing a web crawler

Hi,

I wish to develop a web crawler in R. I have been using the functionalities
available under the RCurl package.
I am able to extract the html content of the site but i don't know how to go


In general this can be a big effort but there may be things in
text processing packages you could adapt to execute html and javascript.
However, I guess what I'd be looking for is something like a "webkit"
package or other open source browser with or without an "R" interface.
This actually may be an ideal solution for a lot of things as you get
all the content handlers of at least some browser.


Now that you mention it, I wonder if there are browser plugins to handle
"R" content ( I'd have to give this some thought, put a script up as
a web page with mime type "test/R" and have it execute it in R. )


There are server-side solutions for this sort of thing. See 
http://rapache.net/ . Also, there was a string of messages on R-devel 
some years ago addressing the mime type issue; beginning here: 
http://tolstoy.newcastle.edu.au/R/devel/05/11/3054.html . Though I don't 
know whether there was a resolution. Some suggestions were text/x-R, 
text/x-Rd, application/x-RData.


-Matt






about analyzing the html formatted document.
I wish to know the frequency of a word in the document. I am only acquainted
with analyzing data sets.
So how should i go about analyzing data that is not available in table
format.

Few chunks of code that i wrote:
w<-
getURL("http://www.amazon.com/Kindle-Wireless-Reader-Wifi-Graphite/dp/B003DZ1Y8Q/ref=dp_reviewsanchor#FullQuotes";)
write.table(w,"test.txt")
t<- readLines(w)

readLines also didnt prove out to be of any help.

Any help would be highly appreciated. Thanks in advance.


--
View this message in context: 
http://r.789695.n4.nabble.com/Developing-a-web-crawler-tp3332993p3332993.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.




--
Matthew S Shotwell   Assistant Professor   School of Medicine
 Department of Biostatistics   Vanderbilt 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.


[R] embed latex beamer sans serif default font into R plot

2011-03-03 Thread Kwok, Heemun
Hello,
I have seen instructions on how to embed Latex Computer Modern fonts into R, 
but these are the default serif fonts. I am trying to embed the default font 
used for Latex beamer (theme Warsaw), which is a sans serif font and may be the 
default LateX Computer Modern sans serif font.Does anyone know the names of 
the font files?
 
Thanks
Heemun
 

-
Heemun Kwok, M.D.
Research Fellow
Harbor-UCLA Department of Emergency Medicine
1000 West Carson Street, Box 21
Torrance, CA 90509-2910
office 310-222-3501, fax 310-212-6101

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


Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread jpmaroco
Hi Martin,

No, I get frequencies greather than 1.

 

See the code:

#TLC uniform

n=30

mi=1; mx=6

nrep=1000

xbar=rep(0,nrep)

for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))}

hist(xbar, freq=FALSE)

#hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n), 
xlab="Média", ylab="Probabilidade")

curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red")

 

Thanks anyway

Best

Jº

 

From: Martyn Byng [via R] 
[mailto:ml-node+757-242386738-215...@n4.nabble.com] 
Sent: quinta-feira, 3 de Março de 2011 17:12
To: jpmaroco
Subject: Re: Probabilities greather than 1 in HIST

 

Hi, 

Does 

xx = rnorm(100) 
hist(xx,freq=FALSE) 
curve(dnorm,add=TRUE) 

give you what you want? 

Martyn 
-Original Message- 
From: [hidden email] [mailto:[hidden email]] On Behalf Of David Winsemius 
Sent: 03 March 2011 17:00 
To: jpmaroco 
Cc: [hidden email] 
Subject: Re: [R] Probabilities greather than 1 in HIST 


On Mar 3, 2011, at 10:29 AM, jpmaroco wrote: 


> Dear David, 
> 
> Thanks for your prompt reply. 
> 
> I see your point. But how can I get a histogram with relative   
> frequencies? If I use 
> 
>> plot(xhist,yhist) 
> 
> I get absolute frequencies in the Y axis. 


In my earlier reply I meant to type yaxt="n". 

-- 
David. 


> 
> Best, 
> 
> Joao 
> 
> 
> 
> From: David Winsemius [via R] [mailto:[hidden email] 
> ] 
> Sent: quinta-feira, 3 de Março de 2011 16:01 
> To: jpmaroco 
> Subject: Re: Probabilities greather than 1 in HIST 
> 
> 
> 
> 
> On Mar 3, 2011, at 8:03 AM, jpmaroco wrote: 
> 
> 
>> Dear all, 
>> I am a newbie in R and could not find help on this problem. I am 
>> trying to 
>> plot an histogram with probabilities in the y axis. This is the code 
>> I am 
>> using: 
>> 
>> #TLC uniform 
>> n=30 
>> mi=1; mx=6 
>> nrep=1000 
>> xbar=rep(0,nrep) 
>> for (i in 1:nrep) {xbar[i]=mean(runif(n,min=mi,max=mx))} 
>> hist(xbar,prob=TRUE,breaks="Sturges",xlim=c(1,6),main=paste("n =",n), 
>> xlab="Média", ylab="Probabilidade") 
>> curve(dnorm(x,mean=mean(xbar),sd=sd(xbar)),add=TRUE,lwd=2,col="red") 
>> 
>> The problem is that I am getting greater than 1 probabilities in the 
>> Y axis? 
>> Is there a way to correct this? 
> 
> 
> Despite the argument name, which I agree suggests that probabilities 
> will be plotted, what is really described in the help page is that 
> densities will be plotted, and densities may be greater than 1. You 
> can suppress plotting of the y-axis, calculate the probabilities for 
> each of the groups returned by hist,  and then use the axes function. 
> 
>> xhist <- hist(xbar,breaks="Sturges",plot=FALSE) 
>> yhist <- xhist$counts/sum(xhist$counts) 
>> yhist 
>  [1] 0.002 0.027 0.087 0.236 0.287 0.228 0.107 0.021 0.004 0.001 
> 
> 
> 
> 
>> Many thanks in advance. 
>> Joao 
>> 
>> -- 
>> View this message in context: 
>> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p388.html
>>  
>> 
>>
>>  
>> >  
>> 
>>
>> > 
>> Sent from the R help mailing list archive at Nabble.com. 
>> [[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. 
> 
> 
> David Winsemius, MD 
> Heritage Laboratories 
> West Hartford, CT 
> 
> __ 
> [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. 
> 
> 
> 
>  _ 
> 
> If you reply to this email, your message will be added to the   
> discussion below: 
> 
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p619.html
>  
> 
>  
> 
> To unsubscribe from Probabilities greather than 1 in HIST, click   
> here 
>   
> 
>  &node=388&code=anBtYXJvY29AZ21haWwuY29tfDMzMzMzODh8LTE1ODEwNTQwMA==  
> > . 
> 
> 
> 
> -- 
> View this message in context: 
> http://r.789695.n4.nabble.com/Probabilities-greather-than-1-in-HIST-tp388p670.html
>  
> 

Re: [R] Ploting Histogram with Y axis is percentage of sample for each bin

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 12:44 PM, leinwand wrote:


I'm trying to do something very simple...

I wan to plot a histogram where the y axis represent the percentage  
of the

total sample that each bin represents.

I know how to plot a histogram with the counts and density... but  
can't find

anything that gives me perenct of sample on the y axis.

Any help is appriciated

Below is the script I'm working with

par(mfrow=c(1,2))
hist(ISIS$ASH_BA1K_ISIS[ISIS$Pest_Status=="-1"], main="Ash BA 1K  
Negative

Detection",  xlab="ASH BA 1K")
lines(density(ISIS$ASH_BA1K_ISIS), col="blue")
hist(ISIS$ASH_BA1K_ISIS[ISIS$Pest_Status=="1"], main="Ash BA 1K  
Positive

Detection", xlab="Ash BA 1K")
lines(density(ISIS$ASH_BA1K_ISIS), col="red")


Script but no data.

There is a pretty much identical question asked and answered earlier  
today... despite the fact theat the OP doesn't seem to undersatnd or  
be able to apply the directions, you should see if the thread  
"Probabilities greather than 1 in HIST" answers your question.





--
View this message in context: 
http://r.789695.n4.nabble.com/Ploting-Histogram-with-Y-axis-is-percentage-of-sample-for-each-bin-tp961p961.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Calling a function to store values

2011-03-03 Thread Kumaraguru Paramasivam
Hi,

I tried this approach.
cdata_1_1_3 <- readData(cData1,1,3)
cdata_2_4_7 <- readData(cData2,4,7)

Its still not working. The result I get is NULL.

Thanks,
Kumar

On Thu, Mar 3, 2011 at 9:50 AM, David Winsemius wrote:

>
> On Mar 3, 2011, at 10:12 AM, kparamas wrote:
>
>  Hi,
>>
>> I am calling a function with different arguments to read different files
>> and
>> want the results to be stored in
>> different matrices.
>>
>> Ex:
>> cData1 = NULL
>> cData2 = NULL
>>
>> readData = function(cData, start, end)
>> {
>>
>> 
>>  cData = //reads from the file
>> }
>>
>> I am calling the functions using
>> readData(cData1,1,3)
>> readData(cData2,4,7)
>>
>> But After running the code, cData1 and cData2 are not getting updated.
>> Is there a way in R to do this?
>>
> You need to assign the results of the function to an R object in the global
> environment. At the moment calling readData() only creates the cData object
> in the environment of the function which then disappears after function
> completion.
>
> Try :
>
> cdata_1_1_3 <- readData(cData1,1,3)
> cdata_2_4_7 <- readData(cData2,4,7)
>
>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Calling-a-function-to-store-values-tp644p644.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.
>>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>


-- 
Thanks 'n' Regards,
Kumaraguru

[[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] Interpreting the coefficient of an interaction between continuous variables in a regression model

2011-03-03 Thread Sverre Stausland
Hello,

my question is triggered by an actual model I am running, but I will
pose it as a very general question with a hypothetical example.

Take the following regression model:

I have a binomial dependent variable "Happiness", whose two values are
0 (=unhappy) and 1 (=happy). My two independent continuous variables
are "Income" and "Children". Imagine that "Income" has no significant
effect, and that "Children" has a significant positive effect (more
children give more happiness). Now I am interested in the interaction
between "Income" and "Children", i.e. 'Income : Children'. Say that
the model finds a non-significant negative coefficient. How do I
interpret that? If I understand it correctly, the model is asking
"When the numerical values in "Income" and "Children" are both
increasing, does it significantly affect the dependent variable?". But
what if the interaction between them is inverse - such that a
decreasing value in "Income" paired with an increasing value in
"Children" will significantly affect the dependent variable
"Happiness". Will the model not be able to capture that connection
without doing some additional tweaking?

Thank you
Sverre

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

2011-03-03 Thread Bobby Lee
Could you please take my email off the help center? Thank you very much.

[[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] creating a count variable in R

2011-03-03 Thread JonC
Hi R helpers,

I'm trying to create a count in R , but as there is no retain function like
in SAS I'm running into difficulties.

I have the following :

Date_var   and wish to obtain  Date_var 
Count_var 
01/01/2011   01/01/2011 
1
01/01/2011   01/01/2011 
2
02/01/2011   02/01/2011 
1
02/01/2011   02/01/2011 
2
02/01/2011   02/01/2011 
3
02/01/2011   02/01/2011 
4
03/01/2011   03/01/2011 
1
03/01/2011   03/01/2011 
2
03/01/2011   03/01/2011 
3
03/01/2011   03/01/2011 
4
03/01/2011   03/01/2011 
5
03/01/2011   03/01/2011 
6
03/01/2011   03/01/2011 
7

As can be seen above the count var is re initialised every time a new date
is found. I hope this is easy.

Many thanks in advance for assistance. It is appreciated. 

Cheers

Jon 


--
View this message in context: 
http://r.789695.n4.nabble.com/creating-a-count-variable-in-R-tp3334288p3334288.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] Normalising proportional binomial data that has a set top value

2011-03-03 Thread sboardman
I've got some data in proportional format which has a set maximum value of
0.5 and I want to know how to normalise it.

I've calculated a lateralisation index to determine whether an organism
deviates from an equal number of left and right turns within a trial (as
opposed to measuring the proportion of left and right turns in total).  My
proportions are therefore between 0 (equal number of left and right turns)
and 0.5 (all turns in the same direction, either left or right).

I want to analyse the data using an ANOVA to test repeated measures for the
repeatability coefficient but recognise I will have to normalise the data
for it to work properly.

Any help is much appreciated.

SB

--
View this message in context: 
http://r.789695.n4.nabble.com/Normalising-proportional-binomial-data-that-has-a-set-top-value-tp754p754.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] PCA - scores

2011-03-03 Thread Shari Clare
I am running a PCA, but would like to rotate my data and limit the  
number of factors that are analyzed.  I can do this using the  
"principal" command from the psych package [principal(my.data,  
nfactors=3,rotate="varimax")], but the issue is that this does not  
report scores for the Principal Components the way "princomp" does.

My question is:

Can you get an output of scores using "principal" OR, is there a way  
to limit the number of factors that are included when you use  
"princomp"?

Thanks,
Shari Clare

PhD Candidate
Department of Renewable Resources
University of Alberta
scl...@ualberta.ca
780-492-2540








[[alternative HTML version deleted]]

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


Re: [R] Help center

2011-03-03 Thread David Winsemius
You need to unsubscribe using the same method you use to subscribe  
go to the webpage for the list and log in with the password you set.  
If all you wnat to stop is the mailing, you can do so without  
unsubscribing.



On Mar 3, 2011, at 3:09 PM, Bobby Lee wrote:

Could you please take my email off the help center? Thank you very  
much.


[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Regression with many independent variables

2011-03-03 Thread Matthew Douglas
Thanks greg,

 that formula was exactly what I was looking for. Except now when I
run it on my data I get the following error:

"Error in model.matrix.default(mt, mf, contrasts) : cannot allocate
vector of length 2043479998"

I know there are probably many 2-way interactions that are zero so I
thought I could save space by removing these. Is there some way that
can just delete all the two way interactions that are zero and keep
the columns that have non-zero entries? I think that will
significantly cut down the memory needed. Or is there just another way
to get around this?

thanks,
Matt

On Tue, Mar 1, 2011 at 3:56 PM, Greg Snow  wrote:
> You can use ^2 to get all 2 way interactions and ^3 to get all 3 way 
> interactions, e.g.:
>
> lm(Sepal.Width ~ (. - Sepal.Length)^2, data=iris)
>
> The lm.fit function is what actually does the fitting, so you could go 
> directly there, but then you lose the benefits of using . and ^.  The Matrix 
> package has ways of dealing with sparse matricies, but I don't know if  that 
> would help here or not.
>
> You could also just create x'x and x'y matricies directly since the variables 
> are 0/1 then use solve.  A lot depends on what you are doing and what 
> questions you are trying to answer.
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
>> -Original Message-
>> From: Matthew Douglas [mailto:matt.dougla...@gmail.com]
>> Sent: Tuesday, March 01, 2011 1:09 PM
>> To: Greg Snow
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Regression with many independent variables
>>
>> Hi Greg,
>>
>> Thanks for the help, it works perfectly. To answer your question,
>> there are 339 independent variables but only 10 will be used at one
>> time . So at any given line of the data set there will be 10 non zero
>> entries for the independent variables and the rest will be zeros.
>>
>> One more question:
>>
>> 1. I still want to find a way to look at the interactions of the
>> independent variables.
>>
>> the regression would look like this:
>>
>> y = b12*X1X2 + b23*X2X3 +...+ bk-1k*Xk-1Xk
>>
>> so I think the regression in R would look like this:
>>
>> lm(MARGIN, P235:P236+P236:P237+,weights = Poss, data = adj0708),
>>
>> my problem is that since I have technically 339 independent variables,
>> when I do this regression I would have 339 Choose 2 = approx 57000
>> independent variables (a vast majority will be 0s though) so I dont
>> want to have to write all of these out. Is there a way to do this
>> quickly in R?
>>
>> Also just a curious question that I cant seem to find to online:
>> is there a more efficient model other than lm() that is better for
>> very sparse data sets like mine?
>>
>> Thanks,
>> Matt
>>
>>
>> On Mon, Feb 28, 2011 at 4:30 PM, Greg Snow  wrote:
>> > Don't put the name of the dataset in the formula, use the data
>> argument to lm to provide that.  A single period (".") on the right
>> hand side of the formula will represent all the columns in the data set
>> that are not on the left hand side (you can then use "-" to remove any
>> other columns that you don't want included on the RHS).
>> >
>> > For example:
>> >
>> >> lm(Sepal.Width ~ . - Sepal.Length, data=iris)
>> >
>> > Call:
>> > lm(formula = Sepal.Width ~ . - Sepal.Length, data = iris)
>> >
>> > Coefficients:
>> >      (Intercept)       Petal.Length        Petal.Width
>>  Speciesversicolor
>> >           3.0485             0.1547             0.6234            -
>> 1.7641
>> >  Speciesvirginica
>> >          -2.1964
>> >
>> >
>> > But, are you sure that a regression model with 339 predictors will be
>> meaningful?
>> >
>> > --
>> > Gregory (Greg) L. Snow Ph.D.
>> > Statistical Data Center
>> > Intermountain Healthcare
>> > greg.s...@imail.org
>> > 801.408.8111
>> >
>> >
>> >> -Original Message-
>> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> >> project.org] On Behalf Of Matthew Douglas
>> >> Sent: Monday, February 28, 2011 1:32 PM
>> >> To: r-help@r-project.org
>> >> Subject: [R] Regression with many independent variables
>> >>
>> >> Hi,
>> >>
>> >> I am trying use lm() on some data, the code works fine but I would
>> >> like to use a more efficient way to do this.
>> >>
>> >> The data looks like this (the data is very sparse with a few 1s, -1s
>> >> and the rest 0s):
>> >>
>> >> > head(adj0708)
>> >>       MARGIN Poss P235 P247 P703 P218 P430 P489 P83 P307 P337
>> >> 1   64.28571   29    0    0    0    0    0    0   0    0    0    0
>> >> 0    0    0
>> >> 2 -100.0    6    0    0    0    0    0    0   0    1    0    0
>> >> 0    0    0
>> >> 3  100.0    4    0    0    0    0    0    0   0    1    0    0
>> >> 0    0    0
>> >> 4  -33.3    7    0    0    0    0    0    0   0    0    0    0
>> >> 0    0    0
>> >> 5  200.0    2    0    0    0    0    0    0   0    0    0    0
>> >> -1    0    0
>> >> 6  -83.3   12    0    -1    0    0    0    0   0    0    0    0
>

Re: [R] creating a count variable in R

2011-03-03 Thread William Dunlap
Use cumsum() to count the change points:

> Date_var <- as.Date(rep(c("2011-02-04","2011-02-07","2011-01-29"),
c(2,3,1)))
> data.frame(Date_var, count=cumsum(c(TRUE,
Date_var[-1]!=Date_var[-length(Date_var)])))
Date_var count
1 2011-02-04 1
2 2011-02-04 1
3 2011-02-07 2
4 2011-02-07 2
5 2011-02-07 2
6 2011-01-29 3

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of JonC
> Sent: Thursday, March 03, 2011 1:58 PM
> To: r-help@r-project.org
> Subject: [R] creating a count variable in R
> 
> Hi R helpers,
> 
> I'm trying to create a count in R , but as there is no retain 
> function like
> in SAS I'm running into difficulties.
> 
> I have the following :
> 
> Date_var   and wish to obtain  
> Date_var 
> Count_var 
> 01/01/2011
>01/01/2011 
> 1
> 01/01/2011
>01/01/2011 
> 2
> 02/01/2011
>02/01/2011 
> 1
> 02/01/2011
>02/01/2011 
> 2
> 02/01/2011
>02/01/2011 
> 3
> 02/01/2011
>02/01/2011 
> 4
> 03/01/2011
>03/01/2011 
> 1
> 03/01/2011
>03/01/2011 
> 2
> 03/01/2011
>03/01/2011 
> 3
> 03/01/2011
>03/01/2011 
> 4
> 03/01/2011
>03/01/2011 
> 5
> 03/01/2011
>03/01/2011 
> 6
> 03/01/2011
>03/01/2011 
> 7
> 
> As can be seen above the count var is re initialised every 
> time a new date
> is found. I hope this is easy.
> 
> Many thanks in advance for assistance. It is appreciated. 
> 
> Cheers
> 
> Jon 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/creating-a-count-variable-in-R-t
p3334288p3334288.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] Regression with many independent variables

2011-03-03 Thread Matthew Douglas
Thanks for getting back to me so quickly greg. Im not quite sure how
to do what you just said, is there an example that you can show?

I understand how to create the string with a formula in it but im not
sure how to loop through the pairs of variables? How do I first get
these 2way interaction variables, I can no longer use the "^" right?

Sorry for so many questions,

Matt
On Thu, Mar 3, 2011 at 4:16 PM, Greg Snow  wrote:
> What you might need to do is create a character string with your formula in 
> it (looping through pairs of variables and using paste or sprint) then 
> convert that to a formula using the as.formula function.
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
>> -Original Message-
>> From: Matthew Douglas [mailto:matt.dougla...@gmail.com]
>> Sent: Thursday, March 03, 2011 2:09 PM
>> To: Greg Snow
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Regression with many independent variables
>>
>> Thanks greg,
>>
>>  that formula was exactly what I was looking for. Except now when I
>> run it on my data I get the following error:
>>
>> "Error in model.matrix.default(mt, mf, contrasts) : cannot allocate
>> vector of length 2043479998"
>>
>> I know there are probably many 2-way interactions that are zero so I
>> thought I could save space by removing these. Is there some way that
>> can just delete all the two way interactions that are zero and keep
>> the columns that have non-zero entries? I think that will
>> significantly cut down the memory needed. Or is there just another way
>> to get around this?
>>
>> thanks,
>> Matt
>>
>> On Tue, Mar 1, 2011 at 3:56 PM, Greg Snow  wrote:
>> > You can use ^2 to get all 2 way interactions and ^3 to get all 3 way
>> interactions, e.g.:
>> >
>> > lm(Sepal.Width ~ (. - Sepal.Length)^2, data=iris)
>> >
>> > The lm.fit function is what actually does the fitting, so you could
>> go directly there, but then you lose the benefits of using . and ^.
>>  The Matrix package has ways of dealing with sparse matricies, but I
>> don't know if  that would help here or not.
>> >
>> > You could also just create x'x and x'y matricies directly since the
>> variables are 0/1 then use solve.  A lot depends on what you are doing
>> and what questions you are trying to answer.
>> >
>> > --
>> > Gregory (Greg) L. Snow Ph.D.
>> > Statistical Data Center
>> > Intermountain Healthcare
>> > greg.s...@imail.org
>> > 801.408.8111
>> >
>> >
>> >> -Original Message-
>> >> From: Matthew Douglas [mailto:matt.dougla...@gmail.com]
>> >> Sent: Tuesday, March 01, 2011 1:09 PM
>> >> To: Greg Snow
>> >> Cc: r-help@r-project.org
>> >> Subject: Re: [R] Regression with many independent variables
>> >>
>> >> Hi Greg,
>> >>
>> >> Thanks for the help, it works perfectly. To answer your question,
>> >> there are 339 independent variables but only 10 will be used at one
>> >> time . So at any given line of the data set there will be 10 non
>> zero
>> >> entries for the independent variables and the rest will be zeros.
>> >>
>> >> One more question:
>> >>
>> >> 1. I still want to find a way to look at the interactions of the
>> >> independent variables.
>> >>
>> >> the regression would look like this:
>> >>
>> >> y = b12*X1X2 + b23*X2X3 +...+ bk-1k*Xk-1Xk
>> >>
>> >> so I think the regression in R would look like this:
>> >>
>> >> lm(MARGIN, P235:P236+P236:P237+,weights = Poss, data = adj0708),
>> >>
>> >> my problem is that since I have technically 339 independent
>> variables,
>> >> when I do this regression I would have 339 Choose 2 = approx 57000
>> >> independent variables (a vast majority will be 0s though) so I dont
>> >> want to have to write all of these out. Is there a way to do this
>> >> quickly in R?
>> >>
>> >> Also just a curious question that I cant seem to find to online:
>> >> is there a more efficient model other than lm() that is better for
>> >> very sparse data sets like mine?
>> >>
>> >> Thanks,
>> >> Matt
>> >>
>> >>
>> >> On Mon, Feb 28, 2011 at 4:30 PM, Greg Snow 
>> wrote:
>> >> > Don't put the name of the dataset in the formula, use the data
>> >> argument to lm to provide that.  A single period (".") on the right
>> >> hand side of the formula will represent all the columns in the data
>> set
>> >> that are not on the left hand side (you can then use "-" to remove
>> any
>> >> other columns that you don't want included on the RHS).
>> >> >
>> >> > For example:
>> >> >
>> >> >> lm(Sepal.Width ~ . - Sepal.Length, data=iris)
>> >> >
>> >> > Call:
>> >> > lm(formula = Sepal.Width ~ . - Sepal.Length, data = iris)
>> >> >
>> >> > Coefficients:
>> >> >      (Intercept)       Petal.Length        Petal.Width
>> >>  Speciesversicolor
>> >> >           3.0485             0.1547             0.6234
>>  -
>> >> 1.7641
>> >> >  Speciesvirginica
>> >> >          -2.1964
>> >> >
>> >> >
>> >> > But, are you sure that a regression model with 339 predictors will
>> be
>> >> meaningful?
>> >>

Re: [R] Scatter plot with multiple data sets

2011-03-03 Thread Joshua Wiley
Hi Joe,

The easiest option will be to combine all 6 datasets (at least the
variables you want to use in your scatter plot), and then create
another variable that indicates to which group the observations
belong.  Here is a small example of what you might do once your data
are all together (obviously replace "mtcars" with your dataset name
and the variables with your variables):

with(mtcars, plot(x = hp, y = mpg, pch = carb))

I am also fond using the ggplot2 package for graphs.

require(ggplot2)
ggplot(mtcars, aes(x = hp, y = mpg, shape = factor(carb))) + geom_point()

Cheers,

Josh

On Thu, Mar 3, 2011 at 12:03 PM, Jorseff  wrote:
> Hi, I have multiple (6) data sets which I would like to plot together on one
> scatter graph. The reason they are all separate is that I require a
> different symbol to be plotted for each set. Could somebody advise on how to
> do this?
>
> Many thanks,
>
> Joe
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Scatter-plot-with-multiple-data-sets-tp3334096p3334096.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] creating a count variable in R

2011-03-03 Thread David Winsemius


On Mar 3, 2011, at 3:58 PM, JonC wrote:


Hi R helpers,

I'm trying to create a count in R , but as there is no retain  
function like

in SAS I'm running into difficulties.


Your data is not cut-pastable as presented but this should work:

> dfrm$count_var <- ave(as.numeric(dfrm$Date_var), dfrm$Date_var,  
FUN=seq_along)

> dfrm
 Date_var count_var
1  01/01/2011 1
2  01/01/2011 2
3  02/01/2011 1
4  02/01/2011 2
5  02/01/2011 3
6  02/01/2011 4
7  03/01/2011 1
8  03/01/2011 2
9  03/01/2011 3
10 03/01/2011 4
11 03/01/2011 5
12 03/01/2011 6
13 03/01/2011 7




I have the following :

Date_var   and wish to obtain  Date_var
Count_var
01/01/2011
01/01/2011

1
01/01/2011
01/01/2011

2
02/01/2011
02/01/2011

1
02/01/2011
02/01/2011

2
02/01/2011
02/01/2011

3
02/01/2011
02/01/2011

4
03/01/2011
03/01/2011

1
03/01/2011
03/01/2011

2
03/01/2011
03/01/2011

3
03/01/2011
03/01/2011

4
03/01/2011
03/01/2011

5
03/01/2011
03/01/2011

6
03/01/2011
03/01/2011

7

As can be seen above the count var is re initialised every time a  
new date

is found. I hope this is easy.

Many thanks in advance for assistance. It is appreciated.

Cheers

Jon


--
View this message in context: 
http://r.789695.n4.nabble.com/creating-a-count-variable-in-R-tp3334288p3334288.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] creating a count variable in R

2011-03-03 Thread Bill.Venables
You can probably simplify this if you can assume that the dates are in sorted 
order.  Here is a way of doing it even if the days are in arbitrary order.  The 
count refers to the number of times that this date has appeared so far in the 
sequence.

con <- textConnection("
01/01/2011
01/01/2011
02/01/2011
02/01/2011
02/01/2011
02/01/2011
03/01/2011
03/01/2011
03/01/2011
03/01/2011
03/01/2011
03/01/2011
03/01/2011
")
days <- scan(con, what = "")
close(con)
X <- model.matrix(~days-1)
XX <- apply(X, 2, cumsum)
dat <- data.frame(days = days, count = rowSums(X*XX))
dat

###
this uses days as a character string vector.  If they are actual dates, then 
convert them to character strings for this operation.

Bill Venables. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of JonC
Sent: Friday, 4 March 2011 7:58 AM
To: r-help@r-project.org
Subject: [R] creating a count variable in R

Hi R helpers,

I'm trying to create a count in R , but as there is no retain function like
in SAS I'm running into difficulties.

I have the following :

Date_var   and wish to obtain  Date_var 
Count_var 
01/01/2011   01/01/2011 
1
01/01/2011   01/01/2011 
2
02/01/2011   02/01/2011 
1
02/01/2011   02/01/2011 
2
02/01/2011   02/01/2011 
3
02/01/2011   02/01/2011 
4
03/01/2011   03/01/2011 
1
03/01/2011   03/01/2011 
2
03/01/2011   03/01/2011 
3
03/01/2011   03/01/2011 
4
03/01/2011   03/01/2011 
5
03/01/2011   03/01/2011 
6
03/01/2011   03/01/2011 
7

As can be seen above the count var is re initialised every time a new date
is found. I hope this is easy.

Many thanks in advance for assistance. It is appreciated. 

Cheers

Jon 


--
View this message in context: 
http://r.789695.n4.nabble.com/creating-a-count-variable-in-R-tp3334288p3334288.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.


[R] R: Help center

2011-03-03 Thread l.mittempergher
I also would like to stop the mailing, without unsubscribing myself from the 
help center.

How can I proceed?Thanks

Lorenza

Da: r-help-boun...@r-project.org [r-help-boun...@r-project.org] per conto di 
David Winsemius [dwinsem...@comcast.net]
Inviato: giovedì 3 marzo 2011 23.45
A: Bobby Lee
Cc: R-help@r-project.org
Oggetto: Re: [R] Help center

You need to unsubscribe using the same method you use to subscribe
go to the webpage for the list and log in with the password you set.
If all you wnat to stop is the mailing, you can do so without
unsubscribing.


On Mar 3, 2011, at 3:09 PM, Bobby Lee wrote:

> Could you please take my email off the help center? Thank you very
> much.
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

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


[R] Plotting Mean in plotting degree distribution

2011-03-03 Thread kparamas
Hi,

I am plotting degree distribution of a graph using the function,

library(igraph)
dd1 = degree.distribution(G)

plot(dd1, xlab = "degree", ylab="frequency")

I would like to plot the mean of the distribution as a vertical line in the
attached plot.
Please let me know how to do this.

Thanks,
Kumar http://r.789695.n4.nabble.com/file/n3334375/cdata3_dd.png
cdata3_dd.png 

--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-Mean-in-plotting-degree-distribution-tp3334375p3334375.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] lattice custom axis function -- right side margins

2011-03-03 Thread Timothy W. Hilton
To clarify the trouble I'm having with ylab.right, I am not getting an
error message; the right-side label just does not appear on the plot.

-Tim

> On Thu, Mar 3, 2011 at 1:50 PM, Timothy W. Hilton wrote:
> 
> > Many thanks, Richard -- the position argument does exactly what I
> > needed.  I'm not having any luck with the ylab.right argument.  My R and
> > lattice are up to date (below); is there something else I should check?
> >
> > Thanks for the help,
> > Tim
> >
> > > sessionInfo()
> > R version 2.12.2 (2011-02-25)
> > Platform: i386-apple-darwin9.8.0/i386 (32-bit)
> >
> > 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
> >
> > other attached packages:
> > [1] lattice_0.19-17
> >
> > loaded via a namespace (and not attached):
> > [1] grid_2.12.2  tools_2.12.2
> >
> > On Thu, Mar 2011, 03 at 01:05:49PM -0500, Richard M. Heiberger wrote:
> > > print(my_plot(example_data, ylab.right=expression(e==mc^2)),
> > > position=c(0,0,.95,1))
> > >
> > > You will need a recent R version for the ylab.right argument.
> > >
> > > On Thu, Mar 3, 2011 at 12:52 PM, Timothy W. Hilton  > >wrote:
> > >
> > > > Dear R help list,
> > > >
> >

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


Re: [R] error in saved .csv

2011-03-03 Thread Jim Holtman
why didn't work?  What was the error, or why did you assume there was an error? 
 Can you clarify.

Sent from my iPad

On Mar 1, 2011, at 17:50, Tamas Barjak  wrote:

> Yes, the format is incorrect. I have already tried the write.table, but it 
> didn't work.
> 
> 
> 2011/3/1 jim holtman 
> I am not sure what you are saying your problem is?  Is the format
> incorrect?  BTW, notice that write.csv does not have a 'sep'
> parameter.  Maybe you should be using write.table.
> 
> On Tue, Mar 1, 2011 at 4:36 PM, Tamas Barjak  wrote:
> > Help me please!
> >
> > I would like to be saved a data table:
> >
> > write.csv(random.t1, "place", dec=",", append = T, quote = FALSE, sep = " ",
> > qmethod = "double", eol = "\n", row.names=F)
> >
> > It's OK!
> >
> > But the rows of file
> >
> >  1,1,21042,-4084.87179487179,2457.66483516483,-582.275562799881
> > 2,2,23846,-6383.86480186479,-3409.98451548449,-3569.72145340269
> > and no
> >
> > 1
> > 21042 - 4084.87179487179 2457.66483516483
> > Not proportional...
> >
> > What's the problem???
> >
> > 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.
> >
> 
> 
> 
> --
> Jim Holtman
> Data Munger Guru
> 
> What is the problem that you are trying to solve?
> 

[[alternative HTML version deleted]]

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


Re: [R] lattice: How to increase space between ticks and labels of z-axis?

2011-03-03 Thread P Ehlers

Marius Hofert wrote:

Dear expeRts,

How can I increase the space between the ticks and the labels in the wireframe 
plot
below? I tried some variations with par.settings=list(..) but it just didn't 
work.


Marius,

I tried setting the 'distance' parameter, but that was less
than satisfactory. One way is to modify the labels appropriately:

 z_at <- seq(2000,1,2000)
 z_labs <- paste(z_at, "", sep="")

which tacks on some spaces, and then plot:

 wireframe(z~grid[,1]*grid[,2],
  aspect=1,
  scales = list(arrows = FALSE,
z = list(at = z_at, lab = z_labs)
  ),
  zlab = list("z", hjust = 3),
  ylab = list(rot = -40),
  xlab = list(rot = 30)
)

Peter Ehlers



Many thanks,

Marius



library(lattice)

u <- seq(0, 1, length.out=20)
grid <- expand.grid(x=u, y=u)
z <- apply(grid, 1, function(x) 1/(x[1]*x[2]+0.0001))

wireframe(z~grid[,1]*grid[,2], aspect=1, scales=list(col=1, arrows=FALSE))
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice custom axis function -- right side margins

2011-03-03 Thread P Ehlers

Timothy W. Hilton wrote:

To clarify the trouble I'm having with ylab.right, I am not getting an
error message; the right-side label just does not appear on the plot.


Maybe this is mac-specific. On Windows, the label shows up
just fine. You might be able to make it appear by adjusting
the 'vjust' argument to ylab.right:

print(my_plot(example_data,
  ylab.right = list(expression(e==mc^2), vjust = -2)),
  position = c(0,0,.95,1))

Try playing with 'vjust'.

Peter Ehlers



-Tim


On Thu, Mar 3, 2011 at 1:50 PM, Timothy W. Hilton wrote:


Many thanks, Richard -- the position argument does exactly what I
needed.  I'm not having any luck with the ylab.right argument.  My R and
lattice are up to date (below); is there something else I should check?

Thanks for the help,
Tim


sessionInfo()

R version 2.12.2 (2011-02-25)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

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

other attached packages:
[1] lattice_0.19-17

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

On Thu, Mar 2011, 03 at 01:05:49PM -0500, Richard M. Heiberger wrote:

print(my_plot(example_data, ylab.right=expression(e==mc^2)),
position=c(0,0,.95,1))

You will need a recent R version for the ylab.right argument.

On Thu, Mar 3, 2011 at 12:52 PM, Timothy W. Hilton 
Dear R help list,



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

2011-03-03 Thread Joshua Wiley
Hi Shari,

Yes, please look at the documentation for principal.  You can access
this (assuming you have loaded psych) by typing at the console:

?principal

note the logical argument "scores".

Here is a small example:

##
require(psych)
require(GPArotation)

dat <- principal(mtcars[, c("mpg", "hp", "wt")], nfactors = 1,
  rotate = "oblimin", scores = TRUE)

dat$scores
##

Cheerio,

Josh

On Thu, Mar 3, 2011 at 1:02 PM, Shari Clare  wrote:
> I am running a PCA, but would like to rotate my data and limit the
> number of factors that are analyzed.  I can do this using the
> "principal" command from the psych package [principal(my.data,
> nfactors=3,rotate="varimax")], but the issue is that this does not
> report scores for the Principal Components the way "princomp" does.
>
> My question is:
>
> Can you get an output of scores using "principal" OR, is there a way
> to limit the number of factors that are included when you use
> "princomp"?
>
> Thanks,
> Shari Clare
>
> PhD Candidate
> Department of Renewable Resources
> University of Alberta
> scl...@ualberta.ca
> 780-492-2540
>
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
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] lattice custom axis function -- right side margins

2011-03-03 Thread Timothy W. Hilton
I went to try your suggestion, and the label appeared without the vjust
argument.  I usually run R within emacs using ESS; I happened to restart
my emacs earlier today.  That's the only thing I can think of that I
changed.  Next time I'll try running R outside of emacs before asking
for help.

Many thanks to all who responded!

-Tim

On Thu, Mar 2011, 03 at 05:01:58PM -0800, P Ehlers wrote:
> Timothy W. Hilton wrote:
> >To clarify the trouble I'm having with ylab.right, I am not getting an
> >error message; the right-side label just does not appear on the plot.
> 
> Maybe this is mac-specific. On Windows, the label shows up
> just fine. You might be able to make it appear by adjusting
> the 'vjust' argument to ylab.right:
> 
> print(my_plot(example_data,
>   ylab.right = list(expression(e==mc^2), vjust = -2)),
>   position = c(0,0,.95,1))
> 
> Try playing with 'vjust'.
> 
> Peter Ehlers
> 
> >
> >-Tim
> >
> >>On Thu, Mar 3, 2011 at 1:50 PM, Timothy W. Hilton 
> >>wrote:
> >>
> >>>Many thanks, Richard -- the position argument does exactly what I
> >>>needed.  I'm not having any luck with the ylab.right argument.  My R and
> >>>lattice are up to date (below); is there something else I should check?
> >>>
> >>>Thanks for the help,
> >>>Tim
> >>>
> sessionInfo()
> >>>R version 2.12.2 (2011-02-25)
> >>>Platform: i386-apple-darwin9.8.0/i386 (32-bit)
> >>>
> >>>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
> >>>
> >>>other attached packages:
> >>>[1] lattice_0.19-17
> >>>
> >>>loaded via a namespace (and not attached):
> >>>[1] grid_2.12.2  tools_2.12.2
> >>>
> >>>On Thu, Mar 2011, 03 at 01:05:49PM -0500, Richard M. Heiberger wrote:
> print(my_plot(example_data, ylab.right=expression(e==mc^2)),
> position=c(0,0,.95,1))
> 
> You will need a recent R version for the ylab.right argument.
> 
> On Thu, Mar 3, 2011 at 12:52 PM, Timothy W. Hilton  wrote:
> 
> >Dear R help list,
> >
> >
> >__
> >R-help@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/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] R usage survey

2011-03-03 Thread Bill.Venables
No.  That's not answering the question.  ALL surveys are for collecting 
information.

The substantive issue is what purpose do you have in seeking this information 
in the first place and what are you going to do with it when you get it?

Do you have some commercial purpose in mind?  If so, what is it?

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Harsh
Sent: Friday, 4 March 2011 1:13 AM
To: rex.dw...@syngenta.com
Cc: r-help@r-project.org
Subject: Re: [R] R usage survey

Hi Rex and useRs,

The purpose of the survey has been mentioned on the survey link goo.gl/jw1ig
but I will also reproduce it here.
- Geographical distribution of R users
- Application areas where R is being used
- Supporting technology being used along with R
- Academic background distribution of R users

The potential personally identifiable information such as name and employer
name are optional fields. Actually all the fields in the survey are
optional.

Some of the analysis output(s) could be along the lines of :-
- Usage statistics of various R packages
- Distribution of R users across countries/cities
- Mapping various applications to packages
- Text Mining of the responses to create informative word clouds

Personally, I am excited about the kind of data I will receive through this
survey and the various insights that could be derived. As already mentioned,
the results will be shared with the community.

Thank you Rex for raising an important point. It is indeed necessary for me
to personally assure the user community that the results will be shared in a
manner that will not contain any personally identifiable information.

Those who wish to gain access to the raw data will be provided with all the
fields but not the name and employer name fields.

Just out of curiosity : It is possible to get name, employer name, location,
usage information and academic background details when searching for R users
on LinkedIn and the many R related groups there.
Does this also provide potential opportunities for misuse and "outrageous"
analyses, since almost anyone can get onto LinkedIn and access user profiles
?

Thank you for your interest and support.
Regards,
Harsh












On Thu, Mar 3, 2011 at 8:02 PM,  wrote:

> Harsh, "Suitably analyzed" for whose purposes?  One man's "suitable" is
> another's "outrageous". That's why people want to see the gowns at the
> Oscars.  Under what auspices are you conducting this survey?  What do you
> intend to do with it?  You don't give any assurance that the results you
> post won't have personally identifiable information. I don't get the
> impression that you know much about survey design.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Harsh
> Sent: Thursday, March 03, 2011 5:53 AM
> To: r-help@r-project.org
> Subject: [R] R usage survey
>
> Hi R users,
> I request members of the R community to consider filling a short survey
> regarding the use of R.
> The survey can be found at http://goo.gl/jw1ig
>
> Please accept my apologies for posting here for a non-technical reason.
>
> The data collected will be suitably analyzed and I'll post a link to the
> results in the coming weeks.
>
> Thank you all for your interest and for sharing your R usage information.
>
> Regards,
> Harsh Singhal
>
> [[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.
>
>
>
>
> message may contain confidential information. If you are not the designated
> recipient, please notify the sender immediately, and delete the original and
> any copies. Any use of the message by you is prohibited.
>
>

[[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] Floating points and floor() ?

2011-03-03 Thread Folkes, Michael
Perhaps somebody could clarify for me if the following is a floating
point matter or otherwise, and how am I to correct for it?

> floor(100*.1)
[1] 10

> 100*(1.0-.9)
[1] 10

> floor(100*(1-0.9))
[1] 9


Thanks!
Michael
___
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans 
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  michael.fol...@dfo-mpo.gc.ca


[[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] What am I doing wrong with this loop ?

2011-03-03 Thread eric
Bill, I addressed the first issue with the data frames and length(x). But my
loops still isn't working. More importantly, you commented that I should be
using if(...) ... else ... rather than ifelse(.,.,).

Please help me understand the difference. I thought ifelse was just a faster
way of doing if(...)...else(.,.,).

What is the difference between these two methods ?

--
View this message in context: 
http://r.789695.n4.nabble.com/What-am-I-doing-wrong-with-this-loop-tp3332703p3334591.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Plotting Mean in plotting degree distribution

2011-03-03 Thread Scott Chamberlain
library(igraph)
G <- erdos.renyi.game(1000, 1/1000) # a random graph

dd1 = degree.distribution(G) 

plot(dd1, xlab = "degree", ylab="frequency") 
abline(h = mean(dd1)) # the mean would be a horizontal line

On Thursday, March 3, 2011 at 4:43 PM, kparamas wrote: 
> Hi,
> 
> I am plotting degree distribution of a graph using the function,
> 
> library(igraph)
> dd1 = degree.distribution(G)
> 
> plot(dd1, xlab = "degree", ylab="frequency")
> 
> I would like to plot the mean of the distribution as a vertical line in the
> attached plot.
> Please let me know how to do this.
> 
> Thanks,
> Kumar http://r.789695.n4.nabble.com/file/n3334375/cdata3_dd.png
> cdata3_dd.png 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Plotting-Mean-in-plotting-degree-distribution-tp3334375p3334375.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.


  1   2   >