[R] Combined grouped and stacked bargraph

2012-05-02 Thread Nicola Van Wilgen
Dear R-list

 

I am having some trouble drawing a bar-graph with two groups, both of
which are stacked.

 

Here are my data in the dput format:

 

cs.not.log.bp - (

structure(c(168, 69, 16, 69, 41, 6, 148, 6, 5, 4, 7, 4, 4, 2, 7, 2, 4,
2, 4, 2, 1, 0, 2, 0), .Dim = c(4L, 6L), .Dimnames = list(

c(IUCN.Terrestrial, IUCN.Marine, National.CS.Terrestrial, 

National.CS.Marine), c(NE, LC, NT, VU, EN, CR

))) )

 

The database format is shown below, where columns represent conservation
status and the rows are two classification methods each split into
marine and terrestrial:

 

 NE  LC NT VU EN CR

IUCN.Terrestrial168  41  5  4  4  1

IUCN.Marine  69   6  4  2  2  0

National.CS.Terrestrial  16 148  7  7  4  2

National.CS.Marine   69   6  4  2  2  0

 

I would like to plot the conservation status according to two
classifications (i.e. my groups - IUCN status and national status), and
for each of those groups I would like data for the marine and
terrestrial species to be stacked. 

 

I have tried the following code (where cs.not.log.bp is my data), but it
does not work:

 

barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
Number of species, col = c(grey90,grey80), ylim = c(0,250), space
= 2)

 

barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
T,add = T,names.arg = NA)

 

legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
Terrestrial,National CS Marine),  col =
c(grey90,grey80,grey60,grey30), pch = 15)

 

What happens is that some of the data in the second group stacks onto
the first group and then the remainder forms a second group. I would
like only like data (i.e. from the same database row) to stack within
a group.

 

