Re: [R] Experiment Design

2014-06-13 Thread Chatcher
Thanks for the comments.
I think i phrased my question incorrectly but the following gave me what I
wanted. 18 treatments(plants) , 3 blocks, a total of 54 plots. I could not
figure out exac

 library(agricolae)
 trt-
 c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)
 design.rcbd(trt, 3, serie = 2, seed = 0, kinds = Super-Duper,
 first=TRUE)
$parameters
$parameters$design
[1] rcbd

$parameters$trt
 [1] 1  2  3  4  5  6  7  8  9  10 11 12 13 14
15 16 17
[18] 18

$parameters$r
[1] 3

$parameters$serie
[1] 2

$parameters$seed
[1] 942260715

$parameters$kinds
[1] Super-Duper


$book
   plots block trt
1101 1   3
2102 1  17
3103 1   4
4104 1  18
5105 1   6
6106 1   5
7107 1   9
8108 1   2
9109 1  16
10   110 1  10
11   111 1   8
12   112 1   7
13   113 1  13
14   114 1  12
15   115 1  11
16   116 1   1
17   117 1  14
18   118 1  15
19   201 2  13
20   202 2   6
21   203 2  18
22   204 2  10
23   205 2   4
24   206 2   3
25   207 2   8
26   208 2  14
27   209 2  16
28   210 2   5
29   211 2  15
30   212 2   7
31   213 2  12
32   214 2   2
33   215 2   1
34   216 2  17
35   217 2  11
36   218 2   9
37   301 3  10
38   302 3   4
39   303 3   2
40   304 3   8
41   305 3   5
42   306 3   7
43   307 3  16
44   308 3  15
45   309 3  13
46   310 3   1
47   311 3  12
48   312 3  18
49   313 3   6
50   314 3  14
51   315 3  11
52   316 3   3
53   317 3  17
54   318 3   9

 




--
View this message in context: 
http://r.789695.n4.nabble.com/Experiment-Design-tp4692015p4692028.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] Experiment Design

2014-06-13 Thread Denis Haine
I guessed you mean 2 treatment groups, N=18 and 3 blocks (so n=6 per block):

blocks - 3
ngroups - 2
groupsize - 3

group - NULL;
block - NULL;
set.seed(911)
for (i in 1:blocks){
foo - sample(rep(c('A', 'B'), groupsize))
group - c(group, foo)
block - c(block, rep(i, groupsize*ngroups))
}

cbind(group, block, rep(1:(groupsize*ngroups), blocks))

Denis


*_Denis *Haine
+1-514-572-7174


2014-06-12 13:59 GMT-04:00 Sarah Goslee sarah.gos...@gmail.com:

 Sorry, try this again.

 Does this help:


 http://www2.warwick.ac.uk/fac/sci/moac/degrees/moac/ch923/lectures/moac_-_designing_experiments_in_r.pdf

 If not, we need some more specifics about what you've tried and where
 you are running into problems.

 Sarah


 On Thu, Jun 12, 2014 at 11:34 AM, Chatcher cnyi...@vols.utk.edu wrote:
  Good Morning,
  I would like help with code that creates a RBD experiment. That is I
 have 18
  treatments and I will need three blocks. I cannot seem to find an easy
 way
  to do this in R.
  I think it is a relatively easy thing to do but i tried Agricolae and
 seem
  to be getting so lost I cannot even get started.
 
  Thanks.
 
 
 --
 Sarah Goslee
 http://www.sarahgoslee.com
 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.


[[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] Simulating spatio-temporal marked ETAS point process

2014-06-13 Thread Ferra Xu
Hello all

I am searching for a package or code that is used for generating data for 
spatio-temporal marked ETAS processes. I saw that spatial ETAS function in 
PtProcess package doesn't work with simulate function...


Thank you in advance,
Ferra
[[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] no x label using axis.Date

2014-06-13 Thread MKN
I have tried multiple different methods to figure out how to get a date axis
of my preference (start date of each month). Any assistance would be
appreciated.
The below section is not producing a date axis:

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*

The above section is used in the following plot:

par(mfrow=c(4,1))
par(mar=c(0.8,0,0,0))
par(oma=c(2,4.5,3,2))

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Dmax),xaxt=n)
points(D$date,D$TSP,col=Dcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Dmax-20,labels=DM1',cex=1)
legend(topright,pch=16,cex=0.8,col=colLegend,
   legend=ALegend)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Bmax),xaxt=n)
