Re: [R] outer() or some other function for regression prediction with 2 IVs

2012-07-10 Thread peter dalgaard

On Jul 10, 2012, at 05:35 , Joseph Clark wrote:

 
 Thanks. I was able to get what I wanted by doing this:
 
 
 
 predxn - function(s,d) { coef(m3)[1] + coef(m3)[2]*s + coef(m3)[3]*s^2 + 
 coef(m3)[4]*d + coef(m3)[5]*d^2 }
 
 
 But it's not very elegant...
 

You didn't take Michael's hint:

coef(m3) %*% cbind(1, s, s^2, d, d^2)

or even

predict(m3, newdata=data.frame(x1=s, x2=d))

(in which x1, x2 needs replacement to match the names used in m3). 

Also, a quick (but not fast) solution to the generic non-vectorized-function 
problem is to Vectorize() it.

 
 
 
 
 
 // joseph w. clark , phd candidate
 \\ usc marshall school of business  
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] package JM -- version 1.0-0

2012-07-10 Thread Dimitris Rizopoulos

Dear R-users,

I'd like to announce the release of version 1.0-0 of package JM (already 
available from CRAN) for the joint modeling of longitudinal and 
time-to-event data using shared parameter models. These models are 
applicable in mainly two settings. First, when focus is in the survival 
outcome and we wish to account for the effect of an endogenous (aka 
internal) time-dependent covariate measured with error. Second, when 
focus is in the longitudinal outcome and we wish to correct for 
nonrandom dropout.


Some basic features of JM:

* it fits joint models for continuous longitudinal responses and allows 
for several options for the survival submodel, including PH models with 
Weibull, piecewise-constant, spline-approximated and unspecified 
baseline hazard functions. The most complete option is the PH model with 
the spline-approximated baseline hazard, which also allows for the 
inclusion of stratification factors, competing risks and (exogenous) 
time-varying covariates;


* it allows for several formulations of the association structure 
between the longitudinal and survival outcomes;


* it computes dynamic individualized predictions for the survival and 
longitudinal outcomes, which are updated as extra longitudinal 
information is recorded;


* it computes time-dependent sensitivity and specificity, and the 
corresponding ROCs and AUCs with several options for the prediction rule;


* several types of residuals are supported for both outcomes;

* fast fitting of these models is facilitated with a pseudo-adaptive 
Gaussian-Hermite rule.



The theory and application of this type of models along with a 
comprehensive overview of the capabilities of the package can be found 
in the recently published book Joint Models for Longitudinal and 
Time-to-Event Data, with Applications in R by Chapman and Hall/CRC 
(http://www.crcpress.com/product/isbn/9781439872864). The code used in 
the book and additional material are available in the R-forge web site: 
http://jmr.r-forge.r-project.org/


Additional information can be found in the corresponding help files, and 
examples at the R wiki web page devoted to JM: 
http://rwiki.sciviews.org/doku.php?id=packages:cran:jm


As always, any kind of feedback (e.g., questions, suggestions, 
bug-reports, etc.) is more than welcome.


Best,
Dimitris


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] Read vector as multi-dimensional data in R by row

2012-07-10 Thread arun
Hi,

Try this:
b1-aperm(array(a,dim=c(5,2,2)),perm=c(2,1,3))
 b1
, , 1

 [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10

, , 2

 [,1] [,2] [,3] [,4] [,5]
[1,]   11   12   13   14   15
[2,]   16   17   18   19   20

A.K.



- Original Message -
From: HJ YAN yhj...@googlemail.com
To: r-help@r-project.org
Cc: 
Sent: Monday, July 9, 2012 7:25 PM
Subject: [R] Read vector as multi-dimensional data in R by row

Dear R users


Say I wanted to read a vector into R as multi-dimensional array by row,
e.g.

a-c(1:20)

 b-array(a,dim=c(2,5,2))
 b
, , 1

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10

, , 2

     [,1] [,2] [,3] [,4] [,5]
[1,]   11   13   15   17   19
[2,]   12   14   16   18   20


But actually I wanted...

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10

, , 2

     [,1] [,2] [,3] [,4] [,5]
[1,]   11   12   13   14   15
[2,]   16   17   18   19   20


I checked '?array' but there is not an argument or something  like
'byrow=T' as the one in 'matrix'.

Could anyone help please?

Many thanks in advance!

HJ

    [[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] Skipping lines and incomplete rows

2012-07-10 Thread vioravis
Thanks a lot Rui and Arun.

The methods work fine with the data I gave but when I tried the two methods
with the following semi-colon separated data using sep = ;. Only the first
3 columnns are read properly rest of the columns are either empty or NAs.


**
Remove this line
Remove this line
Remove this line
Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
;[m/s];[°];°C;[hPa];[MWh];[MWh]
1/1/2012;0.0;0;#N/A;#N/A;0.;0.
1/2/2012;0.0;0;#N/A;#N/A;0.;0.
1/3/2012;0.0;0;#N/A;#N/A;1.5651;2.2112
1/4/2012;0.0;0;#N/A;#N/A;1.;2.
1/5/2012;0.0;0;#N/A;#N/A;3.2578;7.5455
***

I used the following code:
dat1-read.table(testInput.txt,sep=;,skip=3,fill=TRUE,header=TRUE) 
dat1-dat1[-1,] 
row.names(dat1)-1:nrow(dat1)

Could you please let me know what is wrong with this approach? 

Thank you.

Ravi

--
View this message in context: 
http://r.789695.n4.nabble.com/Skipping-lines-and-incomplete-rows-tp4635830p4635952.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 add marker in Stacked bar plot?

2012-07-10 Thread Manish Gupta
Thanks it works fine. But can i control its width? 

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-add-marker-in-Stacked-bar-plot-tp4635946p4635954.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 add marker in Stacked bar plot?

2012-07-10 Thread Manish Gupta
 I found arrow is too thin. I have one arrow image. I want to put it there.
How can i import external image and merge with stacked bar plot.

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-add-marker-in-Stacked-bar-plot-tp4635946p4635955.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to use external image with R plot?

2012-07-10 Thread Manish Gupta
Hi, 

I am wokring on stacked bar plot and i need to add one arrow dynamically. 


http://r.789695.n4.nabble.com/file/n4635959/arrow_glossy_right_red.jpg 

http://r.789695.n4.nabble.com/file/n4635959/Screenshot.10.png 

Final image: 

http://r.789695.n4.nabble.com/file/n4635959/Screenshot.1.png 

Is there any packae which can be used for merging images?

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-external-image-with-R-plot-tp4635959.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] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-10 Thread Jessica Streicher
Hi Jeremy,

newData-data.frame(JVeg5=factor(Jdata[,JVeg5]),scale(Jdata[,c(Elevation,Lat_Y_pos,Coast_dist,Stream_dist)]))
Global - polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
data=newData, na.action = na.omit, Hess = TRUE)

summary(Global)

Does this still do what you want? At least it doesn't produce the error like 
this.

greetings Jessi


On 09.07.2012, at 11:55, Jeremy Little wrote:

 Hello,
 
 I am trying to run an ordinal logistic regression (polr) using the package
 'MASS'.
 
 I have successfully run other regression classes (glm, multinom) without
 much problem, but with the 'polr' class I get the following error:
  Error in svd(X) : infinite or missing values in 'x' 
 which appears when I run the summary command.
 
 The data file is large (585000 rows) and has no NA, - or blank values.
 
 My script (in brief) is as follows, with results:
 
 
 library(MASS)
 
 ## ADD DATA
 Jdata- read.delim(/Analysis/20120709 JLittle data file.txt, header=T)
 
 attach(Jdata)
 names(Jdata)
 [1] POINTID Lat_Y_pos   JVeg5   Subregion   Rock_U_Nam 
 Rock_Name   Elevation   Slope   Aspect  Hillshade  
 Stream_dist Coast_dist  Coast_SE   
 [14] Coast_E Wind_310TPI Landform   
 
 Global - polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
 data=Jdata)
 
 summary(Global)
 Error in svd(X) : infinite or missing values in 'x'
 
 ##Try with omit NA command
 Global - polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
 data=Jdata, na.action = na.omit, Hess = TRUE)
 
 summary(Global)
 Error in svd(X) : infinite or missing values in 'x'
 
 
 Does this imply an 'infinite value' and what would this mean?
 
 If anyone has any idea how to address this error, I would very much
 appreciate your response.
 
 Thank you in advance.
 
 Jeremy
 
 Date File Attachment (200 rows):
 http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt
 20120709_JLittle_data_file.txt 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.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] outer() or some other function for regression prediction with 2 IVs

2012-07-10 Thread Joseph Clark

I saw the hint but didn't know how to implement it, I learn more every day.

Thanks for spelling it out!

 

I knew there had to be a function like predict!




// joseph w. clark , phd candidate
\\ usc marshall school of business



 Subject: Re: [R] outer() or some other function for regression prediction 
 with 2 IVs
 From: pda...@gmail.com
 Date: Tue, 10 Jul 2012 08:46:42 +0200
 CC: michael.weyla...@gmail.com; r-help@r-project.org
 To: joeclar...@hotmail.com


 On Jul 10, 2012, at 05:35 , Joseph Clark wrote:


 Thanks. I was able to get what I wanted by doing this:



 predxn - function(s,d) { coef(m3)[1] + coef(m3)[2]*s + coef(m3)[3]*s^2 + 
 coef(m3)[4]*d + coef(m3)[5]*d^2 }


 But it's not very elegant...


 You didn't take Michael's hint:

 coef(m3) %*% cbind(1, s, s^2, d, d^2)

 or even

 predict(m3, newdata=data.frame(x1=s, x2=d))

 (in which x1, x2 needs replacement to match the names used in m3).

 Also, a quick (but not fast) solution to the generic non-vectorized-function 
 problem is to Vectorize() it.






 // joseph w. clark , phd candidate
 \\ usc marshall school of business
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] Skipping lines and incomplete rows

2012-07-10 Thread Rui Barradas

Hello,

My approach was slightly different, to use readLines to take care of the 
header and read.table for the data. This works with the new dataset 
you've posted, but we must use the option comment.char = .


Try the following.


head - readLines(test.txt, n=4)[4]
dat - read.table(test.txt, skip=5, sep=;, stringsAsFactors=FALSE, 
comment.char=c)

names(dat) - unlist(strsplit(head, ;))

dat$Time - as.Date(dat$Time, format=%m/%d/%Y)
dat$Temp[dat$Temp == '#N/A'] - NA
dat$Press[dat$Press == '#N/A'] - NA
dat


It works with me, good luck.

Rui Barradas

Em 10-07-2012 06:41, vioravis escreveu:

Thanks a lot Rui and Arun.

The methods work fine with the data I gave but when I tried the two methods
with the following semi-colon separated data using sep = ;. Only the first
3 columnns are read properly rest of the columns are either empty or NAs.


**
Remove this line
Remove this line
Remove this line
Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
;[m/s];[°];°C;[hPa];[MWh];[MWh]
1/1/2012;0.0;0;#N/A;#N/A;0.;0.
1/2/2012;0.0;0;#N/A;#N/A;0.;0.
1/3/2012;0.0;0;#N/A;#N/A;1.5651;2.2112
1/4/2012;0.0;0;#N/A;#N/A;1.;2.
1/5/2012;0.0;0;#N/A;#N/A;3.2578;7.5455
***

I used the following code:
dat1-read.table(testInput.txt,sep=;,skip=3,fill=TRUE,header=TRUE)
dat1-dat1[-1,]
row.names(dat1)-1:nrow(dat1)

Could you please let me know what is wrong with this approach?

Thank you.

Ravi

--
View this message in context: 
http://r.789695.n4.nabble.com/Skipping-lines-and-incomplete-rows-tp4635830p4635952.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] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread vimmster
Dear Mr. Holtman,

but I cannot leave out the value and cannot change the values to 1200.995
manually (for each test subject with a reaction time  1000 ms), because the
first your lead to incomplete data and the latter would be too
time-consuming.

Dear Rui,

here I have three files, which have exactly the same content as
XYZ_34.txt, EXCEPT that the file XYZ_50.txt doesn't have a period in the
first value 1200.9952 IF YOU OPEN IT WITH THE EDITOR (!), maybe because I
didn't change the structure with MS Excel. The other two files should be
identical.

http://r.789695.n4.nabble.com/file/n4635962/XYZ_2.txt XYZ_2.txt 
http://r.789695.n4.nabble.com/file/n4635962/XYZ_50.txt XYZ_50.txt 
http://r.789695.n4.nabble.com/file/n4635962/XYZ_1112.txt XYZ_1112.txt 

R gives me the following output:

 fun - function(x){
+ dat - read.table(x, skip=14)
+ dat[ , 8] - as.numeric(gsub(\\., , dat[, 8]))
+ mean(dat[, 8])
+ }

 sapply(list.files(pattern=XYZ.*\\.txt), fun)
XYZ_1112.txtXYZ_2.txt   XYZ_50.txt 
345210.4 345210.4 310112.0

Your second suggestion leads to the same output:

 fun - function(x, skip = 14){
+ dat - read.table(x, skip=skip) 
+ dat[ , 8] - as.numeric(gsub(\\., , dat[, 8]))
+ mean(dat[, 8])
+ }

 sapply(list.files(pattern=XYZ.*\\.txt), fun)
XYZ_1112.txtXYZ_2.txt   XYZ_50.txt 
345210.4 345210.4 310112.0

Thank you for your replies!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4635962.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] Skipping lines and incomplete rows

2012-07-10 Thread Rui Barradas
Or maybe it's better to coerce Temp and Press to numeric, if they are 
variables temperature and presssure.


dat$Time - as.Date(dat$Time, format=%m/%d/%Y)
dat$Temp - as.numeric(dat$Temp)
dat$Press - as.numeric(dat$Press)

This makes those '#N/A' values NA.

Rui Barradas

Em 10-07-2012 09:34, Rui Barradas escreveu:

Hello,

My approach was slightly different, to use readLines to take care of the
header and read.table for the data. This works with the new dataset
you've posted, but we must use the option comment.char = .

Try the following.


head - readLines(test.txt, n=4)[4]
dat - read.table(test.txt, skip=5, sep=;, stringsAsFactors=FALSE,
comment.char=c)
names(dat) - unlist(strsplit(head, ;))

dat$Time - as.Date(dat$Time, format=%m/%d/%Y)
dat$Temp[dat$Temp == '#N/A'] - NA
dat$Press[dat$Press == '#N/A'] - NA
dat


It works with me, good luck.

Rui Barradas

Em 10-07-2012 06:41, vioravis escreveu:

Thanks a lot Rui and Arun.

The methods work fine with the data I gave but when I tried the two
methods
with the following semi-colon separated data using sep = ;. Only the
first
3 columnns are read properly rest of the columns are either empty or NAs.


**

Remove this line
Remove this line
Remove this line
Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
;[m/s];[°];°C;[hPa];[MWh];[MWh]
1/1/2012;0.0;0;#N/A;#N/A;0.;0.
1/2/2012;0.0;0;#N/A;#N/A;0.;0.
1/3/2012;0.0;0;#N/A;#N/A;1.5651;2.2112
1/4/2012;0.0;0;#N/A;#N/A;1.;2.
1/5/2012;0.0;0;#N/A;#N/A;3.2578;7.5455
***


I used the following code:
dat1-read.table(testInput.txt,sep=;,skip=3,fill=TRUE,header=TRUE)
dat1-dat1[-1,]
row.names(dat1)-1:nrow(dat1)

Could you please let me know what is wrong with this approach?

Thank you.

Ravi

--
View this message in context:
http://r.789695.n4.nabble.com/Skipping-lines-and-incomplete-rows-tp4635830p4635952.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] boxplot with cut

2012-07-10 Thread Rui Barradas

Hello,

Maybe this iss what you're looking for. GD is your data.frame.



multi.boxplot - function(x, by, ...){
x - as.data.frame(x)
sp - split(x, by)
len - length(sp) - 1
n - ncol(x)
n1 - n + 1
boxplot(x[[ 1 ]] ~ by, at = 0:len*n1 + 1,
xlim = c(0, (len + 1)*n1), ylim = range(unlist(x)), xaxt = n, 
...)
for(i in seq_len(n)[-1])
boxplot(x[[i]] ~ by, at = 0:len*n1 + i, xaxt = n, add = TRUE, 
...)
axis(1, at = 0:len*n1 + n1/2, labels = names(sp), tick = TRUE)
}

cols - grep(ReadCount, names(GD))
multi.boxplot(GD[, cols], cut(GD$GeneDensity, breaks=10))


If this is it and you don't like those x-axis tick lables, use 
as.integer(cut(...etc...)).


Hope this helps,

Rui Barradas

Em 09-07-2012 20:51, Vining, Kelly escreveu:

Dear UseRs,
I'm making box plots from a data set that looks like this:


   Chr Start   End GeneDensity ReadCount_Explant ReadCount_Callus 
ReadCount_Regen
1   1 1 1  107.82 1.2431.047   1.496
2   1 10001 2  202.50 0.8350.869   0.456
3   1 20001 3  158.80 1.8131.529   1.131
4   1 30001 4  100.53 1.7311.752   1.610
5   1 40001 5  100.53 3.0562.931   3.631
6   1 50001 6  100.53 1.9602.013   2.459