There was one other similar post on the R-list
(http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
the user had the same problem as I did, but it does not seem that this
was resolved.

 

Please let me know if you have any suggestions.

 

Thanks and best wishes,

 

Nicola

 


This e-mail communication and any attachments are confidential and are intended 
only for the individual(s) or entity named above and others who have been 
specifically authorized to receive it. If you are not the intended recipient, 
please do not copy, use or disclose the contents of this communication to 
others. 
Please notify the sender that you have received this email in error by replying 
to the e-mail or by telephoning the sender. Please then delete the e-mail and 
any copies of it. This information may contain private, confidential or 
privileged material. 
Thank you. 

[[alternative HTML version deleted]]

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


[R] How can I read the text or character string from a txt file?

2012-05-02 Thread jpm miao
Hello,

   I have a large number of time series, which needs to be transformed by
log or difference. Some of them are just processed by level (LV) without
any transformation. For that purpose, I produce a text file (.csv or .xls)
as follows:

DLN DLNDLN LV LV LV...

How can I read the preceding strings so that I can easily access them,
i.e., S[1]=DLN, S[2]=DLN, S[3]=DLN, S[4]=LV,S[5]=LV,S[6]=LV? I tried
read.csv and read.table, but they don't work well. If I can access the
string, then I will be able to write an if statement so that

   If the string is DLN, then take log and then difference.
   If the string is LV, then just keep it as it is.

   Thanks,

miao

[[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] Hmisc's latex: na.blank and grouping not working as expected

2012-05-02 Thread Marius Hofert
Dear expeRts,

Why does na.blank=TRUE not replace the NA's in the following LaTeX table?

x - matrix(1:72, ncol=4, nrow=8)
colnames(x) - c(gr1.sgr1, gr1.sgr2, gr2.sgr1, gr2.sgr2)
rn - apply(expand.grid(beta=c(0.25, 0.75), n=c(100, 500), d=c(10, 100))[, 
3:1], 2, rmNames)
x - cbind(rn, x) # append columns containing the row labels
x[2,5] - NA
stopifnot(is.na(x[2,5]))

require(Hmisc)
latex(x,
  file=,
  na.blank=TRUE,
  rowlabel=c(d, n, beta),
  booktabs=TRUE)

In the end, I would like to have the columns displayed in groups like this:

Group 1 Group 2
d   n   beta   Sub-group 1   Sub-group 2   Sub-group 1   Sub-group 2
10  100 0.25   1 9
0.75   2
500 0.25   310
0.75   411 ...   ...
100 100 0.25   512
0.75   613
500 0.25   7...
0.75   8

If anybody knows how to do this, please let me know :-) This is (one of) my 
trial(s):

latex(x,
  file=,
  cgroup=c(, Group 1, Group 2),
  n.cgroup=c(3, 2, 2),
  na.blank=TRUE,
  rowlabel=c(d, n, beta),
  booktabs=TRUE)

Why are there two empty columns inserted and the table has suddenly 9 columns 
instead of 7?

Cheers,

Marius

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


Re: [R] Define lower-upper bound for parameters in Optim using Nelder-Mead method

2012-05-02 Thread Hans W Borchers
Ben Bolker bbolker at gmail.com writes:

 
  Ted.Harding at wlandres.net writes:
 
   In addition to these options, there is also a derivative-free
 box-constrained optimizer (bobyqa) in the 'minqa' package (and in
 an optim-like wrapper via the optimx package), and
 a box-constrained Nelder-Mead optimizer in the development
 (r-forge) version of lme4, which is based on the NLopt optimization
 library (also accessible via the nloptr package).
 

I could add another Nelder-Mead implementation in package 'dfoptim'. It comes
in pure R and is still quite efficient, based on Kelley's well-known book code.
It exists in unconstrained and box-constraint versions.

The optimization world in R is by now really scattered across many different
package with sometimes 'strange' names. Some of the packages have not yet made
it from R-Forge to CRAN. Unfortunately, the Optimization task view is not of
much help anymore in this shattered world.

We will get a lot more of these questions on R-help if we do not come up with a
solution to this problem, for instance more up-to-date optimization functions
in R base, a recommened package for optimization, or e.g. an optimization guide
as a kind of global vignette.

Hans Werner

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


[R] Help in poLCA

2012-05-02 Thread arunkumar1111
Hi

My data  looks like this

 dat=
 X1 X2  Group
84  44  1
86  29  1
94  77  1
78  87  2
94  78  2
60  31  2

I use the formula

form = cbind(X1,X2) ~ Group
poLCA(form,dat)

But i'm getting error stating that 

ALERT: some manifest variables contain values that are not   positive
integers.  For poLCA to run, please recode categorical   outcome variables
to increment from 1 to the maximum number of   outcome categories for each
variable


Please can any one help

  

-
Thanks in Advance
Arun
--
View this message in context: 
http://r.789695.n4.nabble.com/Help-in-poLCA-tp4602300.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] calibration of Garch models to historical data

2012-05-02 Thread Ivette
I have done the usual estimation of GARCH models, applied to my historical
dataset (commodities futures) with a maximum likelihood function and
selected the best model on the basis of information criteria such as Akaike
and Bayes.

Can somebody explain me please the calibration scheme for a GARCH model? 

I was not able to find a paper, dealing with exactly this algorithm for my
case. I only understood that I have to compare the performance of the best
GARCH model (from the estimation step), fitted to my historical dataset and
a GARCH simulation (let's abbreviate this Squared Error difference to E2).
However, it is not clear to me:
- with what parameters' values to start this simulation,
- how many times it is normal to perform it, and 
- what to compare via E2 (maximum likelihood values, or parameter values)
- how to constructassess E2 for the GARCH case.

Thank you in advance for your suggestions.

Ivette

--
View this message in context: 
http://r.789695.n4.nabble.com/calibration-of-Garch-models-to-historical-data-tp4602606.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to read ANOVA output

2012-05-02 Thread aRghhhhhh
Hey all who have responded to this post. I am a newbie to ANOVA analysis in
R, and let me tell you- resources for us learners are scant, horrible,
unclear, imprecise.. in other words.. the worst ever. So advice like go
look it up in your classical textbook or on google is not helpful at all.
I am scouring posts like these to try to find some kind soul who not only
understands the basics, but is willing to help us new folk out.. sadly..
here is not the place.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-read-ANOVA-output-tp2329457p4602403.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] DepmixS4

2012-05-02 Thread deepakw
Hi I am trying to use depmixS4 package. Based on the documentation, it seems
that depmix allows one to fit an HMM model based on a training data with
time-varying co-variates. However, I did not find any routines which can
help test the accuracy on the fitted HMM model on out-of-sample data.
Can someone confirm if that is indeed the case?
Also are there any alternate packages for the same? 
Thanks
-Deepak

--
View this message in context: 
http://r.789695.n4.nabble.com/DepmixS4-tp4602417.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] Tutorial for ff package

2012-05-02 Thread Indrajit Sengupta
Is anybody planning to write an extensive tutorial on the ff package? I am 
finding the web links highly inadequate.
 
Regards,
Indrajit
[[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] Referencing factors through their equivalent numeric level

2012-05-02 Thread Kaushik Krishnan
Hey folks

I'm sorry for bringing what must be a very simple question to R-help,
but after some research I haven't been able to find a solution to my
problem.

Suppose I create a simple factor:
[code]
 x-c(A,B,B,C,A)
 x
[1] A B B C A
 x - as.factor(x)
 x
[1] A B B C A
Levels: A B C
[/code]

Now, when I see this factor in terms of its numeric level values, I get
[code]
 as.numeric(x)
[1] 1 2 2 3 1
[/code]

Suppose I have
[code]
y - 2
[/code]

I want the numeric value of y to reference the level of factor x. That
is, I am looking for a function (`foo') so that I will get the
following
[code]
foo(y) #or maybe foo(y,x)
[1] B
[/code]

I can think of a roundabout way of doing through a user defined
function, but I am sure that there is a built-in function that offers
this functionality. I'd be grateful if someone could tell me what that
function is.

Thanks in advance

-- 
Kaushik Krishnan
(kaushik.s.krish...@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] list objects calculation

2012-05-02 Thread jiangxijixzy
I have two kinds of list,
for example,  one is like
t[[1]]=
1 6
2 7
3 8
4 9
5 10
...
t[[731]]
the other is
k[[1]]= 9 10
...
k[[731]]
I want to have a new list,like x
x[[1]]=
(1-9)/9(6-10)/10
(2-9)/9(7-10)/10
(3-9)/9(8-10)/10
(4-9)/9(9-10)/10
(5-9)/9(10-10)/10 
...
x[[731]]
How should I do?
Thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/list-objects-calculation-tp4602437.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] Extracting results from a median polish

2012-05-02 Thread Martin Raymond Lefebvre
Quick question from a new user to R,
 
 How do I extract my solution of a median polish matrix from R to a spreadsheet 
file such as .csv?
 
From my reading of my guide book (R for SPSS and SAS users version 2), I 
deduce that exporting a file to .csv would look like the following:
write.csv(medpolish, file =outfilename.csv, row.names = FALSE) , 

by I get the following:
Error in as.data.frame.default(x[[i]], optional = TRUE) : 
  cannot coerce class 'function' into a data.frame

So far I've been copy/pasting segment by segment into Excel and running 
text2column, but there has got to be a better way.


Martin R. Lefebvre


[[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] Numeric data not numeric in .csv file

2012-05-02 Thread Jim Lemon

On 05/02/2012 10:47 AM, Eve Proper wrote:

I am a raw novice to R, playing around with a mini .csv dataset created in
Excel. I can read it in and the data looks OK in Excel and upon initial
inspection in R:

hikes- read.csv(/Users/eproper/Desktop/hikes.csv, header=TRUE)
print(hikes)

does exactly what it is supposed to do.

Two of the variables are genuine strings, but the others ought to be
numeric, and R will calculate their min, max etc. However, is.numeric
returns FALSE for all of them; storage.mode returns language. as.numeric
returns Error: 'pairlist' object cannot be coerced to type 'double'. In
what I suspect is a related problem, any command that calls for a variable
name requires an initial ~ to work. That is, instead of plot(miles) I have
to use plot(~miles).

No doubt there is some very elementary mistake I am making, but I can't
figure it out. Any help would be appreciated.


Hi Eve,
Have you tried as.numeric on them? As Jeff suggested, you may be 
importing spaces along with the digits or some other character that 
changes the class of the variable. Also note that the default behavior 
of functions like read.csv is to coerce all of the values in a column of 
the resulting data frame to the lowest common denominator. If you have 
one text value in a column of numbers, you usually get factor values. 
This is due to the restriction that all values in a column must be of 
the same class (data type).


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] How to plot stacked histogram in R?

2012-05-02 Thread Manish Gupta
Hi, 

I am working on data analysis. I need to plot stacked histogram for two
Files.

File1: 
1
2
3
3
4
4

File2:
4
5
6
6
7
7
7

How can i plot them on same graph?

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-plot-stacked-histogram-in-R-tp4602369.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] Batch importing data

2012-05-02 Thread jiangxijixzy
Thank you very much.

--
View this message in context: 
http://r.789695.n4.nabble.com/Batch-importing-data-tp4592997p4602378.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] Combined grouped and stacked bargraph

2012-05-02 Thread Jim Lemon

On 05/02/2012 04:18 PM, Nicola Van Wilgen wrote:

Dear R-list



I am having some trouble drawing a bar-graph with two groups, both of
which are stacked.



Here are my data in the dput format:



cs.not.log.bp- (

structure(c(168, 69, 16, 69, 41, 6, 148, 6, 5, 4, 7, 4, 4, 2, 7, 2, 4,
2, 4, 2, 1, 0, 2, 0), .Dim = c(4L, 6L), .Dimnames = list(

 c(IUCN.Terrestrial, IUCN.Marine, National.CS.Terrestrial,

 National.CS.Marine), c(NE, LC, NT, VU, EN, CR

 ))) )



The database format is shown below, where columns represent conservation
status and the rows are two classification methods each split into
marine and terrestrial:



  NE  LC NT VU EN CR

IUCN.Terrestrial168  41  5  4  4  1

IUCN.Marine  69   6  4  2  2  0

National.CS.Terrestrial  16 148  7  7  4  2

National.CS.Marine   69   6  4  2  2  0



I would like to plot the conservation status according to two
classifications (i.e. my groups - IUCN status and national status), and
for each of those groups I would like data for the marine and
terrestrial species to be stacked.



I have tried the following code (where cs.not.log.bp is my data), but it
does not work:



barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
Number of species, col = c(grey90,grey80), ylim = c(0,250), space
= 2)



barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
T,add = T,names.arg = NA)



legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
Terrestrial,National CS Marine),  col =
c(grey90,grey80,grey60,grey30), pch = 15)



What happens is that some of the data in the second group stacks onto
the first group and then the remainder forms a second group. I would
like only like data (i.e. from the same database row) to stack within
a group.



There was one other similar post on the R-list
(http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
the user had the same problem as I did, but it does not seem that this
was resolved.


Hi Nicola,
This is somewhat unusual. You can do a QD like this:

barstack-function(x,y,heights,width,border=par(fg),col=NA) {
 nrect-length(heights)
 rect(rep(x-width/2,nrect),c(0,cumsum(heights[1:(nrect-1)])),
  rep(x+width/2,nrect),cumsum(heights),border=border,col=col)
}
cs.not.log.bp - (structure(c(168, 69, 16, 69, 41, 6, 148,
 6, 5, 4, 7, 4, 4, 2, 7, 2, 4,
 2, 4, 2, 1, 0, 2, 0), .Dim = c(4L, 6L),
 .Dimnames = list(
 c(IUCN.Terrestrial, IUCN.Marine, National.CS.Terrestrial,
   National.CS.Marine), c(NE, LC, NT, VU, EN, CR

plot(0,xlim=c(0.5,6.5),ylim=c(0,240),type=n)
for(stack in 1:6) {
 barstack(stack-0.2,0,cs.not.log.bp[1:2,stack],0.4,
  col=c(lightblue,blue))
 barstack(stack+0.2,0,cs.not.log.bp[3:4,stack],0.4,
  col=c(lightgreen,green))
}
legend(4,200,c(IUCN Terrestrial,IUCN Marine,
 National Terrestrial,National Marine),
 fill=c(lightblue,blue,lightgreen,green))

If you only need this one illustration, that is probably the easiest 
thing to do. You can add the appropriate title, axis labels and x-axis 
tick labels to finish it off. If you need to do a lot of this, it could 
be wrapped up in a little function that would incorporate or call the 
barstack function.


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.


Re: [R] How to plot stacked histogram in R?

2012-05-02 Thread Jim Lemon

On 05/02/2012 02:58 PM, Manish Gupta wrote:

Hi,

I am working on data analysis. I need to plot stacked histogram for two
Files.

File1:
1
2
3
3
4
4

File2:
4
5
6
6
7
7
7

How can i plot them on same graph?


Hi Manish,
Have a look at the third example for the barp function (plotrix).

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] Two ecdf with log-scales

2012-05-02 Thread Johannes Radinger
Hi,

i want to plot empirical cumulative density functions for two variables in
one plot. For better visualizing the differences in the two cumulative curves 
I'd like to log-scale the axis.

So far I found 3 possible functions to plot ecdf:

1) ecdf() from the package 'stats'. I don't know how to successfully set the 
log.scales? Combining two plots is not a problem:

plot(ecdf(x1))
lines(ecdf(x2),col.h=red)

2) gx.ecdf() from package 'rgr'. It is easily possible to plot log-scales, but 
I don't know how to plot two densities?

gx.ecdf(x1,log=TRUE,ifqs = TRUE)

3) Ecdf() from package 'Hmisc'. No log-option directly available and here I 
also don't know how to 'stack' two plots...

Ecdf(x1,what=F)


Probably there are many more solutions (e.g. ggplot etc.)...
...Has anyone faced a similar task and found a simple solution? Any suggestions 
are welcome!

Best regards,

Johannes


-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

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


Re: [R] How can I read the text or character string from a txt file?

2012-05-02 Thread Jim Holtman
If the symbols are separated by spaces, try:

scan(yourFile, what = '')

Sent from my iPad

On May 2, 2012, at 2:36, jpm miao miao...@gmail.com wrote:

 Hello,
 
   I have a large number of time series, which needs to be transformed by
 log or difference. Some of them are just processed by level (LV) without
 any transformation. For that purpose, I produce a text file (.csv or .xls)
 as follows:
 
DLN DLNDLN LV LV LV...
 
How can I read the preceding strings so that I can easily access them,
 i.e., S[1]=DLN, S[2]=DLN, S[3]=DLN, S[4]=LV,S[5]=LV,S[6]=LV? I tried
 read.csv and read.table, but they don't work well. If I can access the
 string, then I will be able to write an if statement so that
 
   If the string is DLN, then take log and then difference.
   If the string is LV, then just keep it as it is.
 
   Thanks,
 
 miao
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to read ANOVA output

2012-05-02 Thread Ista Zahn
My experience is the opposite -- the web is filled with introductory
statistics material, some of it quite good. If you google for
introduction to anova textbook the first hit seems to give exactly
what you are asking for. The fifth one down the list also looks good
(http://vassarstats.net/textbook/ch13pt1.html). And that's just what
you get for free! If you want more you can buy a textbook. I don't
understand why you are reluctant to take this advice, or why you think
someone here is going to be able to explain it better than a good
textbook will.

Best,
Ista

On Wed, May 2, 2012 at 1:37 AM, aRghh sydney.ver...@gmail.com wrote:
 Hey all who have responded to this post. I am a newbie to ANOVA analysis in
 R, and let me tell you- resources for us learners are scant, horrible,
 unclear, imprecise.. in other words.. the worst ever. So advice like go
 look it up in your classical textbook or on google is not helpful at all.
 I am scouring posts like these to try to find some kind soul who not only
 understands the basics, but is willing to help us new folk out.. sadly..
 here is not the place.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-read-ANOVA-output-tp2329457p4602403.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] Referencing factors through their equivalent numeric level

2012-05-02 Thread Berend Hasselman

On 02-05-2012, at 07:22, Kaushik Krishnan wrote:

 Hey folks
 
 I'm sorry for bringing what must be a very simple question to R-help,
 but after some research I haven't been able to find a solution to my
 problem.
 
 Suppose I create a simple factor:
 [code]
 x-c(A,B,B,C,A)
 x
 [1] A B B C A
 x - as.factor(x)
 x
 [1] A B B C A
 Levels: A B C
 [/code]
 
 Now, when I see this factor in terms of its numeric level values, I get
 [code]
 as.numeric(x)
 [1] 1 2 2 3 1
 [/code]
 
 Suppose I have
 [code]
 y - 2
 [/code]
 
 I want the numeric value of y to reference the level of factor x. That
 is, I am looking for a function (`foo') so that I will get the
 following
 [code]
 foo(y) #or maybe foo(y,x)
 [1] B
 [/code]
 
 I can think of a roundabout way of doing through a user defined
 function, but I am sure that there is a built-in function that offers
 this functionality. I'd be grateful if someone could tell me what that
 function is.

Maybe this?

levels(x)[y]

Berend

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


Re: [R] Clustering analysis with ordination plots

2012-05-02 Thread Gavin Simpson
Please read the posting guide for future questions.

I presume you mean using the vegan package? If so, then see this blog
post of mine which shows how to do something similar:

http://wp.me/pZRQ9-73

If you post more details and an example I will help further if the blog
post is not sufficient for you to get the solution you want.

G

On Mon, 2012-04-30 at 09:44 -0700, borinot wrote:
 Hello to all, 
 
 I'm new to R so I have a lot of problems with it, but I'll only ask the main
 one. 
 
 I have clustered an environmental matrix with 2 different methods, and I'd
 like to plot them in a PCA and a db-RDA. I mean, I want see these clusters
 in the plots like points of differents colours, together with the rest
 information of the plot, but I don't know how to do this. 
 
 I've checked a lot of bibliography and forums, and I haven't found the
 solution... it can't be so hard! 
 
 Well, thanks in advance! :) 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Clustering-analysis-with-ordination-plots-tp4598695.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.
 

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

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


Re: [R] VarCorr procedure from lme4

2012-05-02 Thread Nutter, Benjamin
I've run into this situation and have been able to prevent problems by using

 lme4::VarCor(...)

  Benjamin Nutter |  Biostatistician     |  Quantitative Health Sciences
  Cleveland Clinic    |  9500 Euclid Ave.  |  Cleveland, OH 44195  | (216) 
445-1365


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of David Stevens
Sent: Tuesday, May 01, 2012 9:58 PM
To: r-help@r-project.org
Subject: Re: [R] VarCorr procedure from lme4

That was it - detaching 'nlme' was the trick. Thanks Walmes and the rest.

David

On 5/1/2012 7:47 PM, David Stevens wrote:
 Yes - I also have nlme.  Bad juju?

 David

 On 5/1/2012 1:32 PM, Walmes Zeviani wrote:
 It could be a bad coexistence between packages in the same R session. 
 Are you using nlme and/or doBy packages too?

 Bests.
 Walmes.

 =
 =
 Walmes Marques Zeviani
 LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 
 49.231759 W) Departamento de Estatística - Universidade Federal do 
 Paraná
 fone: (+55) 41 3361 3573
 VoIP: (3361 3600) 1053 1173
 e-mail: wal...@ufpr.br
 twitter: @walmeszeviani
 homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 
 =
 =

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

--
David K Stevens, P.E., Ph.D., Professor
Civil and Environmental Engineering
Utah Water Research Laboratory
8200 Old Main Hill
Logan, UT  84322-8200
435 797 3229 - voice
435 797 1363 - fax
david.stev...@usu.edu




[[alternative HTML version deleted]]


===

 Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News  World Report (2010).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

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


Re: [R] Define lower-upper bound for parameters in Optim using Nelder-Mead method

2012-05-02 Thread Arnaud Mosnier
Thanks for this good idea !

Arnaud

2012/5/1 Ted Harding ted.hard...@wlandres.net

 On 01-May-2012 19:58:41 Arnaud Mosnier wrote:
  Dear UseRs,
 
  Is there a way to define the lower-upper bounds for parameters
  fitted by optim using the Nelder-Mead method ?
 
  Thanks,
  Arnaud

 The Nelder-Mead method does not provide built-in capability
 to set bounds on the range of paramaters. However, you can
 achieve it by hand by re-defining the function being
 minimised, so that it tests whether an out-of-range parameter
 parameter value is being used.

 If not out-of-range, then return the standard value of the function.
 If out-of range, then return a very large value.

 Nelder-Mead will very happily bounce off high walls of this
 kind, and if the minimum of the function is at the wall will
 happily converge as close to it as you please.

 Hoping this helps,
 Ted.

 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Date: 01-May-2012  Time: 22:39:15
 This message was sent by XFMail
 -


[[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] error in La.svd Lapack routine 'dgesdd'

2012-05-02 Thread Philipp Grueber
Dear R Users,

I have an unbalanced panel with (on average) approx. 100 individuals over
1370 time intervals (with individual time series of different lengths,
varying between 60 and 1370 time intervals). I use the following model:

res1-plm(x~c+d+e,data=pdata_frame, effect=twoways, model=within,
na.action=na.omit))


I repeatedly get the following error (which has been discussed in the past):

Error in La.svd(x, nu, nv) : error code 1 from Lapack routine ‘dgesdd’

I found it hard to create a reproducible example. As noted by Douglas Bates,
the error might be related to the scaling of the matrix. 

For variables x,c,d,and e in object pdata_frame, I find that all sd() are
reasonably similar both among the cross-sections as well as among the
variables. However, I find that extracting the demeaned data from plm(),
variables demXt$d and demXt$e (i.e. the demeaned variables) have sd()s that
are very small compared to those of dem_yt and demXt$c (approx. by factor
1e-15). I extract the demeaned data as follows:

dem_yt-pmodel.response(res) 
demXt-model.matrix(res)

How is this possible? What is it that plm() does with my data so that the
standard deviations change? 

I suspect effect=twoways to play a central role because plm() works fine
for effect=individual. I thought about the idea that maybe, time-effects
simply do not apply here. However: In order to test my regression for
time-effects (which I detect for subsamples (by time) and for equation x~e
at high levels of significance), I need both the model with and and the
model without time effects (as otherwise, I can't compare the two models in
an F-test), right? Any alternative tests? 
Another thought was that the impact of d and e changes over time (as in the
subsamples I do see such a change).

Any help is appreciated!

Best wishes,
Philipp Grueber

-

EBS Universitaet fuer Wirtschaft und Recht
FARE Department
Wiesbaden/ Germany
http://www.ebs.edu/index.php?id=finaccL=0
--
View this message in context: 
http://r.789695.n4.nabble.com/error-in-La-svd-Lapack-routine-dgesdd-tp2125052p4603097.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] Hypothesis Testing using Wald Criterion for two regression models with dummy variables

2012-05-02 Thread peter dalgaard

On May 1, 2012, at 22:01 , meredith wrote:

 I have two models, controlled by dummy variables to see if the models can be
 combined into one model with similar intercepts and slopes. Has anyone tried
 to conduct this type of test in R. I am utilizing the econometric idea of
 hypothesis testing through the hypothesis of coincidence. I have tried to
 run an anova with test of Chisq, but I am not sure what the results are
 telling. In addition, I used the rms package with a lrm model in an anova
 test, again I am not sure what the results are telling me:
 
 Can anyone help me with this?

Not unless you say what you are trying to do... As far as I can tell, you are 
(A) using a chi-square test for a standard linear model (Gaussian response) and 
(B) fitting a logistic regression model to the same response, which assumes 
that it is a proportion or binary response. Neither makes any sense to me. 

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] 2nd call for chapters: book Data Mining Applications with R; due by 31 May 2012

2012-05-02 Thread Yanchang Zhao
Book title: Data Mining Applications with R
Publisher: Elsevier
URL: http://www.rdatamining.com/books/book2
Due date: 2nd round of chapter proposals due by 31 May 2012
Potential authors are expected to submit a 1-2 page manuscript
proposal clearly explaining the mission and concerns of the proposed
chapter.
See details at http://www.rdatamining.com/books/book2.

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

2012-05-02 Thread Charles Determan Jr
Greetings R users,