points(B$date,B$TSP,col=Bcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Bmax-20,labels=DM2,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Amax),xaxt=n)
points(A$date,A$TSP,col=Acol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Amax-20,labels=DM3,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*
points(E$date,E$TSP,col=Ecol,type=p,pch=16,lwd=2)
text(mdate,Emax-20,labels=DM4',cex=1)
abline(h=Target,col=red,lwd=2)

title(main=Amain, ylab=Labely,
  outer=TRUE,cex.lab=1, cex.main=1.5)

Below is an excerpt of the total days data:

totaldays   y
1   2013-11-01  1
2   2013-11-02  1
3   2013-11-03  1
4   2013-11-04  1
5   2013-11-05  1
6   2013-11-06  1
7   2013-11-07  1
8   2013-11-08  1
9   2013-11-09  1
10  2013-11-10  1




--
View this message in context: 
http://r.789695.n4.nabble.com/no-x-label-using-axis-Date-tp4692034.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Extracting data from density plots

2014-06-13 Thread Parimal Lokhande
I have a dataframe
​df ​
with 3 columns. Details
​of df are ​
as follows

 summary(df)
  DateTestVartype
 Min.   :2002-05-10 00:00:00   Min.   :-3.8531   Bottom: 313
 1st Qu.:2005-05-09 12:00:00   1st Qu.:-0.7773   Other :2501
 Median :2008-05-07 00:00:00   Median : 0.2482   Top   : 313
 Mean   :2008-05-07 00:00:00   Mean   : 0.1980
 3rd Qu.:2011-05-05 12:00:00   3rd Qu.: 1.2250
 Max.   :2014-05-05 00:00:00   Max.   : 3.6633


 str(df)
'data.frame':   3127 obs. of  3 variables:
 $ Date   : POSIXlt, format: 2002-05-10 2002-05-13 2002-05-14 ...
 $ TestVar: num  1.34 2.02 1.39 1.54 2.45 ...
 $ type   : Factor w/ 3 levels Bottom,Other,..: 3 3 3 3 3 3 3 3 2 2 ...

I have plotted the following density plot for column 2 i.e. TestVar and then
color coded according to factor variable type

http://r.789695.n4.nabble.com/file/n4691999/Rplot01.jpeg

 ggplot(df)+  geom_density(aes(x=TestVar, color=type))



I now want to filter out data samples such that the density
​curve
of Top is
higher than Bottom. Basically I need TestVar values for which blue line is
higher than red line.

How can this be achieved? Is there a way i can extract density values out of
the plot?

[[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] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Pascal Oettli
Dear list,

Please consider the following example:

library(plotrix)
barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

How to force the bars to start at 0? I could not find the way to do it.

Regards,
Pascal

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


Re: [R] Add points to subplots

2014-06-13 Thread Luca Cerone
Thanks David,
I already did this, but in case the code gets updated I will have to
re-add the annotation, which I do not think it is ideal.

I was just wondering if there is an easy solution to this.
Thanks a lot for the help,

Cheers,
Luca

2014-06-13 3:12 GMT+02:00 David Winsemius dwinsem...@comcast.net:

 On Jun 12, 2014, at 8:06 AM, Luca Cerone wrote:

 Dear all,
 I am running some analysis using the pamr package (available on CRAN).

 One of the plots I produce is made using the function pamr.plotcv.
 This displays two plots in the same figure (using par(mfrow=c(2,1)).

 When the figure is created, I would like to be able to add some points
 and lines, to the top plot.

 After producing the plot with pamr.cvplot, I have tried to add a line
 doing something like:

 par(mfg=c(1,1))
 lines(c(3,3), c(0,1), col = blue, lty = 3)

 However this doesn't work and the line is shown in the bottom plot.
 How can I add points and lines to the top plot?

 I think you would be better off hacking the code and inserting your desired 
 annotations before the focus is moved to the second region. There are split 
 screen methods that allow changing focus for base graphics, but I'm not aware 
 of ones that use the par() controls.

 --

 David Winsemius
 Alameda, CA, USA




-- 
Luca Cerone

Tel: +34 692 06 71 28
Skype: luca.cerone

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


Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Jim Lemon
On Fri, 13 Jun 2014 06:50:59 PM Pascal Oettli wrote:
 Dear list,
 
 Please consider the following example:
 
 library(plotrix)
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))
 
 How to force the bars to start at 0? I could not find the way to do it.
 
Hi Pascal,
You are right, I had not considered the idea of setting a negative y limit 
when there were no negative values. I think you can fix this by changing:

 negy-any(height0,na.rm=TRUE)
 
 to

negy-any(height0,na.rm=TRUE) || ylim[1]  0

I'll check this later (I'm just going out) and if it doesn't work, I'll send 
another email with something that does.

Jim

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


Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Jorge I Velez
Hi Pascal,

Perhaps I am missing something, but what about changing passing ylim = c(0,
10) to barp()?

Best,
Jorge.-


On Fri, Jun 13, 2014 at 7:50 PM, Pascal Oettli kri...@ymail.com wrote:

 Dear list,

 Please consider the following example:

 library(plotrix)
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

 How to force the bars to start at 0? I could not find the way to do it.

 Regards,
 Pascal

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Pascal Oettli
Hi Jim,

Thank you for the suggestion. I will try it.

Pascal

On Fri, Jun 13, 2014 at 7:09 PM, Jim Lemon j...@bitwrit.com.au wrote:
 On Fri, 13 Jun 2014 06:50:59 PM Pascal Oettli wrote:
 Dear list,

 Please consider the following example:

 library(plotrix)
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

 How to force the bars to start at 0? I could not find the way to do it.

 Hi Pascal,
 You are right, I had not considered the idea of setting a negative y limit
 when there were no negative values. I think you can fix this by changing:

  negy-any(height0,na.rm=TRUE)

  to

 negy-any(height0,na.rm=TRUE) || ylim[1]  0

 I'll check this later (I'm just going out) and if it doesn't work, I'll send
 another email with something that does.

 Jim




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Pascal Oettli
Hi Jorge,

It is in order to have different barplots with the same range of
limits, to keep them easily comparable. Some have negative values,
some others no.

Pascal

On Fri, Jun 13, 2014 at 7:11 PM, Jorge I Velez jorgeivanve...@gmail.com wrote:
 Hi Pascal,

 Perhaps I am missing something, but what about changing passing ylim = c(0,
 10) to barp()?

 Best,
 Jorge.-


 On Fri, Jun 13, 2014 at 7:50 PM, Pascal Oettli kri...@ymail.com wrote:

 Dear list,

 Please consider the following example:

 library(plotrix)
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

 How to force the bars to start at 0? I could not find the way to do it.

 Regards,
 Pascal

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





-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Defining default method for S3, S4 and R5 classes

2014-06-13 Thread Luca Cerone
Dear all,

I am writing a script implementing a pipeline to analyze some of the
data we receive.

One of the steps in this pipeline involves clustering the data, and I
am interested
in studying the effects of different clustering algorithms on the final results.

I am having issues making my code general enough because the
clustering algorithms we are interested all return different types of
objects (S3, S4 and R5 classes, as well as simple named lists).

From the output of these algorithms I need to extract a list with as many
elements as the number of clusters and such that each element contains the ids
of the elements in each cluster.

I have easily done this for each of the cluster algorithms,
the problem is: how can I make so that rather than having to check for
classes and
types this is done automatically?

For example, for the algorithms that return S3 classes I have defined
a method get_cluster_list.default and then created the methods for
the individual classes, which is used in the main body of the
pipeline.

I have no idea how I can do this for S4 and R5 classes and,  more
importantly, I would
like an approach that works when using all S3, S4 and R5 classes.

Do you know how I could do this?

Thanks for the help,
Luca

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


Re: [R] Rscript fails where Rterm works

2014-06-13 Thread Bond, Stephen
Hadley,

You are a genius.

Stephen B
-Original Message-
From: Hadley Wickham [mailto:h.wick...@gmail.com] 
Sent: Thursday, June 12, 2014 5:18 PM
To: Bond, Stephen
Cc: r-help@r-project.org
Subject: Re: [R] Rscript fails where Rterm works

Explicitly load the methods package: library(methods)

Hadley

On Thu, Jun 12, 2014 at 2:22 PM, Bond, Stephen stephen.b...@cibc.com wrote:
 I have a script which loads

 library(XLConnect)
 wb - loadWorkbook(wbname)

 the code works without errors when run from ESS which uses
 R version 3.0.1 (2013-05-16) -- Good Sport
 Copyright (C) 2013 The R Foundation for Statistical Computing
 Platform: i386-w64-mingw32/i386 (32-bit)

 But fails when run from Rscript
 which Rscript
 C:\Program Files\R\R-3.0.1\bin\i386\Rscript.EXE

 Rscript updatevols.R

 Warning message:
 package 'RODBC' was built under R version 3.0.2
 XLConnect 0.2-7 by Mirai Solutions GmbH
 http://www.mirai-solutions.com ,
 http://miraisolutions.wordpress.com
 Warning message:
 package 'XLConnect' was built under R version 3.0.3
 Error in .jfield(x, Ljava/lang/Class;, TYPE) :
   could not find function getClass
 Calls: loadWorkbook ... ._java_class_list - lapply - FUN - .jfield - .Call
 Execution halted
 Warning message:
 closing unused RODBC handle 1

 Any clues?

 Stephen B

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



-- 
http://had.co.nz/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Release of R 3.1.1 scheduled for July 10

2014-06-13 Thread Peter Dalgaard
Just a quick notice that we intend to have a patch release on July 10. Nickname 
is still undecided.

Due to calendar conflicts, the binaries for some platforms may be delayed by a 
week or so. 

-pd

-- 
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-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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

2014-06-13 Thread Adams, Jean
I don't know if you can get the information from the plot, but you can
certainly get it from the density() function directly.  For example,