I'm breaking the GeneDensity column into deciles, then making a box plot of the 
relationship between the GeneDensity parameter and each of the three ReadCount columns. 
Here's an example of one of my boxplot commands:

boxplot(GeneDensity$ReadCount_Explant ~ cut(GeneDensitySorted$GeneDensity, breaks=10), ylim=c(0,40), 
ylab=RPKM, xlab=GENE DENSITY (LOW - HIGH), main=INTERNODE EXPLANT)

Right now, I'm making three separate graphs: one for each of the three 
ReadCount columns. I'd like to put all three sets on one graph, so that each 
decile is represented by three boxes, one for each ReadCount category, but don't know how 
to make that work. I tried this:

boxplot(GeneDensitySorted$ReadCount_Explant ~ cut(GeneDensitySorted$GeneDensity, breaks=10), 
GeneDensitySorted$ReadCount_Callus ~ cut(GeneDensitySorted$GeneDensity, breaks=10), 
GeneDensitySorted$ReadCount_Regen ~ cut(GeneDensitySorted$GeneDensity, breaks=10), ylim=c(0,40), 
ylab=RPKM, xlab=GENE DENSITY (LOW - HIGH))

Not surprisingly, I got this error:

Error in as.data.frame.default(data) :
   cannot coerce class 'formula' into a data.frame

Does anyone know how to accomplish this box plot?

Any help is much appreciated.

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



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


[R] how can I show the xlab and ylab information while using layout

2012-07-10 Thread Jie Tang
hi  R-users:
  I want to draw three plot into one figure by layout and the script has
been shown below.
 But I find R does  not show  the xlab and ylab information  completely as
shown the figure attached.
How can I midify the script.? thank you .

xxlab-paste(cpmd, (,ro,%),sep= )
yylab-paste(rfmd, (,co,%),sep= )
par(mar=c(3,3,1,1))
#layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),widths=lcm(30),
heights=lcm(25),TRUE)
layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),c(5,1),c(1,5),TRUE)
layout.show(3)
plot(data_cpmd,data_rfmd,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)
abline(1,1)
#rug(side=1,jitter(data_cpmd,5))
#rug(side=2,jitter(data_rfmd,5))
#plot(homo_ana$dism16cpmd,homo_ana$dism16rfmd,main=mtitle,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)

par(mar=c(0,3,1,1))
barplot(data_cpmd, axes=FALSE, ylim=YY, space=0)
par(mar=c(3,0,1,1))
barplot(data_rfmd, axes=FALSE,main=mtitle, xlim=XX, space=0, horiz=TRUE)

#boxplot(data_cpmd,horizontal = TRUE,xlim=XX,ylim=YY,outline=ifout, xaxt =
n)
#par(mar=c(3,0,1,1))
#boxplot(data_rfmd,xlim=XX,ylim=YY,outline=ifout,yaxt = n)
attachment: homo_jawt_pgtwhr24.png__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 show the xlab and ylab information while using layout

2012-07-10 Thread Sarah Goslee
The margins you specified aren't large enough to hold the information
you're trying to put in them, so you need to make them larger.

Sarah

On Tuesday, July 10, 2012, Jie Tang wrote:

 hi  R-users:
   I want to draw three plot into one figure by layout and the script has
 been shown below.
  But I find R does  not show  the xlab and ylab information  completely as
 shown the figure attached.
 How can I midify the script.? thank you .

 xxlab-paste(cpmd, (,ro,%),sep= )
 yylab-paste(rfmd, (,co,%),sep= )
 par(mar=c(3,3,1,1))
 #layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),widths=lcm(30),
 heights=lcm(25),TRUE)
 layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),c(5,1),c(1,5),TRUE)
 layout.show(3)
 plot(data_cpmd,data_rfmd,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)
 abline(1,1)
 #rug(side=1,jitter(data_cpmd,5))
 #rug(side=2,jitter(data_rfmd,5))

 #plot(homo_ana$dism16cpmd,homo_ana$dism16rfmd,main=mtitle,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)

 par(mar=c(0,3,1,1))
 barplot(data_cpmd, axes=FALSE, ylim=YY, space=0)
 par(mar=c(3,0,1,1))
 barplot(data_rfmd, axes=FALSE,main=mtitle, xlim=XX, space=0, horiz=TRUE)

 #boxplot(data_cpmd,horizontal = TRUE,xlim=XX,ylim=YY,outline=ifout, xaxt =
 n)
 #par(mar=c(3,0,1,1))
 #boxplot(data_rfmd,xlim=XX,ylim=YY,outline=ifout,yaxt = n)



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread Rui Barradas

Hello,

Ok, I think that there were two problems.
One, gsub substitutes all (g - global) occurrences of the search 
pattern, so both periods were removed.
The other, it would allways consider column 8 as character, but when 
there are no values with two periods it's read in with class numeric.

Both are now corrected.



fun - function(x, skip = 14){
dat - read.table(x, skip=skip, stringsAsFactors = FALSE)
if(is.character(dat[, 8])){
len - sapply(strsplit(dat[, 8], \\.), length)
dat[len == 3 , 8] - sub(\\., , dat[len == 3 , 8])
dat[, 8] - as.numeric(dat[, 8])
}
mean(dat[, 8])
}

sapply(list.files(pattern=XYZ.*\\.txt), fun)


Rui Barradas

Em 10-07-2012 09:35, vimmster escreveu:

Dear Mr. Holtman,

but I cannot leave out the value and cannot change the values to 1200.995
manually (for each test subject with a reaction time  1000 ms), because the
first your lead to incomplete data and the latter would be too
time-consuming.

Dear Rui,

here I have three files, which have exactly the same content as
XYZ_34.txt, EXCEPT that the file XYZ_50.txt doesn't have a period in the
first value 1200.9952 IF YOU OPEN IT WITH THE EDITOR (!), maybe because I
didn't change the structure with MS Excel. The other two files should be
identical.

http://r.789695.n4.nabble.com/file/n4635962/XYZ_2.txt XYZ_2.txt
http://r.789695.n4.nabble.com/file/n4635962/XYZ_50.txt XYZ_50.txt
http://r.789695.n4.nabble.com/file/n4635962/XYZ_1112.txt XYZ_1112.txt

R gives me the following output:


fun - function(x){

+ dat - read.table(x, skip=14)
+ dat[ , 8] - as.numeric(gsub(\\., , dat[, 8]))
+ mean(dat[, 8])
+ }


sapply(list.files(pattern=XYZ.*\\.txt), fun)

XYZ_1112.txtXYZ_2.txt   XYZ_50.txt
 345210.4 345210.4 310112.0

Your second suggestion leads to the same output:


fun - function(x, skip = 14){

+ dat - read.table(x, skip=skip)
+ dat[ , 8] - as.numeric(gsub(\\., , dat[, 8]))
+ mean(dat[, 8])
+ }


sapply(list.files(pattern=XYZ.*\\.txt), fun)

XYZ_1112.txtXYZ_2.txt   XYZ_50.txt
 345210.4 345210.4 310112.0

Thank you for your replies!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4635962.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] How to use external image with R plot?

2012-07-10 Thread Michael Sumner
There are many ways to do this, here is one using an example from ?barplot

library(jpeg)
x - readJPEG(arrow_glossy_right_red.jpg)
barplot(VADeaths, border = dark blue)
rasterImage(x, 0, 60, 1, 80)

You'll have to change those numbers to suit your plot, par('usr)
gives a quick idea of the extents. You should be able to see that JPEG
is not a good format for drawings like this (and using images like
this is not a good method anyway since you never know what scale you
might want the shape to be drawn at). You might be better just using
?arrows or ?symbols but if you are bound to a particular image source
try to save it as a pixel format that doesn't crush the data (such as
PNG).

Also, I'm not really merging images here, and I wouldn't say that's
the way to go about it. This is using R's plot support for vector and
raster graphics.

Cheers, Mike.

On Tue, Jul 10, 2012 at 5:19 PM, Manish Gupta mandecent.gu...@gmail.com wrote:
 Hi,

 I am wokring on stacked bar plot and i need to add one arrow dynamically.


 http://r.789695.n4.nabble.com/file/n4635959/arrow_glossy_right_red.jpg

 http://r.789695.n4.nabble.com/file/n4635959/Screenshot.10.png

 Final image:

 http://r.789695.n4.nabble.com/file/n4635959/Screenshot.1.png

 Is there any packae which can be used for merging images?

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-use-external-image-with-R-plot-tp4635959.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.



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.com

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


Re: [R] is it possible to insert a figure into into another new figure by r script

2012-07-10 Thread Thomas Adams
Jie,

I think the R contributed package, grImport, by Paul Murrell does what you
want. See this:

http://www.jstatsoft.org/v30/i04/paper/

Tom

On Mon, Jul 9, 2012 at 11:14 PM, Mikhail Titov m...@gmx.us wrote:

 Jie Tang totang...@gmail.com writes:

  hi R-users
 Now I have a figure in emf or png or tiff format  that have been drawn
  by other tool and I want to insert this figure into
   my new figure by R script. I wonder if is possible ?

 This [1] might be relevant.

 [1] http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=168

 --
 Mikhail

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  thomas.ad...@noaa.gov
VOICE:  937-383-0528
FAX:937-383-0033

[[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] image.plot transparent?

2012-07-10 Thread Chris82
Hi R users,

I have a maybe strange problem.

Normaly I do image.plot() with x,y coordinates and add=T and if I have some
NA values in my data matrix z, the color will be transparent of these
pixels.

But now I have a disorted coordinate system and x,y are a matrix. It works
also fine, but now NA values are white colored and not transparent anymore.

It is problematic if I have a secondary information underlying.

Is there any solution for this stuff?

Thanks!

best regards

--
View this message in context: 
http://r.789695.n4.nabble.com/image-plot-transparent-tp4635976.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 add marker in Stacked bar plot?

2012-07-10 Thread Jorge I Velez
Yes, you can.  See the lwd argument under ?arrows.   --JIV


On Tue, Jul 10, 2012 at 2:16 AM, Manish Gupta mandecent.gu...@gmail.comwrote:

 Thanks it works fine. But can i control its width?

 Regards

 --
 View this message in context:
 http://r.789695.n4.nabble.com/How-to-add-marker-in-Stacked-bar-plot-tp4635946p4635954.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] Predicted values for zero-inflated Poisson

2012-07-10 Thread Laura Lee
Alain-

Thanks again for the response. I guess my question is more related to R, which 
I'm learning as I go along. Could you provide guidance as to how I would code 
this in R?

Thanks,
Laura

From: Alain Zuur [via R] [mailto:ml-node+s789695n4635920...@n4.nabble.com]
Sent: Monday, July 09, 2012 5:20 PM
To: Lee, Laura
Subject: Re: Predicted values for zero-inflated Poisson

Laura Lee laura.lee at ncdenr.gov
Mon Jul 9 22:51:40 CEST 2012

 Previous message: [R] Predicted values for zero-inflated Poisson
 Next message: [R] Lavaan Package - How to Extract Residuals in Data Values
 Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Thanks for your reply. I do have a copy of Zero Inflated Models and
Generalized Linear Mixed Models with R and have been using that as a guide.
I applied the predict function (type=count) to the dataset for which I
built the model to compare the predicted bycatch numbers to the observed to
ensure I was doing things correctly. When I summed over the new predicted
variable, the value is over 500 whereas there were less than 10 observed.
I'd appreciate any advice regarding what I'm doing wrong.

--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635916.html
Sent from the R help mailing list archive at Nabble.com.




AFZ:
Laurano...you don't want to compare the count part of the model with raw 
datayou need to compare
the Exp(Y) = (1-pi) * mu with the raw data. Have a look at the Epilogue 
chapterit shows the difference
between mu and (1-pi) * mu.



Alain







--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7http://www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: [hidden email]/user/SendEmail.jtp?type=nodenode=4635920i=0
URL: www.highstat.comhttp://www.highstat.com
URL: www.brodgar.comhttp://www.brodgar.com


[[alternative HTML version deleted]]

__
[hidden email]/user/SendEmail.jtp?type=nodenode=4635920i=1 mailing list
https://stat.ethz.ch/mailman/listinfo/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. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7http://www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.commailto:highs...@highstat.com
URL: www.highstat.comhttp://www.highstat.com
URL: www.brodgar.comhttp://www.brodgar.com


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635920.html
To unsubscribe from Predicted values for zero-inflated Poisson, click 
herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4635861code=bGF1cmEubGVlQG5jZGVuci5nb3Z8NDYzNTg2MXw0NTg5ODY5NTk=.
NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml


-
Laura M. Lee
Senior Stock Assessment Scientist
North Carolina Division of Marine Fisheries
E-Mail: laura@ncdenr.gov
--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635978.html
Sent from the R help mailing 

Re: [R] how can I show the xlab and ylab information while using layout

2012-07-10 Thread Sarah Goslee
The mar argument to par(). Please do read ?par and perhaps the posting
guide.

Sarah

On Tuesday, July 10, 2012, Jie Tang wrote:

 which parameter ?

 2012/7/10 Sarah Goslee sarah.gos...@gmail.com javascript:_e({}, 'cvml',
 'sarah.gos...@gmail.com');

 The margins you specified aren't large enough to hold the information
 you're trying to put in them, so you need to make them larger.

 Sarah


 On Tuesday, July 10, 2012, Jie Tang wrote:

 hi  R-users:
   I want to draw three plot into one figure by layout and the script has
 been shown below.
  But I find R does  not show  the xlab and ylab information  completely
 as
 shown the figure attached.
 How can I midify the script.? thank you .

 xxlab-paste(cpmd, (,ro,%),sep= )
 yylab-paste(rfmd, (,co,%),sep= )
 par(mar=c(3,3,1,1))
 #layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),widths=lcm(30),
 heights=lcm(25),TRUE)
 layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),c(5,1),c(1,5),TRUE)
 layout.show(3)
 plot(data_cpmd,data_rfmd,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)
 abline(1,1)
 #rug(side=1,jitter(data_cpmd,5))
 #rug(side=2,jitter(data_rfmd,5))

 #plot(homo_ana$dism16cpmd,homo_ana$dism16rfmd,main=mtitle,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)

 par(mar=c(0,3,1,1))
 barplot(data_cpmd, axes=FALSE, ylim=YY, space=0)
 par(mar=c(3,0,1,1))
 barplot(data_rfmd, axes=FALSE,main=mtitle, xlim=XX, space=0, horiz=TRUE)

 #boxplot(data_cpmd,horizontal = TRUE,xlim=XX,ylim=YY,outline=ifout, xaxt
 =
 n)
 #par(mar=c(3,0,1,1))
 #boxplot(data_rfmd,xlim=XX,ylim=YY,outline=ifout,yaxt = 



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] image.plot transparent?

2012-07-10 Thread Sarah Goslee
This may be device and OS dependent, so please provide the information
requested in the posting guide, at a minimum the output of sessionInfo(). A
small reproducible example is also necessary.

Sarah

On Tuesday, July 10, 2012, Chris82 wrote:

 Hi R users,

 I have a maybe strange problem.

 Normaly I do image.plot() with x,y coordinates and add=T and if I have some
 NA values in my data matrix z, the color will be transparent of these
 pixels.

 But now I have a disorted coordinate system and x,y are a matrix. It works
 also fine, but now NA values are white colored and not transparent anymore.

 It is problematic if I have a secondary information underlying.

 Is there any solution for this stuff?

 Thanks!

 best regards

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

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



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] RGB components of plot() colours

2012-07-10 Thread Ted Harding
A quick question:

Is there anywhere a listing of the RGB components of the
named colours listed by colors()?

For example, where would I find the RGB for orange1
or salmon?

When I look at an EPS file from R where I have used
these colours, it seems that for:

salmon:
0.9804 0.5020 0.4471 rgb

orange1:
1 0.6471 0 rgb

However, this is a tedious way of finding out!

With thanks,
Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 10-Jul-2012  Time: 14:05:15
This message was sent by XFMail

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


Re: [R] number of decimal places in a number?

2012-07-10 Thread Martin Ivanov
 
Dear R users,

Thank You very much for Your responsiveness. I think the suggestion of arun's 
modification of Josh's code works best and it is what I am going to implement.

Cite Ellison:
Surely the issue is not the particular numeric resolution of the numbers but 
the idea that the bounding box limits should be integer multiples of the 
resolution?
Is that not accomplished more straightforwardly by things like
min - resol * floor( min(lat)/resol )
max - resol * ceil( max(lat)/resol )
?
Dear Ellison,
not the bounding box limits, but the bounding box RANGE needs to be an integer 
multiple of the resolution, that is max-min=ineger*resolution. The bbox limits 
must just be rounded to the same number of digits as the resolution and include 
all available values, of course.