My interest in the Q2cum score comes my endeavor to replicate SIMCAP PLS-DA
analysis in R.  I use the exact same dataset.  After doing the analysis in
R, I can get the exact same R2Ycum.  However, the Q2cum is significantly
off.  Adding the Q2cum of the 1st and 2nd component comes close but that
seems unconvincing and I don't understand why the 3rd component Q2cum would
be so far off.  Below is the code and output:

pls.reg.new=plsreg2(newserumvars.sc, newtimematrix, nc=3)
pls.reg.new$expvar  #this provides the exact R2Y I get in SIMCAP
pls.reg.new$Q2cum

The Q2cum values should be close to
component 1 = .2149
component 2 = .4578
*component 3 = .6627* #value of concern

All of the R output values are close for the respective class except for
the final Q2cum value:

   Q2cum.B Q2cum.FR8 Q2cum.S45  Q2cum
t1-0.05460.39920.2973   0.2140
t2 0.28630.38240.7039   0.4573
t3 0.58390.74300.6980   *0.3735  *#*not close*
Done.


I have read that the plspm package used LOO cross validation.  SIMCAP uses
the same method, however it leaves '7' out instead.  Perhaps this might be
an issue that results in this difference?

Any insight or assistance would be most appreciated.  I certainly
appreciate any time you take to answer my question.

Regards,

Charles Determan

[[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] list objects calculation

2012-05-02 Thread Petr PIKAL
Hi

you maybe can use mapply

If you have 2 lists

xl-list(x, x+5)
 xl
[[1]]
[1] 1 2 3 4 5

[[2]]
[1]  6  7  8  9 10

 yl-list(9,10)
 yl
[[1]]
[1] 9

[[2]]
[1] 10

and this function


fff- function(xl,yl) (xl-yl)/yl

mapply(fff, xl, yl)
   [,1] [,2]
[1,] -0.889 -0.4
[2,] -0.778 -0.3
[3,] -0.667 -0.2
[4,] -0.556 -0.1
[5,] -0.444  0.0

gives you probably desired result.

Regards
Petr


 
 I have two kinds of list,
 for example,  one is like
 t[[1]]=
 1 6
 2 7
 3 8
 4 9
 5 10
 ...
 t[[731]]
 the other is
 k[[1]]= 9 10
 ...
 k[[731]]
 I want to have a new list,like x
 x[[1]]=
 (1-9)/9(6-10)/10
 (2-9)/9(7-10)/10
 (3-9)/9(8-10)/10
 (4-9)/9(9-10)/10
 (5-9)/9(10-10)/10 
 ...
 x[[731]]
 How should I do?
 Thank you.
 
 --
 View this message in context: 
http://r.789695.n4.nabble.com/list-objects-
 calculation-tp4602437.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] Formal test for proportional subdistribution hazards assumption

2012-05-02 Thread Kruijsdijk, R.C.M. van
L.s.

I want to test the proportional subdistribution hazards assumption for several 
competing risk regression models I fitted using the crr()-function 
(cmprsk-package). I am able to plot the Schoenfeld-type residuals against 
failure time, but in some cases I doubt whether the assumption holds or not, so 
I was wondering whether a formal test analogous to the cox.zph for 
Cox-regression models exists for crr?

Thanks,

Rob van Kruijsdijk
University Medical Centre Utrecht


 

--

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

--

This message may contain confidential information and is...{{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.


[R] date and time conversion

2012-05-02 Thread mpostje




Hi

I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. the problem is that the database has put 
a T
between the numbers and R will not accept any conversions. 

this is the format that it's in now
1981-01-02T08:00

can anyone help?
cheers!   

--
View this message in context: 
http://r.789695.n4.nabble.com/date-and-time-conversion-tp4602786.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] convert numbers into dates and time

2012-05-02 Thread mpostje
Hi

I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. the problem is that the database has
put a T
between the numbers and R will not accept any conversions. 

this is the format that it's in now
1981-01-02T08:00

can anyone help?
cheers!

--
View this message in context: 
http://r.789695.n4.nabble.com/convert-numbers-into-dates-and-time-tp4602708.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] factor conversion to date/time

2012-05-02 Thread marjolein post




Hi, I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. I've tried as.Date, as.POSIXlt and 
strptime  the problem is that the database has put a T between the numbers and 
R will not accept any conversions. currently it sees the date as a factor with 
the format  as 1981-01-02T08:00I would like to keep only the year and month, 
but my primary focus is to get R to recognize it as a date.

Thank you for your help. cheers,Marjolein   
  
[[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] scanning a data set for strings

2012-05-02 Thread Daniel_55
Hello,

I'm looking for what I'm sure is a quick answer. I'm working with a data set
that looks like this:

 Week  Game.ID VTm VPts HTm HPts
Differential HomeWin
11  NFL_20050908_OAK@NE   OAK   20  NE 30   10 
FALSE
21 NFL_20050911_ARI@NYGARI   19  NYG   42   23 
FALSE
31 NFL_20050911_CHI@WAS   CHI7   WAS92  
FALSE
41 NFL_20050911_CIN@CLECIN   27   CLE13  -14   
FALSE
51  NFL_20050911_DAL@SD DAL   28  SD  24   -4   
 
FALSE
61 NFL_20050911_DEN@MIA  DEN   10 MIA34   24   
FALSE

NFL data. I want to pair each team with the points they received at home and
away and create another table showing this. I know it's easy to do, but all
the methods I am coming up with involve doing each team individually via a
for loop that searches for [i,5]==NE, [i,5]==NYG. I would then use the
same method to pair the same team code (NYG or NE) with VPTs when it's
Visiting.

Thanks for the help.

--
View this message in context: 
http://r.789695.n4.nabble.com/scanning-a-data-set-for-strings-tp4602953.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to read ANOVA output

2012-05-02 Thread John Kane
Or look for A handbook of Statistical Analyses using R. (Everitt and Holhorn) 
available on line in pdf format.

John Kane
Kingston ON Canada


 -Original Message-
 From: istaz...@gmail.com
 Sent: Wed, 2 May 2012 07:01:22 -0400
 To: sydney.ver...@gmail.com
 Subject: Re: [R] How to read ANOVA output
 
 My experience is the opposite -- the web is filled with introductory
 statistics material, some of it quite good. If you google for
 introduction to anova textbook the first hit seems to give exactly
 what you are asking for. The fifth one down the list also looks good
 (http://vassarstats.net/textbook/ch13pt1.html). And that's just what
 you get for free! If you want more you can buy a textbook. I don't
 understand why you are reluctant to take this advice, or why you think
 someone here is going to be able to explain it better than a good
 textbook will.
 
 Best,
 Ista
 
 On Wed, May 2, 2012 at 1:37 AM, aRghh sydney.ver...@gmail.com
 wrote:
 Hey all who have responded to this post. I am a newbie to ANOVA analysis
 in
 R, and let me tell you- resources for us learners are scant, horrible,
 unclear, imprecise.. in other words.. the worst ever. So advice like go
 look it up in your classical textbook or on google is not helpful at
 all.
 I am scouring posts like these to try to find some kind soul who not
 only
 understands the basics, but is willing to help us new folk out.. sadly..
 here is not the place.
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/How-to-read-ANOVA-output-tp2329457p4602403.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.


GET FREE SMILEYS FOR YOUR IM  EMAIL - Learn more at 
http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most 
webmails

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

2012-05-02 Thread alcesgabbo
I have a variable : 
*sim.var[,1]
*
Object of class SpatialPixelsDataFrame
Object of class SpatialPixels
Grid topology:
 cellcentre.offset cellsize cells.dim
Xloc   0.3 0.0597
Yloc   0.1 0.05   117
SpatialPoints:
Xloc Yloc
   [1,] 0.30 1.70
   [2,] 0.35 1.70
   [3,] 0.35 1.75
   [4,] 0.40 1.70
   [5,] 0.40 1.75
   [6,] 0.40 1.80
   [7,] 0.40 1.85
   [8,] 0.40 1.90
   [9,] 0.40 2.10
  [10,] 0.40 2.15
  [11,] 0.40 2.20
  [12,] 0.40 2.40
  [13,] 0.40 2.45


and a variable :
*sim.mean[,1]*
Object of class SpatialPixelsDataFrame
Object of class SpatialPixels
Grid topology:
 cellcentre.offset cellsize cells.dim
Xloc   0.3 0.0597
Yloc   0.1 0.05   117
SpatialPoints:
Xloc Yloc
   [1,] 0.30 1.70
   [2,] 0.35 1.70
   [3,] 0.35 1.75
   [4,] 0.40 1.70
   [5,] 0.40 1.75
   [6,] 0.40 1.80
   [7,] 0.40 1.85
   [8,] 0.40 1.90
   [9,] 0.40 2.10
  [10,] 0.40 2.15
  [11,] 0.40 2.20

If I plot these variables with:
*spplot(sim.var[,1],main=var)*
and 
*spplot(sim.mean[,1],main=mean)*

it works.

But how can I plot these two variables together with a single scale?

Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/Multiple-plots-tp4603205.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] DepmixS4

2012-05-02 Thread Ingmar Visser
Deepak,

On Wed, May 2, 2012 at 7:53 AM, deepakw deepakwarr...@gmail.com wrote:

 Hi I am trying to use depmixS4 package. Based on the documentation, it
 seems
 that depmix allows one to fit an HMM model based on a training data with
 time-varying co-variates. However, I did not find any routines which can
 help test the accuracy on the fitted HMM model on out-of-sample data.
 Can someone confirm if that is indeed the case?


depmixS4 does not have functionality for forecasting/state prediction and
similar if that is what you are after.


 Also are there any alternate packages for the same?


Not sure whether other packages can do that in combination with
time-varying co-variates.

Best, Ingmar


 Thanks
 -Deepak

 --
 View this message in context:
 http://r.789695.n4.nabble.com/DepmixS4-tp4602417.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Hypothesis Testing using Wald Criterion for two regression models with dummy variables

2012-05-02 Thread Bert Gunter
Meredith:

You are clearly out of your depth. Get local help. R-help is, err,
an R help list, not a resource for remote statistical consulting.
Although, I admit, there is often some overlap.

-- Bert

On Wed, May 2, 2012 at 5:58 AM, peter dalgaard pda...@gmail.com wrote:

 On May 1, 2012, at 22:01 , meredith wrote:

 I have two models, controlled by dummy variables to see if the models can be
 combined into one model with similar intercepts and slopes. Has anyone tried
 to conduct this type of test in R. I am utilizing the econometric idea of
 hypothesis testing through the hypothesis of coincidence. I have tried to
 run an anova with test of Chisq, but I am not sure what the results are
 telling. In addition, I used the rms package with a lrm model in an anova
 test, again I am not sure what the results are telling me:
 
 Can anyone help me with this?

 Not unless you say what you are trying to do... As far as I can tell, you are 
 (A) using a chi-square test for a standard linear model (Gaussian response) 
 and (B) fitting a logistic regression model to the same response, which 
 assumes that it is a proportion or binary response. Neither makes any sense 
 to me.

 --
 Peter Dalgaard, Professor
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] factor conversion to date/time

2012-05-02 Thread Duncan Murdoch

On 02/05/2012 8:08 AM, marjolein post wrote:




Hi, I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. I've tried as.Date, as.POSIXlt and 
strptime  the problem is that the database has put a T between the numbers and 
R will not accept any conversions. currently it sees the date as a factor with 
the format  as 1981-01-02T08:00I would like to keep only the year and month, 
but my primary focus is to get R to recognize it as a date.


To stop the conversion to factors, use argument stringsAsFactors=FALSE 
when you read the file, or even better, options(stringsAsFactors=FALSE) 
for a global change.


To convert a string, specify the format (following the instructions in 
?strptime):


x - 1981-01-02T08:00I
strptime(x, format=%Y-%m-%dT%H:%MI)

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] Numeric data not numeric in .csv file

2012-05-02 Thread R. Michael Weylandt
On Wed, May 2, 2012 at 4:34 AM, Jim Lemon j...@bitwrit.com.au wrote:
 On 05/02/2012 10:47 AM, Eve Proper wrote:

 I am a raw novice to R, playing around with a mini .csv dataset created in
 Excel. I can read it in and the data looks OK in Excel and upon initial
 inspection in R:

 hikes- read.csv(/Users/eproper/Desktop/hikes.csv, header=TRUE)
 print(hikes)

 does exactly what it is supposed to do.

 Two of the variables are genuine strings, but the others ought to be
 numeric, and R will calculate their min, max etc. However, is.numeric
 returns FALSE for all of them; storage.mode returns language. as.numeric
 returns Error: 'pairlist' object cannot be coerced to type 'double'. In
 what I suspect is a related problem, any command that calls for a variable
 name requires an initial ~ to work. That is, instead of plot(miles) I have
 to use plot(~miles).

 No doubt there is some very elementary mistake I am making, but I can't
 figure it out. Any help would be appreciated.

 Hi Eve,
 Have you tried as.numeric on them? As Jeff suggested, you may be importing
 spaces along with the digits or some other character that changes the class
 of the variable. Also note that the default behavior of functions like
 read.csv is to coerce all of the values in a column of the resulting data
 frame to the lowest common denominator. If you have one text value in a
 column of numbers, you usually get factor values. This is due to the
 restriction that all values in a column must be of the same class (data
 type).

 Jim


If accidentally coerced to factors, the OP might prefer

as.numeric(as.character(x))

to get the apparent numeric values rather than the internal ones.

Also seconded Jeff's advice about str()

Michael

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


Re: [R] scanning a data set for strings

2012-05-02 Thread R. Michael Weylandt
I think you are looking for something like

aggregate(cbind(VPts, HPts) ~ VTm + HTm, data = NFL, sum)

but you should look at the examples for ?aggregate to tweak it to what
you need.

Michael

On Wed, May 2, 2012 at 7:45 AM, Daniel_55 serna.da...@gmail.com wrote:
 Hello,

 I'm looking for what I'm sure is a quick answer. I'm working with a data set
 that looks like this:

  Week              Game.ID                     VTm VPts HTm HPts
 Differential HomeWin
 1    1  NFL_20050908_OAK@NE   OAK   20      NE     30           10
 FALSE
 2    1 NFL_20050911_ARI@NYG    ARI   19      NYG   42           23
 FALSE
 3    1 NFL_20050911_CHI@WAS   CHI    7       WAS    9            2
 FALSE
 4    1 NFL_20050911_CIN@CLE    CIN   27       CLE    13          -14
 FALSE
 5    1  NFL_20050911_DAL@SD     DAL   28      SD      24           -4
 FALSE
 6    1 NFL_20050911_DEN@MIA  DEN   10     MIA    34           24
 FALSE

 NFL data. I want to pair each team with the points they received at home and
 away and create another table showing this. I know it's easy to do, but all
 the methods I am coming up with involve doing each team individually via a
 for loop that searches for [i,5]==NE, [i,5]==NYG. I would then use the
 same method to pair the same team code (NYG or NE) with VPTs when it's
 Visiting.

 Thanks for the help.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/scanning-a-data-set-for-strings-tp4602953.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] date and time conversion