# fake data
TestVar - rnorm(60)
type - rep(c(Bottom, Other, Top), 20)

# density of TestVar for each type, estimated at 100 points along range of
TestVar
d - tapply(TestVar, type, density, from=min(TestVar), to=max(TestVar),
n=100)
results - data.frame(TestVar=d$Top$x, sapply(d, [[, 2))

# select only those records where the Top density is greater than the
Bottom density
results[results$Top  results$Bottom, ]

Jean



On Thu, Jun 12, 2014 at 10:25 PM, Parimal Lokhande 
parimallokha...@gmail.com wrote:

 I have a dataframe
 ​df ​
 with 3 columns. Details
 ​of df are ​
 as follows

  summary(df)
   DateTestVartype
  Min.   :2002-05-10 00:00:00   Min.   :-3.8531   Bottom: 313
  1st Qu.:2005-05-09 12:00:00   1st Qu.:-0.7773   Other :2501
  Median :2008-05-07 00:00:00   Median : 0.2482   Top   : 313
  Mean   :2008-05-07 00:00:00   Mean   : 0.1980
  3rd Qu.:2011-05-05 12:00:00   3rd Qu.: 1.2250
  Max.   :2014-05-05 00:00:00   Max.   : 3.6633


  str(df)
 'data.frame':   3127 obs. of  3 variables:
  $ Date   : POSIXlt, format: 2002-05-10 2002-05-13 2002-05-14 ...
  $ TestVar: num  1.34 2.02 1.39 1.54 2.45 ...
  $ type   : Factor w/ 3 levels Bottom,Other,..: 3 3 3 3 3 3 3 3 2 2 ...

 I have plotted the following density plot for column 2 i.e. TestVar and
 then
 color coded according to factor variable type

 http://r.789695.n4.nabble.com/file/n4691999/Rplot01.jpeg

  ggplot(df)+  geom_density(aes(x=TestVar, color=type))



 I now want to filter out data samples such that the density
 ​curve
 of Top is
 higher than Bottom. Basically I need TestVar values for which blue line
 is
 higher than red line.

 How can this be achieved? Is there a way i can extract density values out
 of
 the plot?

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


[R] data format setting

2014-06-13 Thread eliza botto

Dear R family,
I hope you all be doing great. I have a dataset of following format. The data 
file is of the following format.

  st year month day discharge
1  A 2004 1   1  6.752828
2  A 2004 1   2  7.602053
3  A 2004 1   3  5.583619
4  A 2004 1   4  5.019562
5  A 2004 1   5  4.804489
6  A 2004 1   6  4.363541
7  A 2004 1   7  3.801333
8  A 2004 1   8  3.455991
9  A 2004 1   9  3.402634
10 A 2004 1  10  3.250693
.. 
..
continue
..
..
 st year month day discharge
2AY 196710   3  0.56
20001AY 196710   4  0.56
20002AY 196710   5  0.48
20003AY 196710   6  0.56
20004AY 196710   7  0.48
20005AY 196710   8  0.40
20006AY 196710   9  0.40
20007AY 196710  10  0.56
20008AY 196710  11  0.56
20009AY 196710  12  0.65
20010AY 196710  13  0.85

you can see that there are five columns.
The first column has the name of the station. I want to split the data w.r.t 
the names of the stations. Each station has data for certain years. for example 
A has data for years from 2004 to 2010 and for AY its from 1967 to 
2000.similarly for other years there is data for different number of years.
I want to make a list of matrices each containing the data for that station in 
the following format
$A
2004200520062007200820092010
..
...
...
..
...

$AY

196719682000

each column should have 365 to 366 values depending on whether there is a leap 
year or not. obviously for non-leap years 366th row should be an NA.
kindly help me on it.
Thankyou very much in advance.
Eliza

  
[[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] data format setting

2014-06-13 Thread Clint Bowman

?sort,
?unique, and
subset come to mind.

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 13 Jun 2014, eliza botto wrote:



Dear R family,
I hope you all be doing great. I have a dataset of following format. The data 
file is of the following format.

 st year month day discharge
1  A 2004 1   1  6.752828
2  A 2004 1   2  7.602053
3  A 2004 1   3  5.583619
4  A 2004 1   4  5.019562
5  A 2004 1   5  4.804489
6  A 2004 1   6  4.363541
7  A 2004 1   7  3.801333
8  A 2004 1   8  3.455991
9  A 2004 1   9  3.402634
10 A 2004 1  10  3.250693
..
..
continue
..
..
st year month day discharge
2AY 196710   3  0.56
20001AY 196710   4  0.56
20002AY 196710   5  0.48
20003AY 196710   6  0.56
20004AY 196710   7  0.48
20005AY 196710   8  0.40
20006AY 196710   9  0.40
20007AY 196710  10  0.56
20008AY 196710  11  0.56
20009AY 196710  12  0.65
20010AY 196710  13  0.85

you can see that there are five columns.
The first column has the name of the station. I want to split the data w.r.t the names of the 
stations. Each station has data for certain years. for example A has data for years 
from 2004 to 2010 and for AY its from 1967 to 2000.similarly for other years there is 
data for different number of years.
I want to make a list of matrices each containing the data for that station in 
the following format
$A
2004200520062007200820092010
..
...
...
..
...

$AY

196719682000

each column should have 365 to 366 values depending on whether there is a leap 
year or not. obviously for non-leap years 366th row should be an NA.
kindly help me on it.
Thankyou very much in advance.
Eliza


[[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] no x label using axis.Date

2014-06-13 Thread MacQueen, Don
I'd suggest a different strategy for calculating your axis. You may also
be using the axis.Date() function incorrectly. See this example:

tmpd - data.frame(dt=seq.Date( as.Date('2014-1-7'),
as.Date('2014-08-13'), len=15),
   y=runif(15)
   )
xax - seq.Date(min(tmpd$dt), max(tmpd$dt), by='mon')

plot(tmpd$dt, tmpd$y, xaxt='n')axis(1, at=xax, lab=format(xax,'%b-%Y'))


By the way, most of the information in your post does not appear to be
relevant to your question (all the stuff starting with and following the
first par() statement), and it is distracting. It's always best to pare
things down to the minimum, as it makes it easier for potential helpers.
Also, it's hard to figure out why your attempt doesn't work, because you
haven't provided a reproducible example, which is easily done.

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 6/12/14 7:47 PM, MKN matthewnewl...@gauge.com.au wrote:

I have tried multiple different methods to figure out how to get a date
axis
of my preference (start date of each month). Any assistance would be
appreciated.
The below section is not producing a date axis:

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*

The above section is used in the following plot:

par(mfrow=c(4,1))
par(mar=c(0.8,0,0,0))
par(oma=c(2,4.5,3,2))

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Dmax),xaxt=n)
points(D$date,D$TSP,col=Dcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Dmax-20,labels=DM1',cex=1)
legend(topright,pch=16,cex=0.8,col=colLegend,
   legend=ALegend)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Bmax),xaxt=n)
points(B$date,B$TSP,col=Bcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Bmax-20,labels=DM2,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Amax),xaxt=n)
points(A$date,A$TSP,col=Acol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Amax-20,labels=DM3,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*
points(E$date,E$TSP,col=Ecol,type=p,pch=16,lwd=2)
text(mdate,Emax-20,labels=DM4',cex=1)
abline(h=Target,col=red,lwd=2)

title(main=Amain, ylab=Labely,
  outer=TRUE,cex.lab=1, cex.main=1.5)

Below is an excerpt of the total days data:

   totaldays   y
1  2013-11-01  1
2  2013-11-02  1
3  2013-11-03  1
4  2013-11-04  1
5  2013-11-05  1
6  2013-11-06  1
7  2013-11-07  1
8  2013-11-08  1
9  2013-11-09  1
10 2013-11-10  1




--
View this message in context:
http://r.789695.n4.nabble.com/no-x-label-using-axis-Date-tp4692034.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] data format setting

2014-06-13 Thread eliza botto
Thanks dennis,
It worked but I had to do some simple modifications to get to the ultimate 
format.
Now I have a list in the following format
$A
2004200520062007200820092010
..
...
...
..
...

$AY

196719682000...

some columns had 365 rows and some 366. those with 365 rows had their 366 row 
as NA. 
Now I want to apply approx. command to interpolate 366 values to 365, but when 
I apply approx command I gives out something 
which is with $x and $y, and frankly speaking it messed up everything.
Is their a way that i do it neatly without getting the format deteriorated?


In any way, thank-you very much indeed.

Eliza

 Date: Fri, 13 Jun 2014 11:11:37 -0700
 Subject: Re: [R] data format setting
 From: djmu...@gmail.com
 To: eliza_bo...@hotmail.com
 
 Hi:
 
 Maybe something like this:
 
 library(reshape2)
 L - split(DF, DF$year)
 L2 - llply(L, function(d) dcast(d, month + day ~ year, value.var =
 discharge))
 
 Obviously untested, so caveat emptor. The idea is to use the dcast
 function to reshape the data from long to wide format within year.
 
 Dennis
 
 On Fri, Jun 13, 2014 at 8:55 AM, eliza botto eliza_bo...@hotmail.com wrote:
 
  Dear R family,
  I hope you all be doing great. I have a dataset of following format. The 
  data file is of the following format.
 
st year month day discharge
  1  A 2004 1   1  6.752828
  2  A 2004 1   2  7.602053
  3  A 2004 1   3  5.583619
  4  A 2004 1   4  5.019562
  5  A 2004 1   5  4.804489
  6  A 2004 1   6  4.363541
  7  A 2004 1   7  3.801333
  8  A 2004 1   8  3.455991
  9  A 2004 1   9  3.402634
  10 A 2004 1  10  3.250693
  ..
  ..
  continue
  ..
  ..
   st year month day discharge
  2AY 196710   3  0.56
  20001AY 196710   4  0.56
  20002AY 196710   5  0.48
  20003AY 196710   6  0.56
  20004AY 196710   7  0.48
  20005AY 196710   8  0.40
  20006AY 196710   9  0.40
  20007AY 196710  10  0.56
  20008AY 196710  11  0.56
  20009AY 196710  12  0.65
  20010AY 196710  13  0.85
 
  you can see that there are five columns.
  The first column has the name of the station. I want to split the data 
  w.r.t the names of the stations. Each station has data for certain years. 
  for example A has data for years from 2004 to 2010 and for AY its from 
  1967 to 2000.similarly for other years there is data for different number 
  of years.
  I want to make a list of matrices each containing the data for that station 
  in the following format
  $A
  2004200520062007200820092010
  ..
  ...
  ...
  ..
  ...
 
  $AY
 
  196719682000
 
  each column should have 365 to 366 values depending on whether there is a 
  leap year or not. obviously for non-leap years 366th row should be an NA.
  kindly help me on it.
  Thankyou very much in advance.
  Eliza
 
 
  [[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.


[R] Error message in varimp function: Party package

2014-06-13 Thread Roxanne Snook

Dear R community,

I’m trying to use the “party” package to view variables that are 
important in my data frame (FIM_RS4). My data has a combination of ordinal, 
nominal, categorical, and continuous data. I’ve written my code below, with 
my predictor variables being 2:36, and my response is 37 (Mussel). If anyone 
could point me in the direction of how to get rid of this error message, I 
would very much appreciate the guidance.

FIM_RS4-read.csv(FIM_RS_4.csv, header=TRUE, stringsAsFactors=T) 

#all ordinal variables have been ordered in my complete code as well

mycontrols - cforest_control(ntree=5000,mtry=4, minsplit=5)

cforest.rf - cforest(as.factor(Mussel)~., data=FIM_RS4[,c(37,2:36)], 
controls=mycontrols)

# indata=FIM_RS4[,2:36]

# rf.model=cforest.rf

temp - varimp.function(indata=FIM_RS4[,2:6], 
rf.model=cforest.rf,num.iterations=5, seedset = 2000,condition.varimp = 
T,write_csv=F)

Ø  Error in model@fit(data, ...) : error code 1 from Lapack routine 'dgesdd'

 #The reason I’m assigning a varimp.function to temp is to run iterations in 
the next piece of code.

#Same error occurs if I do not assign the iteration function varimp.function to 
temp, and simply do:

varimp(cforest.rf, conditional = TRUE)



Ø  Error in model@fit(data, ...) : error code 1 from Lapack routine 'dgesdd'



Many thanks in advance,

Rox
[[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] data format setting

2014-06-13 Thread Jeff Newmiller
As always, you are requested to post in plain text and to provide a 
reproducible example. Messed things up is quite vague.
FWIW: In general, processing in sequence is best done BEFORE you cast your data 
to wide format.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On June 13, 2014 12:46:01 PM MDT, eliza botto eliza_bo...@hotmail.com wrote:
Thanks dennis,
It worked but I had to do some simple modifications to get to the
ultimate format.
Now I have a list in the following format
$A
2004   200520062007200820092010
..
...
...
..
...

$AY

1967   19682000...

some columns had 365 rows and some 366. those with 365 rows had their
366 row as NA. 
Now I want to apply approx. command to interpolate 366 values to 365,
but when I apply approx command I gives out something 
which is with $x and $y, and frankly speaking it messed up everything.
Is their a way that i do it neatly without getting the format
deteriorated?


In any way, thank-you very much indeed.

Eliza

 Date: Fri, 13 Jun 2014 11:11:37 -0700
 Subject: Re: [R] data format setting
 From: djmu...@gmail.com
 To: eliza_bo...@hotmail.com
 
 Hi:
 
 Maybe something like this:
 
 library(reshape2)
 L - split(DF, DF$year)
 L2 - llply(L, function(d) dcast(d, month + day ~ year, value.var =
 discharge))
 
 Obviously untested, so caveat emptor. The idea is to use the dcast
 function to reshape the data from long to wide format within year.
 
 Dennis
 
 On Fri, Jun 13, 2014 at 8:55 AM, eliza botto
eliza_bo...@hotmail.com wrote:
 
  Dear R family,
  I hope you all be doing great. I have a dataset of following
format. The data file is of the following format.
 
st year month day discharge
  1  A 2004 1   1  6.752828
  2  A 2004 1   2  7.602053
  3  A 2004 1   3  5.583619
  4  A 2004 1   4  5.019562
  5  A 2004 1   5  4.804489
  6  A 2004 1   6  4.363541
  7  A 2004 1   7  3.801333
  8  A 2004 1   8  3.455991
  9  A 2004 1   9  3.402634
  10 A 2004 1  10  3.250693
  ..
  ..
  continue
  ..
  ..
   st year month day discharge
  2AY 196710   3  0.56
  20001AY 196710   4  0.56
  20002AY 196710   5  0.48
  20003AY 196710   6  0.56
  20004AY 196710   7  0.48
  20005AY 196710   8  0.40
  20006AY 196710   9  0.40
  20007AY 196710  10  0.56
  20008AY 196710  11  0.56
  20009AY 196710  12  0.65
  20010AY 196710  13  0.85
 
  you can see that there are five columns.
  The first column has the name of the station. I want to split the
data w.r.t the names of the stations. Each station has data for certain
years. for example A has data for years from 2004 to 2010 and for
AY its from 1967 to 2000.similarly for other years there is data for
different number of years.
  I want to make a list of matrices each containing the data for that
station in the following format
  $A
  2004200520062007200820092010
  ..
  ...
  ...
  ..
  ...
 
  $AY
 
  196719682000
 
  each column should have 365 to 366 values depending on whether
there is a leap year or not. obviously for non-leap years 366th row
should be an NA.
  kindly help me on it.
  Thankyou very much in advance.
  Eliza
 
 
  [[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.

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


Re: [R] no x label using axis.Date

2014-06-13 Thread Duncan Mackay
Dates are a problem in any language because they are irregular
As you have not provided a reproducible example

here are 2 solutions

totaldays - seq.Date(as.Date(2013-11-01), by = 7, length = 10)
 str(totaldays)
 Date[1:10], format: 2013-11-01 2013-11-08 2013-11-15 2013-11-22
2013-11-29 2013-12-06 2013-12-13 2013-12-20 2013-12-27
2014-01-03

 plot(totaldays, rep(1,10), axes = F)
 axis(1, at =  seq.Date(as.Date(2013-11-01), by = month, length = 3),
labels = format(seq.Date(as.Date(2013-11-01), by = month, length = 3),
%b %Y))
 axis(2, at = seq(0,2,0.5), labels = paste(seq(0,2,0.5)))
 box()
 
 
library(lattice)
xyplot(rep(1,10)~ totaldays,
   scales = list(x= list(at =  seq.Date(as.Date(2013-11-01), by =
month, length = 3),
 labels = format(seq.Date(as.Date(2013-11-01),
by = month, length = 3), %b %Y

If you have more data you may get away without having to format the xaxis in
lattice.

xyplot(rep(1,10)~ totaldays,
xlim =c(as.Date(2013-10-01), as.Date(2014-02-01)) )

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of MKN
Sent: Friday, 13 June 2014 12:47
To: r-help@r-project.org
Subject: [R] no x label using axis.Date

I have tried multiple different methods to figure out how to get a date axis
of my preference (start date of each month). Any assistance would be
appreciated.
The below section is not producing a date axis:

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*

The above section is used in the following plot:

par(mfrow=c(4,1))
par(mar=c(0.8,0,0,0))
par(oma=c(2,4.5,3,2))

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Dmax),xaxt=n)
points(D$date,D$TSP,col=Dcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Dmax-20,labels=DM1',cex=1)
legend(topright,pch=16,cex=0.8,col=colLegend,
   legend=ALegend)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Bmax),xaxt=n)
points(B$date,B$TSP,col=Bcol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Bmax-20,labels=DM2,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Amax),xaxt=n)
points(A$date,A$TSP,col=Acol,type=p,pch=16,lwd=2,xaxt=n)
text(mdate,Amax-20,labels=DM3,cex=1)
abline(h=Target,col=red,lwd=2)

plot(totaldays$totaldays,totaldays$y,type=n,ylim=c(0,Emax),xaxt=n)
*xlabels-(strptime(totaldays$totaldays,%Y-%m-%d,tz=))
xlabels-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format=%b-%Y)*
points(E$date,E$TSP,col=Ecol,type=p,pch=16,lwd=2)
text(mdate,Emax-20,labels=DM4',cex=1)
abline(h=Target,col=red,lwd=2)

title(main=Amain, ylab=Labely,
  outer=TRUE,cex.lab=1, cex.main=1.5)

Below is an excerpt of the total days data:

totaldays   y
1   2013-11-01  1
2   2013-11-02  1
3   2013-11-03  1
4   2013-11-04  1
5   2013-11-05  1
6   2013-11-06  1
7   2013-11-07  1
8   2013-11-08  1
9   2013-11-09  1
10  2013-11-10  1




--
View this message in context:
http://r.789695.n4.nabble.com/no-x-label-using-axis-Date-tp4692034.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] Add points to subplots

2014-06-13 Thread Jim Lemon
On Fri, 13 Jun 2014 12:02:34 PM Luca Cerone wrote:
 Thanks David,
 I already did this, but in case the code gets updated I will have to
 re-add the annotation, which I do not think it is ideal.
 
 I was just wondering if there is an easy solution to this.
 Thanks a lot for the help,
 
Hi Luca,
I decided to try using the split.screen function, which I had previously 
tried without getting what I wanted. This example:

split.screen(c(2,1))
screen(1)
screen()
plot(1:7)
screen(2)
plot(1:6)
screen(1,FALSE)
screen()
points(x=7:1,y=1:7,col=red)

when run with no graphics devices currently open, seems to work and do 
what you want. When I first tried it on an open device (x11) it would not 
switch screens properly, remaining on the top (first) screen despite calls 
to screen() that reported that the screen had changed. I tried this after 
opening a png device and it also worked correctly, so I think that if you 
are careful to initialize the graphics device immediately before 
split.screen it should do it.

Jim

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


Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Pascal Oettli
Hi Jim,

I tried your fix.

This one works:
barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

This one fails:
barp(c(2,3,4,5,6,7,8))

Regards,
Pascal

On Fri, Jun 13, 2014 at 7:09 PM, Jim Lemon j...@bitwrit.com.au wrote:
 On Fri, 13 Jun 2014 06:50:59 PM Pascal Oettli wrote:
 Dear list,

 Please consider the following example:

 library(plotrix)
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

 How to force the bars to start at 0? I could not find the way to do it.

 Hi Pascal,
 You are right, I had not considered the idea of setting a negative y limit
 when there were no negative values. I think you can fix this by changing:

  negy-any(height0,na.rm=TRUE)

  to

 negy-any(height0,na.rm=TRUE) || ylim[1]  0

 I'll check this later (I'm just going out) and if it doesn't work, I'll send
 another email with something that does.

 Jim




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] data format setting

2014-06-13 Thread Frede Aakmann Tøgersen
Hi Eliza

To me it seems like that you're not thinking before you messing about with the 
data before an analysis.

The years with data for 366 days is leap years. It happens every fourth year 
and the extra day falls on the 29th of februar. I guess it is the results from 
the dcast function that screws things up to make you believe that it's day 
number 366.

The best thing to do is to do your analysis on the complete data with some 
missing values for February 29th between leap years.

Or you can discard the leap year day for leap years and do the analysis for all 
years of 365 days.

What is the rationale by imputing missing data using the approx function? I 
mean the no leap year has only 365 days.

If you for some unknown reasons you want to fill in value for the NAs one 
natural way is to substitute the NAs on February 29th by the mean of the 
values on February 28th and Marts 1st. I think there is a na.approx function 
for that in some package (perhaps zoo). Other metods are available in R: google 
for R + impute.

Best Regards

Frede

Sendt fra Samsung mobil


 Oprindelig meddelelse 
Fra: eliza botto
Dato:13/06/2014 20.48 (GMT+01:00)
Til: r-help@r-project.org
Emne: Re: [R] data format setting

Thanks dennis,
It worked but I had to do some simple modifications to get to the ultimate 
format.
Now I have a list in the following format
$A
2004200520062007200820092010
..
...
...
..
...

$AY

196719682000...

some columns had 365 rows and some 366. those with 365 rows had their 366 row 
as NA.
Now I want to apply approx. command to interpolate 366 values to 365, but when 
I apply approx command I gives out something
which is with $x and $y, and frankly speaking it messed up everything.
Is their a way that i do it neatly without getting the format deteriorated?


In any way, thank-you very much indeed.

Eliza

 Date: Fri, 13 Jun 2014 11:11:37 -0700
 Subject: Re: [R] data format setting
 From: djmu...@gmail.com
 To: eliza_bo...@hotmail.com

 Hi:

 Maybe something like this:

 library(reshape2)
 L - split(DF, DF$year)
 L2 - llply(L, function(d) dcast(d, month + day ~ year, value.var =
 discharge))

 Obviously untested, so caveat emptor. The idea is to use the dcast
 function to reshape the data from long to wide format within year.

 Dennis

 On Fri, Jun 13, 2014 at 8:55 AM, eliza botto eliza_bo...@hotmail.com wrote:
 
  Dear R family,
  I hope you all be doing great. I have a dataset of following format. The 
  data file is of the following format.
 
st year month day discharge
  1  A 2004 1   1  6.752828
  2  A 2004 1   2  7.602053
  3  A 2004 1   3  5.583619
  4  A 2004 1   4  5.019562
  5  A 2004 1   5  4.804489
  6  A 2004 1   6  4.363541
  7  A 2004 1   7  3.801333
  8  A 2004 1   8  3.455991
  9  A 2004 1   9  3.402634
  10 A 2004 1  10  3.250693
  ..
  ..
  continue
  ..
  ..
   st year month day discharge
  2AY 196710   3  0.56
  20001AY 196710   4  0.56
  20002AY 196710   5  0.48
  20003AY 196710   6  0.56
  20004AY 196710   7  0.48
  20005AY 196710   8  0.40
  20006AY 196710   9  0.40
  20007AY 196710  10  0.56
  20008AY 196710  11  0.56
  20009AY 196710  12  0.65
  20010AY 196710  13  0.85
 
  you can see that there are five columns.
  The first column has the name of the station. I want to split the data 
  w.r.t the names of the stations. Each station has data for certain years. 
  for example A has data for years from 2004 to 2010 and for AY its from 
  1967 to 2000.similarly for other years there is data for different number 
  of years.
  I want to make a list of matrices each containing the data for that station 
  in the following format
  $A
  2004200520062007200820092010
  ..
  ...
  ...
  ..
  ...
 
  $AY
 
  196719682000
 
  each column should have 365 to 366 values depending on whether there is a 
  leap year or not. obviously for non-leap years 366th row should be an NA.
  kindly help me on it.
  Thankyou very much in advance.
  Eliza
 
 
  [[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]]


Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Jim Lemon
On Sat, 14 Jun 2014 12:57:12 PM you wrote:
 Hi Jim,
 
 I tried your fix.
 
 This one works:
 barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))
 
 This one fails:
 barp(c(2,3,4,5,6,7,8))
 
 Regards,
 Pascal
 
Hi Pascal,
Right again. This seems to work for both and I think handles the problem 
correctly:

 if(is.null(ylim)) {
  negy-any(height0,na.rm=TRUE)
  if(negy) miny-min(height,na.rm=TRUE)*1.05
  else miny-ifelse(ylog,min(height)/10,0)
  ylim-c(miny,max(height,na.rm=TRUE)*1.05)
 }
 else {
  miny-ylim[1]
  negy-miny0
 }

Remove the line:

negy-any(height0,na.rm=TRUE)

and modify the succeeding conditional clause as above. This will appear 
in version 3.5-8.

Jim

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


Re: [R] I have a question

2014-06-13 Thread Jim Lemon
On Sat, 14 Jun 2014 10:59:07 AM 오건희 wrote:
 Hi
 
 I got a wrong graph when I typed  
qplot(names(termFrequency),termFrequency,
 geom=bar, xlab=Terms,stat=bin)+coord_flip() 
 
 The frequency weren't displayed on the graph. what's the problem?
 
 I attached the screen shot to this e-mail.
 
Hi 오건희 ,
You seem to be supplying a character vector - names(termFrequency) - 
as the x argument to qplot. Making a wild guess that these names are 
actually numbers, perhaps:

as.numeric(names(termFrequency))

will work. If the wild guess was wrong, perhaps you want to specify 
termFrequency as the first argument. When something like this happens, 
it is often helpful to explicitly name your arguments:

qplot(x=names(termFrequency),y=termFrequency,
 geom=bar, xlab=Terms,stat=bin)+coord_flip()

This will sometimes give a meaningful error message that helps to 
identify what has gone wrong.

Jim

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


Re: [R-es] p values con LMER

2014-06-13 Thread Marcelino de la Cruz


Para obtener el pvalue de un t-test, lo que puedes hacer es

(1-pt(abs(tval), df=dftval))*2

donde tval es el valor de tu estadístico t (el que te sale en el 
summary) y  dftval son los grados de libertad del test.


La discusión sobre los p-valores en los modelos mixtos tiene que ver con 
cómo estimar adecuadamente los grados de libertad. Una vez decidas 
cuántos grados de libertad tienes, ya lo tienes solucionado ... ;-)


Saludos,

Marcelino




El 13/06/2014 14:05, José Luis Cañadas escribió:

Existe discusión sobre el uso de los p-valores en modelos mixtos. Como se
ha dicho antes, para mi  lo más adecuado es comparar modelos mediante la
función anova.  Por Internet se puede encontrar un buen libro de Douglas
Bates y en español,  busca modelos mixtos con R de Luis Cayuela, enfocado
hacia ecología, pero está muy bien
El 13/06/2014 14:00, Jorge I Velez jorgeivanve...@gmail.com escribió:


Hola Miguel,


2014-06-13 21:50 GMT+10:00 Miguel Lázaro lazar...@yahoo.es:


Hola Manuel
lo he tratado de hacer pero me sale

Error: unexpected string constante in:




Creo que te falto una 




anova(a,as,test=Chisq)


   ^
  debe ser
  anova(a, as, test = Chisq)

Saludos,
Jorge.-





no tengo ni idea de por qué...

Me resulta alucinante no poder contar ya con pvals.fnc. ¿Será imposible
hacerse con ello?

Saludos,
Miguel




El vie, 13/6/14, Manuel Azcárate mazcarategar...@gmail.com escribió:

  Asunto: Re: [R-es] p values con LMER
  Para: Miguel Lázaro lazar...@yahoo.es
  CC: r-help-es@r-project.org
  Fecha: viernes, 13 de junio, 2014 13:21



  Hola Miguel,


  Aunque algo más arduo que
  algún paquete que lo calcule
  directamente, yo lo que hago es crear un modelo reducido sin
  la variable de la
  que quiero saber el pvalor y compararlos mediante un test
  anova. El valor
  obtenido por esta comparación puede utilizarse con el
  pvalor de esa variable.


  Por ejemplo:

  Lm1=lmer(rt_ln ~ (fre_ln *
  Z_nsize * frebase_ln + (1|word),
  data = x)

  Lm2= lmer(rt_ln ~ (Z_nsize
  * frebase_ln + (1|word), data =
  x)

  anova(Lm1,Lm2,
  test=Chisq) #Obtiens el pvalor de
  la variable fre_ln



  Lm3=lmer(rt_ln ~ (fre_ln *
  frebase_ln + (1|word), data = x)

  anova(Lm1,Lm3,
  test=Chisq) #Obtiens el pvalor de
  la variable  Z_nsize



  Espero que te sea de
  utilidad,

  Un saludo

  Manuel



  El 13 de junio de 2014,
  12:25, Miguel Lázaro lazar...@yahoo.es
  escribió:

  Hola
  a todos,

  quería preguntaros un medio para obtener los valores p
  usando lmer. He tratado con pvals.fnc, que es lo que me
  habían recomendado, pero por algún motivo no está ya
  disponible etc.



  Ésta es la función que tengo, pero da las t,
  sin los valores p. Aunque Baayen indica que valores por
  encima de 2 son significativos necesito saber las p.



  resultado = lmer(rt_ln ~ (fre_ln * Z_nsize * frebase_ln +
  (1|word) data = x)  (abreviado)

  = print (resultado, c=F)



  Fixed effects:

 Estimate Std. Error t value

  (Intercept)6.640496   0.034490  192.54

  fre_ln-0.046880   0.008278   -5.66

  Z_nsize0.005787   0.0088490.65

  frebase_ln-0.009938   0.006670   -1.49

  Z_wlength 14.239570  20.1025360.71

  Z_slength  0.011011   0.0066921.65

  Z_TF   0.009903   0.0088011.13

  Z_prodctvsufij-0.005079   0.009052   -0.56

  Z_rootlenght -17.961932  25.420022   -0.71

  Zaverageres_1  0.018265   0.0091951.99

  Zrootlengthres_1  10.954681  15.5111460.71







  Saludos,



  Miguel



  ___

  R-help-es mailing list

  R-help-es@r-project.org

  https://stat.ethz.ch/mailman/listinfo/r-help-es

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



 [[alternative HTML version deleted]]


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




[[alternative HTML version deleted]]



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



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


Re: [R-es] p values con LMER

2014-06-13 Thread Miguel Lázaro
Sí, en efecto, aunque es muy extraño porque lo ahbía mirado. Me faltaba unas 
comillas.
Ahora lo veo ahí bien claro.

Como decís hay una enorme discusión sobre esto de los valores y supongo que si 
no los dan directamente en lmer será porque decidieron no hacerlo. En todo caso 
el tema de pvals.fnc, para lo que usamos la estadística a nivel usuario, estaba 
fenomenal.
Utilizo el procedimiento que me habéis mostrado y quedo a la expectativa de que 
vuelva a estar disponible, o algo similar, lo anterior.

¡muchas gracias!

Miguel



El vie, 13/6/14, José Luis Cañadas canadasre...@gmail.com escribió:

 Asunto: Re: [R-es] p values con LMER
 Para: Jorge I Velez jorgeivanve...@gmail.com
 CC: Miguel Lázaro lazar...@yahoo.es, r-help-es r-help-es@r-project.org
 Fecha: viernes, 13 de junio, 2014 14:05

 Existe
 discusión sobre el uso de los p-valores en modelos mixtos.
 Como se ha dicho antes, para mi  lo más adecuado es
 comparar modelos mediante la función anova.  Por Internet
 se puede encontrar un buen libro de Douglas Bates y en
 español,  busca modelos mixtos con R de Luis Cayuela,
 enfocado hacia ecología, pero está muy bien 

 El 13/06/2014 14:00,
 Jorge I Velez jorgeivanve...@gmail.com
 escribió:

 Hola Miguel,





 2014-06-13 21:50 GMT+10:00 Miguel Lázaro lazar...@yahoo.es:



  Hola Manuel

  lo he tratado de hacer pero me sale

 

  Error: unexpected string constante in:

 





 Creo que te falto una 





 

  anova(a,as,test=Chisq)

 

       ^

              debe ser

                                  anova(a,
 as, test = Chisq)



 Saludos,

 Jorge.-







 

  no tengo ni idea de por qué...

 

  Me resulta alucinante no poder contar ya con pvals.fnc.
 ¿Será imposible

  hacerse con ello?

 

  Saludos,

  Miguel

 

 

 

  

  El vie, 13/6/14, Manuel Azcárate mazcarategar...@gmail.com
 escribió:

 

   Asunto: Re: [R-es] p values con LMER

   Para: Miguel Lázaro lazar...@yahoo.es

   CC: r-help-es@r-project.org

   Fecha: viernes, 13 de junio, 2014 13:21

 

 

 

   Hola Miguel,

 

 

   Aunque algo más arduo que

   algún paquete que lo calcule

   directamente, yo lo que hago es crear un modelo
 reducido sin

   la variable de la

   que quiero saber el pvalor y compararlos mediante un
 test

   anova. El valor

   obtenido por esta comparación puede utilizarse con
 el

   pvalor de esa variable.

 

 

   Por ejemplo:

 

   Lm1=lmer(rt_ln ~ (fre_ln *

   Z_nsize * frebase_ln + (1|word),

   data = x)

 

   Lm2= lmer(rt_ln ~ (Z_nsize

   * frebase_ln + (1|word), data =

   x)

 

   anova(Lm1,Lm2,

   test=Chisq) #Obtiens el pvalor de

   la variable fre_ln

 

 

 

   Lm3=lmer(rt_ln ~ (fre_ln *

   frebase_ln + (1|word), data = x)

 

   anova(Lm1,Lm3,

   test=Chisq) #Obtiens el pvalor de

   la variable  Z_nsize

 

 

 

   Espero que te sea de

   utilidad,

 

   Un saludo

 

   Manuel

 

 

 

   El 13 de junio de 2014,

   12:25, Miguel Lázaro lazar...@yahoo.es

   escribió:

 

   Hola

   a todos,

 

   quería preguntaros un medio para obtener los valores
 p

   usando lmer. He tratado con pvals.fnc, que es lo que
 me

   habían recomendado, pero por algún motivo no está
 ya

   disponible etc.

 

 

 

   Ésta es la función que tengo, pero da las
 t,

   sin los valores p. Aunque Baayen indica que valores
 por

   encima de 2 son significativos necesito saber las
 p.

 

 

 

   resultado = lmer(rt_ln ~ (fre_ln * Z_nsize *
 frebase_ln +

   (1|word) data = x)  (abreviado)

 

   = print (resultado, c=F)

 

 

 

   Fixed effects:

 

                      Estimate Std. Error t
 value

 

   (Intercept)        6.640496   0.034490
  192.54

 

   fre_ln            -0.046880   0.008278  
 -5.66

 

   Z_nsize            0.005787   0.008849  
  0.65

 

   frebase_ln        -0.009938   0.006670  
 -1.49

 

   Z_wlength         14.239570  20.102536  
  0.71

 

   Z_slength          0.011011   0.006692  
  1.65

 

   Z_TF               0.009903   0.008801  
  1.13

 

   Z_prodctvsufij    -0.005079   0.009052   -0.56

 

   Z_rootlenght     -17.961932  25.420022   -0.71

 

   Zaverageres_1      0.018265   0.009195  
  1.99

 

   Zrootlengthres_1  10.954681  15.511146    0.71

 

 

 

 

 

 

 

   Saludos,

 

 

 

   Miguel

 

 

 

   ___

 

   R-help-es mailing list

 

   R-help-es@r-project.org

 

   https://stat.ethz.ch/mailman/listinfo/r-help-es

 

  ___

  R-help-es mailing list

  R-help-es@r-project.org

  https://stat.ethz.ch/mailman/listinfo/r-help-es

 



         [[alternative HTML version deleted]]




 ___

 R-help-es mailing list

 R-help-es@r-project.org

 https://stat.ethz.ch/mailman/listinfo/r-help-es

___
R-help-es mailing list
R-help-es@r-project.org

[R-es] Crear matriz binaria

2014-06-13 Thread Rolando Valdez
Hola,

Estoy tratando de crear una matriz cuadrada, binaria y no tengo idea por dónde 
comenzar.

Los datos que tengo son patentes e inventores por patente, las patentes las 
identifico por su código y a los inventores por nombre y también los tengo 
codificados.

Deseo hacer una matriz de nxn en donde los renglones son inventores de la A a 
la Z y columnas son los mismos inventores de la A a la Z, las entradas de la 
matriz corresponderán a 1 si el inventor A tiene una patente con el inventor 
K…L…M, cualquier otra situación será cero. Evidentemente la matriz debe tener 
ceros en la diagonal pues el inventor B no puede patentar algo con el inventor 
B.

Pues bien, intenté hacerlo en excel con tablas dinámicas pero no me permite 
poner la misma variable (inventores) en renglones y columnas. Pensé que se 
puede hacer en R, pero no tengo idea por dónde empezar, nisiquiera cuál sería 
la mejor forma de ordenar los datos.

Si pudieran ayudarme sugiréndome algún manual o algún ejemplo para comenzar, se 
los agradezco de antemano.

Saludos.

Rolando Valdez

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


Re: [R-es] Crear matriz binaria

2014-06-13 Thread Rolando Valdez
Hola,

Esta es una tabla dinámica que cree, en donde los renglones son los inventores 
y las columnas son patentes, las entradas de la matriz tienen 1 en aquellos 
inventores que participan por patente.

https://www.dropbox.com/s/b8gx0hei6w91ko0/tabla_din.xlsx

Esta es otra tabla es un arreglo parecido al de arriba, sólo que los renglones 
son patentes y las columnas son número de inventores, tienen 1 en donde 
participan inventores en la patente.

https://www.dropbox.com/s/xpi0hescm1xm58c/tabla_din2.xlsx

Este es otro arreglo donde sólo hay tres columnas, patentes, número de inventor 
e inventor.

https://www.dropbox.com/s/rmmgiswmbppt68w/datos_col.csv


El 13/06/2014, a las 10:27, Jorge I Velez jorgeivanve...@gmail.com escribió:

 Hola Rolando,
 
 Podrias enviarnos una submatriz de esos datos?   Quizas tusdatos[1:10, 1:10]? 
   Creo que es mas facil trabajar sobre ello.  
 
 Gracias,
 Jorge.-
 
 
 
 2014-06-14 1:10 GMT+10:00 Rolando Valdez rvald...@gmail.com:
 Hola, no encuentro el momento en el que  se relacionan los inventores, es 
 decir, lo que relaciona a dos o más inventores es la patente.
 
 Primero, ¿cómo debo ordenar los datos?
 
 Tengo 1813 número de patentes, es decir, la matriz es de dimension 1813 x 
 1813.
 
 Tengo varios órdenes en los datos, por ejemplo, el primer arreglo es por 
 patente, en las columnas tengo “no. de patente”, “inventor 1”, “inventor 2”, 
 “inventor 3”…… “inventor 13”, y en las filas tengo números de patente. En las 
 entradas tengo nombre del inventor.
 
 Otro arreglo que tengo es mediante una tabla dinámica que hice en donde tengo 
 por columnas “nombre de inventor”, “inventor 1”, “inventor 2”……. “ inventor 
 13”. En los renglones tengo nombres de inventor y en las entradas tengo 1 y 0.
 
 Saludos.
 El 13/06/2014, a las 09:14, Jorge I Velez jorgeivanve...@gmail.com escribió:
 
  Hola Rolando,
 
  Podrias adaptar lo siguiente:
 
  set.seed(10)
  X - matrix(sample(0:1, 100, replace = TRUE), ncol = 10)
  colnames(X) - LETTERS[1:10]
  X
 
  Y - X = 1
  Y - apply(Y, 2, as, numeric) #boolean matrix
  rownames(Y) - rownames(X)
  Z - t(Y) %*% Y  #adjacency matrix
  Z[Z = 1] - 1
  diag(Z) - 0
  Z
 
  Saludos,
  Jorge.-
 
 
  2014-06-14 0:08 GMT+10:00 Rolando Valdez rvald...@gmail.com:
  Hola,
 
  Estoy tratando de crear una matriz cuadrada, binaria y no tengo idea por 
  dónde comenzar.
 
  Los datos que tengo son patentes e inventores por patente, las patentes las 
  identifico por su código y a los inventores por nombre y también los tengo 
  codificados.
 
  Deseo hacer una matriz de nxn en donde los renglones son inventores de la A 
  a la Z y columnas son los mismos inventores de la A a la Z, las entradas de 
  la matriz corresponderán a 1 si el inventor A tiene una patente con el 
  inventor K…L…M, cualquier otra situación será cero. Evidentemente la matriz 
  debe tener ceros en la diagonal pues el inventor B no puede patentar algo 
  con el inventor B.
 
  Pues bien, intenté hacerlo en excel con tablas dinámicas pero no me permite 
  poner la misma variable (inventores) en renglones y columnas. Pensé que se 
  puede hacer en R, pero no tengo idea por dónde empezar, nisiquiera cuál 
  sería la mejor forma de ordenar los datos.
 
  Si pudieran ayudarme sugiréndome algún manual o algún ejemplo para 
  comenzar, se los agradezco de antemano.
 
  Saludos.
 
  Rolando Valdez
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es
 
 
 Rolando Valdez
 
 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es
 

Rolando Valdez

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