Best regards.



  Оригинално писмо 
 От:  arun 
 Относно: Re: [R] number of decimal places in a number?
 До:  ted.hard...@wlandres.net  
 Изпратено на: Събота, 2012, Юли 7 22:50:03 EEST
 
 
 Hi, 
 
 
 I checked the count for the cases (A) and (F) with a variant of Josh's 
 function:
 
 decimalnumcount-function(x){stopifnot(class(x)==quot;characterquot;)
  x-gsub(quot;(.*)(#92;#92;.)|([0]*#36;)quot;,quot;quot;,x)
  nchar(x)
  }
  A) 
 x-quot;123456789.123456789quot;
  decimalnumcount(x)
 #[1] 9
 
 x-quot;923456789.123456789quot;
 decimalnumcount(x)
 #[1] 9
 
 B)
  x-quot;0.012345quot;
  decimalnumcount(x)
 #[1] 10
 
 
 c)
 x - c(quot;3.14quot;, quot;3.142quot;, quot;3.1400quot;, 
 quot;123456.123456789quot;, quot;123456789.123456789quot;,pi,sqrt(2))
   decimalnumcount(x)
 #[1]  2  3  2  9  9 14 13
 x
 [1] quot;3.14quot;    quot;3.142quot;   
 quot;3.1400quot; 
 [4] quot;123456.123456789quot;    quot;123456789.123456789quot; 
 quot;3.14159265358979quot;   
 [7] quot;1.4142135623731quot;    
 
 
 
 D)
  x - c(3.14, 3.142, 3.1400, 123456.123456789, 123456789.123456789,pi,sqrt(2))
 decimalnumcount(as.character(x) )
 [1]  2  3  2  9  6 14 13
 #as.character(x)
 #[1] quot;3.14quot; quot;3.142quot;    
 quot;3.14quot; quot;123456.123456789quot;
 #[5] quot;123456789.123457quot; quot;3.14159265358979quot; 
 quot;1.4142135623731quot; 
 
 E)
 print(pi,22)
 #[1] 3.141592653589793115998
 print(sqrt(2),22)
 #[1] 1.414213562373095145475
     x - c(quot;3.14quot;, quot;3.142quot;, quot;3.1400quot;, 
 quot;123456.123456789quot;, 
 quot;123456789.123456789quot;,quot;3.141592653589793115998quot;,quot;1.414213562373095145475quot;)
  decimalnumcount(x)
 #[1]  2  3  2  9  9 21 21
 
 F) 
 formatC(pi,format=quot;fquot;,digits=22)
 #[1] quot;3.1415926535897931159980quot;
  formatC(sqrt(2),format=quot;fquot;,digits=22)
 #[1] quot;1.4142135623730951454746quot;
 
  x - c(quot;3.14quot;, quot;3.142quot;, quot;3.1400quot;, 
 quot;123456.123456789quot;, 
 quot;123456789.123456789quot;,formatC(pi,format=quot;fquot;,digits=22),formatC(sqrt(2),format=quot;fquot;,digits=22))
  decimalnumcount(x)
 #[1]  2  3  2  9  9 21 22
 
 
 G)
 #  formatC() didn't show the limitations of print() 
  print(sqrt(2),22)
 #[1] 1.414213562373095145475
 
 print(sqrt(2),35)
 #Error in print.default(sqrt(2), 35) : invalid 'digits' argument
 
 formatC(sqrt(2),35)
 #[1] quot;1.4142135623730951454746218587388285quot;
 or,
 formatC(sqrt(2),format=quot;fquot;,digits=35)
 #[1] quot;1.41421356237309514547462185873882845quot;
 
 
 #using 22
 
 x - c(quot;3.14quot;, quot;3.142quot;, quot;3.1400quot;, 
 quot;123456.123456789quot;, 
 quot;123456789.123456789quot;,formatC(pi,format=quot;fquot;,digits=35),formatC(sqrt(2),format=quot;fquot;,digits=50))
  decimalnumcount(x)
 #[1]  2  3  2  9  9 35 50
 
 
 
 
 So, I guess it will be better to deal with character strings rather than 
 using as.character.
 A.K.
 
 
 
 
 - Original Message -
 From: quot;ted.hard...@wlandres.netquot; 
 To: r-help@r-project.org
 Cc: Martin Ivanov 
 Sent: Saturday, July 7, 2012 8:12 AM
 Subject: Re: [R] number of decimal places in a number?
 
 I had thought of also (as well as my numerical routing) suggesting
 a quot;gsub()quot; type solution like Joshua's below, but held back because
 the result could depend on how the number arose (keyboard input,
 file input, or from computation within R).
 
 However, I now also realise that (again because of binary rounding
 errors), the quot;gsub()quot; method has interesting differences from my
 numerical method. Example:
 
 [A] (as from my original method):
   f(123456789.123456789)
   # [1] 7
 
 [B] (the quot;gsub()quot; method)
   nchar(gsub(quot;(.*#92;#92;.)|([0]*#36;)quot;, quot;quot;, 
 as.character(123456789.123456789)))
   # [1] 6
 
 Now look at:
 
 [C] (what as.character() does to 123456789.123456789)
   as.character(123456789.123456789)
   # [1] quot;123456789.123457quot;
 
 [D] (quot;22quot; is the maximum number of decimal digits for print())
   print(123456789.123456789,22)
   # [1] 123456789.1234568
 
 So as.character() has rounded it to 6 decimal places (agreeing
 with [B]), while 

[R] define stuff to be only usable in the same file

2012-07-10 Thread Jessica Streicher
Hello R-Help!

I've looked around and have not found:

A simple(short) way to hide functions and variables from the global 
environment. What i want is for a few of them to only be accessable from the 
scriptfile they're in. I probably could do fun things with environments , but 
that seems quite a hassle.

As example: I have a file that gets me stuff from the database and creates an R 
object from the results, plus some functions on that object. Now i want the 
objectrelated stuff to be global, while the functions and variables i use for 
accessing the database shall be hidden.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Liviu Andronic
Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:
 (.xb - iris[ iris$Species=='zz', ])
[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)
 dim(.xb)
[1] 0 5
 (.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))
  X1 X2 X3 X4 X5
1 NA NA NA NA NA
 names(.xa) - names(.xb)
 (.xb - .xa)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler? Regards
Liviu


-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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


Re: [R] RGB components of plot() colours

2012-07-10 Thread Duncan Murdoch

On 12-07-10 9:05 AM, (Ted Harding) wrote:

A quick question:

Is there anywhere a listing of the RGB components of the
named colours listed by colors()?

For example, where would I find the RGB for orange1
or salmon?

When I look at an EPS file from R where I have used
these colours, it seems that for:

salmon:
0.9804 0.5020 0.4471 rgb

orange1:
1 0.6471 0 rgb

However, this is a tedious way of finding out!


col2rgb(salmon)
  [,1]
red250
green  128
blue   114

Those need to be divided by 255 to get the colours on the 0-1 scale.

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] define stuff to be only usable in the same file

2012-07-10 Thread Duncan Murdoch

On 12-07-10 9:13 AM, Jessica Streicher wrote:

Hello R-Help!

I've looked around and have not found:

A simple(short) way to hide functions and variables from the global 
environment. What i want is for a few of them to only be accessable from the 
scriptfile they're in. I probably could do fun things with environments , but 
that seems quite a hassle.


The simplest and best way to do this is to write a package.  You can 
also use local() around the code in a script, but it gets messy when you 
want to export more than one thing.


Duncan Murdoch


As example: I have a file that gets me stuff from the database and creates an R 
object from the results, plus some functions on that object. Now i want the 
objectrelated stuff to be global, while the functions and variables i use for 
accessing the database shall be hidden.


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


Re: [R] RGB components of plot() colours

2012-07-10 Thread Sarah Goslee
R uses the sandard X11 colors, I believe, and if you're using linux there's
a rgb.txt file on your computer that contains them.

It's also available here
http://cvsweb.xfree86.org/cvsweb/*checkout*/xc/programs/rgb/rgb.txt?rev=1.1

and a less-authoritative but prettier version:
http://en.wikipedia.org/wiki/X11_color_names

Within R, colors() is what you need. See here for an exhaustive discussion:
http://research.stowers-institute.org/efg/R/Color/Chart/

Sarah

On Tuesday, July 10, 2012, Ted Harding wrote:

 A quick question:

 Is there anywhere a listing of the RGB components of the
 named colours listed by colors()?

 For example, where would I find the RGB for orange1
 or salmon?

 When I look at an EPS file from R where I have used
 these colours, it seems that for:

 salmon:
 0.9804 0.5020 0.4471 rgb

 orange1:
 1 0.6471 0 rgb

 However, this is a tedious way of finding out!

 With thanks,
 Ted.

 -
 E-Mail: (Ted Harding) ted.hard...@wlandres.net javascript:;
 Date: 10-Jul-2012  Time: 14:05:15
 This message was sent by XFMail

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



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] Predicted values for zero-inflated Poisson

2012-07-10 Thread Achim Zeileis

On Tue, 10 Jul 2012, Laura Lee wrote:


Alain-

Thanks again for the response. I guess my question is more related to R, 
which I'm learning as I go along. Could you provide guidance as to how I 
would code this in R?


That depends on what exactly you want to predict.

As Alain said: The type=count predictions are probably not interesting 
to you. In the JSS paper accompanying zeroinfl, these correspond to 
exp(x'b) in Equation 8.


More interesting is probably the mean (1 - pi) * exp(x'b) which is the 
expected mean mu_i in Equation 8. This can be obtained as type=response.


Additionally, you might be interested in the individual probabilities for 
counts of 0, 1, 2, ... etc. This corresponds to evaluating Equation 7 
for y = 0, 1, 2, ... which can be obtained via type=prob. And from this 
you could also get the mode or median rather than the mean of the 
distribution.


hth,
Z



Thanks,
Laura

From: Alain Zuur [via R] [mailto:ml-node+s789695n4635920...@n4.nabble.com]
Sent: Monday, July 09, 2012 5:20 PM
To: Lee, Laura
Subject: Re: Predicted values for zero-inflated Poisson

Laura Lee laura.lee at ncdenr.gov
Mon Jul 9 22:51:40 CEST 2012

Previous message: [R] Predicted values for zero-inflated Poisson
Next message: [R] Lavaan Package - How to Extract Residuals in Data Values
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Thanks for your reply. I do have a copy of Zero Inflated Models and
Generalized Linear Mixed Models with R and have been using that as a guide.
I applied the predict function (type=count) to the dataset for which I
built the model to compare the predicted bycatch numbers to the observed to
ensure I was doing things correctly. When I summed over the new predicted
variable, the value is over 500 whereas there were less than 10 observed.
I'd appreciate any advice regarding what I'm doing wrong.

--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635916.html
Sent from the R help mailing list archive at Nabble.com.




AFZ:
Laurano...you don't want to compare the count part of the model with raw 
datayou need to compare
the Exp(Y) = (1-pi) * mu with the raw data. Have a look at the Epilogue 
chapterit shows the difference
between mu and (1-pi) * mu.



Alain







--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7http://www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: [hidden email]/user/SendEmail.jtp?type=nodenode=4635920i=0
URL: www.highstat.comhttp://www.highstat.com
URL: www.brodgar.comhttp://www.brodgar.com


   [[alternative HTML version deleted]]

__
[hidden email]/user/SendEmail.jtp?type=nodenode=4635920i=1 mailing list
https://stat.ethz.ch/mailman/listinfo/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. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7http://www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.commailto:highs...@highstat.com
URL: www.highstat.comhttp://www.highstat.com
URL: www.brodgar.comhttp://www.brodgar.com


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635920.html
To unsubscribe from Predicted values for zero-inflated Poisson, click 

Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Rui Barradas

Hello,

If you write a function, it becomes less convoluted...


empty - function(x){
if(NROW(x) == 0){
y - rep(NA, NCOL(x))
names(y) - names(x)
y
}else x
}

(.xb - iris[ iris$Species=='zz', ])
empty(.xb)


Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb - iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))

   X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) - names(.xb)
(.xb - .xa)

   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler? Regards
Liviu




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


Re: [R] Plotting rpart trees with long list of class members

2012-07-10 Thread Jean V Adams
Thanks.  Very helpful.

You can use the information from the splits in the first tree, to define a 
new grouping variable, which will simplify the plot:
suvar - sort(unique(test_set$list_var))
test_set$var_grp - as.factor(testtree$csplit[match(test_set$list_var, 
suvar)])
testtree2 - rpart ( list_val ~ var_grp, data = test_set ) 
rpart.plot(testtree2, type=3) 

Not to other readers, you will need to load these packages, before running 
the code:
library(rpart)
library(rpart.plot)

Jean


MarkBeauchene markbeauch...@hotmail.com wrote on 07/09/2012 03:42:32 PM:
 Here is some sample code.  It generates a class (list_var) that is used 
in
 rpart.  list_val is the dependant variable.
 
 The plot shows all the values of the class, which is a mess and makes 
the
 plot unuseable.  I'd like to either suppress the list entirely or 
replace it
 with something like Group 1, Group 2, etc.
 
 list_var - rep(NA,2000)
 list_val - rep(NA,2000)
 for (i in 1:1000) {
 list_var[i] - paste(A,i%/%25,sep='')
 list_val[i] - runif(1,0,1) }
 test_set - data.frame(list_var, list_val )
 
 
 
 
 testtree - rpart ( list_val ~ list_var, data = test_set )
 rpart.plot(testtree, type=3)

[[alternative HTML version deleted]]

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


Re: [R] image.plot transparent?

2012-07-10 Thread Prof Brian Ripley

On 10/07/2012 13:41, Sarah Goslee wrote:

This may be device and OS dependent, so please provide the information
requested in the posting guide, at a minimum the output of sessionInfo(). A
small reproducible example is also necessary.


I think not.  My guess is it is part of a package which we were not told 
('fields'), and this is the programmed behaviour in its two subcases.


But we'd need reproducible code (including which package) to be sure.

If this is fields, read ?poly.image.



Sarah

On Tuesday, July 10, 2012, Chris82 wrote:


Hi R users,

I have a maybe strange problem.

Normaly I do image.plot() with x,y coordinates and add=T and if I have some
NA values in my data matrix z, the color will be transparent of these
pixels.

But now I have a disorted coordinate system and x,y are a matrix. It works
also fine, but now NA values are white colored and not transparent anymore.

It is problematic if I have a secondary information underlying.

Is there any solution for this stuff?

Thanks!



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


[R] customize packages' help index ( 00index.html file )

2012-07-10 Thread Damien Georges

Hi all,

I'm writing my packages helps files and I'm not really satisfied by the 
visual results.


I'm would like to make subsections in a package function help index file.

I would like for example to put all S4 object documentation link 
together, then all the getters function.. and so on..


Does someone know if it's possible to do it?
Is it possible to define by myself the html/00index.html file that will 
be use in my package?


If it's not possible, how could I add the alphabetic subsections that 
exist in most of packages index help files?


Best,

Damien

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] identify.hclust() doesn't cut tree at the vertical position of the mouse pointer

2012-07-10 Thread WATSON Mick
Dear All

According to the identify.hclust documentation the function cuts the tree at 
the vertical position of the pointer and highlights the cluster containing the 
horizontal position of the pointer.

When I carry out this, the tree isn't cut where I click - in fact, there seems 
to be a limit below which I cannot go.

Consider the following code:

mat - matrix(rnorm(5000), ncol=5)
hc - hclust(dist(mat))
plot(hc)
identify(hc)

No matter where I click on the tree, I cannot cut below around about 5.   I can 
cut above that value, but not below.

Any help is much appreciated.

 sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

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

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

other attached packages:
 [1] geneplotter_1.34.0   lattice_0.20-6   annotate_1.34.1  
AnnotationDbi_1.18.1 Biobase_2.16.0   BiocGenerics_0.2.0   
BiocInstaller_1.4.7  gplots_2.11.0MASS_7.3-18 
[10] KernSmooth_2.23-7caTools_1.13 bitops_1.0-4.1   
gdata_2.11.0 gtools_2.7.0

loaded via a namespace (and not attached):
[1] DBI_0.2-5  IRanges_1.14.4 RColorBrewer_1.0-5 RSQLite_0.11.1 
stats4_2.15.1  tools_2.15.1   XML_3.9-4.1xtable_1.7-0  

Thanks
Mick

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[R] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread Rantony
Hi,

i have a matrix like this,

ABCXYZ...   .
- --
1220  ...   .
2435  ...   .
3040  ...   .

Here, i need to get 
   Sum of each columns,
   Mean of each columns, 
   median of each columns,
   mode of each columns, 
   Standard deviation  of each columns, 
   variance of each columns, 
   range of each columns,
   count of each columns,
   max of each columns, 
   min of each columns

Can i get output using sappy or tappy functions ? because there have alots
of records.

Could you please help me fast its kind of urgent !

- Thanks 
Antony 

--
View this message in context: 
http://r.789695.n4.nabble.com/Use-of-Sappy-and-Tappy-for-Mathematical-Calculation-tp4635969.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] fitting power growth

2012-07-10 Thread Thomas Hoffmann

Dear all

I am using the x and y vectors as defined below and want do to a power 
law regression:


y = a x^b

using
 lm(log(y)~log(x))

gives reasonable values (b=1.23) but is not very popular due to biases 
of back-transformation from log to non-log values.  Using


 nls(y~a*x^b,start=list(a=100,b=1.23))

is statistically more correct but gives a too large a value and a too 
small b value.



Doe anybody have a better way to solve the above power-law regression 
(using for instance maximum likely hood or anything else).


Kind regards for your help
Thomas



 x
 [1]   744.90   806.40   838.00   910.70  1818.60  2870.10  4070.00 
4476.80  4857.60  4858.10
[11]  5916.40 13970.80 27306.60 28226.60  2532.10  2658.40 18863.10   
758.0054.0079.00
[21]   139.0046.70  1003.0024.00   106.00   186.00 1503.00   
228.0010.24   162.00