2012-05-02 Thread R. Michael Weylandt
Quick and dirty solution is to use sub() to change the T to a space
and then use as.POSIXct as usual.

x - 1981-01-02T08:00

as.POSIXct(sub(T, , x), format = %Y-%m-%d %H:%M)

but it does look to me like R can work around the T if you give a good
format argument:

as.POSIXct(x, format = %Y-%m-%dT%H:%M)

Michael

On Wed, May 2, 2012 at 6:10 AM, mpostje mayo_j...@hotmail.com wrote:




 Hi

 I've been trying to convert numbers from an online temperature database
 into dates and time that R recognizes. the problem is that the database has 
 put a T
 between the numbers and R will not accept any conversions.

 this is the format that it's in now
 1981-01-02T08:00

 can anyone help?
 cheers!

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/date-and-time-conversion-tp4602786.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] factor conversion to date/time

2012-05-02 Thread R. Michael Weylandt
Please don't triple post.

Michael

On Wed, May 2, 2012 at 8:08 AM, marjolein post mayo_j...@hotmail.com wrote:




 Hi, I've been trying to convert numbers from an online temperature database
 into dates and time that R recognizes. I've tried as.Date, as.POSIXlt and 
 strptime  the problem is that the database has put a T between the numbers 
 and R will not accept any conversions. currently it sees the date as a factor 
 with the format  as 1981-01-02T08:00I would like to keep only the year and 
 month, but my primary focus is to get R to recognize it as a date.

 Thank you for your help. cheers,Marjolein
        [[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] Hypothesis Testing using Wald Criterion for two regression models with dummy variables

2012-05-02 Thread meredith
Peter-
  Maybe I have not articulately my problem clearly, I have had local help
with the statistical part just trying to figure out how to correctly program
this test.  For clarity's sake, I have months worth of data, I want to
potentially combine those months into four, shall we say seasons, that have
close to the same behaviour.  Therefore to do this, I am trying a monthly
moving window to categorize these seasons.  After talking to a couple water
resources statisician's we decided the way to test if the months are
different is through the use of hypothesis testing and a dummy variable. So
I have one regression, Model A, that includes a zero in the dummy spot with
the two months of data combined, then I have another regression, Model B,
that includes the interaction term for the changes between the months (the
intercept changes, using a 0 or 1 dummy variable). Now we discussed running
a Wald testing, Chi squared, to test to see if the interaction term is of
importance probability wise, can I do this utilizing anova? Does this make
more sense?  Then I will run another set of restricted and unrestricted
models to account for potential differences in the mean (i.e the slope).
Does this explain my problem better?

Meredith

--
View this message in context: 
http://r.789695.n4.nabble.com/Hypothesis-Testing-using-Wald-Criterion-for-two-regression-models-with-dummy-variables-tp4601582p4603260.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] Numeric data not numeric in .csv file

2012-05-02 Thread David Winsemius


On May 1, 2012, at 8:47 PM, Eve Proper wrote:

I am a raw novice to R, playing around with a mini .csv dataset  
created in
Excel. I can read it in and the data looks OK in Excel and upon  
initial

inspection in R:

hikes - read.csv(/Users/eproper/Desktop/hikes.csv, header=TRUE)
print(hikes)

does exactly what it is supposed to do.

Two of the variables are genuine strings, but the others ought to be
numeric, and R will calculate their min, max etc. However, is.numeric
returns FALSE for all of them;


How did you do this? What code did you use? It should have been:

lapply(hikes, is.numeric)


storage.mode returns language.


Well, that suggests that you were trying to use unquoted variable  
names without the data objects name. Did you use attach() on the basis  
of some misguided instructions?




as.numeric
returns Error: 'pairlist' object cannot be coerced to type  
'double'. In
what I suspect is a related problem, any command that calls for a  
variable
name requires an initial ~ to work. That is, instead of plot(miles)  
I have

to use plot(~miles).


As I said, you are not correctly referencing column names within data  
objects.




No doubt there is some very elementary mistake I am making, but I  
can't

figure it out. Any help would be appreciated.

http://theturducken.blogspot.com/

[[alternative HTML version deleted]]


And you should read the Posting Guide and correct your posting format.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] calibration of Garch models to historical data

2012-05-02 Thread R. Michael Weylandt
This might be more of a question for R-SIG-Finance and followup should
probably be there, but you might get a start with the rugarch package.

Michael

On Wed, May 2, 2012 at 4:13 AM, Ivette iva_mihayl...@mail.ru wrote:
 I have done the usual estimation of GARCH models, applied to my historical
 dataset (commodities futures) with a maximum likelihood function and
 selected the best model on the basis of information criteria such as Akaike
 and Bayes.

 Can somebody explain me please the calibration scheme for a GARCH model?

 I was not able to find a paper, dealing with exactly this algorithm for my
 case. I only understood that I have to compare the performance of the best
 GARCH model (from the estimation step), fitted to my historical dataset and
 a GARCH simulation (let's abbreviate this Squared Error difference to E2).
 However, it is not clear to me:
 - with what parameters' values to start this simulation,
 - how many times it is normal to perform it, and
 - what to compare via E2 (maximum likelihood values, or parameter values)
 - how to constructassess E2 for the GARCH case.

 Thank you in advance for your suggestions.

 Ivette

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/calibration-of-Garch-models-to-historical-data-tp4602606.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] Arules and different item columns with same item labelsŠ.

2012-05-02 Thread John Kane
It is not clear what you mean.  Can you supply some sample data?  Have a look 
at ?dput for a handy way to supply data.

John Kane
Kingston ON Canada


 -Original Message-
 From: lterle...@anadolu.edu.tr
 Sent: Tue, 1 May 2012 17:55:25 +
 To: r-help@r-project.org
 Subject: [R] Arules and different item columns with same item labelsŠ.
 
 Dear Users,
 
 I have data that have different data columns (hair color, eye color, etc.
 ) with same item labels and I do not want to recode them like
 haircolor=brown, etc. Is it possible to do it automatically?
 
 Thanks right now for your tips and given directions.
 --
 Levent TERLEMEZ
 
 
   [[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.


Receive Notifications of Incoming Messages
Easily monitor multiple email accounts  access them with a click.
Visit http://www.inbox.com/notifier and check it out!

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


Re: [R] coxph reference hazard rate

2012-05-02 Thread David Winsemius
As has been answered several times on rhelp ... the baseline hazard is  
for a case with the mean value. It's not a meaningful case with all  
factor variables. There can be no cases where fidelity3 has a  
fractional value.  You should be using predict() and survfit() to  
display estimates for particular meaningful cases. You might want to  
use a different rhs formula as well because the one offered omits the  
main effects. Choosing ~bucket*factor(fidelity  3) would include  
those terms.


--
David.


On May 1, 2012, at 8:37 PM, Georges Dupret wrote:


Hi,

In the following results I interpret exp(coef) as the factor that  
multiplies
the base hazard rate if the corresponding variable is TRUE. For  
example,
when the bucket is ks008 and fidelity = 3, then the rate, compared  
to the
base rate h_0(t), is h(t) = 0.200 h_0(t). My question is then, to  
what case
does the base hazard rate correspond to? I would expect the  
reference to be

the first factor value, i.e. bucket jpc001 with fidelity = 3, but its
exp(coef) is not one. I verified the contrasts, and the row  
corresponding to
the first factor value is zero everywhere; moreover, I didn't change  
the
default, so a bad setting of the contrasts doesn't seem to be the  
issue.


Best,

ge

Call:
coxph(formula = Surv(time, event = (censored ==
   FALSE)) ~ bucket:factor(fidelity  3), data = week.15)


coef exp(coef) se(coef)   
z  p
bucketjpc001:factor(fidelity  3)FALSE -1.606 0.201  0.00624  
-257.5  0
bucketks006:factor(fidelity  3)FALSE  -1.613 0.199  0.00627  
-257.5  0
bucketks007:factor(fidelity  3)FALSE  -1.620 0.198  0.00626  
-258.8  0
bucketks008:factor(fidelity  3)FALSE  -1.611 0.200  0.00625  
-257.6  0
bucketks009:factor(fidelity  3)FALSE  -1.620 0.198  0.00626  
-258.9  0
bucketks010:factor(fidelity  3)FALSE  -1.619 0.198  0.00626  
-258.6  0
bucketjpc001:factor(fidelity  3)TRUE  -0.156 0.856  0.00596   
-26.2  0
bucketks006:factor(fidelity  3)TRUE   -0.171 0.842  0.00600   
-28.6  0
bucketks007:factor(fidelity  3)TRUE   -0.168 0.845  0.00602   
-28.0  0
bucketks008:factor(fidelity  3)TRUE   -0.167 0.846  0.00600   
-27.8  0
bucketks009:factor(fidelity  3)TRUE   -0.170 0.844  0.00599   
-28.4  0
bucketks010:factor(fidelity  3)TRUE   NANA  0.0  
NA NA


Likelihood ratio test=294562  on 11 df, p=0  n= 1173838, number of  
events=

629383

--
View this message in context: 
http://r.789695.n4.nabble.com/coxph-reference-hazard-rate-tp4602092.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] Extracting results from a median polish

2012-05-02 Thread R. Michael Weylandt
write.csv() is definitely the right way to go so you're on track

What is str(medpolish)?

From the error message, it sounds like it's a functionIf it is,
are you sure you don't mean write.csv(medpolish( xx )) ?

Michael

On Wed, May 2, 2012 at 12:39 AM, Martin Raymond Lefebvre
mlefe...@uwo.ca wrote:
 Quick question from a new user to R,

  How do I extract my solution of a median polish matrix from R to a 
 spreadsheet file such as .csv?

 From my reading of my guide book (R for SPSS and SAS users version 2), I 
 deduce that exporting a file to .csv would look like the following:
 write.csv(medpolish, file =outfilename.csv, row.names = FALSE) ,

 by I get the following:
 Error in as.data.frame.default(x[[i]], optional = TRUE) :
   cannot coerce class 'function' into a data.frame

 So far I've been copy/pasting segment by segment into Excel and running 
 text2column, but there has got to be a better way.


 Martin R. Lefebvre


        [[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] Two ecdf with log-scales

2012-05-02 Thread David Winsemius


On May 2, 2012, at 6:14 AM, Johannes Radinger wrote:


Hi,

i want to plot empirical cumulative density functions for two  
variables in
one plot. For better visualizing the differences in the two  
cumulative curves I'd like to log-scale the axis.


So far I found 3 possible functions to plot ecdf:

1) ecdf() from the package 'stats'. I don't know how to successfully  
set the log.scales? Combining two plots is not a problem:


plot(ecdf(x1))
lines(ecdf(x2),col.h=red)

2) gx.ecdf() from package 'rgr'. It is easily possible to plot log- 
scales, but I don't know how to plot two densities?


gx.ecdf(x1,log=TRUE,ifqs = TRUE)

3) Ecdf() from package 'Hmisc'. No log-option directly available and  
here I also don't know how to 'stack' two plots...


Ecdf(x1,what=F)


Probably there are many more solutions (e.g. ggplot etc.)...
...Has anyone faced a similar task and found a simple solution? Any  
suggestions are welcome!


Have you searched the Archives? I seem to remember that the log(0) was  
a barrier to persons attempting this in the past. (ISTR a posting in  
the last few weeks.)  Maybe you could also provide a test data object  
that has the same range as your x1 and x 2 variables.



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


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] factor conversion to date/time

2012-05-02 Thread John Kane
Try something like this.  Convert the vector to character and grab the first 10 
characters then convert to a date.

aa - as.factor(1981-01-02T08:00I)
aa - as.character(aa)
aa - substr(aa, 1, 10)
class(b)

John Kane
Kingston ON Canada


 -Original Message-
 From: mayo_j...@hotmail.com
 Sent: Wed, 2 May 2012 14:08:26 +0200
 To: r-help@r-project.org
 Subject: [R] factor conversion to date/time
 
 Hi, I've been trying to convert numbers from an online temperature
 database
 into dates and time that R recognizes. I've tried as.Date, as.POSIXlt and
 strptime  the problem is that the database has put a T between the
 numbers and R will not accept any conversions. currently it sees the date
 as a factor with the format  as 1981-01-02T08:00I would like to keep only
 the year and month, but my primary focus is to get R to recognize it as a
 date.
 
 Thank you for your help. cheers,Marjolein
   [[alternative HTML version deleted]]



FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

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


Re: [R] Hypothesis Testing using Wald Criterion for two regression models with dummy variables

2012-05-02 Thread peter dalgaard

On May 2, 2012, at 15:48 , meredith wrote:

 Peter-
  Maybe I have not articulately my problem clearly, I have had local help
 with the statistical part just trying to figure out how to correctly program
 this test.  For clarity's sake, I have months worth of data, I want to
 potentially combine those months into four, shall we say seasons, that have
 close to the same behaviour.  Therefore to do this, I am trying a monthly
 moving window to categorize these seasons.  After talking to a couple water
 resources statisician's we decided the way to test if the months are
 different is through the use of hypothesis testing and a dummy variable. So
 I have one regression, Model A, that includes a zero in the dummy spot with
 the two months of data combined, then I have another regression, Model B,
 that includes the interaction term for the changes between the months (the
 intercept changes, using a 0 or 1 dummy variable). Now we discussed running
 a Wald testing, Chi squared, to test to see if the interaction term is of
 importance probability wise, can I do this utilizing anova? Does this make
 more sense?  Then I will run another set of restricted and unrestricted
 models to account for potential differences in the mean (i.e the slope).
 Does this explain my problem better?

Not really. It does indicate that Bert is right, though: You need to enlist a 
local statistician. There are things clearly not understood, which we cannot 
help you with on this list. 

-pd

PS. This is a mailing list. Please quote context.

 
 Meredith
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Hypothesis-Testing-using-Wald-Criterion-for-two-regression-models-with-dummy-variables-tp4601582p4603260.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.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] selection by two unique variables

2012-05-02 Thread Ayyappa Chaturvedula
Dear Group,

I am working with a large dataset where I need to select for each unique id
the the unique lastpk row.  Here is a sample subject:

  id wtdt   wt lastpk

  64050256 2010-09-18   275  2010-09-16

  64050256 2010-09-19   277  2010-09-18

  64050256 2010-09-20   272  2010-09-18

  64050256 2010-09-21   277  2010-09-18



I want the result as:

   id   wtdt wt  lastpk

64050256 2010-09-18 275 2010-09-16

64050256 2010-09-19 277 2010-09-18



I am using !(duplicated(data$id)) to select the first row but now I want to
select the first row of the unique lastpk in each unique id.



I appreciate your help on this.



Regards,

Ayyappa

[[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] rgl.Sweave not producing transparency in pdf plots with alpha

2012-05-02 Thread Alexander Shenkin
Hi Folks,

I'm trying to get rgl.Sweave to produce plots with transparency.
However, it just seems to produce opaque plots when pdf is the output
type.  Perhaps this is a known issue?  I'll just use .png in the
meantime, but wanted to see about this, as I didn't see it in the
documentation (though it's possible I missed it).

Thanks,
Allie




\documentclass{article}
\title {rgl test}
\usepackage{Sweave}
\begin {document}

This is a test of rgl.sweave's alpha capability.

\begin{figure}
% uncomment line below for png output (correct transparency)
% echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
resolution=100=
echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
resolution=100, outputtype=pdf, pdf=TRUE=
library(rgl)
data(volcano)
z - 2 * volcano# Exaggerate the relief
x - 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y - 10 * (1:ncol(z))   # 10 meter spacing (E to W)
zlim - range(y)
zlen - zlim[2] - zlim[1] + 1
colorlut - terrain.colors(zlen) # height color lookup table
col - colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
#open3d()
surface3d(x, y, z, color=col, back=lines, alpha=0.75)
@
\end{figure}

\end{document}

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


Re: [R] selection by two unique variables

2012-05-02 Thread Bert Gunter
?tapply

?with is also useful here

as in (untested)
with(yourdataframe, tapply(lastpk, id, unique))

-- Bert

On Wed, May 2, 2012 at 7:58 AM, Ayyappa Chaturvedula
ayyapp...@gmail.com wrote:
 Dear Group,

 I am working with a large dataset where I need to select for each unique id
 the the unique lastpk row.  Here is a sample subject:

          id             wtdt           wt         lastpk

  64050256 2010-09-18   275  2010-09-16

  64050256 2010-09-19   277  2010-09-18

  64050256 2010-09-20   272  2010-09-18

  64050256 2010-09-21   277  2010-09-18



 I want the result as:

       id               wtdt         wt      lastpk

 64050256 2010-09-18 275 2010-09-16

 64050256 2010-09-19 277 2010-09-18



 I am using !(duplicated(data$id)) to select the first row but now I want to
 select the first row of the unique lastpk in each unique id.



 I appreciate your help on this.



 Regards,

 Ayyappa

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] strange differences in vector operation versus manual calculation

2012-05-02 Thread Rajarshi Guha
Hi, I'm running a calculation in two ways. The first way is to employ
vectors and evaluate a function in one go. The second way is to break
down the function into pieces and combine the pieces to the final
answer.

Algebraically, they should give me the same result. But the final
vector differs significantly. I must be missing something very
obvious, but I just cannot see it

xx - c(-9.56305825951348, -8.20220288142583, -6.84134750333818,
-5.48049212525052,
-4.11963674716287)
params - structure(c(-7.9292094394, 4.9549173134, 4.738588416, 101.5743644892
 ), .Names = c(LOG_AC50, HILL_COEF,
INF_ACTIVITY, ZERO_ACTIVITY
  ))
yy - params[4] + (params[3] - params[4])/(1 + 10^(params[1]-xx)^params[2])

t1 -  10^(params[1]-xx)
t2 - params[3] - params[4]
t3 - (1+t1)^params[2]
t4 - t2/t3;
t5 - params[4] + t4

I would've expected yy and t5 to be the same; yet they are not

-- 
Rajarshi Guha | http://blog.rguha.net
NIH Center for Advancing Translational Science

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

2012-05-02 Thread Beatriz De Francisco
Walmes, Thank you so much!!!
I am still trying to understand all of your code but it works. I have changed 
it a bit so that I get upper and lower limits for the error bar, and that the 
origin starts at 0 so the negative values are plotted correctly.

barchart(Change~fTreat,groups=Process,change,
 stderr=change$stderr,
 ylab=Pocertage change,
 xlab=Treatment,
 #ylim=-115:50,
 scales=list(alternating=FALSE,
 tick.number=7,
 tck=c(-1,0)),
 prepanel=function(y, stderr, subscripts=subscripts, ...){
   uy - as.numeric(y+stderr[subscripts])
   ly - as.numeric(y-stderr[subscripts])
   list(ylim=range(y,uy,ly, finite=TRUE))
 },
 panel=
   function(x, y, subscripts, groups, stderr, box.ratio, ...){
 panel.barchart(x, y, subscripts=subscripts,
groups=groups, box.ratio=box.ratio,origin=0, ...)
 panel.abline(h=0,col=black,...)
 d - 1/(nlevels(groups)+nlevels(groups)/box.ratio)
 g - (as.numeric(groups[subscripts])-1); g - (g-median(g))*d
 panel.arrows(as.numeric(x)+g,y-stderr[subscripts], 
as.numeric(x)+g, y+stderr[subscripts],
  code=3,angle=90, length=0.025)
   }
 )
I am very new to creating function and would be great if you could explain what 
the d and g elemens actually do?
this is just for me to understand and later maybe make my own functions. I am 
assuming that g centers the error bars? but d?

Regards

Beatriz de Francisco Mora
PhD Student
The Scottish Association for Marine Science
Scottish Marine Institute
Oban
PA37 1QA
Tel: 06131 559000 (switchboard)
Fax: 01631559001
E. beatriz.defranci...@sams.ac.uk
http://www.smi.ac.uk/beatriz-de-franciso

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of 
ilai [ke...@math.montana.edu]
Sent: 02 May 2012 04:14
To: Walmes Zeviani
Cc: r-help@r-project.org
Subject: Re: [R] error bars for a barchart

Thank you for your example. I only skimmed it, but since both
solutions use nlevels and box.ratio it is no surprise we end up at the
same place (although I do think your g-median is nicer than my 3/4).

Thing is, I wouldn't call either of these simple... would be nice if
one could just query the new centers, but I don't know if there is a
way without hacking panel.barchart itself ?

Cheers

On Tue, May 1, 2012 at 1:34 PM, Walmes Zeviani walmeszevi...@gmail.com wrote:
 I have a repoducibe example here

 http://ridiculas.wordpress.com/2011/11/23/media-e-desvio-padrao-de-muitas-variaveis-separado-por-grupos/

 Sorry for it be in Portuguese.

 Walmes.

 ==
 Walmes Marques Zeviani
 LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)
 Departamento de Estatística - Universidade Federal do Paraná
 fone: (+55) 41 3361 3573
 VoIP: (3361 3600) 1053 1173
 e-mail: wal...@ufpr.br
 twitter: @walmeszeviani
 homepage: http://www.leg.ufpr.br/~walmes
 linux user number: 531218
 ==

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
The Scottish Association for Marine Science (SAMS) is registered in Scotland as 
a Company Limited by Guarantee (SC009292) and is a registered charity (9206). 
SAMS has an actively trading wholly owned subsidiary company: SAMS Research 
Services Ltd a Limited Company (SC224404). All Companies in the group are 
registered in Scotland and share a registered office at Scottish Marine 
Institute, Oban Argyll PA37 1QA. The content of this message may contain 
personal views which are not the views of SAMS unless specifically stated. 
Please note that all email traffic is monitored for purposes of security and 
spam filtering. As such individual emails may be examined in more detail.

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


Re: [R] strange differences in vector operation versus manual calculation

2012-05-02 Thread William Dunlap
Your multistep approach corresponds to the following, which has one
more set of parentheses than you used
   yy - params[4] + (params[3] - params[4])/((1 + 10^(params[1]-xx))^params[2])
In R lingo, both of your approaches are vectorized and you probably won't find
a huge difference in speed between them.  I would use the long approach,
as it is more understandable.  (I would also give memorable names to the
intermediate results, not t1, t2, ..., unless they really had no meaning.)

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 Rajarshi Guha
 Sent: Wednesday, May 02, 2012 8:42 AM
 To: R
 Subject: [R] strange differences in vector operation versus manual calculation
 
 Hi, I'm running a calculation in two ways. The first way is to employ
 vectors and evaluate a function in one go. The second way is to break
 down the function into pieces and combine the pieces to the final
 answer.
 
 Algebraically, they should give me the same result. But the final
 vector differs significantly. I must be missing something very
 obvious, but I just cannot see it
 
 xx - c(-9.56305825951348, -8.20220288142583, -6.84134750333818,
 -5.48049212525052,
 -4.11963674716287)
 params - structure(c(-7.9292094394, 4.9549173134, 4.738588416, 101.5743644892
  ), .Names = c(LOG_AC50, HILL_COEF,
 INF_ACTIVITY, ZERO_ACTIVITY
   ))
 yy - params[4] + (params[3] - params[4])/(1 + 10^(params[1]-xx)^params[2])
 
 t1 -  10^(params[1]-xx)
 t2 - params[3] - params[4]
 t3 - (1+t1)^params[2]
 t4 - t2/t3;
 t5 - params[4] + t4
 
 I would've expected yy and t5 to be the same; yet they are not
 
 --
 Rajarshi Guha | http://blog.rguha.net
 NIH Center for Advancing Translational Science
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] interactive loop

2012-05-02 Thread Ondřej Mikula
Dear R-helpers,
I have a number of point configurations representing skull shapes, but
some of them contain superfluous points. I want to write a loop in
which each configuration is plotted and I am asked to write the
numbers of points that are superfluous. However, I don't know how to
introduce this interactive element.
Would you give me an advice?
Best regards
Ondřej Mikula



-- 
Ondřej Mikula

Institute of Animal Physiology and Genetics
Academy of Sciences of the Czech Republic
Veveri 97, 60200 Brno, Czech Republic

Institute of Vertebrate Biology
Academy of Sciences of the Czech Republic
Studenec 122, 67502 Konesin, Czech Republic

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


Re: [R] interactive loop

2012-05-02 Thread R. Michael Weylandt michael.weyla...@gmail.com
I think readline() will do what you want. It can display a message and take 
user input, assigning it to a character value so you might need as.numeric()

Michael

On May 2, 2012, at 12:08 PM, Ondřej Mikula onmik...@gmail.com wrote:

 Dear R-helpers,
 I have a number of point configurations representing skull shapes, but
 some of them contain superfluous points. I want to write a loop in
 which each configuration is plotted and I am asked to write the
 numbers of points that are superfluous. However, I don't know how to
 introduce this interactive element.
 Would you give me an advice?
 Best regards
 Ondřej Mikula
 
 
 
 -- 
 Ondřej Mikula
 
 Institute of Animal Physiology and Genetics
 Academy of Sciences of the Czech Republic
 Veveri 97, 60200 Brno, Czech Republic
 
 Institute of Vertebrate Biology
 Academy of Sciences of the Czech Republic
 Studenec 122, 67502 Konesin, Czech Republic
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] rgl.Sweave not producing transparency in pdf plots with alpha

2012-05-02 Thread Duncan Murdoch

On 02/05/2012 11:00 AM, Alexander Shenkin wrote:

Hi Folks,