[31]   381.70   312.60   209.00   246.00   221.20  1151.55
 y
 [1] 1.500e+08 2.850e+08 1.800e+08 1.800e+08 6.300e+08 7.200e+08 
1.170e+09 1.095e+09 1.620e+09
[10] 4.650e+09 1.575e+09 4.200e+09 7.755e+09 8.745e+09 9.900e+08 
6.600e+08 1.077e+10 3.450e+08
[19] 1.350e+07 2.550e+07 6.600e+07 6.000e+06 3.300e+07 1.500e+06 
4.500e+06 7.500e+06 2.415e+08
[28] 6.900e+07 9.000e+05 9.450e+06 3.510e+07 4.880e+07 3.100e+06 
1.930e+07 2.270e+07 5.270e+07


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

2012-07-10 Thread Alastair
Hi,

I've been using R for a number of years and have always installed the newest
version when released. However I've just noticed that old versions of R are
taking up quite a lot of disk space.

lap-alastair:/ alastair$ du -h -d 1
/Library/Frameworks/R.framework/Versions/
266M/Library/Frameworks/R.framework/Versions/2.10
204M/Library/Frameworks/R.framework/Versions/2.11
459M/Library/Frameworks/R.framework/Versions/2.12
511M/Library/Frameworks/R.framework/Versions/2.13
478M/Library/Frameworks/R.framework/Versions/2.14
217M/Library/Frameworks/R.framework/Versions/2.15
32K /Library/Frameworks/R.framework/Versions/2.5
5.5M/Library/Frameworks/R.framework/Versions/2.6
84M /Library/Frameworks/R.framework/Versions/2.8
2.2G/Library/Frameworks/R.framework/Versions/

Do I need to keep any of the versions before the current (2.15). If I delete
all the previous versions will that have any impact on the current
installation, or is each version entirely self-contained? 

Thanks.


--
View this message in context: 
http://r.789695.n4.nabble.com/Mac-OS-X-R-uninstallation-question-tp4635971.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] Questions about doing analysis based on time

2012-07-10 Thread APOCooter
Thanks to everyone for their help so far.  It's been greatly appreciated.  I
have a new, but similar problem:

I have data that I have broken down by hour (median/mean for each hour).  I
would like to break it down further, by each half hour (0:00-0:29,
0:30-0:59, 1:00-1:29, 1:30-1:59, etc).  I thought cut.dates() from the chron
package would be able to do it, but I can't find anything in the chron
package documention.  I'm fairly certain that if I can figure out how to
break down the data by half hour that I can do all the other analysis just
fine (median/mean for each half hour, etc)


Here is a small sample of the data:

 dput(head(SundayData, 100))
structure(list(SunDate = structure(c(1273377600, 1307851200, 
1213502640, 1217736420, 1311480420, 1211688540, 1337487060, 1255839120, 
1268543520, 1293945120, 1280635980, 1309061640, 1322975640, 1297574280, 
1221970740, 1253420340, 1218946800, 1329024060, 1290316920, 1224994980, 
1218342420, 1269750420, 1257658080, 1322371680, 1214108940, 1312086540, 
1260077400, 1228023060, 1315110660, 1281241920, 1272774960, 1224995820, 
1275194220, 1246768860, 1302410460, 1234071780, 1305434580, 1232257500, 
1243140300, 1284871500, 1247373960, 1265521560, 1273985160, 1310273160, 
1226209620, 1270356420, 1330235280, 1222577400, 1310878200, 1324187400, 
1242535860, 1336279860, 1283057520, 1291528320, 1324187580, 1330840380, 
1298786100, 1307854500, 1236491880, 1298786280, 1233468180, 1280034240, 
1230444300, 1213506360, 1251608760, 1215320820, 1304226420, 1320556080, 
1299391740, 1286687580, 1296972780, 1296972780, 1321164780, 1260684960, 
1315113420, 1287292680, 1292134800, 1303017600, 1307251200, 1278825720, 
1238304180, 1212902640, 1231655100, 1254029100, 1311485100, 1295159160, 
1220160420, 1297578540, 1300599000, 1241933640, 1225604100, 1269149880, 
1283665140, 1244958120, 1245562980, 1289716980, 1235890020, 1282456080, 
1279432140, 1279432140), class = c(POSIXct, POSIXt), tzone = ), 
SunTime = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 6L, 6L, 
6L, 7L, 8L, 8L, 9L, 10L, 10L, 11L, 12L, 13L, 14L, 15L, 15L, 
16L, 16L, 17L, 17L, 18L, 19L, 19L, 20L, 21L, 22L, 22L, 23L, 
23L, 24L, 24L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 27L, 27L, 
28L, 29L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L, 
34L, 34L, 35L, 36L, 37L, 38L, 38L, 39L, 39L, 40L, 41L, 42L, 
42L, 42L, 42L, 43L, 44L, 45L, 46L, 46L, 46L, 47L, 48L, 49L, 
50L, 50L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 
60L, 60L, 61L, 62L, 63L, 63L), .Label = c(0:00, 0:04, 
0:07, 0:09, 0:11, 0:12, 0:13, 0:14, 0:18, 0:19, 
0:20, 0:21, 0:22, 0:23, 0:27, 0:28, 0:29, 0:30, 
0:31, 0:32, 0:36, 0:37, 0:41, 0:43, 0:45, 0:46, 
0:47, 0:48, 0:50, 0:51, 0:52, 0:53, 0:55, 0:58, 
1:03, 1:04, 1:05, 1:06, 1:07, 1:08, 1:09, 1:13, 
1:16, 1:17, 1:18, 1:20, 1:22, 1:23, 1:24, 1:25, 
1:26, 1:27, 1:29, 1:30, 1:34, 1:35, 1:38, 1:39, 
1:42, 1:43, 1:47, 1:48, 1:49, 1:52, 1:54, 1:55, 
1:56, 1:57, 1:59, 10:00, 10:04, 10:07, 10:08, 
10:09, 10:10, 10:11, 10:12, 10:14, 10:15, 10:16, 
10:18, 10:20, 10:22, 10:23, 10:24, 10:25, 10:26, 
10:27, 10:28, 10:30, 10:31, 10:32, 10:33, 10:34, 
10:35, 10:36, 10:37, 10:38, 10:39, 10:40, 10:41, 
10:43, 10:44, 10:45, 10:47, 10:48, 10:49, 10:50, 
10:51, 10:53, 10:54, 10:55, 10:56, 10:58, 10:59, 
11:01, 11:02, 11:05, 11:06, 11:07, 11:09, 11:10, 
11:12, 11:14, 11:15, 11:16, 11:20, 11:21, 11:22, 
11:23, 11:24, 11:26, 11:27, 11:29, 11:30, 11:31, 
11:33, 11:34, 11:35, 11:36, 11:37, 11:38, 11:39, 
11:40, 11:43, 11:44, 11:46, 11:47, 11:49, 11:52, 
11:56, 11:58, 11:59, 12:00, 12:01, 12:02, 12:03, 
12:04, 12:05, 12:06, 12:07, 12:08, 12:09, 12:10, 
12:11, 12:13, 12:14, 12:15, 12:17, 12:19, 12:21, 
12:22, 12:24, 12:25, 12:26, 12:27, 12:28, 12:30, 
12:31, 12:32, 12:34, 12:36, 12:37, 12:38, 12:39, 
12:41, 12:45, 12:46, 12:47, 12:48, 12:49, 12:50, 
12:51, 12:53, 12:54, 12:55, 12:56, 12:57, 12:58, 
12:59, 13:00, 13:01, 13:02, 13:03, 13:04, 13:05, 
13:06, 13:07, 13:08, 13:09, 13:10, 13:12, 13:13, 
13:14, 13:15, 13:17, 13:18, 13:19, 13:20, 13:21, 
13:23, 13:25, 13:26, 13:27, 13:30, 13:31, 13:32, 
13:34, 13:35, 13:36, 13:38, 13:39, 13:40, 13:44, 
13:45, 13:46, 13:47, 13:48, 13:49, 13:50, 13:51, 
13:52, 13:53, 13:54, 13:55, 13:57, 13:58, 13:59, 
14:00, 14:01, 14:02, 14:04, 14:05, 14:06, 14:07, 
14:08, 14:11, 14:12, 14:13, 14:14, 14:15, 14:16, 
14:17, 14:18, 14:20, 14:21, 14:22, 14:23, 14:25, 
14:26, 14:28, 14:29, 14:30, 14:31, 14:32, 14:34, 
14:35, 14:36, 14:37, 14:38, 14:40, 14:41, 14:42, 
14:43, 14:45, 14:46, 14:47, 14:49, 14:50, 14:51, 
14:52, 14:53, 14:54, 14:56, 14:57, 14:58, 14:59, 
15:01, 15:02, 15:03, 15:04, 15:05, 15:07, 15:11, 
15:12, 15:13, 15:14, 15:15, 15:17, 15:18, 15:19, 
15:20, 15:22, 15:23, 15:24, 15:25, 15:26, 15:28, 
15:29, 15:30, 15:31, 15:33, 15:34, 15:35, 15:36, 
15:37, 15:38, 15:40, 15:41, 15:42, 15:43, 

[R] Count of elements in coulmns of a matrix

2012-07-10 Thread Rantony
Could you please tell me what is the function or method to get count of
elements in all the columns in a matrix ?

for eg :-

ABC  XYZPQR
--  - --
234
   4   5
54   3
  2

Result will be like
ABC  XYZPQR
--  - --
2 43

Could you please help me ?

--
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-elements-in-coulmns-of-a-matrix-tp4635979.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] gdata: Problem reading excel document containing non-US characters

2012-07-10 Thread Rolf Marvin Bøe Lindgren
I am using the gdata package to read in an Excel document. read.xls chokes on a 
“foreign” character.  Here's the original code:

   require(gdata)
   dendro - read.xls(/tmp/avitot.xlsv3WiXg,fileEncoding=Latin1)

Now, the fileEncoding=Latin1 ought to work, because if i copy the code for 
read.xls, and edit

   retval - read.csv(con, na.strings = na.strings, ...)

appropriately, to include fileEncoding=Latin1 and include the definition to 
override read.xls (to those who wish to test this: you need to include findPerl 
as well), then it works.

but from the code, seems plain that read.xls should pass the 
‘fileEncoding=Latin1’ all the way to when read.csv is called.

So I don't know if this is a bug, or if I have misuderstood something. 

Is there a better way to achieve this than to edit and override read.xls?  

Any and all suggestions are welcome. 

Thank you,


-- 
Rolf Marvin Bøe Lindgren
r...@grendel.no
http:/www.grendel.no/

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


Re: [R] Count of elements in coulmns of a matrix

2012-07-10 Thread Sarah Goslee
It depends: what's in those empty space?

Some combination of apply() and something else, depending on what your
matrix *actually* looks like, and here dput() would be vastly
preferable to copy and paste of something that didn't even come from
an R session.

The something else might involve length() or is.na() or, well, other
possibilities but my telepathy is on the fritz today.

Sarah

On Tue, Jul 10, 2012 at 8:31 AM, Rantony antony.akk...@ge.com wrote:
 Could you please tell me what is the function or method to get count of
 elements in all the columns in a matrix ?

 for eg :-

 ABC  XYZPQR
 --  - --
 234
4   5
 54   3
   2

 Result will be like
 ABC  XYZPQR
 --  - --
 2 43

 Could you please help me ?


-- 
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] define stuff to be only usable in the same file

2012-07-10 Thread Jessica Streicher

On 10.07.2012, at 15:24, Duncan Murdoch wrote:

 On 12-07-10 9:13 AM, Jessica Streicher wrote:
 Hello R-Help!
 
 I've looked around and have not found:
 
 A simple(short) way to hide functions and variables from the global 
 environment. What i want is for a few of them to only be accessable from the 
 scriptfile they're in. I probably could do fun things with environments , 
 but that seems quite a hassle.
 
 The simplest and best way to do this is to write a package.  

After an hour i can say it is neither simple nor short nor will it work at all 
at the moment

 ERROR
cannot change to directory 'testpack'

- tried to use the build command from pretty much everywhere

 You can also use local() around the code in a script, but it gets messy when 
 you want to export more than one thing.

I think local isn't quite what i imagined.

 
 Duncan Murdoch
 
 As example: I have a file that gets me stuff from the database and creates 
 an R object from the results, plus some functions on that object. Now i want 
 the objectrelated stuff to be global, while the functions and variables i 
 use for accessing the database shall be hidden.
 
 


[[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] Mac OS X R uninstallation question

2012-07-10 Thread Prof Brian Ripley

Please ask Mac-specific questions on R-sig-mac.

In particular, it is a little odd that these are not getting deleted 
when you install a new version.


But *if all your packages are up to date* you do not need earlier 
versions of R.framework, so run


update.packages(checkBuilt=TRUE)

first.

On 10/07/2012 11:55, Alastair wrote:

Hi,

I've been using R for a number of years and have always installed the newest
version when released. However I've just noticed that old versions of R are
taking up quite a lot of disk space.

lap-alastair:/ alastair$ du -h -d 1
/Library/Frameworks/R.framework/Versions/
266M/Library/Frameworks/R.framework/Versions/2.10
204M/Library/Frameworks/R.framework/Versions/2.11
459M/Library/Frameworks/R.framework/Versions/2.12
511M/Library/Frameworks/R.framework/Versions/2.13
478M/Library/Frameworks/R.framework/Versions/2.14
217M/Library/Frameworks/R.framework/Versions/2.15
32K /Library/Frameworks/R.framework/Versions/2.5
5.5M/Library/Frameworks/R.framework/Versions/2.6
84M /Library/Frameworks/R.framework/Versions/2.8
2.2G/Library/Frameworks/R.framework/Versions/

Do I need to keep any of the versions before the current (2.15). If I delete
all the previous versions will that have any impact on the current
installation, or is each version entirely self-contained?

Thanks.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Peter Ehlers

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty - function(x){
if(NROW(x) == 0){
y - rep(NA, NCOL(x))
names(y) - names(x)
y
}else x
}

(.xb - iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

  (.xb - iris[ iris$Species=='zz', ])
  .xb - .xb[1, ]   # this probably shouldn't work, but it does.

?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb - iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))

X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) - names(.xb)
(.xb - .xa)

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler? Regards
Liviu




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] define stuff to be only usable in the same file

2012-07-10 Thread Jessica Streicher

On 10.07.2012, at 16:45, Jessica Streicher wrote:

 
 On 10.07.2012, at 15:24, Duncan Murdoch wrote:
 
 On 12-07-10 9:13 AM, Jessica Streicher wrote:
 Hello R-Help!
 
 I've looked around and have not found:
 
 A simple(short) way to hide functions and variables from the global 
 environment. What i want is for a few of them to only be accessable from 
 the scriptfile they're in. I probably could do fun things with environments 
 , but that seems quite a hassle.
 
 The simplest and best way to do this is to write a package.  
 
 After an hour i can say it is neither simple nor short nor will it work at 
 all at the moment
 
 ERROR
 cannot change to directory 'testpack'
 
 - tried to use the build command from pretty much everywhere

Forget about that, i'm stupid and can't use the tools available...

 
 You can also use local() around the code in a script, but it gets messy when 
 you want to export more than one thing.
 
 I think local isn't quite what i imagined.
 
 
 Duncan Murdoch
 
 As example: I have a file that gets me stuff from the database and creates 
 an R object from the results, plus some functions on that object. Now i 
 want the objectrelated stuff to be global, while the functions and 
 variables i use for accessing the database shall be hidden.
 
 
 
 
   [[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] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Brian Diggs

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty - function(x){
if(NROW(x) == 0){
y - rep(NA, NCOL(x))
names(y) - names(x)
y
}else x
}

(.xb - iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

   (.xb - iris[ iris$Species=='zz', ])
   .xb - .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better

empty - function(x) {
  if(NROW(x) == 0) {
x[NA,]
  } else {
x
  }
}

It even preserves the factor nature of things:

 empty(iris[iris$Specis=='zz',])
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NANA
 str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
 $ Sepal.Length: num NA
 $ Sepal.Width : num NA
 $ Petal.Length: num NA
 $ Petal.Width : num NA
 $ Species : Factor w/ 3 levels setosa,versicolor,..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb - iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))

X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) - names(.xb)
(.xb - .xa)

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




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






--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

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


[R] Help with vectors and rollapply

2012-07-10 Thread Raghuraman Ramachandran
Hello

I have a vector a =(-2,0,0,0,1,0,0,3,0,0,-4)

I want to replace all zeros into previous non-zero state. So for instance the 
above vector should be converted into:

a= (-2,-2,-2,-2,1,1,1,3,3,3,-4)

I tried many things and finally concluded that probably(?) rollapply may be the 
best way?

I tried
f= function(x){
ifelse(x==0,Lag(x),x)
}

And then, rollappy(a,1,f) and that didn't work. Can someone help please?

Thx
R


Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
this email, including any attachments, are confidential to the ordinary user of 
the email address to which it was addressed. If you are not the addressee of 
this email you may not copy, forward, disclose or otherwise use it or any part 
of it in any form whatsoever. Since the confidentiality of Internet e-mail 
cannot be guaranteed, please do not include private or confidential information 
(such as account numbers) or instructions requiring your authorization (such as 
orders or funds transfers) in your e-mail communication to us. This email may 
be produced at the request of regulators or in connection with civil 
litigation. Jefferies accepts no liability for any errors or omissions arising 
as a result of transmission. Although this transmission and any attachments are 
believed to be free of any virus or other defect that might affect any computer 
system into which it is received and opened, it is the!
  responsibility of the recipient to ensure that it is virus free and no 