I'm trying to get rgl.Sweave to produce plots with transparency.
However, it just seems to produce opaque plots when pdf is the output
type.  Perhaps this is a known issue?  I'll just use .png in the
meantime, but wanted to see about this, as I didn't see it in the
documentation (though it's possible I missed it).
That uses the rgl.postscript() function, which uses the GL2PS library to 
convert to PDF.  It may be that it doesn't support transparency in your 
scene.  Or perhaps it just hasn't been turned on:  GL2PS didn't support 
transparency when rgl.postscript was written.


Duncan Murdoch



Thanks,
Allie




\documentclass{article}
\title {rgl test}
\usepackage{Sweave}
\begin {document}

This is a test of rgl.sweave's alpha capability.

\begin{figure}
% uncomment line below for png output (correct transparency)
%echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
resolution=100=
echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
resolution=100, outputtype=pdf, pdf=TRUE=
library(rgl)
data(volcano)
z- 2 * volcano# Exaggerate the relief
x- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y- 10 * (1:ncol(z))   # 10 meter spacing (E to W)
zlim- range(y)
zlen- zlim[2] - zlim[1] + 1
colorlut- terrain.colors(zlen) # height color lookup table
col- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
#open3d()
surface3d(x, y, z, color=col, back=lines, alpha=0.75)
@
\end{figure}

\end{document}

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

2012-05-02 Thread Sarah Goslee
You might start with par(ask=TRUE) and identify().

A reproducible example might get you actual code. Also, how do you
know they're superfluous? Perhaps that knowledge can be used to
automate identification.

Sarah

On Wed, May 2, 2012 at 12:08 PM, Ondřej Mikula onmik...@gmail.com wrote:
 Dear R-helpers,
 I have a number of point configurations representing skull shapes, but
 some of them contain superfluous points. I want to write a loop in
 which each configuration is plotted and I am asked to write the
 numbers of points that are superfluous. However, I don't know how to
 introduce this interactive element.
 Would you give me an advice?
 Best regards
 Ondřej Mikula



 --

-- 
Sarah Goslee
http://www.functionaldiversity.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] Statistical test for predictor selection

2012-05-02 Thread jing tang
Hi,

In a data I have two predictors and one response variable. The response
variable is categorical and fixed. Now I want to choose which predictor
would better predict the response variable. Is there a statistical test for
that?

 

Best,

Jing

 

--

Jing Tang, PhD

Senior Researcher

Institute for Molecular Medicine Finland (FIMM)

FI-00014 University of Helsinki

Finland

 

 


[[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] Problems accessing environment() in function

2012-05-02 Thread Uwe Ligges



On 01.05.2012 19:57, Heiko Neuhaus wrote:

Hi all,

I am trying to create a list of all variable/value combinations in
environment().

When a function with unset arguments is called, the method I have been
using fails with a missing argument error. However it should be
possible to simply skip these missing objects in the generation of the
list?

Could anyone recommend me a better way (that does not use a slow
for/eval-combination) to achieve the desired effect?

You can easily reproduce my problem using this code:

--

test1 - function(a, b, c)
{
x - as.list(environment())
print (hi from test1!)
test2(a = a, b = b, c = c)


You are rying to pass a, b, c here and hence R tries to insert those 
into the environment of test2 once it is called, you have not passed 
arguments to your test1 call.


Uwe Ligges


}

test2 - function(a, b, c)
{
# PROBLEM: Why can't I get a list as in test1() here?
x - as.list(environment())
print (hi from test2!)
}

test1()

--

I want my list x in test2() to work behave just like x in test1().
(In this example the correct list in test2() would be empty).

Thanks a lot for your time.

Best wishes,
Heiko Neuhaus

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

2012-05-02 Thread Sarah Goslee
And now we have two entirely different interpretations of the question.

I think Ondřej needs to provide a more detailed explanation of the
problem and intended result.

Sarah

On Wed, May 2, 2012 at 12:23 PM, R. Michael Weylandt
michael.weyla...@gmail.com michael.weyla...@gmail.com wrote:
 I think readline() will do what you want. It can display a message and take 
 user input, assigning it to a character value so you might need as.numeric()

 Michael

 On May 2, 2012, at 12:08 PM, Ondřej Mikula onmik...@gmail.com wrote:

 Dear R-helpers,
 I have a number of point configurations representing skull shapes, but
 some of them contain superfluous points. I want to write a loop in
 which each configuration is plotted and I am asked to write the
 numbers of points that are superfluous. However, I don't know how to
 introduce this interactive element.
 Would you give me an advice?
 Best regards
 Ondřej Mikula




-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] rgl.Sweave not producing transparency in pdf plots with alpha

2012-05-02 Thread Duncan Murdoch

On 02/05/2012 12:26 PM, Duncan Murdoch wrote:

On 02/05/2012 11:00 AM, Alexander Shenkin wrote:
  Hi Folks,

  I'm trying to get rgl.Sweave to produce plots with transparency.
  However, it just seems to produce opaque plots when pdf is the output
  type.  Perhaps this is a known issue?  I'll just use .png in the
  meantime, but wanted to see about this, as I didn't see it in the
  documentation (though it's possible I missed it).
That uses the rgl.postscript() function, which uses the GL2PS library to
convert to PDF.  It may be that it doesn't support transparency in your
scene.  Or perhaps it just hasn't been turned on:  GL2PS didn't support
transparency when rgl.postscript was written.


I just took a look:  transparency is turned off, and when it's turned 
on, it doesn't look very good.


It's possible that there are tuning parameters that could make it look 
good, but I don't know what they are.


Duncan Murdoch



Duncan Murdoch


  Thanks,
  Allie




  \documentclass{article}
  \title {rgl test}
  \usepackage{Sweave}
  \begin {document}

  This is a test of rgl.sweave's alpha capability.

  \begin{figure}
  % uncomment line below for png output (correct transparency)
  %echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
  resolution=100=
  echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
  resolution=100, outputtype=pdf, pdf=TRUE=
  library(rgl)
  data(volcano)
  z- 2 * volcano# Exaggerate the relief
  x- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
  y- 10 * (1:ncol(z))   # 10 meter spacing (E to W)
  zlim- range(y)
  zlen- zlim[2] - zlim[1] + 1
  colorlut- terrain.colors(zlen) # height color lookup table
  col- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
  #open3d()
  surface3d(x, y, z, color=col, back=lines, alpha=0.75)
  @
  \end{figure}

  \end{document}

  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] rgl.Sweave not producing transparency in pdf plots with alpha

2012-05-02 Thread Alexander Shenkin


On 5/2/2012 11:40 AM, Duncan Murdoch wrote:
 On 02/05/2012 12:26 PM, Duncan Murdoch wrote:
 On 02/05/2012 11:00 AM, Alexander Shenkin wrote:
   Hi Folks,
 
   I'm trying to get rgl.Sweave to produce plots with transparency.
   However, it just seems to produce opaque plots when pdf is the output
   type.  Perhaps this is a known issue?  I'll just use .png in the
   meantime, but wanted to see about this, as I didn't see it in the
   documentation (though it's possible I missed it).
 That uses the rgl.postscript() function, which uses the GL2PS library to
 convert to PDF.  It may be that it doesn't support transparency in your
 scene.  Or perhaps it just hasn't been turned on:  GL2PS didn't support
 transparency when rgl.postscript was written.
 
 I just took a look:  transparency is turned off, and when it's turned
 on, it doesn't look very good.
 
 It's possible that there are tuning parameters that could make it look
 good, but I don't know what they are.
 
 Duncan Murdoch

Thanks Duncan, I'll just stick with png for now then.

 

 Duncan Murdoch

 
   Thanks,
   Allie
 
 
 
 
   \documentclass{article}
   \title {rgl test}
   \usepackage{Sweave}
   \begin {document}
 
   This is a test of rgl.sweave's alpha capability.
 
   \begin{figure}
   % uncomment line below for png output (correct transparency)
   %echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
   resolution=100=
   echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
   resolution=100, outputtype=pdf, pdf=TRUE=
   library(rgl)
   data(volcano)
   z- 2 * volcano# Exaggerate the relief
   x- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
   y- 10 * (1:ncol(z))   # 10 meter spacing (E to W)
   zlim- range(y)
   zlen- zlim[2] - zlim[1] + 1
   colorlut- terrain.colors(zlen) # height color lookup table
   col- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each
 point
   #open3d()
   surface3d(x, y, z, color=col, back=lines, alpha=0.75)
   @
   \end{figure}
 
   \end{document}
 
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/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] please help me

2012-05-02 Thread Uwe Ligges



On 02.05.2012 02:55, Ulfa Hasanah wrote:

hi all,can you help me? index moran is very difficut for me, i have data n 
neighbor as enclosure:
please help me to make the program for find index moran value each 
variabel,...thank very much



Which translates to:

please help me, and note that

- I have to do some homework
- I do not want to read the posting guide
- I do not want to read a stats textbook about the methods I have to apply
- I do not want to read An Introduction to R
- I do not want to fix the broken shift key of my keyboard
- I am too lazy to type what I did so far


Now, I think we can assume that it is impossible to help you with a 
simple e-mail response. Please ask your supervisor.


Uwe Ligges





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

2012-05-02 Thread Uwe Ligges



On 02.05.2012 11:19, mpostje wrote:

Hi

I've been trying to convert numbers from an online temperature database
into dates and time that R recognizes. the problem is that the database has
put a T
between the numbers and R will not accept any conversions.

this is the format that it's in now
1981-01-02T08:00


strptime(1981-01-02T08:00, format=%Y-%m-%dT%H:%M)

seems to work for me.

Uwe Ligges




can anyone help?
cheers!

--
View this message in context: 
http://r.789695.n4.nabble.com/convert-numbers-into-dates-and-time-tp4602708.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] selection by two unique variables

2012-05-02 Thread jim holtman
try this:

 x - read.table(text = id wtdt   wt lastpk
+
+  64050256 2010-09-18   275  2010-09-16
+
+  64050256 2010-09-19   277  2010-09-18
+
+  64050256 2010-09-20   272  2010-09-18
+
+  64050256 2010-09-21   277  2010-09-18, as.is = TRUE, header = TRUE)

  first - lapply(split(x, list(x$id, x$lastpk), drop = TRUE), function(a){
+ a[1,, drop = FALSE]
+ })
 do.call(rbind, first)
  id   wtdt  wt lastpk
64050256.2010-09-16 64050256 2010-09-18 275 2010-09-16
64050256.2010-09-18 64050256 2010-09-19 277 2010-09-18





On Wed, May 2, 2012 at 11:23 AM, Bert Gunter gunter.ber...@gene.com wrote:
 ?tapply

 ?with is also useful here

 as in (untested)
 with(yourdataframe, tapply(lastpk, id, unique))

 -- Bert

 On Wed, May 2, 2012 at 7:58 AM, Ayyappa Chaturvedula
 ayyapp...@gmail.com wrote:
 Dear Group,

 I am working with a large dataset where I need to select for each unique id
 the the unique lastpk row.  Here is a sample subject:

          id             wtdt           wt         lastpk

  64050256 2010-09-18   275  2010-09-16

  64050256 2010-09-19   277  2010-09-18

  64050256 2010-09-20   272  2010-09-18

  64050256 2010-09-21   277  2010-09-18



 I want the result as:

       id               wtdt         wt      lastpk

 64050256 2010-09-18 275 2010-09-16

 64050256 2010-09-19 277 2010-09-18



 I am using !(duplicated(data$id)) to select the first row but now I want to
 select the first row of the unique lastpk in each unique id.



 I appreciate your help on this.



 Regards,

 Ayyappa

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



 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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



-- 
Jim Holtman
Data Munger Guru

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

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


Re: [R] Problems accessing environment() in function

2012-05-02 Thread Heiko Neuhaus

Thanks a lot for your answer!


--

test1 - function(a, b, c)
{
x - as.list(environment())
print (hi from test1!)
test2(a = a, b = b, c = c)


You are rying to pass a, b, c here and hence R tries to insert those
into the environment of test2 once it is called, you have not passed
arguments to your test1 call.

Uwe Ligges


I am aware that I am passing non existing arguments here, which is why 
my method of creating a list of the environment as.list(environment()) 
seems to fail in this case.


What I need is a way to just skip non existing objects when I create my 
list. In my given example I was intending to receive an empty list, 
since no valid arguments were passed to test2().


In other words: I want a list containing all _existing_ variable/value 
combinations and just skip the missing ones.


Thanks again for your time

Best wishes,
Heiko Neuhaus

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


Re: [R] strange differences in vector operation versus manual calculation

2012-05-02 Thread Petr Savicky
On Wed, May 02, 2012 at 11:42:27AM -0400, Rajarshi Guha wrote:
 Hi, I'm running a calculation in two ways. The first way is to employ
 vectors and evaluate a function in one go. The second way is to break
 down the function into pieces and combine the pieces to the final
 answer.
 
 Algebraically, they should give me the same result. But the final
 vector differs significantly. I must be missing something very
 obvious, but I just cannot see it
 
 xx - c(-9.56305825951348, -8.20220288142583, -6.84134750333818,
 -5.48049212525052,
 -4.11963674716287)
 params - structure(c(-7.9292094394, 4.9549173134, 4.738588416, 101.5743644892
  ), .Names = c(LOG_AC50, HILL_COEF,
 INF_ACTIVITY, ZERO_ACTIVITY
   ))
 yy - params[4] + (params[3] - params[4])/(1 + 10^(params[1]-xx)^params[2])
 
 t1 -  10^(params[1]-xx)
 t2 - params[3] - params[4]
 t3 - (1+t1)^params[2]
 t4 - t2/t3;
 t5 - params[4] + t4
 
 I would've expected yy and t5 to be the same; yet they are not

Hi.

The difference is caused by different placement of parenthesis.
Replacing

  (1 + 10^(params[1]-xx)^params[2])

by

  (1 + 10^(params[1]-xx))^params[2]

yields

  [1] 101.574364 101.057295  35.949148   6.428122   4.812942

which is equal to t5.

Petr Savicky.

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


[R] Forestplot question

2012-05-02 Thread Ben Ganzfried
Hi,

I'm trying to build a Forest Plot using the second and fourth columns in
the table (test.csv) below. My code is the following:
curated - data.frame(test.csv)
tmp - curated$coef
tmp1 - curated$se_coef
plt - metaplot(tmp, tmp1, xlim = c(-.45, .45))

I keep getting the following error at the last line and am not sure why:
Error in if (is.na(lower[i] + upper[i])) next :
  argument is of length zero

For the metaplot() function, the help page looks like at a minimum I need
to input the point estimates from the studies as well as the standard
errors of the point estimates as parameters (an earlier error occurred
telling me I needed xlim as well).  I would greatly appreciate any
clarification anyone can provide.

 IDs coef exp_coef se_coef z Pr(|z|)  1 -0.203063307 0.816226567
0.082936899 -2.448407282 0.014348936  2 0 1 0 NA NA  3 -0.193553687
0.824025596 0.114027975 -1.697422824 0.089616751  4 -0.032175939 0.968336199
0.239318707 -0.134448074 0.893048269  5 -0.20511693 0.814552066 0.121275633
-1.691328457 0.090774088  6 -0.201827336 0.817236023 0.154827334 -1.30356398
0.192382289  7 -0.439783875 0.644175628 0.105856496 -4.154528917 3.26E-05  8
-0.262717505 0.768959094 0.144606241 -1.816778471 0.069251041  9
-0.208431217 0.811856875 0.225960968 -0.922421329 0.356308848

[[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] Problems accessing environment() in function

2012-05-02 Thread Duncan Murdoch

On 02/05/2012 12:59 PM, Heiko Neuhaus wrote:

Thanks a lot for your answer!

  --

  test1- function(a, b, c)
  {
  x- as.list(environment())
  print (hi from test1!)
  test2(a = a, b = b, c = c)

  You are rying to pass a, b, c here and hence R tries to insert those
  into the environment of test2 once it is called, you have not passed
  arguments to your test1 call.

  Uwe Ligges

I am aware that I am passing non existing arguments here, which is why
my method of creating a list of the environment as.list(environment())
seems to fail in this case.

What I need is a way to just skip non existing objects when I create my
list. In my given example I was intending to receive an empty list,
since no valid arguments were passed to test2().

In other words: I want a list containing all _existing_ variable/value
combinations and just skip the missing ones.


That's hard to do, because missing arguments exist, they just have a 
special value to signal that they were missing.  The missing() function 
tests for that value, but it is picky about its arguments.  So if you 
want to do all of this in R you probably need some tricky programming, 
like this:


f - function(a,b,c) {
  names - ls(environment())  # get all the names
  result - list()
  for (n in names) {
if (!do.call(missing, list(as.name(n
  result[n] - get(n)
  }
  result
}

If you put the ls() call later, you'll pick up other local variables 
(names, result, n) as well.


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] adding a caption to a mosaic plot?

2012-05-02 Thread Simon Kiss
Dear all:
Is there a way to add text to the margins or outer margins of a mosaic plot 
using the vcd package? I understand the margins argument to mosaic, but I don't 
know how to add text to that. 
I'd like to add a caption to a plot.  If possible, I'd like to know how to set 
the font and size for that function as well. My plot looks roughly as below. 
Thank you for your time!
Simon J. Kiss

mydat-data.frame(gender=factor(rbinom(100, 1, 0.5),  labels=c('female', 
'male')), hair=factor(rbinom(100, 1, 0.5), labels=c('blonde', 'black')))
mosaic_1-table(mydat) 
mosaic(mosaic_1, gp=shading_hsv, main='my title', pop=FALSE, 
split_vertical=FALSE,  margins=c(4.1, 2.1, 8, 5.1), 
labeling_args=list(rot_labels=c(left=0), offset_labels=c(left=3), 
gp_main=gpar(cex=2), offset_varnames=c(left=5.5), gp_labels=gpar(cex=1.5), 
gp_varnames=gpar(cex=1.5), labeling_values=c('observed')))
labeling_cells(text=round(prop.table(mosaic_1, 1)*100), gp_text=gpar(ces=2), 
clip=FALSE)(mosaic_1)

*
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606

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


[R] Problem with 'nls' fitting logistic model (5PL)

2012-05-02 Thread Michal Figurski

Dear R-Helpers,

I'm working with immunoassay data and 5PL logistic model. I wanted to 
experiment with different forms of weighting and parameter selection, 
which is not possible in instrument software, so I turned to R.


I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the 
model - I started with the same model and weighting type (1/y) as in the 
instrument to see if I'll get similar results. However, in some 
instances I don't get any results - just errors.


Here is an example calibration data, representative of my experiment. 
Instrument soft had no problem fitting it:

x - structure(list(SPL = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L,
4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c(St1, St2, St3,
St4, St5, St6, St7), class = factor), MFI = c(10755.5,
9839, 5142.5, 4857, 1510.5, 1505, 502.5, 451, 215, 195.5, 58,
57, 15, 15), nom = c(206, 206, 125, 125, 68, 68, 38, 38, 24,
24, 13, 13, 6.5, 6.5), weights = c(0.0013946353028683, 0.00152454517735542,
0.00291686922702965, 0.00308832612723904, 0.0099304865938431,
0.00996677740863787, 0.0298507462686567, 0.0332594235033259,
0.0697674418604651, 0.0767263427109974, 0.258620689655172, 
0.263157894736842,

1, 1)), .Names = c(SPL, MFI, nom, weights), row.names = c(NA,
-14L), class = data.frame)

And here is the nls fit:
fit - nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights, 
start=c(a=100, b=1, c=100, d=-1, f=1))


I've tried every possible combination of starting values, including the 
values fitted by the instrument soft - to no avail. I've probably seen 
all possible error messages from 'nls' trying to fit this.


If anyone has an idea why it's not working - let me know.

Best regards,

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney S
Philadelphia, PA 19104
tel. (215) 662-3413

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 with 'nls' fitting logistic model (5PL)

2012-05-02 Thread Bert Gunter
Plot the data. You're clearly overfitting.

(If you don't know what this means or why it causes the problems you
see, try a statistical help list or consult your local statistician).

-- Bert

On Wed, May 2, 2012 at 12:32 PM, Michal Figurski
figur...@mail.med.upenn.edu wrote:
 Dear R-Helpers,

 I'm working with immunoassay data and 5PL logistic model. I wanted to
 experiment with different forms of weighting and parameter selection, which
 is not possible in instrument software, so I turned to R.

 I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the model
 - I started with the same model and weighting type (1/y) as in the
 instrument to see if I'll get similar results. However, in some instances I
 don't get any results - just errors.

 Here is an example calibration data, representative of my experiment.
 Instrument soft had no problem fitting it:
 x - structure(list(SPL = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L,
 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c(St1, St2, St3,
 St4, St5, St6, St7), class = factor), MFI = c(10755.5,
 9839, 5142.5, 4857, 1510.5, 1505, 502.5, 451, 215, 195.5, 58,
 57, 15, 15), nom = c(206, 206, 125, 125, 68, 68, 38, 38, 24,
 24, 13, 13, 6.5, 6.5), weights = c(0.0013946353028683, 0.00152454517735542,
 0.00291686922702965, 0.00308832612723904, 0.0099304865938431,
 0.00996677740863787, 0.0298507462686567, 0.0332594235033259,
 0.0697674418604651, 0.0767263427109974, 0.258620689655172,
 0.263157894736842,
 1, 1)), .Names = c(SPL, MFI, nom, weights), row.names = c(NA,
 -14L), class = data.frame)

 And here is the nls fit:
 fit - nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights,
 start=c(a=100, b=1, c=100, d=-1, f=1))

 I've tried every possible combination of starting values, including the
 values fitted by the instrument soft - to no avail. I've probably seen all
 possible error messages from 'nls' trying to fit this.

 If anyone has an idea why it's not working - let me know.

 Best regards,

 --
 Michal J. Figurski, PhD
 HUP, Pathology  Laboratory Medicine
 Biomarker Research Laboratory
 3400 Spruce St. 7 Maloney S
 Philadelphia, PA 19104
 tel. (215) 662-3413

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Problems accessing environment() in function

2012-05-02 Thread Heiko Neuhaus

Thank you very much for your suggestion.


f - function(a,b,c) {
names - ls(environment()) # get all the names
result - list()
for (n in names) {
if (!do.call(missing, list(as.name(n
result[n] - get(n)
}
result
}


I have already figured out a very similar solution using for/eval that 
basically does the same. I was hoping that I would somehow could get 
around the ugly loop using a more elegant approach. The loop should have 
a negative impact on performance since my function is using a lot of 
parameters. I was hoping, that there was some flag to tell the as.list 
function to ignore non existing objects. If that is not possible I will 
have to accept this.



If you put the ls() call later, you'll pick up other local variables
(names, result, n) as well.


Of course. That is why I call it at the very first line of my function.

Thanks again!

Heiko Neuhaus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jonathan Greenberg
R-helpers:

What would be the absolute fastest way to make a large empty file (e.g.
filled with all zeroes) on disk, given a byte size and a given number
number of empty values.  I know I can use writeBin, but the object in
this case may be far too large to store in main memory.  I'm asking because
I'm going to use this file in conjunction with mmap to do parallel writes
to this file.  Say, I want to create a blank file of 10,000 floating point
numbers.

Thanks!

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
http://www.geog.illinois.edu/people/JonathanGreenberg.html

[[alternative HTML version deleted]]

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


Re: [R] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jeff Ryan
Look at the man page for dd (assuming you are on *nix)

A quick google will get you a command to try. I'm not at my desk or I would as 
well. 

Jeff

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On May 2, 2012, at 5:23 PM, Jonathan Greenberg j...@illinois.edu wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.
 
 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
[[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc

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


Re: [R] Quickest way to make a large empty file on disk?

2012-05-02 Thread Henrik Bengtsson
An R solution is:

allocateFile - function(pathname, nbrOfBytes) {
  con - file(pathname, open=wb);
  on.exit(close(con));
  seek(con, where=nbrOfBytes-1L, origin=start, rw=write);
  writeBin(as.raw(0), con=con);
  invisible(pathname);
} # allocateFile()

 allocateFile(foo.bin, nbrOfBytes=985403)
 file.info(foo.bin)$size
[1] 985403

Note sure if it works on all OSes/file systems.

/Henrik

On Wed, May 2, 2012 at 3:23 PM, Jonathan Greenberg j...@illinois.edu wrote:
 R-helpers:

 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.

 Thanks!

 --j

 --
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html

        [[alternative HTML version deleted]]

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

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


Re: [R] Problems accessing environment() in function

2012-05-02 Thread Duncan Murdoch

On 12-05-02 5:20 PM, Heiko Neuhaus wrote:

Thank you very much for your suggestion.


f- function(a,b,c) {
names- ls(environment()) # get all the names
result- list()
for (n in names) {
if (!do.call(missing, list(as.name(n
result[n]- get(n)
}
result
}


I have already figured out a very similar solution using for/eval that
basically does the same. I was hoping that I would somehow could get
around the ugly loop using a more elegant approach.


What you're doing looks ugly, so don't expect an elegant solution.  (I 
say it's ugly because you're redefining terms like exists.)  If you 
work with the language things will look nicer.


Duncan Murdoch

 The loop should have

a negative impact on performance since my function is using a lot of
parameters. I was hoping, that there was some flag to tell the as.list
function to ignore non existing objects. If that is not possible I will
have to accept this.


If you put the ls() call later, you'll pick up other local variables
(names, result, n) as well.


Of course. That is why I call it at the very first line of my function.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jeff Ryan
Something like:

http://markus.revti.com/2007/06/creating-empty-file-with-specified-size/

Is one way I know of. 

Jeff

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On May 2, 2012, at 5:23 PM, Jonathan Greenberg j...@illinois.edu wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.
 
 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
[[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc

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


Re: [R] Forestplot question

2012-05-02 Thread Thomas Lumley
It works for me with your data:

 dat-read.table(/tmp/foo.txt,header=TRUE)
 metaplot(a$coef,a$se_coef)

It has boxes of size zero for the point estimates, but that's because
you give the standard error as zero for the second estimate, which
implies all the other boxes should be infinitely smaller.   Presumably
the std error isn't actually zero.

 -thomas

On Thu, May 3, 2012 at 5:39 AM, Ben Ganzfried
benganzfr...@post.harvard.edu wrote:
 Hi,

 I'm trying to build a Forest Plot using the second and fourth columns in
 the table (test.csv) below. My code is the following:
 curated - data.frame(test.csv)
 tmp - curated$coef
 tmp1 - curated$se_coef
 plt - metaplot(tmp, tmp1, xlim = c(-.45, .45))

 I keep getting the following error at the last line and am not sure why:
 Error in if (is.na(lower[i] + upper[i])) next :
  argument is of length zero

 For the metaplot() function, the help page looks like at a minimum I need
 to input the point estimates from the studies as well as the standard
 errors of the point estimates as parameters (an earlier error occurred
 telling me I needed xlim as well).  I would greatly appreciate any
 clarification anyone can provide.

  IDs coef exp_coef se_coef z Pr(|z|)  1 -0.203063307 0.816226567
 0.082936899 -2.448407282 0.014348936  2 0 1 0 NA NA  3 -0.193553687
 0.824025596 0.114027975 -1.697422824 0.089616751  4 -0.032175939 0.968336199
 0.239318707 -0.134448074 0.893048269  5 -0.20511693 0.814552066 0.121275633
 -1.691328457 0.090774088  6 -0.201827336 0.817236023 0.154827334 -1.30356398
 0.192382289  7 -0.439783875 0.644175628 0.105856496 -4.154528917 3.26E-05  8
 -0.262717505 0.768959094 0.144606241 -1.816778471 0.069251041  9
 -0.208431217 0.811856875 0.225960968 -0.922421329 0.356308848

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



-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 La.svd Lapack routine 'dgesdd'

2012-05-02 Thread Philipp Grueber
Addendum to my first post:

Since I wish to understand what plm does to my data, I tried to manually
calculate the demeaned values and use OLS. See below how far I got with the
Grunfeld data; formula's are based on Greene's Econometric Analysis. 

Obviously, I am missing at least one important step as my results differ
from both the plm and the LSDV estimations. Transferring the model to my
original dataset, I i) also get different results for the lm vs. the plm
models, however with the manually demeaned dataset, I do not end up with
incredibly small standard deviations in the demeaned values. That is, the
step that I am missing when reproducing the plm results is highly probable
to cause the error in my analysis.  

###

library(plm) 
library(lmtest)
data(Grunfeld) 
head(Grunfeld)
pdata-pdata.frame(Grunfeld,index=c(firm,year))
head(pdata)
fm-inv~value+capital 
mod-plm(fm, pdata, effect=twoways, model=within) 

y-Grunfeld$inv
x1-Grunfeld$value
x2-Grunfeld$capital

y_i-c()
x1_i-c()
x2_i-c()
for (i in unique(Grunfeld$firm)){
y_i-c(y_i,rep(mean(Grunfeld$inv[Grunfeld$firm==i],na.rm=TRUE),nrow(Grunfeld)))
x1_i-c(x1_i,rep(mean(Grunfeld$value[Grunfeld$firm==i],na.rm=TRUE),nrow(Grunfeld)))
x2_i-c(x2_i,rep(mean(Grunfeld$capital[Grunfeld$firm==i],na.rm=TRUE),nrow(Grunfeld)))
}

y_t-rep(NA,nrow(Grunfeld))
x1_t-rep(NA,nrow(Grunfeld))
x2_t-rep(NA,nrow(Grunfeld))
for (t in unique(Grunfeld$year)){
y_t[Grunfeld$year==t]-rep(mean(Grunfeld$inv[Grunfeld$year==t],na.rm=TRUE),sum(Grunfeld$year==t))
x1_t[Grunfeld$year==t]-rep(mean(Grunfeld$value[Grunfeld$year==t],na.rm=TRUE),sum(Grunfeld$year==t))
x2_t[Grunfeld$year==t]-rep(mean(Grunfeld$capital[Grunfeld$year==t],na.rm=TRUE),sum(Grunfeld$year==t))
}

y_it-rep(mean(Grunfeld$inv,na.rm=TRUE),nrow(Grunfeld))
x1_it-rep(mean(Grunfeld$value,na.rm=TRUE),nrow(Grunfeld))
x2_it-rep(mean(Grunfeld$capital,na.rm=TRUE),nrow(Grunfeld))

y_star-y-y_i-y_t+y_it
x1_star-x1-x1_i-x1_t+x1_it
x2_star-x2-x2_i-x2_t+x2_it

mod_lm-lm(y_star~x1_star+x2_star-1,na.action=na.omit)

mod_dumm-lm(Grunfeld$inv~Grunfeld$value+Grunfeld$capital+as.factor(Grunfeld$year)+as.factor(Grunfeld$firm)-1,na.action=na.omit)

coeftest(mod)
coeftest(mod_lm)
coeftest(mod_dumm)

##

Again, any help is highly appreciated.

Best wishes,
Philipp

-

EBS Universitaet fuer Wirtschaft und Recht
FARE Department
Wiesbaden/ Germany
http://www.ebs.edu/index.php?id=finaccL=0
--
View this message in context: 
http://r.789695.n4.nabble.com/error-in-La-svd-Lapack-routine-dgesdd-tp2125052p4604714.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] Numeric data not numeric in .csv file

2012-05-02 Thread Eve Proper
Thanks everyone for your helpful responses. I looked at the csv file in a
text editor and saw no spaces or non-numerical characters (other than
periods as decimals) outside of the header. str() says me that the
variables are either num or int.

David was spot-on; I was trying
 storage.mode(~miles)
[1] language

instead of

 storage.mode(hikes$miles)
[1] double

The fault was in my grasp of R's syntax, not the data.

Thanks!

On Wed, May 2, 2012 at 10:09 AM, David Winsemius dwinsem...@comcast.netwrote:


 On May 1, 2012, at 8:47 PM, Eve Proper wrote:

  I am a raw novice to R, playing around with a mini .csv dataset created in
 Excel. I can read it in and the data looks OK in Excel and upon initial
 inspection in R:

 hikes - read.csv(/Users/eproper/**Desktop/hikes.csv, header=TRUE)
 print(hikes)

 does exactly what it is supposed to do.

 Two of the variables are genuine strings, but the others ought to be
 numeric, and R will calculate their min, max etc. However, is.numeric
 returns FALSE for all of them;


 How did you do this? What code did you use? It should have been:

 lapply(hikes, is.numeric)

  storage.mode returns language.


 Well, that suggests that you were trying to use unquoted variable names
 without the data objects name. Did you use attach() on the basis of some
 misguided instructions?



  as.numeric
 returns Error: 'pairlist' object cannot be coerced to type 'double'. In
 what I suspect is a related problem, any command that calls for a variable
 name requires an initial ~ to work. That is, instead of plot(miles) I have
 to use plot(~miles).


 As I said, you are not correctly referencing column names within data
 objects.


 No doubt there is some very elementary mistake I am making, but I can't
 figure it out. Any help would be appreciated.

 http://theturducken.blogspot.**com/ http://theturducken.blogspot.com/

[[alternative HTML version deleted]]


 And you should read the Posting Guide and correct your posting format.



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


 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.


[R] is there a way of identifying batch mode running?

2012-05-02 Thread Paul.Rustomji
Hello list
Is there a way of identifying from within R whether a script has been source(d) 
from Rgui.exe or via Rscript.exe in batch mode?

For the code I have I use the commandArgs() function to pick up command line 
args when running in batch mode via Rscript.exe

However I like to get the code working manually first using source(MyRCode.r)

I'd like to be able to put something at the top of the file that discriminates 
between the two running modes eg

#Rscript.exe --slave -e source('MyRCode.r') some_data_file.txt

if(batchmode = TRUE){
#get arguments for script from command line
 foo - commandArgs() #where commandArgs() returns some_data_file.txt
}

if(batchmode == FALSE){
#no command line usage so need to manually supply starting arguments for script
 foo - some_data_file.txt
}





[[alternative HTML version deleted]]

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


Re: [R] is there a way of identifying batch mode running?

2012-05-02 Thread William Dunlap
interactive() does not do exactly what you
ask for, but may be close enough.  It returns
FALSE when run from Rscript and TRUE from
R when you have not redirected standard input.

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 paul.rusto...@csiro.au
 Sent: Wednesday, May 02, 2012 5:10 PM
 To: r-help@r-project.org
 Subject: [R] is there a way of identifying batch mode running?
 
 Hello list
 Is there a way of identifying from within R whether a script has been 
 source(d) from
 Rgui.exe or via Rscript.exe in batch mode?
 
 For the code I have I use the commandArgs() function to pick up command line 
 args when
 running in batch mode via Rscript.exe
 
 However I like to get the code working manually first using 
 source(MyRCode.r)
 
 I'd like to be able to put something at the top of the file that 
 discriminates between the
 two running modes eg
 
 #Rscript.exe --slave -e source('MyRCode.r') some_data_file.txt
 
 if(batchmode = TRUE){
 #get arguments for script from command line
  foo - commandArgs() #where commandArgs() returns some_data_file.txt
 }
 
 if(batchmode == FALSE){
 #no command line usage so need to manually supply starting arguments for 
 script
  foo - some_data_file.txt
 }
 
 
 
 
 
   [[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] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Simon Urbanek

On May 2, 2012, at 6:23 PM, Jonathan Greenberg wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.
 

The most trivial way is to simply seek to the end and write a byte:

 n=10
  f=file(foo,wb)
 seek(f,n-1)
[1] 0
 writeBin(raw(1),f)
 close(f)
 file.info(foo)$size
[1] 1e+05

Cheers,
Simon


 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
   [[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jeff Newmiller
On most UNIX systems this will leave a large unallocated virtual hole in the 
file. If you are not bothered by spreading the allocation task out over the 
program execution interval, this won't matter and will probably give the best 
performance.  However, if you wanted to benchmark your algorithms without the 
erratic filesystem updates mixed in, then you need to write all of those 
zeroes. For that to work most efficiently, write data in large blocks, and if 
possible bypass the C standard library.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Simon Urbanek simon.urba...@r-project.org wrote:


On May 2, 2012, at 6:23 PM, Jonathan Greenberg wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file
(e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object
in
 this case may be far too large to store in main memory.  I'm asking
because
 I'm going to use this file in conjunction with mmap to do parallel
writes
 to this file.  Say, I want to create a blank file of 10,000 floating
point
 numbers.
 

The most trivial way is to simply seek to the end and write a byte:

 n=10
  f=file(foo,wb)
 seek(f,n-1)
[1] 0
 writeBin(raw(1),f)
 close(f)
 file.info(foo)$size
[1] 1e+05

Cheers,
Simon


 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype:
jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
  [[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] scanning a data set for strings

2012-05-02 Thread Daniel_55
Worked like a charm. Thanks for the help! It's really appreciated. 

--
View this message in context: 
http://r.789695.n4.nabble.com/scanning-a-data-set-for-strings-tp4602953p4603410.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] error fitting coxph model

2012-05-02 Thread Jessica Myers

Hi,

I am using coxph from the survival package to fit a large model  
(100,000 observations, ~35 covariates) using both ridge regression (on  
binary covariates) and penalized splines (for continuous covariates).


In fitting, I get a strange error:

Error in if (abs((y[nx] - target)/(y[nx - 1] - target))  0.6)  
doing.well - FALSE else doing.well - TRUE :

  missing value where TRUE/FALSE needed

Unfortunately, I can't reproduce this error without handing over my  
entire dataset, but I thought it would be worth checking if anyone had  
any insight.  I should note that the outcome that I'm using has almost  
everyone having an event (~98,000 events out of 100,000).  I have fit  
other models like this with no problem, but on one particular dataset  
it fails.


Thanks!

Jessica Myers
Instructor in Medicine
Brigham and Women's Hospital


The information in this e-mail is intended only for the ...{{dropped:7}}

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


[R] How can a function in R handle different types of input?

2012-05-02 Thread stella
Hi,
 
How can a function in R handle different types of input?
I have written a function, which should calculate the slope from several
3-time-point measurements by linear regression 

4 three-time-point-measurements:
x-cbind(c(1,2,3,4),c(2,3,4,5),c(3,4,5,6))

time points:
time-c(1,3,9)

function for calculating the slope by linear regression:
fit-function(xx,t){slope - coefficients(lm(log(xx) ~ 0 + t))[1]
return(slope)
}
alpha-fit(x[1,],time)
 
At the moment the function output 'alpha' is calculated for
x(x1=1,x2=2,x3=3). I would like to get 'alphas' for all four rows of x
without using a for-loop.  If I use 'mapply', I get outputs to very entry of
x (12 outputs) instead of four.
 
Thank you very much in advance! Yor help is really appreciated!
Stella
 


--
View this message in context: 
http://r.789695.n4.nabble.com/How-can-a-function-in-R-handle-different-types-of-input-tp4603263.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] pick up the values

2012-05-02 Thread jiangxijixzy
Hi,

I have a list of data, e.g. r[[i]]
r[[1]]=
1  2
1  6
5  5
5.5   3
r[[2]]=
46
35
78
35
…
r[[500]].
In the first column, the selected values should like this:
(the later value)-(the former value)=1
In the second column, the selected values should like this:
(the former value)-(the later value)=1.
The outputs are:
For r[[1]]
[1,1]  1, [3,1]  5, 
[1,2]  2
For r[[2]]
[1,1]  4, [3,1]  7
[1,2]  6, [2,1]  5
…
r[[500]].
I have no idea what kind of functions can be used in this process. Could you
help me? Thank you very much.


--
View this message in context: 
http://r.789695.n4.nabble.com/pick-up-the-values-tp4603277.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] date and time conversion

2012-05-02 Thread Rui Barradas
Hello,


mpostje wrote
 
 Hi
 
 I've been trying to convert numbers from an online temperature database
 into dates and time that R recognizes. the problem is that the database
 has put a T
 between the numbers and R will not accept any conversions. 
 
 this is the format that it's in now
 1981-01-02T08:00
 
 can anyone help?
 cheers!
 

Try

x - 1981-01-02T08:00
x.new - sub(T,  , x)
as.POSIXct(x.new)

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/date-and-time-conversion-tp4602786p4603288.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] strange differences in vector operation versus manual calculation

2012-05-02 Thread Rui Barradas
Hello,


 I must be missing something very obvious, but I just cannot see it.
 
The hardest to find errors.
Wrong manual calculation in t1, powers have precedence right to left and
before additions.

t1b - 10^(params[1]-xx)^params[2]
t3b - 1 + t1b
t4b - t2/t3b
t5b - params[4] + t4b
all.equal(yy, t5b)
TRUE

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/strange-differences-in-vector-operation-versus-manual-calculation-tp4603600p4603707.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] Binary logistic regression with binary predictors

2012-05-02 Thread F.j. Berg

Ey R-people

Trying to do a binary logistic regression with only 
categorical(age,ballot) and binary predictors for a binary response 
variable.  I can model them at least at least i treat the binary 
predictors as categorical with the use of as.factor(etc) and use glm 
with binomial distribution and logit as link function. The problem is 
with interpretation of results and the use of the Wald-test to see if 
certain predictors are significant. When i do the wald test with 
standard code i see in help i can only use my whole model as input and 
terms 0,1 but then i take it all terms 0,1 are taken.
 Is there a better method for this or maybe a package or maybe an other 
approach?

Any help would be welcomed.

Frank

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

2012-05-02 Thread Silvia Molteni
I'm looking for a function for the multiple correlation among three variables.
I have created three vectors (x, y and z) and I want to find a correlation 
coefficient and evaluate its significance.
Can anyone help me?
 
Thanks 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.


[R] output Shapiro-Wild results to a table

2012-05-02 Thread Mary Ann Middleton

Hello, 

I have applied the Shapiro test to a matrix with 26.925 rows of data using the 
following 

F1.norm-apply(F1.n.mat,1,shapiro.test) 

I would now like to view and export a table of the p and W values from the 
Shapiro test, but I am not sure how to approach this. 

I have tried the following with errors. 
 write.table(x=F1.norm,file=I:/R_Work/F1/Shapiro.csv, sep=,) Error in 
 as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = 
 stringsAsFactors) : 
  cannot coerce class 'htest' into a data.frame 

Any suggestions appreciated. 
Mary Ann  
F1 
F1
[[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] Referencing factors through their equivalent numeric level

2012-05-02 Thread Kaushik Krishnan
That did it! Thanks very much Berend.

On Wed, May 2, 2012 at 4:19 AM, Berend Hasselman b...@xs4all.nl wrote:

 On 02-05-2012, at 07:22, Kaushik Krishnan wrote:

 Hey folks

 I'm sorry for bringing what must be a very simple question to R-help,
 but after some research I haven't been able to find a solution to my
 problem.

 Suppose I create a simple factor:
 [code]
 x-c(A,B,B,C,A)
 x
 [1] A B B C A
 x - as.factor(x)
 x
 [1] A B B C A
 Levels: A B C
 [/code]

 Now, when I see this factor in terms of its numeric level values, I get
 [code]
 as.numeric(x)
 [1] 1 2 2 3 1
 [/code]

 Suppose I have
 [code]
 y - 2
 [/code]

 I want the numeric value of y to reference the level of factor x. That
 is, I am looking for a function (`foo') so that I will get the
 following
 [code]
 foo(y) #or maybe foo(y,x)
 [1] B
 [/code]

 I can think of a roundabout way of doing through a user defined
 function, but I am sure that there is a built-in function that offers
 this functionality. I'd be grateful if someone could tell me what that
 function is.

 Maybe this?

 levels(x)[y]

 Berend




-- 
Kaushik Krishnan
(kaushik.s.krish...@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.


  1   2   >