responsibility is accepted by Jefferies, its subsidiaries and affiliates, as 
applicable, for any loss or damage arising in any way from its use. In the 
United Kingdom, Jefferies operates as Jefferies International Limited; 
registered in England: no. 1978621; and Jefferies Bache Limited; registered in 
England: no. 114226; registered office for both: Vintners Place, 68 Upper 
Thames Street, London EC4V 3BJ. Jefferies International Limited and Jefferies 
Bache Limited are authorised and regulated by the Financial Services Authority. 
If you received this transmission in error, please immediately contact the 
sender and destroy the material in its entirety, whether in electronic or hard 
copy format. 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.


Re: [R] multiple comparisons with generalised least squares

2012-07-10 Thread Ariel

racmar wrote
 
 I have also been searching various forums and books to see if there are
 any methods I could use and have only found people, such as yourself,
 asking the same question. 
 

I was looking into this recently, as well, and found that the problem has to
do with building the model.matrix/terms/model.frame for gls objects when
using the glht function.  I ended up creating three gls-specific functions
and was able to get estimates/confidence intervals for the toy example
below.   You may find these functions useful (under the caveat that I only
checked that I got estimates and not that the estimates were correct ;) ).

Ariel

Example:
library(nlme)

Orthodont$fage - factor(Orthodont$age)

#toy example with Orthodont data using age as a factor
fitgls - gls( distance ~ fage, data=Orthodont, 
weights = varIdent(form =~1|fage))



library(multcomp)

#notice the error about the model.matrix for gls objects when using glht
confint( glht (fitgls, mcp(fage=Tukey) ))

#create model.frame, terms, and model.matrix functions specifically for gls
objects
model.matrix.gls - function(object, ...) 
model.matrix(terms(object), data = getData(object), ...)


model.frame.gls - function(object, ...) 
model.frame(formula(object), data = getData(object), ...)


terms.gls - function(object, ...) 
terms(model.frame(object),...)


#now run glht again
confint( glht(  fitgls, mcp(fage=Tukey) ))




--
View this message in context: 
http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4636009.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Count of elements in coulmns of a matrix

2012-07-10 Thread arun
Hi,

Try this:

list1-list(ABC=c(2,5),XYZ=c(3,4,4,2),PQR=c(4,5,3))
 lapply(list1,function(x) length(x))
$ABC
[1] 2

$XYZ
[1] 4

$PQR
[1] 3

 list2-lapply(list1,function(x) length(x))
 dat2-data.frame(list2)
 dat2
  ABC XYZ PQR
1   2   4   3
A.K.



- Original Message -
From: Rantony antony.akk...@ge.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 8:31 AM
Subject: [R] Count of elements in coulmns of a matrix

Could you please tell me what is the function or method to get count of
elements in all the columns in a matrix ?

for eg :-

ABC      XYZ    PQR
--      -     --
2            3            4
               4           5
5            4           3
              2

Result will be like
ABC      XYZ    PQR
--      -     --
2             4            3

Could you please help me ?

--
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-elements-in-coulmns-of-a-matrix-tp4635979.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] RGL 3D curvilinear shapes

2012-07-10 Thread PatGauthier
Dear useRs, 

I'm trying to simply fill in the area under a curve using RGL. Here' the set
up:

x - c(0.75,75.75,150.75,225.75,300.75,375.75,450.75,525.75,600.75,675.75,
   0.5,50.5,100.5,150.5,200.5,250.5,300.5,350.5,400.5,450.5,
   0.25,25.25,50.25,75.25,100.25,125.25,150.25,175.25,200.25,225.25)
y - c(0.05,4.91,9.78,14.64,19.51,24.38,29.24,34.11,38.97,43.84,
   0.1,9.83,19.56,29.29,39.02,48.75,58.48,68.21,77.94,87.67,
   0.15,14.74,29.34,43.93,58.53,73.13,87.72,102.32,116.91,131.51)
z - c(0.05,0.55,0.7,0.78,0.83,0.87,0.9,0.92,0.93,0.94,
   0,0.32,0.59,0.77,0.87,0.93,0.96,0.98,0.99,1,
   0,0.39,0.66,0.82,0.9,0.95,0.97,0.99,0.99,1)

dat - data.frame(x = x, y = y, z = z, ID = c(rep(c(1,2,3),each=10)))

plot3d(dat, type = n, ylab = , xlab = , zlab = , axes = F, ylim =
c(0,200))
lines3d(dat[1:10,])
lines3d(dat[11:20,])
lines3d(dat[21:30,])

axes3d(edge = c(x--, y-+, z--), nticks = 5, ylim = c(0,200))
bbox3d(color = c(black, white), lit = F, back = line)

Any ideas/tips on how to do this?

thanks in advance, 

Patrick

--
View this message in context: 
http://r.789695.n4.nabble.com/RGL-3D-curvilinear-shapes-tp4636011.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Help with vectors and rollapply

2012-07-10 Thread William Dunlap
It looks like you already have the zoo package loaded so you can use its 
na.locf(),
which replaces NA's with the last non-NA value.  Convert the 0s to NAs with
replace() and feed the result into na.locf():
  a  - c(-2,0,0,0,1,0,0,3,0,0,-4)
  aOut - c(-2,-2,-2,-2,1,1,1,3,3,3,-4)
  na.locf(replace(a, a==0, NA) )
  #  [1] -2 -2 -2 -2  1  1  1  3  3  3 -4
  all.equal(aOut, .Last.value)
  # [1] TRUE

If you need to treat NA and 0 differently you will need to do more work.

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 Raghuraman Ramachandran
 Sent: Tuesday, July 10, 2012 8:23 AM
 To: r-help@r-project.org
 Subject: [R] Help with vectors and rollapply
 
 Hello
 
 I have a vector a =(-2,0,0,0,1,0,0,3,0,0,-4)
 
 I want to replace all zeros into previous non-zero state. So for instance the 
 above
 vector should be converted into:
 
 a= (-2,-2,-2,-2,1,1,1,3,3,3,-4)
 
 I tried many things and finally concluded that probably(?) rollapply may be 
 the best
 way?
 
 I tried
 f= function(x){
 ifelse(x==0,Lag(x),x)
 }
 
 And then, rollappy(a,1,f) and that didn't work. Can someone help please?
 
 Thx
 R
 
 
 Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
 this
 email, including any attachments, are confidential to the ordinary user of 
 the email
 address to which it was addressed. If you are not the addressee of this email 
 you may
 not copy, forward, disclose or otherwise use it or any part of it in any form
 whatsoever. Since the confidentiality of Internet e-mail cannot be guaranteed,
 please do not include private or confidential information (such as account 
 numbers)
 or instructions requiring your authorization (such as orders or funds 
 transfers) in your
 e-mail communication to us. This email may be produced at the request of 
 regulators
 or in connection with civil litigation. Jefferies accepts no liability for 
 any errors or
 omissions arising as a result of transmission. Although this transmission and 
 any
 attachments are believed to be free of any virus or other defect that might 
 affect any
 computer system into which it is received and opened, it is the!
   responsibility of the recipient to ensure that it is virus free and no 
 responsibility is
 accepted by Jefferies, its subsidiaries and affiliates, as applicable, for 
 any loss or
 damage arising in any way from its use. In the United Kingdom, Jefferies 
 operates as
 Jefferies International Limited; registered in England: no. 1978621; and 
 Jefferies
 Bache Limited; registered in England: no. 114226; registered office for both: 
 Vintners
 Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International 
 Limited and
 Jefferies Bache Limited are authorised and regulated by the Financial Services
 Authority. If you received this transmission in error, please immediately 
 contact the
 sender and destroy the material in its entirety, whether in electronic or 
 hard copy
 format. Thank you.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Laura Lee
I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type=response)) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type=response))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura

-
Laura M. Lee
Senior Stock Assessment Scientist
North Carolina Division of Marine Fisheries
E-Mail: laura@ncdenr.gov
--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4636016.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] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Rantony
 Sent: Tuesday, July 10, 2012 3:17 AM
 To: r-help@r-project.org
 Subject: [R] Use of Sappy and Tappy for Mathematical Calculation
 
 Hi,
 
 i have a matrix like this,
 
 ABCXYZ...   .
 - --
 1220  ...   .
 2435  ...   .
 3040  ...   .
 
 Here, i need to get
Sum of each columns,
Mean of each columns,
median of each columns,
mode of each columns,
Standard deviation  of each columns,
variance of each columns,
range of each columns,
count of each columns,
max of each columns,
min of each columns
 
 Can i get output using sappy or tappy functions ? because there have
 alots
 of records.
 
 Could you please help me fast its kind of urgent !
 
 - Thanks
 Antony
 

Here is some code to get you started.  You can add in the other functions that 
you want.  You will need to figure out what you want to do if there are missing 
values.  There are built-in functions for most everything you want.  You get 
the range from the min and the max, and you need to decide what to do if a 
variable has 2 or more modes (you  will also need to determine how you are 
going to get the mode).

 
# here is sample matrix
mat - matrix(1:100,nrow=10)
colnames(mat) - LETTERS[1:10]

# define summarize function
summarize - function(m) {
  sums - apply(m, 2, sum)
  counts - apply(m, 2, length)
  means - apply(m, 2, mean)
  return(rbind(sums, counts, means))
}

# summarize your matrix
summarize(mat)


Hope this is helpful,

Dan

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


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


Re: [R] Questions about doing analysis based on time

2012-07-10 Thread Rui Barradas

Hello,

You can use cut.POSIXt from package base.

cut(dat$SunDate, breaks=30 mins)


Hope this helps,

Rui Barradas

Em 10-07-2012 13:43, APOCooter escreveu:

Thanks to everyone for their help so far.  It's been greatly appreciated.  I
have a new, but similar problem:

I have data that I have broken down by hour (median/mean for each hour).  I
would like to break it down further, by each half hour (0:00-0:29,
0:30-0:59, 1:00-1:29, 1:30-1:59, etc).  I thought cut.dates() from the chron
package would be able to do it, but I can't find anything in the chron
package documention.  I'm fairly certain that if I can figure out how to
break down the data by half hour that I can do all the other analysis just
fine (median/mean for each half hour, etc)


Here is a small sample of the data:


dput(head(SundayData, 100))

structure(list(SunDate = structure(c(1273377600, 1307851200,
1213502640, 1217736420, 1311480420, 1211688540, 1337487060, 1255839120,
1268543520, 1293945120, 1280635980, 1309061640, 1322975640, 1297574280,
1221970740, 1253420340, 1218946800, 1329024060, 1290316920, 1224994980,
1218342420, 1269750420, 1257658080, 1322371680, 1214108940, 1312086540,
1260077400, 1228023060, 1315110660, 1281241920, 1272774960, 1224995820,
1275194220, 1246768860, 1302410460, 1234071780, 1305434580, 1232257500,
1243140300, 1284871500, 1247373960, 1265521560, 1273985160, 1310273160,
1226209620, 1270356420, 1330235280, 1222577400, 1310878200, 1324187400,
1242535860, 1336279860, 1283057520, 1291528320, 1324187580, 1330840380,
1298786100, 1307854500, 1236491880, 1298786280, 1233468180, 1280034240,
1230444300, 1213506360, 1251608760, 1215320820, 1304226420, 1320556080,
1299391740, 1286687580, 1296972780, 1296972780, 1321164780, 1260684960,
1315113420, 1287292680, 1292134800, 1303017600, 1307251200, 1278825720,
1238304180, 1212902640, 1231655100, 1254029100, 1311485100, 1295159160,
1220160420, 1297578540, 1300599000, 1241933640, 1225604100, 1269149880,
1283665140, 1244958120, 1245562980, 1289716980, 1235890020, 1282456080,
1279432140, 1279432140), class = c(POSIXct, POSIXt), tzone = ),
 SunTime = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 6L, 6L,
 6L, 7L, 8L, 8L, 9L, 10L, 10L, 11L, 12L, 13L, 14L, 15L, 15L,
 16L, 16L, 17L, 17L, 18L, 19L, 19L, 20L, 21L, 22L, 22L, 23L,
 23L, 24L, 24L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 27L, 27L,
 28L, 29L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L,
 34L, 34L, 35L, 36L, 37L, 38L, 38L, 39L, 39L, 40L, 41L, 42L,
 42L, 42L, 42L, 43L, 44L, 45L, 46L, 46L, 46L, 47L, 48L, 49L,
 50L, 50L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L,
 60L, 60L, 61L, 62L, 63L, 63L), .Label = c(0:00, 0:04,
 0:07, 0:09, 0:11, 0:12, 0:13, 0:14, 0:18, 0:19,
 0:20, 0:21, 0:22, 0:23, 0:27, 0:28, 0:29, 0:30,
 0:31, 0:32, 0:36, 0:37, 0:41, 0:43, 0:45, 0:46,
 0:47, 0:48, 0:50, 0:51, 0:52, 0:53, 0:55, 0:58,
 1:03, 1:04, 1:05, 1:06, 1:07, 1:08, 1:09, 1:13,
 1:16, 1:17, 1:18, 1:20, 1:22, 1:23, 1:24, 1:25,
 1:26, 1:27, 1:29, 1:30, 1:34, 1:35, 1:38, 1:39,
 1:42, 1:43, 1:47, 1:48, 1:49, 1:52, 1:54, 1:55,
 1:56, 1:57, 1:59, 10:00, 10:04, 10:07, 10:08,
 10:09, 10:10, 10:11, 10:12, 10:14, 10:15, 10:16,
 10:18, 10:20, 10:22, 10:23, 10:24, 10:25, 10:26,
 10:27, 10:28, 10:30, 10:31, 10:32, 10:33, 10:34,
 10:35, 10:36, 10:37, 10:38, 10:39, 10:40, 10:41,
 10:43, 10:44, 10:45, 10:47, 10:48, 10:49, 10:50,
 10:51, 10:53, 10:54, 10:55, 10:56, 10:58, 10:59,
 11:01, 11:02, 11:05, 11:06, 11:07, 11:09, 11:10,
 11:12, 11:14, 11:15, 11:16, 11:20, 11:21, 11:22,
 11:23, 11:24, 11:26, 11:27, 11:29, 11:30, 11:31,
 11:33, 11:34, 11:35, 11:36, 11:37, 11:38, 11:39,
 11:40, 11:43, 11:44, 11:46, 11:47, 11:49, 11:52,
 11:56, 11:58, 11:59, 12:00, 12:01, 12:02, 12:03,
 12:04, 12:05, 12:06, 12:07, 12:08, 12:09, 12:10,
 12:11, 12:13, 12:14, 12:15, 12:17, 12:19, 12:21,
 12:22, 12:24, 12:25, 12:26, 12:27, 12:28, 12:30,
 12:31, 12:32, 12:34, 12:36, 12:37, 12:38, 12:39,
 12:41, 12:45, 12:46, 12:47, 12:48, 12:49, 12:50,
 12:51, 12:53, 12:54, 12:55, 12:56, 12:57, 12:58,
 12:59, 13:00, 13:01, 13:02, 13:03, 13:04, 13:05,
 13:06, 13:07, 13:08, 13:09, 13:10, 13:12, 13:13,
 13:14, 13:15, 13:17, 13:18, 13:19, 13:20, 13:21,
 13:23, 13:25, 13:26, 13:27, 13:30, 13:31, 13:32,
 13:34, 13:35, 13:36, 13:38, 13:39, 13:40, 13:44,
 13:45, 13:46, 13:47, 13:48, 13:49, 13:50, 13:51,
 13:52, 13:53, 13:54, 13:55, 13:57, 13:58, 13:59,
 14:00, 14:01, 14:02, 14:04, 14:05, 14:06, 14:07,
 14:08, 14:11, 14:12, 14:13, 14:14, 14:15, 14:16,
 14:17, 14:18, 14:20, 14:21, 14:22, 14:23, 14:25,
 14:26, 14:28, 14:29, 14:30, 14:31, 14:32, 14:34,
 14:35, 14:36, 14:37, 14:38, 14:40, 14:41, 14:42,
 14:43, 14:45, 14:46, 14:47, 14:49, 14:50, 14:51,
 14:52, 14:53, 14:54, 14:56, 14:57, 14:58, 14:59,
 15:01, 15:02, 15:03, 15:04, 15:05, 15:07, 15:11,
 15:12, 15:13, 15:14, 15:15, 15:17, 15:18, 15:19,
 

Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread vimmster
Dear Rui,

thank you very much.

Your solution works perfectly.

One last question:

I need to write a function, with ONE value (here: a ratio) for the correct
reactions divided per trials or trialCount, respectively, FOR EACH test
subject.

/ means divided by in the following.

I need the ratio correct (reactions)/trial or correct
(reactions)/trialCount, respectively (because trial and trialCount are the
same WITHIN test SUBJECTS; BUT they differ in length between BETWEEN test
SUBJECTS!).

It would be very helpful, if I had a data frame in the end in R, with one
column for
trialCount/trial, one column for correct reactions(= 1) AND (more
importantly) one column for correct (= 1) answers / trialCount.

legend (just as additional information) for the variable correct:
1 = correct reaction
2 = false reaction
3 = reaction too slow
4 = reaction too fast
5 = more than one button pressed
6 = no reaction within RT window

I would be very thankful for an answer!

Sorry for the questions, but I am doing this for the first time!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636020.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] calculating the difference between days?

2012-07-10 Thread C W
Hi List,

I have one column of beginning dates and one column of ending dates, I want
to find their difference.  And I want to ignore the trailing zeros,
basically everything after the first colon mark.

Begin_date   End_date
01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
01JAN2000:00:00:00:000   02FEB2000:00:00:00:000

Thanks,

Mike

[[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 to winbugs interface

2012-07-10 Thread Uwe Ligges



On 09.07.2012 19:27, PRAGYA SUR wrote:

Yes that was the problem. Thank you very much. Can anyone tell me the
meaning of
The following object(s) are masked _by_ '.GlobalEnv':

 beta



It means you have two instances of beta, one in your workspace 
('.GlobalEnv') and one that is probably in some data.frame that was 
attached to the search path.


Best,
Uwe Ligges



i was shown this notification after the results were printed.

On Mon, Jul 9, 2012 at 1:15 PM, Uwe Ligges
lig...@statistik.tu-dortmund.de
mailto:lig...@statistik.tu-dortmund.de wrote:



On 09.07.2012 18:19, PRAGYA SUR wrote:

I ran the same program in a different computer where it had run
proper a
week ago. This time around in the log file in WinBUGS the
program stopped
at a line which said :
save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__odc)
save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__txt)
and did not proceed any further.
Can anyone tell me what migh tbe the possible error here?


Although unstated, I guess it was finished and did not close because
you used bugs(., debug=TRUE)?

Uwe Ligges


On Mon, Jul 9, 2012 at 7:04 AM, S Ellison
s.elli...@lgcgroup.com mailto:s.elli...@lgcgroup.com wrote:



-Original Message-
Error in file(con, wb) : cannot open the connection In
addition: Warning messages:
1: In file.create(to[okay]) :
cannot create file 'c:/Program
Files/WinBUGS14//System/Rsrc/__Registry_Rsave.odc', reason
'Permission denied'


This tells you that you do not have operating system
permission to create
a file in the program files area referred to.

2: In file(con, wb) :
cannot open file 'c:/Program
Files/WinBUGS14//System/Rsrc/__Registry.odc':
Permission denied


.. and this tells you you don't have permission to open a
file for writing
(mode 'w' in the same location

Conclusion; you're trying to write to an area you don;t have
permission to
write to.

Either change the permissions for that area (insecure) or
use a different
file location for temporary files.


**__**__***
This email and any attachments are confidential. Any
u...{{dropped:11}}



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





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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Highland Statistics Ltd
*Laura Lee* laura.lee at ncdenr.gov 
mailto:r-help%40r-project.org?Subject=Re%3A%20%5BR%5D%20Predicted%20values%20for%20zero-inflated%20PoissonIn-Reply-To=%3C1341937636301-4636016.post%40n4.nabble.com%3E
/Tue Jul 10 18:27:16 CEST 2012/



I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type=response)) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type=response))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura




Laura
Why do you use the sum? If you use:

PredY - predict(ZIP, type = response) then you have predicted values for 
each of the rows in your effort data frame.
Job done.

You have an offset in your model, isn't it? You will need to choose values for 
this in the data frame effort as well.
Also double check that the offset is only in the count partat least that is 
what I would do.
Note that using an offset means that you assume that if sampling effort is 
doubled, your fish (?) numbers double.




If you fully want to understand what predict is doing, try to do it manually. 
Below is R code from Chapter 7 (Zero Inflation and GLMM with R)






M3 - zeroinfl(ParrotFish ~ Depth + Slope + SQDistRck + DistSed + Swell + Chla 
+ SST,
dist = poisson, link = logit,
data = PF2)

Betas.logistic - coef(M3, model = zero)
X.logistic - model.matrix(M3, model = zero)
eta.logistic   - X.logistic %*% Betas.logistic
p  - exp(eta.logistic) / (1 + exp(eta.logistic))

Betas.log  - coef(M3, model = count)
X.log  - model.matrix(M3, model = count)
eta.log- X.log %*% Betas.log
mu - exp(eta.log)

ExpY   -  mu * (1 - p)
VarY   - (1 - p) * (mu + p * mu^2)



Instead of using model.matrix(M3), you could specify your own data frame with 
covariates.
Your effort. Something like:

M4 - zeroinfl(ParrotFish ~ Depth + Slope   | SST,
dist = poisson, link = logit,
data = PF2)

betapois - coef(M4, model = count)
betaBin  - coef(M4, model = zero)

MyDataPois - data.frame(Depth = blah blah,
  Slope = Blah blah)
MyDataBin  - data.frame(SST =  blah)

Xpois - model.matrix(~ blah blah, data = MyDataPois)
Xbin  - model.matrix(~ blah blah, data = MyDataBin)

eta.Pois - Xpois %*% betapois
eta.Bin - blah blah

mu = blah blah
pi = blah blah

ExpY = ...


Doing it like this means you fully understand it..:-)
   

Alain




-- 

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.com
URL: www.highstat.com
URL: www.brodgar.com


[[alternative HTML version deleted]]

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


Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread Rui Barradas

Hello,

I'm glad it help.

As for this second question, you should explain yourself better.

1. What is a test subject, which column records its id? vpNum?
2. You say divided per trials or trialCount. Does this mean per trial 
number (example: divide by 1, by 2, by 3, etc, by 149) or per number of 
trials (149 in the previous example)
3. 'correct' now seems to be categorical. Divide WHAT by trial or 
trialCount?


Hint: post a small data example with three or four subjects and the 
wanted output.


Rui Barradas

Em 10-07-2012 18:06, vimmster escreveu:

Dear Rui,

thank you very much.

Your solution works perfectly.

One last question:

I need to write a function, with ONE value (here: a ratio) for the correct
reactions divided per trials or trialCount, respectively, FOR EACH test
subject.

/ means divided by in the following.

I need the ratio correct (reactions)/trial or correct
(reactions)/trialCount, respectively (because trial and trialCount are the
same WITHIN test SUBJECTS; BUT they differ in length between BETWEEN test
SUBJECTS!).

It would be very helpful, if I had a data frame in the end in R, with one
column for
trialCount/trial, one column for correct reactions(= 1) AND (more
importantly) one column for correct (= 1) answers / trialCount.

legend (just as additional information) for the variable correct:
1 = correct reaction
2 = false reaction
3 = reaction too slow
4 = reaction too fast
5 = more than one button pressed
6 = no reaction within RT window

I would be very thankful for an answer!

Sorry for the questions, but I am doing this for the first time!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636020.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] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Peter Ehlers

On 2012-07-10 08:50, Brian Diggs wrote:

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty - function(x){
 if(NROW(x) == 0){
 y - rep(NA, NCOL(x))
 names(y) - names(x)
 y
 }else x
}

(.xb - iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

(.xb - iris[ iris$Species=='zz', ])
.xb - .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better


Yes, you can subset with NA or any real number greater than 1.

Peter Ehlers



empty - function(x) {
if(NROW(x) == 0) {
  x[NA,]
} else {
  x
}
}

It even preserves the factor nature of things:

   empty(iris[iris$Specis=='zz',])
 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NANA
   str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
   $ Sepal.Length: num NA
   $ Sepal.Width : num NA
   $ Petal.Length: num NA
   $ Petal.Width : num NA
   $ Species : Factor w/ 3 levels setosa,versicolor,..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb - iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))

 X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) - names(.xb)
(.xb - .xa)

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Rui Barradas

Hello,

Em 10-07-2012 18:59, Peter Ehlers escreveu:

On 2012-07-10 08:50, Brian Diggs wrote:

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty - function(x){
 if(NROW(x) == 0){
 y - rep(NA, NCOL(x))
 names(y) - names(x)
 y
 }else x
}

(.xb - iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

(.xb - iris[ iris$Species=='zz', ])
.xb - .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better


Yes, you can subset with NA or any real number greater than 1.

Peter Ehlers



Good to know,  was completely unaware of this indexing possibility.

Rui Barradas



empty - function(x) {
if(NROW(x) == 0) {
  x[NA,]
} else {
  x
}
}

It even preserves the factor nature of things:

   empty(iris[iris$Specis=='zz',])
 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NANA
   str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
   $ Sepal.Length: num NA
   $ Sepal.Width : num NA
   $ Petal.Length: num NA
   $ Petal.Width : num NA
   $ Species : Factor w/ 3 levels setosa,versicolor,..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb - iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
0 rows (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa - data.frame(matrix(rep(NA, ncol(.xb)), 1)))

 X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) - names(.xb)
(.xb - .xa)

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




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








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


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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Laura Lee
Alain-

Thanks again for your reply. Yes, the offset for effort is only in the count 
part of the model. Sorry I wasn't clear about why I was using 'sum'...my effort 
data set contains records of trips with the effort given for each trip. I 
thought using sum would get me the total number of turtles predicted for the 
new effort data. I did also log-transform the effort in the new effort data 
before applying predict (correct?). I will try the manual method as you 
recommended to help me understand the code.

Thanks,

Laura

From: Alain Zuur [via R] [mailto:ml-node+s789695n4636025...@n4.nabble.com]
Sent: Tuesday, July 10, 2012 1:52 PM
To: Lee, Laura
Subject: Re: Predicted values for zero-inflated Poisson

*Laura Lee* laura.lee at ncdenr.gov
mailto:r-help%40r-project.org?Subject=Re%3A%20%5BR%5D%20Predicted%20values%20for%20zero-inflated%20PoissonIn-Reply-To=%3C1341937636301-4636016.post%40n4.nabble.com%3E
/Tue Jul 10 18:27:16 CEST 2012/



I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type=response)) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type=response))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura




Laura
Why do you use the sum? If you use:

PredY - predict(ZIP, type = response) then you have predicted values for 
each of the rows in your effort data frame.
Job done.

You have an offset in your model, isn't it? You will need to choose values for 
this in the data frame effort as well.
Also double check that the offset is only in the count partat least that is 
what I would do.
Note that using an offset means that you assume that if sampling effort is 
doubled, your fish (?) numbers double.




If you fully want to understand what predict is doing, try to do it manually. 
Below is R code from Chapter 7 (Zero Inflation and GLMM with R)






M3 - zeroinfl(ParrotFish ~ Depth + Slope + SQDistRck + DistSed + Swell + Chla 
+ SST,
dist = poisson, link = logit,
data = PF2)

Betas.logistic - coef(M3, model = zero)
X.logistic - model.matrix(M3, model = zero)
eta.logistic   - X.logistic %*% Betas.logistic
p  - exp(eta.logistic) / (1 + exp(eta.logistic))

Betas.log  - coef(M3, model = count)
X.log  - model.matrix(M3, model = count)
eta.log- X.log %*% Betas.log
mu - exp(eta.log)

ExpY   -  mu * (1 - p)
VarY   - (1 - p) * (mu + p * mu^2)



Instead of using model.matrix(M3), you could specify your own data frame with 
covariates.
Your effort. Something like:

M4 - zeroinfl(ParrotFish ~ Depth + Slope   | SST,
dist = poisson, link = logit,
data = PF2)

betapois - coef(M4, model = count)
betaBin  - coef(M4, model = zero)

MyDataPois - data.frame(Depth = blah blah,
  Slope = Blah blah)
MyDataBin  - data.frame(SST =  blah)

Xpois - model.matrix(~ blah blah, data = MyDataPois)
Xbin  - model.matrix(~ blah blah, data = MyDataBin)

eta.Pois - Xpois %*% betapois
eta.Bin - blah blah

mu = blah blah
pi = blah blah

ExpY = ...


Doing it like this means you fully understand it..:-)


Alain




--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7http://www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: [hidden email]/user/SendEmail.jtp?type=nodenode=4636025i=0
URL: www.highstat.comhttp://www.highstat.com
URL: www.brodgar.comhttp://www.brodgar.com


[[alternative HTML version deleted]]

__
[hidden email]/user/SendEmail.jtp?type=nodenode=4636025i=1 mailing list
https://stat.ethz.ch/mailman/listinfo/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. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: 

Re: [R] Specify model with polynomial interaction terms up to degree n

2012-07-10 Thread YTP
Yep, that code is verbatim what I typed in, using version 2.14 ... seems
weird. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Specify-model-with-polynomial-interaction-terms-up-to-degree-n-tp4635130p4636031.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] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread arun
Hi,

 dat1-data.frame(ABC=c(12,24,30),XYZ=c(20,35,40))
 dat2-as.matrix(dat1)
 #mean
 dat2mean-apply(dat2,2,mean)
 dat2mean
  #   ABC  XYZ 
#22.0 31.7 
dat2sum-apply(dat2,2,sum)
 dat2median-apply(dat2,2,median)
 dat2max-apply(dat2,2,max)
dat2min-apply(dat2,2,min)

 dat2range-apply(dat2,2,range)

dat2count-apply(dat2,2,length)
dat2sd-apply(dat2,2,sd)
dat2var-apply(dat2,2,var)

A.K.



- Original Message -
From: Rantony antony.akk...@ge.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 6:16 AM
Subject: [R] Use of Sappy and Tappy for Mathematical Calculation

Hi,

i have a matrix like this,

ABC        XYZ    ..    .   .
-         --
12            20      ..    .   .
24            35      ..    .   .
30            40      ..    .   .

Here, i need to get 
                           Sum of each columns,
                           Mean of each columns, 
                           median of each columns,
                           mode of each columns, 
                           Standard deviation  of each columns, 
                           variance of each columns, 
                           range of each columns,
                           count of each columns,
                           max of each columns, 
                           min of each columns

Can i get output using sappy or tappy functions ? because there have alots
of records.

Could you please help me fast its kind of urgent !

- Thanks 
Antony 

--
View this message in context: 
http://r.789695.n4.nabble.com/Use-of-Sappy-and-Tappy-for-Mathematical-Calculation-tp4635969.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] HELP me please with import of csv to R

2012-07-10 Thread F86
Hey, 

I am having problems with importing a csv file to R. 

I could read the file by typing:   
read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)

However, i can not analyze the skatter - for ex, when i type: skatter
= read.csv(skatter.csv)

i get this message: 

Error in file(file, rt) : cannot open the connection
In addition: Warning message:
In file(file, rt) :

What i need is to import this file and analyze it using for example
histogram. 

I have Mac(update) and the file is saved in csv file... and I'm quite new
user of R. 



Thank you very much! 




--
View this message in context: 
http://r.789695.n4.nabble.com/HELP-me-please-with-import-of-csv-to-R-tp4636019.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] problem for installing rgdal

2012-07-10 Thread stanislas rebaudet
Hello,

I run [R] 2.14 on Mac OS 10.6 and I've been desperately trying to install rpy2 
in order to compute spatial statistics on QGIS 1.7.3.
rpy2 is dependent upon the rgdal [R]package that I've been unable to install in 
spite of up to date versions of GDAL and PROJ.
More precisely, [R] console writes Error: gdal-config not found. As a matter 
of fact, typing gdal.config on a Terminal shell doesn't work either...

Yet, the file is actually present in 
/Library/Frameworks/GDAL.framework/Versions/1.9/Programs
I then tryed to follow suggestions with:  
--configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.9/Programs/gdal-config'
I received no such file or directory

I also found this option described here 
(http://www.r-bloggers.com/installing-rgdal-on-mac-os-x-2/), but couldn't get 
through it...

As anyone an idea? 
Thanks for your help

stan

[[alternative HTML version deleted]]

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


[R] R code help to change table format

2012-07-10 Thread peziza
I am trying to input an OTU table into EstimateS, however, the format of the
OTU table has to be changed to fit the format EstimateS will accept. In R, I
would like to change the format of the OTU table (from excel).  Here is what
I need to do, take Example 1 and create Example 2.  The problem is that I
have hundreds of OTUs, so I can't do this by hand (and I'd love to have a
code that I could use for different OTU tables). 
Thanks!

Example 1 Example 2
Species Abundance Species
1 3   1
2 2   1
3 2   1
4 2   2
5 4   2

3 

3

4

4

5 
5

5

5

5


--
View this message in context: 
http://r.789695.n4.nabble.com/R-code-help-to-change-table-format-tp4636022.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] Skipping lines and incomplete rows

2012-07-10 Thread arun
Hello Ravi,

I was not aware that your dataset have special character # before NA.  If it 
was just plain NA, it would have worked.  So, It's not because of sep= ;.

See below:

#Without #
dat1-read.table(text=
 Remove this line
 Remove this line
 Remove this line
 Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
  ;[m/s];[°];°C;[hPa];[MWh];[MWh]
 1/1/2012;0.0;0;NA;NA;0.;0.
 1/2/2012;0.0;0;NA;NA;0.;0.
 1/3/2012;0.0;0;NA;NA;1.5651;2.2112
 1/4/2012;0.0;0;NA;NA;1.;2.
 1/5/2012;0.0;0;NA;NA;3.2578;7.5455
 ,sep=;,header=TRUE,fill=TRUE,skip=4,stringsAsFactors=FALSE)
 dat1
  Time Actual.Speed Actual.Direction Temp Press Value1 Value2
1 [m/s]  [°]   °C [hPa]  [MWh]  [MWh]
2 1/1/2012  0.0    0 NA  NA 0. 0.
3 1/2/2012  0.0    0 NA  NA 0. 0.
4 1/3/2012  0.0    0 NA  NA 1.5651 2.2112
5 1/4/2012  0.0    0 NA  NA 1. 2.
6 1/5/2012  0.0    0 NA  NA 3.2578 7.5455


#With #: Reading data from the .txt file.  

# In the documentation 
(http://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html), 
comment.char=# is an option in the read.table, but unfortunately it shows 
only blank columns after the first three columns.  


#I think Rui's method of reading header separately using readLines might be a 
good option.  Or if you know the columnheadings, then you can do this:

dat2-read.table(dat2.txt,skip=4,col.names=c(Time,Actual Speed,Actual 
Direction, 
Temp,Press,Value1,Value2),fill=TRUE,sep=;,comment.char=c)
 dat2
  Time Actual.Speed Actual.Direction Temp Press Value1 Value2
1 [m/s]  [°]   °C [hPa]  [MWh]  [MWh]
2 1/1/2012  0.0    0  #NA   #NA 0. 0.
3 1/2/2012  0.0    0  #NA   #NA 0. 0.
4 1/3/2012  0.0    0  #NA   #NA 1.5651 2.2112
5 1/4/2012  0.0    0  #NA   #NA 1. 2.
6 1/5/2012  0.0    0  #NA   #NA 3.2578 7.5455


A.K.










- Original Message -
From: vioravis viora...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 1:41 AM
Subject: Re: [R] Skipping lines and incomplete rows

Thanks a lot Rui and Arun.

The methods work fine with the data I gave but when I tried the two methods
with the following semi-colon separated data using sep = ;. Only the first
3 columnns are read properly rest of the columns are either empty or NAs.


**
Remove this line
Remove this line
Remove this line
Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
;[m/s];[°];°C;[hPa];[MWh];[MWh]
1/1/2012;0.0;0;#N/A;#N/A;0.;0.
1/2/2012;0.0;0;#N/A;#N/A;0.;0.
1/3/2012;0.0;0;#N/A;#N/A;1.5651;2.2112
1/4/2012;0.0;0;#N/A;#N/A;1.;2.
1/5/2012;0.0;0;#N/A;#N/A;3.2578;7.5455
***

I used the following code:
dat1-read.table(testInput.txt,sep=;,skip=3,fill=TRUE,header=TRUE) 
dat1-dat1[-1,] 
row.names(dat1)-1:nrow(dat1)

Could you please let me know what is wrong with this approach? 

Thank you.

Ravi

--
View this message in context: 
http://r.789695.n4.nabble.com/Skipping-lines-and-incomplete-rows-tp4635830p4635952.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] calculating the difference between days?

2012-07-10 Thread arun
Hi,

Try this:

dat3-read.table(text=
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
,sep=,header=TRUE)

dat3$Begin_date-strptime(dat3[,1],format=%d%b%Y:%H:%M:%S)
dat3$End_date-strptime(dat3[,2],format=%d%b%Y:%H:%M:%S)

 difftime(dat3[,1],dat3[,2])
Time differences in days
[1] -763.  -55. -124.0417  -32.  -32.
attr(,tzone)
[1] 

A.K.

- Original Message -
From: C W tmrs...@gmail.com
To: r-help r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 1:22 PM
Subject: [R] calculating the difference between days?

Hi List,

I have one column of beginning dates and one column of ending dates, I want
to find their difference.  And I want to ignore the trailing zeros,
basically everything after the first colon mark.

Begin_date                           End_date
01JAN2000:00:00:00:000       02FEB2002:00:00:00:000
24MAR2012:00:00:00:000       18MAY2012:00:00:00:000
01OCT2003:00:00:00:000       02FEB2004:00:00:00:000
01JAN2000:00:00:00:000       02FEB2000:00:00:00:000
01JAN2000:00:00:00:000       02FEB2000:00:00:00:000

Thanks,

Mike

    [[alternative HTML version deleted]]

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


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


[R] Times Series Data using GLS

2012-07-10 Thread MRB305
I am trying to use regression to determine the interaction between a couple
of variables while correcting for autocorrelation. Thus far, I have created
the code:
model - gls(yvar~xvar1*xvar2, correlation = corARMA (p=2), method = ML,
data = data)

I'm having a difficult time understanding the different correlation
structure classes and when to use the correct ones. Also, with regards to
method, I am not sure if REML or ML is the correct option.

Thanks to anyone who can give me help with this. I really appreciate it.

--
View this message in context: 
http://r.789695.n4.nabble.com/Times-Series-Data-using-GLS-tp4636026.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] Changing x-axis values displayed on histogram

2012-07-10 Thread jlwoodard
Is it possible to change the x-axis values in a histogram to reflect binned
values?

Here are my data:

histexample-c(6,7,7,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,13,13,13,14,14,14,15,16)
hist(histexample)

Now, I'll bin pairs of adjacent values together (e.g., 5-6, 7-8, 9-10,
11-12, 13-14, 15-16) using the following

bins-c(4.5,6.5,8.5,10.5,12.5,14.5,16.5)
hist(histexample,breaks=bins)

The displayed x-axis values are 6, 8, 10, 12, 14, and 16.  I'd like the
x-axis values to reflect the values in each bin (e.g., 5-6, 7-8, 9-10,
11-12, 13-14, 15-16).  Any suggestions would be greatly appreciated!  Many
thanks in advance.

John 

--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-x-axis-values-displayed-on-histogram-tp4636032.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] Need HELP: how find and use a csv file?

2012-07-10 Thread Faradj Koliev
Hey, 

I am having some problems with importing a csv file into R and then saving it 
for analyzing. 

I got a csv file ( skater.csv) which i could read by typing:
read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;) 

However, when i enter:skatter.csv-read.csv(skatter.csv, header=TRUE) i 
get this message: 
Error in file(file, rt) : cannot open the connection 
In addition: Warning message: 
In file(file, rt) : 
I have tried with:   skatter.csv-file.choose() and other codes to find the 
file but it does not work. 
Please help me fix this problem, i have been sitting with this one in 4 hours.. 



What i need is to import this file and analyze it using for example histogram. 

I have Mac(update) and the file is saved in csv file... and I'm quite new user 
of R. 



Thank you very much! 
[[alternative HTML version deleted]]

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


Re: [R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-10 Thread Rune Haubo
Hi Jeremy,

I think Jessica is right that probably you could make polr converge
and produce a Hessian if the data are better scaled, but there might
also be other things not allowing you to get the Hessian/vcov. Could
be insightful if you showed us the result of
str(Jdata)

Also, I am thinking that perhaps the another implementation of ordinal
regression models might avoid the problem. You could try the ordinal
package (of which I am the author) -- the following should reproduce
the MASS::polr results:

install.packages(ordinal)
library(ordinal)
Global - clm(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist +
Stream_dist, data=Jdata)
summary(Global)

Another option would be Frank Harrell's lrm function in the rms package.

HTH,
Rune

On 9 July 2012 11:55, Jeremy Little jeremy.lit...@my.jcu.edu.au wrote:
 Hello,

 I am trying to run an ordinal logistic regression (polr) using the package
 'MASS'.

 I have successfully run other regression classes (glm, multinom) without
 much problem, but with the 'polr' class I get the following error:
  Error in svd(X) : infinite or missing values in 'x' 
 which appears when I run the summary command.

 The data file is large (585000 rows) and has no NA, - or blank values.

 My script (in brief) is as follows, with results:

 
 library(MASS)

 ## ADD DATA
 Jdata- read.delim(/Analysis/20120709 JLittle data file.txt, header=T)

 attach(Jdata)
 names(Jdata)
  [1] POINTID Lat_Y_pos   JVeg5   Subregion   Rock_U_Nam
 Rock_Name   Elevation   Slope   Aspect  Hillshade
 Stream_dist Coast_dist  Coast_SE
 [14] Coast_E Wind_310TPI Landform

 Global - polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
 data=Jdata)

 summary(Global)
 Error in svd(X) : infinite or missing values in 'x'

 ##Try with omit NA command
 Global - polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
 data=Jdata, na.action = na.omit, Hess = TRUE)

 summary(Global)
 Error in svd(X) : infinite or missing values in 'x'
 

 Does this imply an 'infinite value' and what would this mean?

 If anyone has any idea how to address this error, I would very much
 appreciate your response.

 Thank you in advance.

 Jeremy

 Date File Attachment (200 rows):
 http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt
 20120709_JLittle_data_file.txt


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.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.



-- 
Rune Haubo Bojesen Christensen

Ph.D. Student, M.Sc. Eng.
Phone: (+45) 45 25 33 63
Mobile: (+45) 30 26 45 54

DTU Informatics, Section for Statistics
Technical University of Denmark, Build. 305, Room 122,
DK-2800 Kgs. Lyngby, Denmark

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread Sarah Goslee
Hi,

On Tue, Jul 10, 2012 at 12:48 PM, F86 farad...@gmail.com wrote:
 Hey,

 I am having problems with importing a csv file to R.

 I could read the file by typing:
 read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)

So that command does work?


 However, i can not analyze the skatter - for ex, when i type: skatter
 = read.csv(skatter.csv)

Then you need the above command, not what you type here:

skatter - read.csv(file=/Users/kama/Desktop/skatter.csv,
header=TRUE, sep=;)

But note that if sep=; then you don't have a csv file and should
properly use read.table() instead.

 i get this message:

 Error in file(file, rt) : cannot open the connection
 In addition: Warning message:
 In file(file, rt) :

 What i need is to import this file and analyze it using for example
 histogram.

 I have Mac(update) and the file is saved in csv file... and I'm quite new
 user of R.

That error means that R can't find the file where you told it to look.
Specifying the full and complete path as in your first example should
work.

If you're having problems with paths (which are a Mac issue and not at
all an R issue), you could also try

read.table(file.choose(), header=TRUE, sep=;)

I think that file.choose() should work on Mac.

The Intro to R document that came with R might also be of use.

Sarah

-- 
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] Understanding cenros Error

2012-07-10 Thread Rich Shepard

  Before reading water chemistry into a data frame I removed all missing
data. Yet when I try to run cenros() to summarize a specific chemical I get
an error that I do not understand:

with( subset(chem, param=='Ag'),  cenros(quant,ceneq1) )
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  NA/NaN/Inf in 'y'

  I would like to learn what I did incorrectly so I can avoid these errors
in the future.

  The data frame structure is

str(chem)
'data.frame':   120309 obs. of  8 variables:
 $ site: Factor w/ 65 levels ;Influent,D-1,..: 2 2 2 2 2 2 ...
 $ sampdate: Date, format: 2007-12-12 2007-12-12 ...
 $ preeq0  : logi  TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ param   : Factor w/ 37 levels Ag,Al,Alk_tot,..: 1 2 8 17 3 9 ...
 $ quant   : num  0 0.106 1 231 231 0.011 0 0.002 0 100 ...
 $ ceneq1  : logi  FALSE FALSE TRUE FALSE FALSE FALSE ...
 $ floor   : num  0 0.106 0 231 231 0.011 0 0 0 100 ...
 $ ceiling : Factor w/ 3909 levels 0.000,0.000),..: 1 116 841 1771 ...

  I ran dput() on the data frame but cannot make sense of the output (a 5.5M
ASCII text file).

  Pointers appreciated.

Rich

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


Re: [R] calculating the difference between days?

2012-07-10 Thread C W
When the days and time are identical, difftime() gives difference in secs.
 I still want difference in days.

Say, below my last row is identical
dat3-read.table(text=
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
,sep=,header=TRUE)

-M

On Tue, Jul 10, 2012 at 1:52 PM, arun smartpink...@yahoo.com wrote:

 Hi,

 Try this:

 dat3-read.table(text=
 Begin_date  End_date
 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 ,sep=,header=TRUE)

 dat3$Begin_date-strptime(dat3[,1],format=%d%b%Y:%H:%M:%S)
 dat3$End_date-strptime(dat3[,2],format=%d%b%Y:%H:%M:%S)

  difftime(dat3[,1],dat3[,2])
 Time differences in days
 [1] -763.  -55. -124.0417  -32.  -32.
 attr(,tzone)
 [1] 

 A.K.

 - Original Message -
 From: C W tmrs...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, July 10, 2012 1:22 PM
 Subject: [R] calculating the difference between days?

 Hi List,

 I have one column of beginning dates and one column of ending dates, I want
 to find their difference.  And I want to ignore the trailing zeros,
 basically everything after the first colon mark.

 Begin_date   End_date
 01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000

 Thanks,

 Mike

 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R] Need HELP: how find and use a csv file?

2012-07-10 Thread Sarah Goslee
You don't actually have to post more than once. Really.

skatter - read.table(file.choose(), header=TRUE, sep=;)

or

skatter - read.table(/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)

or whatever the actual path to the file is.

As a new user of R, you should read the Introduction to R that came
with R, and also the R-help posting guide. Both are full of useful
information.

Sarah

On Tue, Jul 10, 2012 at 2:11 PM, Faradj Koliev farad...@gmail.com wrote:
 Hey,

 I am having some problems with importing a csv file into R and then saving it 
 for analyzing.

 I got a csv file ( skater.csv) which i could read by typing:
 read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)

 However, when i enter:skatter.csv-read.csv(skatter.csv, header=TRUE) i 
 get this message:
 Error in file(file, rt) : cannot open the connection
 In addition: Warning message:
 In file(file, rt) :
 I have tried with:   skatter.csv-file.choose() and other codes to find the 
 file but it does not work.
 Please help me fix this problem, i have been sitting with this one in 4 
 hours..



 What i need is to import this file and analyze it using for example histogram.

 I have Mac(update) and the file is saved in csv file... and I'm quite new 
 user of R.


-- 
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] Need HELP: how find and use a csv file?

2012-07-10 Thread Rich Shepard

On Tue, 10 Jul 2012, Faradj Koliev wrote:


I got a csv file ( skater.csv) which i could read by typing:
read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)


  Try:

skatter - read.csv('/Users/kama/Desktop/skatter.csv', header = T, sep =
';')

Rich

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


Re: [R] calculating the difference between days?

2012-07-10 Thread C W
Actually, when specifying unit=days inside difftime() will do.
-M

On Tue, Jul 10, 2012 at 3:55 PM, C W tmrs...@gmail.com wrote:

 When the days and time are identical, difftime() gives difference in secs.
  I still want difference in days.

 Say, below my last row is identical
 dat3-read.table(text=
 Begin_date  End_date
 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
 ,sep=,header=TRUE)

 -M

 On Tue, Jul 10, 2012 at 1:52 PM, arun smartpink...@yahoo.com wrote:

 Hi,

 Try this:

 dat3-read.table(text=
 Begin_date  End_date
 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 ,sep=,header=TRUE)

 dat3$Begin_date-strptime(dat3[,1],format=%d%b%Y:%H:%M:%S)
 dat3$End_date-strptime(dat3[,2],format=%d%b%Y:%H:%M:%S)

  difftime(dat3[,1],dat3[,2])
 Time differences in days
 [1] -763.  -55. -124.0417  -32.  -32.
 attr(,tzone)
 [1] 

 A.K.

 - Original Message -
 From: C W tmrs...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, July 10, 2012 1:22 PM
 Subject: [R] calculating the difference between days?

 Hi List,

 I have one column of beginning dates and one column of ending dates, I
 want
 to find their difference.  And I want to ignore the trailing zeros,
 basically everything after the first colon mark.

 Begin_date   End_date
 01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000

 Thanks,

 Mike

 [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] Changing x-axis values displayed on histogram

2012-07-10 Thread Sarah Goslee
Hi,

Thanks for providing a small reproducible example.

You can disable the default axis and make your own custom version:

hist(histexample,breaks=bins, xaxt=n)
axis(1, at=seq(5.5, 15.5, by=2), labels=c(5-6, 7-8, 9-10,
11-12, 13-14, 15-16))

Sarah

On Tue, Jul 10, 2012 at 3:34 PM, jlwoodard john.wood...@wayne.edu wrote:
 Is it possible to change the x-axis values in a histogram to reflect binned
 values?

 Here are my data:

 histexample-c(6,7,7,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,13,13,13,14,14,14,15,16)
 hist(histexample)

 Now, I'll bin pairs of adjacent values together (e.g., 5-6, 7-8, 9-10,
 11-12, 13-14, 15-16) using the following

 bins-c(4.5,6.5,8.5,10.5,12.5,14.5,16.5)
 hist(histexample,breaks=bins)

 The displayed x-axis values are 6, 8, 10, 12, 14, and 16.  I'd like the
 x-axis values to reflect the values in each bin (e.g., 5-6, 7-8, 9-10,
 11-12, 13-14, 15-16).  Any suggestions would be greatly appreciated!  Many
 thanks in advance.

 John



-- 
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] Specify model with polynomial interaction terms up to degree n

2012-07-10 Thread William Dunlap
a) Please supply some context in your mail message.  Not everyone reads R-help 
via nabble.

b) poly(raw=TRUE, x, degree=degree) was changed for 2.15.0 to allow it to output
a non-full-rank matrix.  See the NEWS file in 2.15.0 or after:
   # in R-2.15.1
   n - news()
   n[grepl(poly, n$Text),]
  Changes in version 2.15.0:  
  
  NEW FEATURES
  
  o   poly(raw = TRUE) no longer requires more unique points than the
  degree.  (Requested by John Fox.)
  ...

c) Error messages include the innermost R function call before the error.  To 
see more call traceback(),
which will show the call stack from the innermost call back to the call you 
made:

   # in R-2.14.1
   m - matrix(1:6, ncol=2)
   poly(m, degree=6, raw=TRUE)
  Error in poly(dots[[1L]], degree, raw = raw) :
'degree' must be less than number of unique points
   traceback()
  6: stop('degree' must be less than number of unique points)
  5: poly(dots[[1L]], degree, raw = raw)
  4: cbind(1, poly(dots[[1L]], degree, raw = raw))
  3: polym(V1 = 1:3, V2 = 4:6, degree = 6, raw = TRUE)
  2: do.call(polym, c(m, degree = degree, raw = raw))
  1: poly(m, degree = 6, raw = TRUE)

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 YTP
 Sent: Tuesday, July 10, 2012 11:23 AM
 To: r-help@r-project.org
 Subject: Re: [R] Specify model with polynomial interaction terms up to degree 
 n
 
 Yep, that code is verbatim what I typed in, using version 2.14 ... seems
 weird.
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Specify-model-with-
 polynomial-interaction-terms-up-to-degree-n-tp4635130p4636031.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] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread R. Michael Weylandt michael.weyla...@gmail.com


On Jul 10, 2012, at 11:30 AM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov 
wrote:

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Rantony
 Sent: Tuesday, July 10, 2012 3:17 AM
 To: r-help@r-project.org
 Subject: [R] Use of Sappy and Tappy for Mathematical Calculation
 
 Hi,
 
 i have a matrix like this,
 
 ABCXYZ...   .
 - --
 1220  ...   .
 2435  ...   .
 3040  ...   .
 
 Here, i need to get
   Sum of each columns,
   Mean of each columns,
   median of each columns,
   mode of each columns,
   Standard deviation  of each columns,
   variance of each columns,
   range of each columns,
   count of each columns,
   max of each columns,
   min of each columns
 
 Can i get output using sappy or tappy functions ? because there have
 alots
 of records.

I like Dan's solution a lot and it teaches inportant idioms, but I might 
suggest that you use the col***() functions from the MatrixStats package if 
speed/data-size is of issue. 

Best,
Michael


 
 Could you please help me fast its kind of urgent !
 
 - Thanks
 Antony
 
 
 Here is some code to get you started.  You can add in the other functions 
 that you want.  You will need to figure out what you want to do if there are 
 missing values.  There are built-in functions for most everything you want.  
 You get the range from the min and the max, and you need to decide what to do 
 if a variable has 2 or more modes (you  will also need to determine how you 
 are going to get the mode).
 
 
 # here is sample matrix
 mat - matrix(1:100,nrow=10)
 colnames(mat) - LETTERS[1:10]
 
 # define summarize function
 summarize - function(m) {
  sums - apply(m, 2, sum)
  counts - apply(m, 2, length)
  means - apply(m, 2, mean)
  return(rbind(sums, counts, means))
 }
 
 # summarize your matrix
 summarize(mat)
 
 
 Hope this is helpful,
 
 Dan
 
 Daniel J. Nordlund
 Washington State Department of Social and Health Services
 Planning, Performance, and Accountability
 Research and Data Analysis Division
 Olympia, WA 98504-5204
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] calculating the difference between days?

2012-07-10 Thread Jorge I Velez
What's wrong with manipulating the results arun got?

dat3-read.table(text=
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
,sep=,header=TRUE)

dat3$Begin_date-strptime(dat3[,1],format=%d%b%Y:%H:%M:%S)
dat3$End_date-strptime(dat3[,2],format=%d%b%Y:%H:%M:%S)

# difference in days
result - difftime(dat3[,1],dat3[,2])

# difference in seconds
ddays - as.numeric(result/(24*3600))
ddays

HTH,
Jorge.-


On Tue, Jul 10, 2012 at 3:55 PM, C W  wrote:

 When the days and time are identical, difftime() gives difference in secs.
  I still want difference in days.

 Say, below my last row is identical
 dat3-read.table(text=
 Begin_date  End_date
 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
 24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
 ,sep=,header=TRUE)

 -M

 On Tue, Jul 10, 2012 at 1:52 PM, arun smartpink...@yahoo.com wrote:

  Hi,
 
  Try this:
 
  dat3-read.table(text=
  Begin_date  End_date
  01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
  24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
  01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
  01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
  01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
  ,sep=,header=TRUE)
 
  dat3$Begin_date-strptime(dat3[,1],format=%d%b%Y:%H:%M:%S)
  dat3$End_date-strptime(dat3[,2],format=%d%b%Y:%H:%M:%S)
 
   difftime(dat3[,1],dat3[,2])
  Time differences in days
  [1] -763.  -55. -124.0417  -32.  -32.
  attr(,tzone)
  [1] 
 
  A.K.
 
  - Original Message -
  From: C W tmrs...@gmail.com
  To: r-help r-help@r-project.org
  Cc:
  Sent: Tuesday, July 10, 2012 1:22 PM
  Subject: [R] calculating the difference between days?
 
  Hi List,
 
  I have one column of beginning dates and one column of ending dates, I
 want
  to find their difference.  And I want to ignore the trailing zeros,
  basically everything after the first colon mark.
 
  Begin_date   End_date
  01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
  24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
  01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
  01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
  01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
 
  Thanks,
 
  Mike
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

 [[alternative HTML version deleted]]

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


[[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] Changing x-axis values displayed on histogram

2012-07-10 Thread jlwoodard
Perfect!  Thanks so much, Sarah!

--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-x-axis-values-displayed-on-histogram-tp4636032p4636051.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] R code help to change table format

2012-07-10 Thread Rui Barradas

Hello,

You should say what is the package you are using, EstimateS returns 
hundreds of hits. [ package sos, findFn() ].


As for the question, try


sp - 1:5
ab - c(3, 2, 2, 2, 4)
rep(sp, ab)


Hope this helps,

Rui Barradas

Em 10-07-2012 18:23, peziza escreveu:

I am trying to input an OTU table into EstimateS, however, the format of the
OTU table has to be changed to fit the format EstimateS will accept. In R, I
would like to change the format of the OTU table (from excel).  Here is what
I need to do, take Example 1 and create Example 2.  The problem is that I
have hundreds of OTUs, so I can't do this by hand (and I'd love to have a
code that I could use for different OTU tables).
Thanks!

Example 1 Example 2
Species Abundance Species
1 3   1
2 2   1
3 2   1
4 2   2
5 4   2

3

3

4

4

5
5

5

5

5


--
View this message in context: 
http://r.789695.n4.nabble.com/R-code-help-to-change-table-format-tp4636022.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] Need HELP: how find and use a csv file?

2012-07-10 Thread R. Michael Weylandt michael.weyla...@gmail.com


On Jul 10, 2012, at 2:56 PM, Rich Shepard rshep...@appl-ecosys.com wrote:

 On Tue, 10 Jul 2012, Faradj Koliev wrote:
 
 I got a csv file ( skater.csv) which i could read by typing:
 read.csv(file=/Users/kama/Desktop/skatter.csv, header=TRUE, sep=;)
 
  Try:
 
 skatter - read.csv('/Users/kama/Desktop/skatter.csv', header = T, sep =
 ';')

That seems paradoxical...

Michael

 
 Rich
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Need HELP: how find and use a csv file?

2012-07-10 Thread mlell08
On 10.07.2012 20:11, Faradj Koliev wrote:
 However, when i enter:skatter.csv-read.csv(skatter.csv, header=TRUE) i 
 get this message: 
 Error in file(file, rt) : cannot open the connection 
 In addition: Warning message: 
 In file(file, rt) : 
 I have tried with:   skatter.csv-file.choose() and other codes to find the 
 file but it does not work. 

Could it be a problem with your Working directory? use getwd() to find
out whether your working directory is set to your Desktop where your
file seems to be and use setwd(/Path/to/Desktop) to go there if you
aren't. Then you can use read.csv() without an absolute path for your
file as you did above

Regards, Moritz

-- 
GnuPG Key: 0x7340821E

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


Re: [R] Mann-Whitney by group

2012-07-10 Thread Oxenstierna
This works very well--thanks so much.

By way of extension:  how would one extract elements from the result object?

For example:

thing=apply(Dtb[,3:10], 2, function(x) wilcox.test(x~Dtb$Group))

summary(thing)$p.value

Does not provide a list of p-values as it would in a regression object. 
Ideally, I would like to be able to extract the W score and p-value by
A,B,C,...

Any ideas greatly appreciated!


--
View this message in context: 
http://r.789695.n4.nabble.com/Mann-Whitney-by-group-tp4635618p4636055.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] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread ollestrat
Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?  

 -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole

--
View this message in context: 
http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.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] Download large file from https url with progress meter

2012-07-10 Thread Gregory Jefferis
Dear useRs,

I would like to download a large (15Mb) file from a github https url with a 
progress meter. My first attempt was:

zip_url=https://github.com/jefferis/AnalysisSuite/zipball/master;
zip_file=tempfile()
 download.file(zip_url,zip_file)
Error in download.file(zip_url, zip_file) : unsupported URL scheme

Then I tried
install.packages(httr)
require(httr)

system.time(request-GET(zip_url, config(ssl.verifypeer = FALSE)))
stop_for_status(request)
writeBin(content(request),zip_file)

   user  system elapsed 
  1.234   0.236  27.685 

I can't seem to find a way for the httr package to show progress. Can anyone 
suggest an alternative approach?

With many thanks,

Greg Jefferis.

--
Gregory Jefferis, PhD  
Division of Neurobiology   
MRC Laboratory of Molecular Biology,   
Hills Road,
Cambridge, CB2 0QH, UK.

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2
http://flybrain.stanford.edu

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Richard M. Heiberger
This is the behavior of the floating point number representation.
Decimal fractions do not come out even in binary notation.
Please see FAQ 7.31

On Tue, Jul 10, 2012 at 4:17 PM, ollestrat stratm...@gmx.de wrote:

 Hello,

 I fear its a stupid question,..but here it is:

 If I do this simple calculation with the R  console, I surprisingly do not
 get a zero. Why?

  -1.1-0.1+1.2
 [1] -2.220446e-16


 greetings, Ole

 --
 View this message in context:
 http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread William Dunlap
It is for the same reason that if you must work with numbers
stored with 2 significant decimal digits 1-(1/3+1/3+1/3)
is 0.01 (== 10 ^ -2).

Double precision numbers, supported by your computer
hardware and used by R, are stored using 52 significant
binary digits and 2^-52 is about -2.220446e-16.

(By the way, in R zero and NULL are different things: the former
is numeric and the latter is not.)

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 ollestrat
 Sent: Tuesday, July 10, 2012 1:17 PM
 To: r-help@r-project.org
 Subject: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?
 
 Hello,
 
 I fear its a stupid question,..but here it is:
 
 If I do this simple calculation with the R  console, I surprisingly do not
 get a zero. Why?
 
  -1.1-0.1+1.2
 [1] -2.220446e-16
 
 
 greetings, Ole
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-
 null-Why-tp4636053.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] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Rolf Turner



In addition to taking cognisance of Richard Heiberger's reply you
should also learn to distinguish between the concept of null and
zero.  They are not at all the same thing.

cheers,

Rolf Turner

On 11/07/12 08:17, ollestrat wrote:

Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?

  -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Thanks! RE: boxplot with cut

2012-07-10 Thread Vining, Kelly
Thanks for your help, Rui! That works and will save me a lot of trouble. 

--Kelly

-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt] 
Sent: Tuesday, July 10, 2012 2:24 AM
To: Vining, Kelly
Cc: r-help@r-project.org
Subject: Re: [R] boxplot with cut

Hello,

Maybe this iss what you're looking for. GD is your data.frame.



multi.boxplot - function(x, by, ...){
x - as.data.frame(x)
sp - split(x, by)
len - length(sp) - 1
n - ncol(x)
n1 - n + 1
boxplot(x[[ 1 ]] ~ by, at = 0:len*n1 + 1,
xlim = c(0, (len + 1)*n1), ylim = range(unlist(x)), xaxt = n, 
...)
for(i in seq_len(n)[-1])
boxplot(x[[i]] ~ by, at = 0:len*n1 + i, xaxt = n, add = TRUE, 
...)
axis(1, at = 0:len*n1 + n1/2, labels = names(sp), tick = TRUE) }

cols - grep(ReadCount, names(GD))
multi.boxplot(GD[, cols], cut(GD$GeneDensity, breaks=10))


If this is it and you don't like those x-axis tick lables, use 
as.integer(cut(...etc...)).

Hope this helps,

Rui Barradas

Em 09-07-2012 20:51, Vining, Kelly escreveu:
 Dear UseRs,
 I'm making box plots from a data set that looks like this:


Chr Start   End GeneDensity ReadCount_Explant ReadCount_Callus 
 ReadCount_Regen
 1   1 1 1  107.82 1.2431.047   
 1.496
 2   1 10001 2  202.50 0.8350.869   
 0.456
 3   1 20001 3  158.80 1.8131.529   
 1.131
 4   1 30001 4  100.53 1.7311.752   
 1.610
 5   1 40001 5  100.53 3.0562.931   
 3.631
 6   1 50001 6  100.53 1.9602.013   
 2.459

 I'm breaking the GeneDensity column into deciles, then making a box plot of 
 the relationship between the GeneDensity parameter and each of the three 
 ReadCount columns. Here's an example of one of my boxplot commands:

 boxplot(GeneDensity$ReadCount_Explant ~ 
 cut(GeneDensitySorted$GeneDensity, breaks=10), ylim=c(0,40), 
 ylab=RPKM, xlab=GENE DENSITY (LOW - HIGH), main=INTERNODE 
 EXPLANT)

 Right now, I'm making three separate graphs: one for each of the three 
 ReadCount columns. I'd like to put all three sets on one graph, so that 
 each decile is represented by three boxes, one for each ReadCount category, 
 but don't know how to make that work. I tried this:

 boxplot(GeneDensitySorted$ReadCount_Explant ~ 
 cut(GeneDensitySorted$GeneDensity, breaks=10), 
 GeneDensitySorted$ReadCount_Callus ~ 
 cut(GeneDensitySorted$GeneDensity, breaks=10), 
 GeneDensitySorted$ReadCount_Regen ~ cut(GeneDensitySorted$GeneDensity, 
 breaks=10), ylim=c(0,40), ylab=RPKM, xlab=GENE DENSITY (LOW - 
 HIGH))

 Not surprisingly, I got this error:

 Error in as.data.frame.default(data) :
cannot coerce class 'formula' into a data.frame

 Does anyone know how to accomplish this box plot?

 Any help is much appreciated.

 --Kelly V.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Rolf Turner

But R-ish NULL is *NOT* equal to R-ish zero, and that's
what counts here.

 cheers,

 Rolf Turner

On 11/07/12 09:19, Erdal Karaca wrote:
 german Null == english zero :-)

 2012/7/10 Rolf Turner rolf.tur...@xtra.co.nz 
 mailto:rolf.tur...@xtra.co.nz



 In addition to taking cognisance of Richard Heiberger's reply you
 should also learn to distinguish between the concept of null and
 zero.  They are not at all the same thing.

 cheers,

 Rolf Turner


 On 11/07/12 08:17, ollestrat wrote:

 Hello,

 I fear its a stupid question,..but here it is:

 If I do this simple calculation with the R  console, I
 surprisingly do not
 get a zero. Why?

   -1.1-0.1+1.2
 [1] -2.220446e-16


 greetings, Ole



[[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] Mann-Whitney by group

2012-07-10 Thread R. Michael Weylandt michael.weyla...@gmail.com
Untested, I think you need to lapply() over thing with some sort of extractor:

lapply(thing, function(x) x[['p.value']])

Michael

On Jul 10, 2012, at 3:45 PM, Oxenstierna david.chert...@gmail.com wrote:

 This works very well--thanks so much.
 
 By way of extension:  how would one extract elements from the result object?
 
 For example:
 
 thing=apply(Dtb[,3:10], 2, function(x) wilcox.test(x~Dtb$Group))
 
 summary(thing)$p.value
 
 Does not provide a list of p-values as it would in a regression object. 
 Ideally, I would like to be able to extract the W score and p-value by
 A,B,C,...
 
 Any ideas greatly appreciated!
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Mann-Whitney-by-group-tp4635618p4636055.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] HELP me please with import of csv to R

2012-07-10 Thread peter dalgaard

On Jul 10, 2012, at 21:44 , Sarah Goslee wrote:
 
 But note that if sep=; then you don't have a csv file and should
 properly use read.table() instead.

That's not actually true. In a substantial part of the world, csv files are 
semicolon separated. That's what read.csv2() is for. (Yes, it is silly, please 
don't get me started...)

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread massimodisasha

Il 7/10/12 4:17 PM, ollestrat ha scritto:

Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?

  -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole

--
View this message in context: 
http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.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.

...

Python :
 -1.1-0.1+1.2
-2.220446049250313e-16
 -1.2-0.2+1.4
0.0


R :
 -1.1-0.1+1.2
[1] -2.220446e-16
 -1.2-0.2+1.4
[1] 0


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