[R] Problems in setting up in MARSS package

2013-08-30 Thread Nilesh Gupta
I am trying to model a state space process using the MARSS package. My
model has two unobservable states and 5 observable time series
along with external covariates in the observation process only. None of the
coefficients in either of the two processes are time varying.
After running my setup and then fitting with MARSS with the fit=FALSE
option turned on I get the following outputs.

Model Structure is
m: 2 state process(es)
n: 5 observation time series
Z :  unconstrained
A :  time-varying
R :  unconstrained
B :  unconstrained
U :  unconstrained
Q :  unconstrained
x0 :  fixed
V0 :  identity

Obviously I have no idea why A has been classfied as time varying. Can
anyone help me as to how to do this correctly ?
A is initialized like this
A1 - zero


The full code has been copied below
#For two  states
B1 - matrix(c(b1,b2,b3,b4),2,2)   #For 2 states
U1 - matrix(c(u1,u2),2,1) #For 2 states
Q1 - unconstrained
Z1 - matrix(c(z1,z2,z3,z4,z5,z6,z7,z8,z9,z10),5,2)
#For 2 states

#Initial Parameters
pi1 - matrix(c(1,2),2,1)
V1 - diag(1,2)
A1 - zero

R1 - matrix(list(r11,r12,r13,r14,r15,
  r12,r22,r23,r24,r25,
  r13,r23,r33,r34,r35,
  r14,r24,r34,r44,r45,
  r15,r25,r35,r45,r55,
  r16,r26,r36,r46,r56)
 ,5,5)
D - unconstrained
d - covariate.data
rownames(d) - rownames(covariate.data)
model.list -
list(B=B1,U=U1,Q=Q1,Z=Z1,A=A1,R=R1,D=D,d=d,x0=pi1,V0=V1,tinitx=0)

fit -
MARSS(yt,model=model.list,control=list(maxit=1,trace=0),fit=FALSE)

Regards
The woods are lovely, dark and deep
But I have promises to keep
And miles to go before I sleep
And miles to go before I sleep
-

[[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] spacing problem in main title using car package scatterplot

2013-08-30 Thread peter dalgaard

On Aug 29, 2013, at 23:56 , John Fox wrote:

 Dear Gerard,
 
 Without your data, it's not possible to reproduce your problem exactly, but
 it's clear that it isn't specific to the scatterplot() function in the car
 package. For example, try
 
 plot(1:10)
 title(main=bquote(paste(Hypothesis 9.4.1\nBaseline XYZ with Disease
 Activity (DAS28)\nat Month 18 (N=, 100 ,))), adj=0)

As far as I can tell, the issue is nothing to do with justification. It's 
because it is pasting the number onto a three-line block of text, so the 
longest line determines where the next thing goes. Using atop() might help, 
except that it doesn't left justify.  

BTW, Gerard, please don't create new threads by replying to old ones. On 
threading mail programs like OSX Mail, this drags in problems with abline 
from October 2010 and two other old threads...

-Peter D.

 
 You should be able to adapt the following solution:
 
 plot(1:10)
 mtext(Hypothesis 9.4.1\nBaseline XYZ with Disease Activity (DAS28),
 side=3, line=2)
 mtext(paste(at Month 18 (N=, 100 ,), sep=), side=3, line=1)
 
 I hope this helps,
 John
 
 ---
 John Fox
 McMaster University
 Hamilton, Ontario, Canada
 
 
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Gerard Smits
 Sent: Thursday, August 29, 2013 5:00 PM
 To: r-help@r-project.org
 Subject: [R] spacing problem in main title using car package
 scatterplot
 
 Hi All,
 
 I'm using R 3.0.0.  I'm trying to add the sample size of the paired
 data (calculated by a function n(), which returns a value of 70,
 correctly).
 
 My main title works fine except that the '70' appears far to the right
 on the line as in:
 
  at Month 18 (N=   70)
 
 Is there a way of left justifying the result of .(ss)?  or some other
 way of removing with whitespace between n= and 70?.
 
 Thanks for any suggestions.
 
 Gerard
 
 
 
 
 library (car)
 data-read.csv(//users//smits//r_work//data.csv, header = TRUE)
 attach(data);
 
 ###
 ###
 ss-n(m18_das28*b_score)
 
 scatterplot(m18_das28~b_score,
 jitter=list(x=1, y=1),
 grid=F,
 smooth=F,
 las=1,
 pch=c(1),
 col='blue',
 main=bquote(paste(Hypothesis 9.4.1\nBaseline XYZ with Disease
 Activity (DAS28)\nat Month 18 (N=,.(ss),))),
 xlab=Baseline XYZ,
 ylab=Month 18 DAS28,
 legend.plot=F)
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.

-- 
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] Outliers Help

2013-08-30 Thread Mª Teresa Martinez Soriano
This is my a part of my data set 

 D[1:15,c(1,5:10)]

   X.  media IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010
1   1108   22.060.0  39 4.0 8.016.0 5.0
2   1479  110.0  NA  NA53.0  1166.0   344.8   110.0
3   1591   86.6   247.0  8795.094.081.076.0
4   3408  807.0   302.0 322   621.0  1071.0  1301.0  1225.0
5   34239.0  NA  NA  NA   410.8 7.011.0
6   3872  103.25000   288.6 113   116.090.094.0 12036.6
7   5823   73.0   117.0  7080.074.069.072.0
8   6051   73.0  NA  NA  NA  NA60.086.0
9   8099  125.16667   196.0 161   150.094.072.078.0
10  8100   70.0  NA  NA  NA  NA48.092.0
11 10640   67.3  1256.61152   664.274.077.051.0
12 12600 2417.0  1960.02383  2453.0  2506.0  2758.0  2442.0
13 14680   38.030.0  61   373.642.019.0   220.8
14 14698  698.16667   553.0 664   847.0   800.0   679.0   646.0
15 17143  392.16667   323.0 322   434.0   383.0   459.0   432.0

 



 I have done multiple imputation and now I have some outliers which I would 
like to replace with the mean of this row or if it is possible with the mean of 
the previos and the next value of this row, I mean for instance:

value 1 - Outlier- Value 2

I would like to replace the outlier with the mean of value 1 and value2, the 
problem is that this values could be NA ( NA after the imputation because they 
don't exist), in this case I would like to replace outlier with the mean of the 
row.


An other problem I have is to detect correctly outlier values, for instance in 
this example of data set for X=3872 and IE.2010, we can see an outlier, I have 
thought to compare the values with the mean ( column media) 

I have tried to do this code
 

 D-datos[, c(1,16:24)]
 m-as.matrix(D) 
 for( i in 1: nrow(D))

{
  
   for( j in 5:(ncol(D)-1)) # I would change this in the new data set, because 
I will have more years than 2010
{   
   if(!is.na(m[i,j]) !is.na 
(m[i,j+1])!is.na(m[i,j-1])!is.na(m[i,2])((m[i,j]/m[i,2])4)){m[m[i,j]]- 
(m[i,j-1]+m[i,j+1])/2 # Here I would like to find the values that are much more 
bigger than the mean of this row, 
#if( !is.na(m[i,j])
# and replace them by the mean of the previous and the next values of the 
same row.
   
  } 
  }
}
D-as.data.frame(m)

But I get a data.frame that I had previously, it changes nothing




I accept any idea.
 Thanks a lot, Teresa 
[[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] scale breaks

2013-08-30 Thread Shane Carey
Thanks


On Fri, Aug 30, 2013 at 1:49 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/30/2013 01:28 AM, Shane Carey wrote:

 Hello all,

 I have decided to go ahead with gap.boxplot. I am trying to suppress the
 axis labels, both x and y labels. I tried using axis.labels=NULL but it
 would not work.

  Hi Shane,
 To suppress the axis labels, pass an empty string:

 gap.barplot(...,xlab=,ylab=**,...)

 Many default values of NULL tell the function to work out labels from the
 data, usually names.

 Jim




-- 
Shane

[[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] create new column to combine 2 data.frames

2013-08-30 Thread Mat
Hello together i have a little problem with the combine of two data.frames.

I have 2 data.frames, which look like this one:

first dataframe:
ID Name
1  Jack
2  John
3  Jill

second dataframe
ID  Days  Type
13   Training
21   Management 
34   Training

At the end i want to create a data.frame like this one (the Type should be
the new column and the entry of the column should be the days):

ID Name  TrainingManagement
1  Jack30
2  John01
3  Jill   40

maybe anyone can help me, how i can do this.

Thanks a lot.

Best regards. Mat



--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-to-combine-2-data-frames-tp4674963.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] create new column to combine 2 data.frames

2013-08-30 Thread Rui Barradas

Hello,

Suposing that your data frames are named dat1 and dat2, the following 
works, but it's a bit complicated, maybe there are simpler solutions.




dat1 - read.table(text = 
ID Name
1  Jack
2  John
3  Jill
, header = TRUE, stringsAsFactors = FALSE)

dat2 - read.table(text = 
ID  Days  Type
13   Training
21   Management
34   Training
, header = TRUE, stringsAsFactors = FALSE)

library(reshape2)
tmp - dcast(data = dat2, ID ~ Type, value.var = Type)

tmp[-1] - lapply(tmp[-1], function(x){
y - integer(length(x))
y[!is.na(x)] - dat2[[Days]][!is.na(x)]
y})
result - merge(dat1, tmp)
result


Hope this helps,

Rui Barradas

Em 30-08-2013 09:37, Mat escreveu:

Hello together i have a little problem with the combine of two data.frames.

I have 2 data.frames, which look like this one:

first dataframe:
ID Name
1  Jack
2  John
3  Jill

second dataframe
ID  Days  Type
13   Training
21   Management
34   Training

At the end i want to create a data.frame like this one (the Type should be
the new column and the entry of the column should be the days):

ID Name  TrainingManagement
1  Jack30
2  John01
3  Jill   40

maybe anyone can help me, how i can do this.

Thanks a lot.

Best regards. Mat



--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-to-combine-2-data-frames-tp4674963.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] Running pre R.14 version of R with R3.0.0

2013-08-30 Thread Uwe Ligges



On 29.08.2013 16:33, Luvalle, Michael J (Michael) wrote:

I upgraded R from 2.12.1 to 3.0.0 (on windows XP(, and as soon as I saved the 3.0.0 workspace, was 
unable to access .Rdata from 2.12.1.  The message in the R console is Error in 
loadNamesSpace(name): there is no package called parallel and a popup window that says 
Fatal error: unable to restore saved date in .Rdata

Is there anything that can be done to access the old .Rdata  without destroying 
the new?


Is it not possible to read all the RData files with a recent R such as 
R-3.0.1?


If not, what is the error message? Your is from reading new files with 
an old R.



Uwe Ligges




Thanks

[[alternative HTML version deleted]]

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



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


Re: [R] create new column to combine 2 data.frames

2013-08-30 Thread Mat
Thanks first.

that doesn't look bad. But if have a equal ID in dat2, the days are no
longer correct.

the correct data.frame has to look like this one:

  ID Name Management Training
1  1 Jack  13
2  2 John  10
3  3 Jill  04

not this one:

  ID Name Management Training
1  1 Jack  11
2  2 John  30
3  3 Jill  01

 dat1 - read.table(text = 
+ ID Name
+ 1  Jack
+ 2  John
+ 3  Jill
+ , header = TRUE, stringsAsFactors = FALSE)
 
 dat2 - read.table(text = 
+ ID  Days  Type
+ 11   Management 
+ 13   Training
+ 21   Management
+ 34   Training
+ , header = TRUE, stringsAsFactors = FALSE)
 
 library(reshape2)
 tmp - dcast(data = dat2, ID ~ Type, value.var = Type)
 
 tmp[-1] - lapply(tmp[-1], function(x){
+ y - integer(length(x))
+ y[!is.na(x)] - dat2[[Days]][!is.na(x)]
+ y})
 result - merge(dat1, tmp)
 result
  ID Name Management Training
1  1 Jack  11
2  2 John  30
3  3 Jill  01
 



--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-to-combine-2-data-frames-tp4674963p4674968.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] Outliers Help

2013-08-30 Thread Jose Iparraguirre
Hi Ma Teresa,

Sorry, but I can't understand what you're trying to achieve.
On a statistical note, I'd tend to think more in terms of medians and would 
think hard before replacing any outliers, but that's another matter.

Here I created the dataframe dd with the means column of D in its first column, 
and then populated with a 1 whenever the value of D for that cell was greater 
than 4 times the mean for that row -your definition of 'outlier'. 
 dd - rep(0,15*7)
 dim(dd) - c(15,7)
 dd[,1]- D[,1]
 for (i in 1:15){
+ for (j in 2:7){
+ dd[i,j] - D[i,(j+1)]/D[i,2]4
+ }
+ }
 dd
   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,]  1108000000
 [2,]  1479   NA   NA0100
 [3,]  1591000000
 [4,]  3408000000
 [5,]  3423   NA   NA   NA100
 [6,]  3872000001
 [7,]  5823000000
 [8,]  6051   NA   NA   NA   NA00
 [9,]  8099000000
[10,]  8100   NA   NA   NA   NA00
[11,] 10640111000
[12,] 12600000000
[13,] 14680001001
[14,] 14698000000
[15,] 17143000000

So, you encounter four situations:

a) as in row 2, you have an outlier preceded and followed by values
b) as in row 5, you have an outlier preceded by an NA
c) as in row 6, there is an outlier in the last column
d) as in row 11, there are two or more consecutive outliers


The replacement rule you described would only apply to situations a) (ie 
replacing the outlier by the mean of the preceding and subsequent values), and 
b) (replacing it by the mean for the row).
But what of situations c) and d)?

And, because this is just a chunk of a bigger dataset, you can also get an 
outlier in the first column, followed by a number. Again, your rule has not 
accounted for this situation either.

Hope this helps,

José

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mª Teresa Martinez Soriano
Sent: 30 August 2013 09:13
To: r-help@r-project.org
Subject: [R] Outliers Help

This is my a part of my data set 

 D[1:15,c(1,5:10)]

   X.  media IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010
1   1108   22.060.0  39 4.0 8.016.0 5.0
2   1479  110.0  NA  NA53.0  1166.0   344.8   110.0
3   1591   86.6   247.0  8795.094.081.076.0
4   3408  807.0   302.0 322   621.0  1071.0  1301.0  1225.0
5   34239.0  NA  NA  NA   410.8 7.011.0
6   3872  103.25000   288.6 113   116.090.094.0 12036.6
7   5823   73.0   117.0  7080.074.069.072.0
8   6051   73.0  NA  NA  NA  NA60.086.0
9   8099  125.16667   196.0 161   150.094.072.078.0
10  8100   70.0  NA  NA  NA  NA48.092.0
11 10640   67.3  1256.61152   664.274.077.051.0
12 12600 2417.0  1960.02383  2453.0  2506.0  2758.0  2442.0
13 14680   38.030.0  61   373.642.019.0   220.8
14 14698  698.16667   553.0 664   847.0   800.0   679.0   646.0
15 17143  392.16667   323.0 322   434.0   383.0   459.0   432.0

 



 I have done multiple imputation and now I have some outliers which I would 
like to replace with the mean of this row or if it is possible with the mean of 
the previos and the next value of this row, I mean for instance:

value 1 - Outlier- Value 2

I would like to replace the outlier with the mean of value 1 and value2, the 
problem is that this values could be NA ( NA after the imputation because they 
don't exist), in this case I would like to replace outlier with the mean of the 
row.


An other problem I have is to detect correctly outlier values, for instance in 
this example of data set for X=3872 and IE.2010, we can see an outlier, I have 
thought to compare the values with the mean ( column media) 

I have tried to do this code
 

 D-datos[, c(1,16:24)]
 m-as.matrix(D) 
 for( i in 1: nrow(D))

{
  
   for( j in 5:(ncol(D)-1)) # I would change this in the new data set, because 
I will have more years than 2010
{   
   if(!is.na(m[i,j]) !is.na 
(m[i,j+1])!is.na(m[i,j-1])!is.na(m[i,2])((m[i,j]/m[i,2])4)){m[m[i,j]]- 
(m[i,j-1]+m[i,j+1])/2 # Here I would like to find the values that are much more 
bigger than the mean of this row, 
#if( !is.na(m[i,j])
# and replace them by the mean of the previous and the next values of the 
same row.
   
  } 
  }
}
D-as.data.frame(m)

But I get a data.frame that I had previously, it changes nothing




I accept any idea.
 Thanks a lot, Teresa 
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the 

Re: [R] scale breaks

2013-08-30 Thread Shane Carey
Hi,

xlab=,
ylab,

Would not work.

Thanks


On Fri, Aug 30, 2013 at 9:37 AM, Shane Carey careys...@gmail.com wrote:

 Thanks


 On Fri, Aug 30, 2013 at 1:49 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/30/2013 01:28 AM, Shane Carey wrote:

 Hello all,

 I have decided to go ahead with gap.boxplot. I am trying to suppress the
 axis labels, both x and y labels. I tried using axis.labels=NULL but it
 would not work.

  Hi Shane,
 To suppress the axis labels, pass an empty string:

 gap.barplot(...,xlab=,ylab=**,...)

 Many default values of NULL tell the function to work out labels from the
 data, usually names.

 Jim




 --
 Shane




-- 
Shane

[[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] scale breaks

2013-08-30 Thread Berend Hasselman

On 30-08-2013, at 11:49, Shane Carey careys...@gmail.com wrote:

 Hi,
 
 xlab=,
 ylab,
 

You were told to use xlab=, ylab=

You seem to have omitted the  = after ylab

Berend

 Would not work.
 
 Thanks
 
 
 On Fri, Aug 30, 2013 at 9:37 AM, Shane Carey careys...@gmail.com wrote:
 
 Thanks
 
 
 On Fri, Aug 30, 2013 at 1:49 AM, Jim Lemon j...@bitwrit.com.au wrote:
 
 On 08/30/2013 01:28 AM, Shane Carey wrote:
 
 Hello all,
 
 I have decided to go ahead with gap.boxplot. I am trying to suppress the
 axis labels, both x and y labels. I tried using axis.labels=NULL but it
 would not work.
 
 Hi Shane,
 To suppress the axis labels, pass an empty string:
 
 gap.barplot(...,xlab=,ylab=**,...)
 
 Many default values of NULL tell the function to work out labels from the
 data, usually names.
 
 Jim
 
 
 
 
 --
 Shane
 
 
 
 
 -- 
 Shane
 
   [[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] scale breaks

2013-08-30 Thread Shane Carey
This is what I put in:
gap.boxplot(DATA$Conductivity~factor(DATA$UnitName_1),ylim=c(LOWER_Y_Conductivity,UPPER_Y_Conductivity_int),gap=gap_Conductivity,
col=colours,outwex=one,whisklty = solid,whisklwd=lwth,outcol=
black, outpch=dtsym,  outcex=dtsize,
range=1.5,xlab=,ylab=)

My aim is to not show the labels at the tick marks as I will add them to
the plot afterwards



On Fri, Aug 30, 2013 at 10:55 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 30-08-2013, at 11:49, Shane Carey careys...@gmail.com wrote:

  Hi,
 
  xlab=,
  ylab,
 

 You were told to use xlab=, ylab=

 You seem to have omitted the  = after ylab

 Berend

  Would not work.
 
  Thanks
 
 
  On Fri, Aug 30, 2013 at 9:37 AM, Shane Carey careys...@gmail.com
 wrote:
 
  Thanks
 
 
  On Fri, Aug 30, 2013 at 1:49 AM, Jim Lemon j...@bitwrit.com.au wrote:
 
  On 08/30/2013 01:28 AM, Shane Carey wrote:
 
  Hello all,
 
  I have decided to go ahead with gap.boxplot. I am trying to suppress
 the
  axis labels, both x and y labels. I tried using axis.labels=NULL but
 it
  would not work.
 
  Hi Shane,
  To suppress the axis labels, pass an empty string:
 
  gap.barplot(...,xlab=,ylab=**,...)
 
  Many default values of NULL tell the function to work out labels from
 the
  data, usually names.
 
  Jim
 
 
 
 
  --
  Shane
 
 
 
 
  --
  Shane
 
[[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.




-- 
Shane

[[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] Changing string to date

2013-08-30 Thread Christofer Bogaso
Hello again,

I have a string which I need to put in some legitimate date format.

My string is: MAY-14

And output format would be 05/01/2014, this should be of Date class,
so that I can make some sensible calculation with it.

I have tried this without any success:

 as.Date(MAY-14, format = %b-%y)
[1] NA


Can somebody help me how I can achieve that?

Thanks and regards,

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


Re: [R] scale breaks

2013-08-30 Thread Jim Lemon

On 08/30/2013 07:57 PM, Shane Carey wrote:

This is what I put in:
gap.boxplot(DATA$Conductivity~factor(DATA$UnitName_1),ylim=c(LOWER_Y_Conductivity,UPPER_Y_Conductivity_int),gap=gap_Conductivity,
 col=colours,outwex=one,whisklty =
solid,whisklwd=lwth,outcol= black, outpch=dtsym,  outcex=dtsize,
 range=1.5,xlab=,ylab=)

My aim is to not show the labels at the tick marks as I will add them to
the plot afterwards

Ah, not the axis labels but the tick labels. This is something I had not 
put into the function. You can edit the gap.boxplot function to do this 
by commenting out line 53:


# axis(1,labels=bxpt$names,at=1:nboxes)

saving the function (call it gap.boxplot2.R) and sourcing the edited 
function:


library(plotrix)
source(gap.boxplot2.R)
gap.boxplot(...)

Remember that you have to load plotrix, _then_ source the new function.
Jim

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


Re: [R] create new column to combine 2 data.frames

2013-08-30 Thread Rui Barradas

Hello,

Ok, try instead



library(reshape2)
tmp - dcast(data = dat2, ID ~ Type, value.var = Type)

tmp[-1] - lapply(tmp[-1], function(x){
y - integer(length(x))
s - as.character(x[!is.na(x)])[1]
idx - which(as.character(dat2[[Type]]) == s)
y[!is.na(x)] - dat2[[Days]][idx]
y})

result - merge(dat1, tmp)
result


Rui Barradas

Em 30-08-2013 10:27, Mat escreveu:

Thanks first.

that doesn't look bad. But if have a equal ID in dat2, the days are no
longer correct.

the correct data.frame has to look like this one:

   ID Name Management Training
1  1 Jack  13
2  2 John  10
3  3 Jill  04

not this one:

   ID Name Management Training
1  1 Jack  11
2  2 John  30
3  3 Jill  01


dat1 - read.table(text = 

+ ID Name
+ 1  Jack
+ 2  John
+ 3  Jill
+ , header = TRUE, stringsAsFactors = FALSE)


dat2 - read.table(text = 

+ ID  Days  Type
+ 11   Management
+ 13   Training
+ 21   Management
+ 34   Training
+ , header = TRUE, stringsAsFactors = FALSE)


library(reshape2)
tmp - dcast(data = dat2, ID ~ Type, value.var = Type)

tmp[-1] - lapply(tmp[-1], function(x){

+ y - integer(length(x))
+ y[!is.na(x)] - dat2[[Days]][!is.na(x)]
+ y})

result - merge(dat1, tmp)
result

   ID Name Management Training
1  1 Jack  11
2  2 John  30
3  3 Jill  01






--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-to-combine-2-data-frames-tp4674963p4674968.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] Changing string to date

2013-08-30 Thread Uwe Ligges



On 30.08.2013 11:59, Christofer Bogaso wrote:

Hello again,

I have a string which I need to put in some legitimate date format.

My string is: MAY-14

And output format would be 05/01/2014, this should be of Date class,
so that I can make some sensible calculation with it.

I have tried this without any success:


as.Date(MAY-14, format = %b-%y)

[1] NA




You must have set an English locale (to recognize the word May as a 
month) and you have to add a day.


Best,
Uwe Ligges





Can somebody help me how I can achieve that?

Thanks and regards,

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

2013-08-30 Thread Shane Carey
Oooff, Right, I will give it a go and see how I get on.

Thanks


On Fri, Aug 30, 2013 at 11:17 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/30/2013 07:57 PM, Shane Carey wrote:

 This is what I put in:
 gap.boxplot(DATA$Conductivity~**factor(DATA$UnitName_1),ylim=**
 c(LOWER_Y_Conductivity,UPPER_**Y_Conductivity_int),gap=gap_**
 Conductivity,
  col=colours,outwex=one,**whisklty =
 solid,whisklwd=lwth,outcol= black, outpch=dtsym,  outcex=dtsize,
  range=1.5,xlab=,ylab=)

 My aim is to not show the labels at the tick marks as I will add them to
 the plot afterwards

  Ah, not the axis labels but the tick labels. This is something I had not
 put into the function. You can edit the gap.boxplot function to do this by
 commenting out line 53:

 # axis(1,labels=bxpt$names,at=1:**nboxes)

 saving the function (call it gap.boxplot2.R) and sourcing the edited
 function:

 library(plotrix)
 source(gap.boxplot2.R)
 gap.boxplot(...)

 Remember that you have to load plotrix, _then_ source the new function.
 Jim




-- 
Shane

[[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] scale breaks

2013-08-30 Thread Shane Carey
It worked perfectly, your a star!!!

Thanks


On Fri, Aug 30, 2013 at 11:40 AM, Shane Carey careys...@gmail.com wrote:

 Oooff, Right, I will give it a go and see how I get on.

 Thanks


 On Fri, Aug 30, 2013 at 11:17 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/30/2013 07:57 PM, Shane Carey wrote:

 This is what I put in:
 gap.boxplot(DATA$Conductivity~**factor(DATA$UnitName_1),ylim=**
 c(LOWER_Y_Conductivity,UPPER_**Y_Conductivity_int),gap=gap_**
 Conductivity,
  col=colours,outwex=one,**whisklty =
 solid,whisklwd=lwth,outcol= black, outpch=dtsym,  outcex=dtsize,
  range=1.5,xlab=,ylab=)

 My aim is to not show the labels at the tick marks as I will add them to
 the plot afterwards

  Ah, not the axis labels but the tick labels. This is something I had
 not put into the function. You can edit the gap.boxplot function to do this
 by commenting out line 53:

 # axis(1,labels=bxpt$names,at=1:**nboxes)

 saving the function (call it gap.boxplot2.R) and sourcing the edited
 function:

 library(plotrix)
 source(gap.boxplot2.R)
 gap.boxplot(...)

 Remember that you have to load plotrix, _then_ source the new function.
 Jim




 --
 Shane




-- 
Shane

[[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] Calculation with Times Series

2013-08-30 Thread PeterSport
Thanks a lot!

It works like I want to!
Am 29.08.2013 15:44 schrieb arun kirshna [via R] 
ml-node+s789695n4674877...@n4.nabble.com:

 HI,
 May be this helps:

  ts1- ts(1:20)
  ts2- ts(1:25)
 ts1[-(1:3)]- ts1[-(1:3)]+ts2[1:17]

  as.numeric(ts1)
 # [1]  1  2  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37


 A.K.


 Hey everyone,

 I`m an absolut beginner in R and need some help for an exercise:

 I want to do ordinary calculations with 2 time series. The issue
  with this, that I want to use different elements of time series.
 Let me give you an example:

 I want to sum let`s say the 10th element of time series 1 with
 the 7th element of time series 2.  And 9th element of TS 1 with 6th
 element of TS 2 and 8th element of TS 1 with 5th element of TS 2 ...

 This pattern of the summation should go all over the time series.

 Is there a function, which allows me to do this, if possible a
 function in which I can change the difference of the position with a
 variable.

 Thanks a lot for your support. I´m for any advice thankful!

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=4674877i=0mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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

 http://r.789695.n4.nabble.com/Calculation-with-Times-Series-tp4674852p4674877.html
  To unsubscribe from Calculation with Times Series, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4674852code=Yy5icmVua2VuQGdtYWlsLmNvbXw0Njc0ODUyfDk2MDYzMzE=
 .
 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





--
View this message in context: 
http://r.789695.n4.nabble.com/Calculation-with-Times-Series-tp4674852p4674956.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Running pre R.14 version of R with R3.0.0

2013-08-30 Thread PIKAL Petr
Hi

Do you have 2 versions of .RData? If yes you probably need to install packages 
which were installed and used before saving old .RData file to be able to 
access this file with new R version. 

If this does not help, you could return to previous R version, save necessary 
objects to separate .rdata file and load them to R 3.0.0 environment.

see ?save, ?load

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Luvalle, Michael J (Michael)
 Sent: Thursday, August 29, 2013 4:33 PM
 To: r-help@r-project.org
 Subject: [R] Running pre R.14 version of R with R3.0.0
 
 I upgraded R from 2.12.1 to 3.0.0 (on windows XP(, and as soon as I
 saved the 3.0.0 workspace, was unable to access .Rdata from 2.12.1.
 The message in the R console is Error in loadNamesSpace(name): there
 is no package called parallel and a popup window that says Fatal
 error: unable to restore saved date in .Rdata
 
 Is there anything that can be done to access the old .Rdata  without
 destroying the new?
 
 Thanks
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Omitted/blank variables in R function

2013-08-30 Thread PIKAL Petr
Hi

It would be good if you provided some more specific inforamation. What function 
do you use for transfering data to R?.

E.g. read.table has option to specify NA values during data transfer.

If you want to set some values to NA in already read objects you can do it

object[object==some value] - NA

Regards
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Greg Snow
 Sent: Friday, August 30, 2013 5:23 AM
 To: newruser12345
 Cc: r-help
 Subject: Re: [R] Omitted/blank variables in R function
 
 Look at the missing function.
 
 Or set the default value of the arguments to NA.
 
 
 On Thu, Aug 29, 2013 at 3:23 PM, newruser12345
 smetc...@gelbergroup.comwrote:
 
  Hi All,
 
  I'm very green user and have little programming background, but
  appreciate any and all help/direction.  I have a spreadsheet that
  successfully sends values from Excel cells to R as variables for a
  function, which then runs and generates a plot.  I cannot figure out
  how to make R recognize those variables as NA if one of the cells in
  Excel is blank - or, for that matter, I don't know how to get an R
  function  to recognize variables as NA if no value is assigned to
 that
  variable.
 
  I have unsuccessfully tried using :
 
  if(is.na(four)) return(NA)
 
  My function is very simple:
 
  mtmatches - c(one,two,three,four)
 
  Everything runs smoothly if the four variables have values assigned
 to
  them.
  Any advice on how to get it to run when one of the variables has no
 value?
  No worries about the Excel element...figure I can decipher that
 puzzle
  later!
 
 
  Thanks!
 
 
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/Omitted-blank-variables-in-R-function-
 tp
  4674931.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.
 
 
 
 
 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.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.


[R] Packaging

2013-08-30 Thread Eva Prieto Castro
Hi,

I have a problem when I try to generate the Documentation pdf (from .rda 
files)in Spanish during the package creation. Could you tell me the way I can 
do it?.
Thanks in advance.

Regards.

Eva
[[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 string to date

2013-08-30 Thread PIKAL Petr
Hi

as.Date(paste(MAY-14,-01, sep=), format = %b-%y-%d)

Shall be OK. Change output format by ?format.

Regards
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Christofer Bogaso
 Sent: Friday, August 30, 2013 12:00 PM
 To: r-help
 Subject: [R] Changing string to date
 
 Hello again,
 
 I have a string which I need to put in some legitimate date format.
 
 My string is: MAY-14
 
 And output format would be 05/01/2014, this should be of Date class,
 so that I can make some sensible calculation with it.
 
 I have tried this without any success:
 
  as.Date(MAY-14, format = %b-%y)
 [1] NA
 
 
 Can somebody help me how I can achieve that?
 
 Thanks and regards,
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] problem in while loop?

2013-08-30 Thread Jonsson
I have three datasets that I want to compute the errors between them using
linear regression.for this, I want to iterate to reach certain criteria for
the calibration. if changes become smaller than eps the iteration is
successful, hence stop and write parameters into cal:eps=0.1 if number
of iterations is  itermax the iteration failed, hence stop and fill cal
with missing value itermax=400

So I tried this code:

  x= c(5,2,4,2,1)
  y= c(5,3,4,6,9)
  z= c(5,8,4,7,3)
  itermax=400
get initial calibration parameters, here we assume that:x is the reference
dataset offset x_a=0, slope x_b=1 the other two datasets y, z are
calibrated to x using a simple linear regression

 res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
  res1=lm(x~z)
  z_a=coef(res1)[1] ; z_b=coef(res1)[2]
  y_t = y/y_b - y_a/y_b  # calibrate y
  z_t = z/z_b - z_a/z_b  #calibrate z
  x_e = sqrt(mean((x-y_t)*(x-z_t)))#calculate error of x
   iter - 0
   while(((x_e-x)  0.1) (iter  itermax)) { 
  iter - 0  ##start iteration
   x = x_e 
   res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
   res1=lm(x~z)
   z_a=coef(res1)[1] ; z_b=coef(res1)[2]
   y_t = y/y_b - y_a/y_b  # calibrate y
   z_t = z/z_b - z_a/z_b  #calibrate z
   x_e = sqrt(mean((x-y_t)*(x-z_t)))
iter - iter + 1 # increase iteration counter
} 
But I got the same result for X_e before and after the loop:

   x_e
 [1] 6.454089



--
View this message in context: 
http://r.789695.n4.nabble.com/problem-in-while-loop-tp4674962.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] create new column to combine 2 data.frames

2013-08-30 Thread PIKAL Petr
Hi

see ?merge

something like 

merge(df1, df2)

Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mat
 Sent: Friday, August 30, 2013 10:37 AM
 To: r-help@r-project.org
 Subject: [R] create new column to combine 2 data.frames
 
 Hello together i have a little problem with the combine of two
 data.frames.
 
 I have 2 data.frames, which look like this one:
 
 first dataframe:
 ID Name
 1  Jack
 2  John
 3  Jill
 
 second dataframe
 ID  Days  Type
 13   Training
 21   Management
 34   Training
 
 At the end i want to create a data.frame like this one (the Type should
 be the new column and the entry of the column should be the days):
 
 ID Name  TrainingManagement
 1  Jack30
 2  John01
 3  Jill   40
 
 maybe anyone can help me, how i can do this.
 
 Thanks a lot.
 
 Best regards. Mat
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/create-new-
 column-to-combine-2-data-frames-tp4674963.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] create new column to combine 2 data.frames

2013-08-30 Thread PIKAL Petr
Hi

Sorry, I did not read your question to the end

library(reshape)

merge(dat1,cast(melt(dat2, c(ID, Type)), ID~Type))
  ID Name Management Training
1  1 Jack  13
2  2 John  1   NA
3  3 Jill NA4

Is close enough, you can easily change NA to 0 if you want.

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mat
 Sent: Friday, August 30, 2013 11:27 AM
 To: r-help@r-project.org
 Subject: Re: [R] create new column to combine 2 data.frames
 
 Thanks first.
 
 that doesn't look bad. But if have a equal ID in dat2, the days are no
 longer correct.
 
 the correct data.frame has to look like this one:
 
   ID Name Management Training
 1  1 Jack  13
 2  2 John  10
 3  3 Jill  04
 
 not this one:
 
   ID Name Management Training
 1  1 Jack  11
 2  2 John  30
 3  3 Jill  01
 
  dat1 - read.table(text = 
 + ID Name
 + 1  Jack
 + 2  John
 + 3  Jill
 + , header = TRUE, stringsAsFactors = FALSE)
 
  dat2 - read.table(text = 
 + ID  Days  Type
 + 11   Management
 + 13   Training
 + 21   Management
 + 34   Training
 + , header = TRUE, stringsAsFactors = FALSE)
 
  library(reshape2)
  tmp - dcast(data = dat2, ID ~ Type, value.var = Type)
 
  tmp[-1] - lapply(tmp[-1], function(x){
 + y - integer(length(x))
 + y[!is.na(x)] - dat2[[Days]][!is.na(x)]
 + y})
  result - merge(dat1, tmp)
  result
   ID Name Management Training
 1  1 Jack  11
 2  2 John  30
 3  3 Jill  01
 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/create-new-
 column-to-combine-2-data-frames-tp4674963p4674968.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] problem in while loop?

2013-08-30 Thread Berend Hasselman

On 30-08-2013, at 09:44, Jonsson amen.alya...@bordeaux.inra.fr wrote:

 I have three datasets that I want to compute the errors between them using
 linear regression.for this, I want to iterate to reach certain criteria for
 the calibration. if changes become smaller than eps the iteration is
 successful, hence stop and write parameters into cal:eps=0.1 if number
 of iterations is  itermax the iteration failed, hence stop and fill cal
 with missing value itermax=400
 
 So I tried this code:
 
  x= c(5,2,4,2,1)
  y= c(5,3,4,6,9)
  z= c(5,8,4,7,3)
  itermax=400
 get initial calibration parameters, here we assume that:x is the reference
 dataset offset x_a=0, slope x_b=1 the other two datasets y, z are
 calibrated to x using a simple linear regression
 
 res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
  res1=lm(x~z)
  z_a=coef(res1)[1] ; z_b=coef(res1)[2]
  y_t = y/y_b - y_a/y_b  # calibrate y
  z_t = z/z_b - z_a/z_b  #calibrate z
  x_e = sqrt(mean((x-y_t)*(x-z_t)))#calculate error of x
   iter - 0
   while(((x_e-x)  0.1) (iter  itermax)) { 
  iter - 0  ##start iteration
   x = x_e 
   res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
   res1=lm(x~z)
   z_a=coef(res1)[1] ; z_b=coef(res1)[2]
   y_t = y/y_b - y_a/y_b  # calibrate y
   z_t = z/z_b - z_a/z_b  #calibrate z
   x_e = sqrt(mean((x-y_t)*(x-z_t)))
iter - iter + 1 # increase iteration counter
} 
 But I got the same result for X_e before and after the loop:
 
 x_e
 [1] 6.454089
 
I tried your code and got this error message:

Error in model.frame.default(formula = x ~ y, drop.unused.levels = TRUE) : 
  variable lengths differ (found for 'y')
Calls: lm - eval - eval - Anonymous - model.frame.default

And looking at your code:  x is a vector, x_e is a scalar and in the while loop 
you are assigning x_e to x so x is then a scalar.

Berend

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


Re: [R] create new column to combine 2 data.frames

2013-08-30 Thread Mat
thanks. Works perfectly 

you made my day :-)



--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-to-combine-2-data-frames-tp4674963p4674994.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] Memory usage bar plot

2013-08-30 Thread mohan . radhakrishnan
Hi,
  I haven't tried the code yet. Is there a way to parse this data 
using R and create bar plots so that each program's 'RAM used' figures are 
grouped together.
So 'uuidd' bars will be together. The data will have about 50 sets. So if 
there are 100 processes each will have about 50 bars.

What is the recommended way to graph these big barplots ? I am looking for 
only 'RAM used' figures.


Thanks,
Mohan


 Private  +   Shared  =  RAM used   Program

 96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
-
453.9 MiB

=
 Private  +   Shared  =  RAM used   Program

 96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
--
453.9 MiB
=


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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] create new column to combine 2 data.frames

2013-08-30 Thread arun
Hi,

You can use 'fill=0' in ?cast()
merge(dat1,cast(melt(dat2, c(ID, Type)), ID~Type,fill=0))
#  ID Name Management Training
#1  1 Jack  1    3
#2  2 John  1    0
#3  3 Jill  0    4
A.K.



- Original Message -
From: PIKAL Petr petr.pi...@precheza.cz
To: Mat matthias.we...@fnt.de; r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Friday, August 30, 2013 5:57 AM
Subject: Re: [R] create new column to combine 2 data.frames

Hi

Sorry, I did not read your question to the end

library(reshape)

merge(dat1,cast(melt(dat2, c(ID, Type)), ID~Type))
  ID Name Management Training
1  1 Jack          1        3
2  2 John          1       NA
3  3 Jill         NA        4

Is close enough, you can easily change NA to 0 if you want.

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mat
 Sent: Friday, August 30, 2013 11:27 AM
 To: r-help@r-project.org
 Subject: Re: [R] create new column to combine 2 data.frames
 
 Thanks first.
 
 that doesn't look bad. But if have a equal ID in dat2, the days are no
 longer correct.
 
 the correct data.frame has to look like this one:
 
   ID Name Management Training
 1  1 Jack          1        3
 2  2 John          1        0
 3  3 Jill          0        4
 
 not this one:
 
   ID Name Management Training
 1  1 Jack          1        1
 2  2 John          3        0
 3  3 Jill          0        1
 
  dat1 - read.table(text = 
 + ID Name
 + 1  Jack
 + 2  John
 + 3  Jill
 + , header = TRUE, stringsAsFactors = FALSE)
 
  dat2 - read.table(text = 
 + ID  Days  Type
 + 1    1       Management
 + 1    3       Training
 + 2    1       Management
 + 3    4       Training
 + , header = TRUE, stringsAsFactors = FALSE)
 
  library(reshape2)
  tmp - dcast(data = dat2, ID ~ Type, value.var = Type)
 
  tmp[-1] - lapply(tmp[-1], function(x){
 + y - integer(length(x))
 + y[!is.na(x)] - dat2[[Days]][!is.na(x)]
 + y})
  result - merge(dat1, tmp)
  result
   ID Name Management Training
 1  1 Jack          1        1
 2  2 John          3        0
 3  3 Jill          0        1
 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/create-new-
 column-to-combine-2-data-frames-tp4674963p4674968.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] Outliers Help

2013-08-30 Thread arun
HI,

Also,

dd1-matrix(cbind(D[,1],(D[-c(1:2)]/D[,2]4)*1),dimnames=NULL,ncol=7)
identical(dd,dd1)
#[1] TRUE
A.K.






- Original Message -
From: Jose Iparraguirre jose.iparragui...@ageuk.org.uk
To: Mª Teresa Martinez Soriano teresama...@hotmail.com; 
r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Friday, August 30, 2013 5:39 AM
Subject: Re: [R] Outliers Help

Hi Ma Teresa,

Sorry, but I can't understand what you're trying to achieve.
On a statistical note, I'd tend to think more in terms of medians and would 
think hard before replacing any outliers, but that's another matter.

Here I created the dataframe dd with the means column of D in its first column, 
and then populated with a 1 whenever the value of D for that cell was greater 
than 4 times the mean for that row -your definition of 'outlier'. 
 dd - rep(0,15*7)
 dim(dd) - c(15,7)
 dd[,1]- D[,1]
 for (i in 1:15){
+ for (j in 2:7){
+ dd[i,j] - D[i,(j+1)]/D[i,2]4
+ }
+ }
 dd
       [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]  1108    0    0    0    0    0    0
[2,]  1479   NA   NA    0    1    0    0
[3,]  1591    0    0    0    0    0    0
[4,]  3408    0    0    0    0    0    0
[5,]  3423   NA   NA   NA    1    0    0
[6,]  3872    0    0    0    0    0    1
[7,]  5823    0    0    0    0    0    0
[8,]  6051   NA   NA   NA   NA    0    0
[9,]  8099    0    0    0    0    0    0
[10,]  8100   NA   NA   NA   NA    0    0
[11,] 10640    1    1    1    0    0    0
[12,] 12600    0    0    0    0    0    0
[13,] 14680    0    0    1    0    0    1
[14,] 14698    0    0    0    0    0    0
[15,] 17143    0    0    0    0    0    0

So, you encounter four situations:

a) as in row 2, you have an outlier preceded and followed by values
b) as in row 5, you have an outlier preceded by an NA
c) as in row 6, there is an outlier in the last column
d) as in row 11, there are two or more consecutive outliers


The replacement rule you described would only apply to situations a) (ie 
replacing the outlier by the mean of the preceding and subsequent values), and 
b) (replacing it by the mean for the row).
But what of situations c) and d)?

And, because this is just a chunk of a bigger dataset, you can also get an 
outlier in the first column, followed by a number. Again, your rule has not 
accounted for this situation either.

Hope this helps,

José

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mª Teresa Martinez Soriano
Sent: 30 August 2013 09:13
To: r-help@r-project.org
Subject: [R] Outliers Help

This is my a part of my data set 

 D[1:15,c(1,5:10)]

       X.      media IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010
1   1108   22.0    60.0      39     4.0     8.0    16.0     5.0
2   1479  110.0      NA      NA    53.0  1166.0   344.8   110.0
3   1591   86.6   247.0      87    95.0    94.0    81.0    76.0
4   3408  807.0   302.0     322   621.0  1071.0  1301.0  1225.0
5   3423    9.0      NA      NA      NA   410.8     7.0    11.0
6   3872  103.25000   288.6     113   116.0    90.0    94.0 12036.6
7   5823   73.0   117.0      70    80.0    74.0    69.0    72.0
8   6051   73.0      NA      NA      NA      NA    60.0    86.0
9   8099  125.16667   196.0     161   150.0    94.0    72.0    78.0
10  8100   70.0      NA      NA      NA      NA    48.0    92.0
11 10640   67.3  1256.6    1152   664.2    74.0    77.0    51.0
12 12600 2417.0  1960.0    2383  2453.0  2506.0  2758.0  2442.0
13 14680   38.0    30.0      61   373.6    42.0    19.0   220.8
14 14698  698.16667   553.0     664   847.0   800.0   679.0   646.0
15 17143  392.16667   323.0     322   434.0   383.0   459.0   432.0





I have done multiple imputation and now I have some outliers which I would like 
to replace with the mean of this row or if it is possible with the mean of the 
previos and the next value of this row, I mean for instance:

value 1 - Outlier- Value 2

I would like to replace the outlier with the mean of value 1 and value2, the 
problem is that this values could be NA ( NA after the imputation because they 
don't exist), in this case I would like to replace outlier with the mean of the 
row.


An other problem I have is to detect correctly outlier values, for instance in 
this example of data set for X=3872 and IE.2010, we can see an outlier, I have 
thought to compare the values with the mean ( column media) 

I have tried to do this code


D-datos[, c(1,16:24)]
m-as.matrix(D) 
for( i in 1: nrow(D))

{
  
   for( j in 5:(ncol(D)-1)) # I would change this in the new data set, because 
I will have more years than 2010
    {  
   if(!is.na(m[i,j]) !is.na 
(m[i,j+1])!is.na(m[i,j-1])!is.na(m[i,2])((m[i,j]/m[i,2])4)){m[m[i,j]]- 
(m[i,j-1]+m[i,j+1])/2 # Here I would like to find the values that are much more 
bigger than the mean of this row, 
    #if( !is.na(m[i,j])
    # and replace them by the mean of the previous and the next values of the 
same row.
  
  } 
  }
}

Re: [R] mean

2013-08-30 Thread arun
Hi,
Better would be to show a reproducible example using ?dput() and the codes you 
used.  Assuming that you tried something like this:
lst1- list(1:10,c(5,4,3),4:15)
 mean(lst1)
#[1] NA
#Warning message:
#In mean.default(lst1) : argument is not numeric or logical: returning NA
 sapply(lst1,mean)  #also depends upon the list elements.  In the example I 
used, it is a vector.
#[1] 5.5 4.0 9.5

#or

lapply(lst1,mean)
#[[1]]
#[1] 5.5
#
#[[2]]
#[1] 4
#
#[[3]]
#[1] 9.5

#Suppose, your list elements are:
set.seed(24)
 lst2- 
list(as.data.frame(matrix(sample(1:10,5*4,replace=TRUE),ncol=5)),as.data.frame(matrix(sample(1:40,8*5,replace=TRUE),ncol=8)))

#and you wanted to find the column means

 lapply(lst2,colMeans)
#[[1]]
 # V1   V2   V3   V4   V5 
#5.00 7.00 5.75 7.00 2.75 
#
#[[2]]
 # V1   V2   V3   V4   V5   V6   V7   V8 
#14.4 16.8 16.4 26.4 11.4 12.0 24.8 16.8 

Hope it helps.

A.K.



When I try to apply mean to a list, I get the answer : 

argument is not numeric or logical: returning NA 

Could you help me? 

(I am a very beginner)

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


Re: [R] Memory usage bar plot

2013-08-30 Thread mohan . radhakrishnan
Hello,
This memory usage should be graphed with time. Are there 
examples of scatterplots that can clearly show usage vs time ?  This is 
for  memory leak detection.


Thanks,
Mohan



From:   PIKAL Petr petr.pi...@precheza.cz
To: mohan.radhakrish...@polarisft.com 
mohan.radhakrish...@polarisft.com, r-help@r-project.org 
r-help@r-project.org
Date:   08/30/2013 05:33 PM
Subject:RE: [R] Memory usage bar plot



Hi

For reading data into R you shall look to read.table and similar.

For plotting ggplot could handle it. However I wonder if 100 times 50 bars 
is the way how to present your data. You shall think over what do you want 
to show to yourself or your audience. Maybe boxplots or scatterplots could 
be better.

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of mohan.radhakrish...@polarisft.com
 Sent: Friday, August 30, 2013 1:25 PM
 To: r-help@r-project.org
 Subject: [R] Memory usage bar plot
 
 Hi,
   I haven't tried the code yet. Is there a way to parse this
 data using R and create bar plots so that each program's 'RAM used'
 figures are grouped together.
 So 'uuidd' bars will be together. The data will have about 50 sets. So
 if there are 100 processes each will have about 50 bars.
 
 What is the recommended way to graph these big barplots ? I am looking
 for only 'RAM used' figures.
 
 
 Thanks,
 Mohan
 
 
  Private  +   Shared  =  RAM used   Program
 
  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 -
 453.9 MiB
 
 =
  Private  +   Shared  =  RAM used   Program
 
  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 --
 453.9 MiB
 =
 
 
 This e-Mail may contain proprietary and confidential information and is
 sent for the intended recipient(s) only.  If by an addressing or
 transmission error this mail has been misdirected to you, you are
 requested to delete this mail immediately. You are also hereby notified
 that any use, any form of reproduction, dissemination, copying,
 disclosure, modification, distribution and/or publication of this e-
 mail message, contents or its attachment other than by its intended
 recipient/s is strictly prohibited.
 
 Visit us at http://www.polarisFT.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.




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.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] Fwd: ddply for comparing simulation results

2013-08-30 Thread jim holtman
forgot to send it back to the list.


Jim Holtman
Data Munger Guru

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



-- Forwarded message --
From: jim holtman jholt...@gmail.com
Date: Fri, Aug 30, 2013 at 8:10 AM
Subject: Re: ddply for comparing simulation results
To: john doe anon.r.u...@gmail.com


try the 'data.table package.  It gives the answer in less than a second.

 # 1 million leads, half of which were simulated, half of which were not
 id=1:100
 isSimulated = c(rep(0,50), rep(1, 50))
 userId=sample(1:10, 100, replace=T)
 df_leads=data.frame(id, isSimulated, userId)
 require(data.table)
Loading required package: data.table
data.table 1.8.8  For help type: help(data.table)
 system.time({
+ df_leads - data.table(df_leads)
+ df_leads_sum - df_leads[
+ , list(count = .N)
+ , keyby = c('isSimulated', 'userId')
+ ]
+ })
   user  system elapsed
   0.750.010.76

 head(df_leads_sum)
   isSimulated userId count
1:   0  1 5
2:   0  2 9
3:   0  3 5
4:   0  4 4
5:   0  5 3
6:   0  6 7


you can use 'setdiff' to find userIDs that are missing from one group
or the other:

 #see which userIDs are missing between the groups
 not_in - setdiff(df_leads_sum$userId[df_leads_sum$isSimulated == 0]
+   , df_leads_sum$userId[df_leads_sum$isSimulated == 1]
+   )
 str(not_in)
 int [1:697] 59 100 204 584 656 828 840 999 1012 1046 ...

Jim Holtman
Data Munger Guru

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


On Thu, Aug 29, 2013 at 11:33 PM, john doe anon.r.u...@gmail.com wrote:
 I am trying to use R and plyr to compare the effectiveness of various
 algorithms for online advertising.  At the core, I am simply counting when a
 user receives a lead: this is measured with the userId column.  Leads that
 were sent in production have a 0 in the isSimulated column, and leads that
 were sent in our simulation have isSimulated=1.  I have two questions: one
 about performance and one about how to use plyr to get the data in a form
 that I want.

 Here is an example of my code:

 # 1 million leads, half of which were simulated, half of which were not
 id=1:100
 isSimulated = c(rep(0,50), rep(1, 50))
 userId=sample(1:10, 100, replace=T)
 df_leads=data.frame(id, isSimulated, userId)

 # split by simulated and userid, and then sum
 system.time(df_leads_sum - ddply(df_leads, .(isSimulated, userId), nrow))
user  system elapsed
  38.167   0.212  38.386

 The above call to ddply is great because it allows me to create histograms
 of how many people receive just a few leads, or a lot of leads, both in
 production and in the simulator.

 Question 1: The above ddply call takes a while to execute.  With production
 data it takes several minutes in R, but only a few seconds in MySQL.  Is
 there a way to improve the performance of the above call?

 Question 2: What I would really like to do is create a histogram which
 measures the distribution of change in leads between non-simulated and
 simulated data.  A complicating fact is that some users might only appear in
 simulated or non-simulated data, so I need to correclty handle the absense
 of a userId.  (In production, users are actually guaranteed to appear in
 production - but the crux of the problem is the same: userIds might be
 missing in one of the splits).  Can someone help me with this?  I've read
 the documentation a few times, and think that the summarize function might
 be able to help, but I'm not quite sure how to do this.

 Thanks.

 --
 You received this message because you are subscribed to the Google Groups
 manipulatr group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to manipulatr+unsubscr...@googlegroups.com.
 To post to this group, send email to manipul...@googlegroups.com.
 Visit this group at http://groups.google.com/group/manipulatr.
 For more options, visit https://groups.google.com/groups/opt_out.

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


Re: [R] Ordering a matrix (and not losing the rownames)

2013-08-30 Thread arun
Hi Ramón,
May be this helps:
tags_totals-matrix(c(15,11,23,7,5),ncol=1,dimnames=list(c(Wikis,Glosarios,Grupos,Bases
 de datos,Taller),NULL))

tags_totals[order(tags_totals[,1],decreasing=TRUE),,drop=FALSE]
#   [,1]
#Grupos   23
#Wikis    15
#Glosarios    11
#Bases de datos    7
#Taller    5

A.K.



Hello, 

I have a matrix like this: 

 tags_totals 
               [,1] 
Wikis            15 
Glosarios        11 
Grupos           23 
Bases de datos    7 
Taller            5 

And I want to order by the value of the first column. I do this: 

ordered_matrix - 
as.matrix(tags_totals[order(tags_totals[,1],decreasing=TRUE)]) 

It orders alright, but I lose the rownames, that I need for the graphics 
 ordered_matrix 
     [,1] 
[1,]   23 
[2,]   15 
[3,]   11 
[4,]    7 
[5,]    5 

 rownames(ordered_matrix) 
NULL 

If I try to do it after converting to a dataframe I get an error that I don't 
understand: 

 tags_totals_frame - as.data.frame(tags_totals) 
 tags_totals_frame[,1] 
[1] 15 11 23  7  5 
 ordered_frame - 
 tags_totals_frame[order(tags_totals_frame[,1],decreasing=TRUE)] 
Error en `[.data.frame`(tags_totals_frame, order(tags_totals_frame[, 1],  : 
  undefined columns selected 

Thanks on any help, 

-- 
== 
Ramón Ovelar 
Campus Virtual Birtuala UPV/EHU 
Tel: (34) 94 601 3407 
http://campusvirtual.ehu.es


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


Re: [R] Memory usage bar plot

2013-08-30 Thread jim holtman
Here is how to parse the data and put it into groups.  Not sure what
the 'timing' of each group is since not time information was given.
Also not sure is there is an 'MiB' qualifier on the data, but you have
the matrix of data which is easy to do with as you want.


 input - readLines(textConnection(
+  Private  +   Shared  =  RAM used   Program
+
+  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
+ 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
+ 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
+ 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
+ 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
+ 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
+ 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
+ -
+ 453.9 MiB
+
+ =
+  Private  +   Shared  =  RAM used   Program
+
+  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
+ 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
+ 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
+ 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
+ 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
+ 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
+ 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
+ --
+ 453.9 MiB
+ =))

 # keep only the data
 input - input[grepl('=', input)]

 # separate into groups
 grps - split(input, cumsum(grepl(=  RAM, input)))

 # parse the data (not sure if there is also 'MiB')
 parsed - lapply(grps, function(.grp){
+ # parse ignoring first and last lines
+ .data - sub(.*= ([^ ]+) ([^ ]+)\\s+(.*), \\1 \\2 \\3
+ , .grp[2:(length(.grp) - 1L)]
+ )
+ # return matrix
+ do.call(rbind, strsplit(.data, ' '))
+ })



 parsed
$`1`
 [,1][,2]  [,3]
[1,] 107.5 KiB uuidd
[2,] 120.5 KiB klogd
[3,] 141.0 KiB hidd
[4,] 146.0 KiB acpid
[5,] 153.5 KiB hald-addon-storage
[6,] 159.0 KiB gpm
[7,] 162.5 KiB pam_timestamp_check

$`2`
 [,1][,2]  [,3]
[1,] 107.5 KiB uuidd
[2,] 120.5 KiB klogd
[3,] 141.0 KiB hidd
[4,] 146.0 KiB acpid
[5,] 153.5 KiB hald-addon-storage
[6,] 159.0 KiB gpm
[7,] 162.5 KiB pam_timestamp_check


Jim Holtman
Data Munger Guru

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


On Fri, Aug 30, 2013 at 7:24 AM,  mohan.radhakrish...@polarisft.com wrote:
 Hi,
   I haven't tried the code yet. Is there a way to parse this data
 using R and create bar plots so that each program's 'RAM used' figures are
 grouped together.
 So 'uuidd' bars will be together. The data will have about 50 sets. So if
 there are 100 processes each will have about 50 bars.

 What is the recommended way to graph these big barplots ? I am looking for
 only 'RAM used' figures.


 Thanks,
 Mohan


  Private  +   Shared  =  RAM used   Program

  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 -
 453.9 MiB

 =
  Private  +   Shared  =  RAM used   Program

  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 --
 453.9 MiB
 =


 This e-Mail may contain proprietary and confidential information and is sent 
 for the intended recipient(s) only.  If by an addressing or transmission 
 error this mail has been misdirected to you, you are requested to delete this 
 mail immediately. You are also hereby notified that any use, any form of 
 reproduction, dissemination, copying, disclosure, modification, distribution 
 and/or publication of this e-mail message, contents or its attachment other 
 than by its intended recipient/s is strictly prohibited.

 Visit us at http://www.polarisFT.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] scale breaks

2013-08-30 Thread Shane Carey
Hi Jim et al,

I want to remove the upper bounding box,
I did this by
#box()

in the gap.plot function. It still leaves me with two horizontal lines. I
would like to remove them also, where are the created within the function?
Thanks, this is great, exactly what I need.
Cheers



On Fri, Aug 30, 2013 at 11:44 AM, Shane Carey careys...@gmail.com wrote:

 It worked perfectly, your a star!!!

 Thanks


 On Fri, Aug 30, 2013 at 11:40 AM, Shane Carey careys...@gmail.com wrote:

 Oooff, Right, I will give it a go and see how I get on.

 Thanks


 On Fri, Aug 30, 2013 at 11:17 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/30/2013 07:57 PM, Shane Carey wrote:

 This is what I put in:
 gap.boxplot(DATA$Conductivity~**factor(DATA$UnitName_1),ylim=**
 c(LOWER_Y_Conductivity,UPPER_**Y_Conductivity_int),gap=gap_**
 Conductivity,
  col=colours,outwex=one,**whisklty =
 solid,whisklwd=lwth,outcol= black, outpch=dtsym,  outcex=dtsize,
  range=1.5,xlab=,ylab=)

 My aim is to not show the labels at the tick marks as I will add them to
 the plot afterwards

  Ah, not the axis labels but the tick labels. This is something I had
 not put into the function. You can edit the gap.boxplot function to do this
 by commenting out line 53:

 # axis(1,labels=bxpt$names,at=1:**nboxes)

 saving the function (call it gap.boxplot2.R) and sourcing the edited
 function:

 library(plotrix)
 source(gap.boxplot2.R)
 gap.boxplot(...)

 Remember that you have to load plotrix, _then_ source the new function.
 Jim




 --
 Shane




 --
 Shane




-- 
Shane

[[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] XLSX package + Excel creation question

2013-08-30 Thread jim holtman
You can also look at the XLConnect package.
Jim Holtman
Data Munger Guru

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


On Thu, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlo zsurzsalas...@gmail.com wrote:
 I understand you response but it does not solve the problem. I'am aware
 that one can simply color every cell in an excel file by using his own
 algorithm.

 The question was if I can write my data to a *single* cells and use
 different formatting for every piece of data.

 -
 - László-András Zsurzsa,-
 - Msc. Infromatics, Technical University Munich, Germany -
 - Scientific Employee, TUM -
 -


 On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurling rhur...@gwdg.de wrote:

 Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo:
  First of all thank you for the quick resposen.
 
  I know I can color and set up every cell. I will take a look again *
  CellStyle* but is it possbile for example to write an array to a single
  cell that has different colors for some data. Basically the color depends
  on the data.

 As far as I know there is no ready to use functionality to mask groups
 of selected cells. You have to write your own function, which selects
 the right cells and changes their style with setCellStyle(cell, cellStyle).

 Some hints are given in the examples section of ?CellStyle.

 
 
 -
  - László-András Zsurzsa,-
  - Msc. Infromatics, Technical University Munich, Germany -
  - Scientific Employee, TUM -
 
 -
 
 
  On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurling rhur...@gwdg.de wrote:
 
  Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo:
  Dear R users,
 
  I have a question about the xlsx package. It's possible to create excel
  files and color cells and etc.
 
  yes, with package xlsx you can colourize you data sheets, even the
  fonts. See for example ?CellStyle .
 
  A good demonstration of the capabilities is on
 
 
 http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/
 
 
  My question would be that is it possible to color only some part of the
  data hold in a cell. Let's assume I've got the following data :
  167,153,120,100 and I want to color to red everything that is bigger
 then
  120. How can I achive this using R.
 
  Example file setup with a few lines in attachment. (SEL_MASS column can
  be
  used for example)
 
  Attachment missing ...
 
  HTH,
  Rainer
 
 
  Thank you in advance,
 
 
 -
  - László-András Zsurzsa,
  -
  - Msc. Infromatics, Technical University Munich, Germany -
  - Scientific Employee, TUM
 -
 
 
 -
 
 
[[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] Memory usage bar plot

2013-08-30 Thread arun
HI,
You could also parse the data by:

input1- input
library(stringr)
input2-str_trim(gsub([=+],,input1))
dat1-read.table(text=word(input2[!grepl(---,input2) input2!=  
!grepl(RAM|MiB,input2)],8,15),sep=,header=FALSE,stringsAsFactors=FALSE)
lst1-split(dat1,cumsum(dat1$V3==uuidd)) 


lst1
#$`1`
# V1  V2  V3
#1 107.5 KiB   uuidd
#2 120.5 KiB   klogd
#3 141.0 KiB    hidd
#4 146.0 KiB   acpid
#5 153.5 KiB  hald-addon-storage
#6 159.0 KiB gpm
#7 162.5 KiB pam_timestamp_check
#
#$`2`
 #     V1  V2  V3
#8  107.5 KiB   uuidd
#9  120.5 KiB   klogd
#10 141.0 KiB    hidd
#11 146.0 KiB   acpid
#12 153.5 KiB  hald-addon-storage
#13 159.0 KiB gpm
#14 162.5 KiB pam_timestamp_check

A.K.

- Original Message -
From: jim holtman jholt...@gmail.com
To: mohan.radhakrish...@polarisft.com
Cc: R mailing list r-help@r-project.org
Sent: Friday, August 30, 2013 9:44 AM
Subject: Re: [R] Memory usage bar plot

Here is how to parse the data and put it into groups.  Not sure what
the 'timing' of each group is since not time information was given.
Also not sure is there is an 'MiB' qualifier on the data, but you have
the matrix of data which is easy to do with as you want.


 input - readLines(textConnection(
+  Private  +   Shared  =  RAM used       Program
+
+  96.0 KiB +  11.5 KiB = 107.5 KiB       uuidd
+ 108.0 KiB +  12.5 KiB = 120.5 KiB       klogd
+ 124.0 KiB +  17.0 KiB = 141.0 KiB       hidd
+ 116.0 KiB +  30.0 KiB = 146.0 KiB       acpid
+ 124.0 KiB +  29.5 KiB = 153.5 KiB       hald-addon-storage
+ 144.0 KiB +  15.0 KiB = 159.0 KiB       gpm
+ 136.0 KiB +  26.5 KiB = 162.5 KiB       pam_timestamp_check
+ -
+                                             453.9 MiB
+
+ =
+  Private  +   Shared  =  RAM used       Program
+
+  96.0 KiB +  11.5 KiB = 107.5 KiB       uuidd
+ 108.0 KiB +  12.5 KiB = 120.5 KiB       klogd
+ 124.0 KiB +  17.0 KiB = 141.0 KiB       hidd
+ 116.0 KiB +  30.0 KiB = 146.0 KiB       acpid
+ 124.0 KiB +  29.5 KiB = 153.5 KiB       hald-addon-storage
+ 144.0 KiB +  15.0 KiB = 159.0 KiB       gpm
+ 136.0 KiB +  26.5 KiB = 162.5 KiB       pam_timestamp_check
+ --
+                                             453.9 MiB
+ =))

 # keep only the data
 input - input[grepl('=', input)]

 # separate into groups
 grps - split(input, cumsum(grepl(=  RAM, input)))

 # parse the data (not sure if there is also 'MiB')
 parsed - lapply(grps, function(.grp){
+     # parse ignoring first and last lines
+     .data - sub(.*= ([^ ]+) ([^ ]+)\\s+(.*), \\1 \\2 \\3
+                 , .grp[2:(length(.grp) - 1L)]
+                 )
+     # return matrix
+     do.call(rbind, strsplit(.data, ' '))
+ })



 parsed
$`1`
     [,1]    [,2]  [,3]
[1,] 107.5 KiB uuidd
[2,] 120.5 KiB klogd
[3,] 141.0 KiB hidd
[4,] 146.0 KiB acpid
[5,] 153.5 KiB hald-addon-storage
[6,] 159.0 KiB gpm
[7,] 162.5 KiB pam_timestamp_check

$`2`
     [,1]    [,2]  [,3]
[1,] 107.5 KiB uuidd
[2,] 120.5 KiB klogd
[3,] 141.0 KiB hidd
[4,] 146.0 KiB acpid
[5,] 153.5 KiB hald-addon-storage
[6,] 159.0 KiB gpm
[7,] 162.5 KiB pam_timestamp_check


Jim Holtman
Data Munger Guru

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


On Fri, Aug 30, 2013 at 7:24 AM,  mohan.radhakrish...@polarisft.com wrote:
 Hi,
           I haven't tried the code yet. Is there a way to parse this data
 using R and create bar plots so that each program's 'RAM used' figures are
 grouped together.
 So 'uuidd' bars will be together. The data will have about 50 sets. So if
 there are 100 processes each will have about 50 bars.

 What is the recommended way to graph these big barplots ? I am looking for
 only 'RAM used' figures.


 Thanks,
 Mohan


  Private  +   Shared  =  RAM used       Program

  96.0 KiB +  11.5 KiB = 107.5 KiB       uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB       klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB       hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB       acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB       hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB       gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB       pam_timestamp_check
 -
                                             453.9 MiB

 =
  Private  +   Shared  =  RAM used       Program

  96.0 KiB +  11.5 KiB = 107.5 KiB       uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB       klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB       hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB       acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB       hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB       gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB       pam_timestamp_check
 

Re: [R] (no subject)

2013-08-30 Thread Uwe Ligges



On 30.08.2013 15:27, Joana Costa wrote:

good afternoon, I´m writting because I´m having some problems with R 
installation. I would like to install R essentials with spss Version 20 but I 
can´t find wher in Cran site I can do the dowload speciffically of Essentials.
Can you help me? I do not understand musch of R software and I just need to run 
it in SPSS menus
Hope forward to hearning from you soon


Please ask your SPSS support. The R project does not offer anything 
called R essentials.


Best,
Uwe Ligges





Best regards
Joana


Joana Costa, MSc, Ph.D.Postdoctoral Researcher(joanasco...@hotmail.com)
CINEICC, University of Coimbra

Rua do Colégio Novo, Apartado 6153

3001-802 Coimbra, Portugal

Telefone: (+351) 239 851450

Fax: (+351) 239851462   
[[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] strange conversion char to date

2013-08-30 Thread Frans Marcelissen
Hi R-friends,
Can anyone explain the following strange behavior to me?
 as.Date( 4/25/71,%m/%d/%y)
[1] 1971-04-25
 as.Date( 4/25/62,%m/%d/%y)
[1] 2062-04-25

so 71 is converted to 1971, while 62 is converted to 2062? Does anyone know
why? And is there a simple way to specify the date?
(does works the same way in R 2.01 as well as in 1.9)

---
dr F.H.G. (Frans) Marcelissen
DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/)
Pomperschans 26
5595 AV Leende
tel: 040 2065030/06 2325 06 53
skype adres: frans.marcelissen
email: frans.marcelis...@digipsy.nl

[[alternative HTML version deleted]]

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


Re: [R] mean

2013-08-30 Thread Albyn Jones
It would be easier to diagnose the problem if you included an example
illustrating exactly what you did.  I'll guess:

 a - list(3,4,5)
 mean(a)
[1] NA
Warning message:
In mean.default(a) : argument is not numeric or logical: returning NA

 mean(as.numeric(a))
[1] 4

But that's just a guess, as I don't know the actual contents of your list!

albyn


On Fri, Aug 30, 2013 at 5:18 AM, agnes69 fes...@gredeg.cnrs.fr wrote:

 When I try to apply mean to a list, I get the answer :

 argument is not numeric or logical: returning NA

 Could you help me?

 (I am a very beginner)



 --
 View this message in context:
 http://r.789695.n4.nabble.com/mean-tp4674999.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] Installing R for use in SPSS (was: no subject)

2013-08-30 Thread Marc Schwartz
On Aug 30, 2013, at 8:27 AM, Joana Costa joanasco...@hotmail.com wrote:

 good afternoon, I´m writting because I´m having some problems with R 
 installation. I would like to install R essentials with spss Version 20 but I 
 can´t find wher in Cran site I can do the dowload speciffically of Essentials.
 Can you help me? I do not understand musch of R software and I just need to 
 run it in SPSS menus
 Hope forward to hearning from you soon
 Best regards
 Joana 
 
 
 Joana Costa, MSc, Ph.D.Postdoctoral Researcher(joanasco...@hotmail.com)
 CINEICC, University of Coimbra


First and foremost:

Do not reply to a prior post with a new query, which is known as hijacking a 
thread. In the future, start a new thread by using a new e-mail and a proper 
subject line.

If you try to find your post in the list archives, it is buried within another 
thread, which makes it problematic.


There is no Essentials installation for R. The basic R installation installs 
Base R plus Recommended Packages and are a part of the standard R 
distribution. You can download the proper binary installation from CRAN for 
your OS (presuming Windows, since you are on hotmail). Just download it and run 
the installer. 

If there is any other configuration that SPSS requires, you will need to 
contact them for support.

To being your journey with R, you should start with the manuals:

 http://cran.r-project.org/manuals.html

and the FAQs:

  http://cran.r-project.org/faqs.html

and consider reading the Posting Guide:

  http://www.r-project.org/posting-guide.html


Regards,

Marc Schwartz

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


Re: [R] strange conversion char to date

2013-08-30 Thread jim holtman
Take a look at the documentation as to what %y means:

‘%y’ Year without century (00-99).  On input, values 00 to 68 are
  prefixed by 20 and 69 to 99 by 19 - that is the behaviour
  specified by the 2004 and 2008 POSIX standards, but they do
  also say ‘it is expected that in a future version the default
  century inferred from a 2-digit year will change’.

This is due to the Y2K problem that maybe you never had to deal with.
Jim Holtman
Data Munger Guru

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


On Fri, Aug 30, 2013 at 9:12 AM, Frans Marcelissen
frans.marcelis...@digipsy.nl wrote:
 Hi R-friends,
 Can anyone explain the following strange behavior to me?
 as.Date( 4/25/71,%m/%d/%y)
 [1] 1971-04-25
 as.Date( 4/25/62,%m/%d/%y)
 [1] 2062-04-25

 so 71 is converted to 1971, while 62 is converted to 2062? Does anyone know
 why? And is there a simple way to specify the date?
 (does works the same way in R 2.01 as well as in 1.9)

 ---
 dr F.H.G. (Frans) Marcelissen
 DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/)
 Pomperschans 26
 5595 AV Leende
 tel: 040 2065030/06 2325 06 53
 skype adres: frans.marcelissen
 email: frans.marcelis...@digipsy.nl

 [[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] Help with Fisher test for a more than two group of genes‏

2013-08-30 Thread Gabriel Wajnberg


From: gabriel.wajnb...@hotmail.com
To: r-help@r-project.org
Subject: Fisher test for a more than two group of genesþ
Date: Wed, 28 Aug 2013 15:53:59 -0300









Good Afternoon,
My name is Gabriel, I'm doing an analysis if there is increase or decrease in 
dependence on the mutated genes, using 3 or more genes using the fisher exact 
test.I performed with success an analysis for two genes using fisher.test( ). 
example of the 2x2 contigency table:
  Gene A mutated | Gene A normalGene B 
mutated|  26|
12Gene
 B normal | 10  |  50

Now I'm wondering how can I perform the analysis for 3 genes (and construct the 
contigency table), as follows: Gene A mutated, Gene A normal, Gene B mutated, 
Gene B normal, Gene C mutated and Gene C normal. How do I perform a fisher test 
using fisher.test( ) function using this data (3x3 contigency table)?Can 
someone help me ?

  
[[alternative HTML version deleted]]

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


Re: [R] mean

2013-08-30 Thread Roy Mendelssohn - NOAA Federal
Use is.numeric(list)  on the list to see if it is a list of numbers or if it is 
list of characters.  If it is a list of characters  (which could be the case if 
you read it in using read.csv or the like) and it makes sense to convert to 
numeric, then do something like:

list-as.numeric(list)

-Roy
On Aug 30, 2013, at 5:18 AM, agnes69 fes...@gredeg.cnrs.fr wrote:

 When I try to apply mean to a list, I get the answer :
 
 argument is not numeric or logical: returning NA
 
 Could you help me?
 
 (I am a very beginner)
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/mean-tp4674999.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.

**
The contents of this message do not reflect any position of the U.S. 
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected 
the arc of the moral universe is long, but it bends toward justice -MLK Jr.

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


Re: [R] Sensitivy / Specificity and nulls

2013-08-30 Thread Brecht Devleesschauwer
Maybe you want to check out the prevalence package 
(http://cran.r-project.org/web/packages/prevalence/index.html), and its 
development version on GitHub (https://github.com/brechtdv/prevalence/). 
When you have two tests, and neither can be considered to be a 'gold 
standard' (ie, SE  SP = 100%), Bayesian latent class approaches can 
help you to estimate true prevalence, sensitivity and specificity.


Brecht



Good Day All,

I am working with a diagnostic test and comparing the new test to an old
test.  Normally I would be able to calculate sensitivity and specificity
quite easily.

However, the 'gold standard' that I am comparing my new diagnostic 
with is
really 'gold-plated' in that sometimes the 'gold standard' fails 
completely
and I have no data from the 'gold standard' but I might have data from 
the

diagnostic test.  Of course sometimes my new diagnostic fails but I have
data from my 'gold standard'

To me this really starts moving towards classification but I cannot 
seem to

find the appropriate calculations.

Can someone point me to some web resources to determine the appropriate
method to be able to deal with the NULLs ?  Resources within the medical
realm would be better (because the rest of the folks would understand 
them
better) but not required. 



--
Devleesschauwer Brecht
Doctoral Researcher, MVSc DVM
Department of Virology, Parasitology and Immunology
Faculty of Veterinary Medicine
Ghent University
Salisburylaan 133
9820 Merelbeke
Belgium

Telephone: +32 9 264 7328
Mobile (Belgium): +32 476 365743
Mobile (Nepal): +977 9842 223323
E-mail: brecht.devleesschau...@ugent.be

http://users.ugent.be/~bdvleess/

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

2013-08-30 Thread John Kane
Hi Joana,
As far as I can see, R Essentials has nothing to do with R in terms of being an 
official R package so you will not find it on CRAN. 

It seems to be an IBM add-in for SPSS that let's you run R code within SPSS.  
It should be available from http://sourceforge.net/projects/ibmspssstat/

Good luck. 

Oh and R is much nicer than SPSS. Come join us.

John Kane
Kingston ON Canada


 -Original Message-
 From: joanasco...@hotmail.com
 Sent: Fri, 30 Aug 2013 14:27:37 +0100
 To: r-help@r-project.org
 Subject: [R] (no subject)
 
 good afternoon, I4m writting because I4m having some problems with R
 installation. I would like to install R essentials with spss Version 20
 but I can4t find wher in Cran site I can do the dowload speciffically of
 Essentials.
 Can you help me? I do not understand musch of R software and I just need
 to run it in SPSS menus
 Hope forward to hearning from you soon
 Best regards
 Joana
 
 
 Joana Costa, MSc, Ph.D.Postdoctoral Researcher(joanasco...@hotmail.com)
 CINEICC, University of Coimbra
 
 Rua do Coligio Novo, Apartado 6153
 
 3001-802 Coimbra, Portugal
 
 Telefone: (+351) 239 851450
 
 Fax: (+351) 239851462
   [[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.


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

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


Re: [R] calculate with different columns from different datasets

2013-08-30 Thread arun
Hi,


Using the same datasets:

dat1- read.table(text= 
V1 V2 V3 
2 6 8 
4 3 4 
1 9 8 
,sep=,header=TRUE) 

dat2- read.table(text= 
V1 V2 V3 
6 8 4 
2 0 7 
8 1 3 
,sep=,header=TRUE) 

sapply(seq_len(ncol(dat1)),function(i) cor(dat1[,i],dat2[,i],method=spearman))
#[1] -1.000  0.500 -0.8660254


#or
 diag(cor(dat1,dat2,method=spearman))
#    V1 V2 V3 
#-1.000  0.500 -0.8660254 

A.K.




- Original Message -
From: laro l_roh...@gmx.ch
To: r-help@r-project.org
Cc: 
Sent: Friday, August 30, 2013 12:52 PM
Subject: Re: [R] calculate with different columns from different datasets

Thank you a lot A.K.!

One more question:

I'd like to compute the Spearman's rank correlation coefficients for V1
(from dat1) and V1 (from dat2) and so on... Do you know how to do that?
I managed to write the Pearson's correlation product moment coefficient with
your sapply-approach, but I have no idea how to rank it.

Kind regards



--
View this message in context: 
http://r.789695.n4.nabble.com/calculate-with-different-columns-from-different-datasets-tp4674918p4675034.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] mean

2013-08-30 Thread agnes69
When I try to apply mean to a list, I get the answer :

argument is not numeric or logical: returning NA

Could you help me?

(I am a very beginner)



--
View this message in context: http://r.789695.n4.nabble.com/mean-tp4674999.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] (no subject)

2013-08-30 Thread Joana Costa
good afternoon, I´m writting because I´m having some problems with R 
installation. I would like to install R essentials with spss Version 20 but I 
can´t find wher in Cran site I can do the dowload speciffically of Essentials.
Can you help me? I do not understand musch of R software and I just need to run 
it in SPSS menus
Hope forward to hearning from you soon
Best regards
Joana 


Joana Costa, MSc, Ph.D.Postdoctoral Researcher(joanasco...@hotmail.com)
CINEICC, University of Coimbra

Rua do Colégio Novo, Apartado 6153

3001-802 Coimbra, Portugal

Telefone: (+351) 239 851450

Fax: (+351) 239851462 
[[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] https://stat.ethz.ch/pipermail/r-help/20

2013-08-30 Thread 886988067174
https://stat.ethz.ch/pipermail/r-help/20。。。!!。!。。。!。。!。。@@@。@。。une/243667.html__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] https://stat.ethz.ch/pipermail/r-help/20

2013-08-30 Thread 886988067174
https://stat.ethz.ch/pipermail/r-help/20。。。!!。!。。。!。。!。。@@@。@。。une/243667.html__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with newline using bquote(paste())

2013-08-30 Thread Gerard Smits
Hi All,

This is a variant of a problem I posted yesterday (see below) where I found I 
had a large gap between my N= and he number I had evaluated using .(x).  I seem 
to have trouble with newlines in a main title.  I find now that all works as 
expected (no unsightly gap between my N= and the value, if all of the title is 
put on the same line.  Whenever I try the newline, I run into problems.

Below, I have one example that gives me no syntax errors, but simply does not 
print the information after the \n (the N= xxx) part.

Any help appreciated.

Thanks,

Gerard

PS using R 3.0.0


ss-n(m18_das28*b_dascore)
par(oma=c(2,2,2,2))
scatterplot(m18_das28~b_score,
 jitter=list(x=1, y=1),
 grid=F,
 smooth=F,
 las=1,
 pch=c(1),
 col='blue',
 main=as.expression(bquote(paste(Baseline xyz with Month 18 DAS28\n)), 
bquote(paste((N=,.(ss),,
 xlab=Baseline xyz, 
 ylab=Month 18 DAS28,
 legend.plot=F)




Prior, related post:

On Aug 29, 2013, at 2:00 PM, Gerard Smits g_sm...@verizon.net wrote:

 Hi All,
 
 I'm using R 3.0.0.  I'm trying to add the sample size of the paired data 
 (calculated by a function n(), which returns a value of 70, correctly).
 
 My main title works fine except that the '70' appears far to the right on the 
 line as in:
 
  at Month 18 (N=   70)
 
 Is there a way of left justifying the result of .(ss)?  or some other way of 
 removing with whitespace between n= and 70?.
 
 Thanks for any suggestions.
 
 Gerard
 
 
 
 
 library (car)
 data-read.csv(//users//smits//r_work//data.csv, header = TRUE)
 attach(data);
 
 ##
 ss-n(m18_das28*b_score)
 
 scatterplot(m18_das28~b_score,
 jitter=list(x=1, y=1),
 grid=F,
 smooth=F,
 las=1,
 pch=c(1),
 col='blue',
 main=bquote(paste(Hypothesis 9.4.1\nBaseline XYZ with Disease Activity 
 (DAS28)\nat Month 18 (N=,.(ss),))),
 xlab=Baseline XYZ, 
 ylab=Month 18 DAS28,
 legend.plot=F)
 

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

2013-08-30 Thread Brian Diggs
On 8/30/2013 3:36 AM, Uwe Ligges wrote:


 On 30.08.2013 11:59, Christofer Bogaso wrote:
 Hello again,

 I have a string which I need to put in some legitimate date format.

 My string is: MAY-14

 And output format would be 05/01/2014, this should be of Date class,
 so that I can make some sensible calculation with it.

 I have tried this without any success:

 as.Date(MAY-14, format = %b-%y)
 [1] NA



 You must have set an English locale (to recognize the word May as a
 month) and you have to add a day.

You can use the yearmon class from the zoo package as an intermediary to 
get around having to explicitly add a day

library(zoo)
as.Date(as.yearmon(MAY-14, format=%b-%y))

gives

  as.Date(as.yearmon(MAY-14, format=%b-%y))
[1] 2014-05-01

 Best,
 Uwe Ligges




 Can somebody help me how I can achieve that?

 Thanks and regards,

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


Re: [R] strange conversion char to date

2013-08-30 Thread John Kane
Maybe there is some built-in assumption about dating and when to change to the 
new century. It seems to kick-in at 1968

as.Date(25/04/69, %d/%m/%y)

as.Date(25/04/68, %d/%m/%y)

as.Date(25/04/60, %d/%m/%y)

John Kane
Kingston ON Canada


 -Original Message-
 From: frans.marcelis...@digipsy.nl
 Sent: Fri, 30 Aug 2013 15:12:40 +0200
 To: r-help@r-project.org
 Subject: [R] strange conversion char to date
 
 Hi R-friends,
 Can anyone explain the following strange behavior to me?
 as.Date( 4/25/71,%m/%d/%y)
 [1] 1971-04-25
 as.Date( 4/25/62,%m/%d/%y)
 [1] 2062-04-25
 
 so 71 is converted to 1971, while 62 is converted to 2062? Does anyone
 know
 why? And is there a simple way to specify the date?
 (does works the same way in R 2.01 as well as in 1.9)
 
 ---
 dr F.H.G. (Frans) Marcelissen
 DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/)
 Pomperschans 26
 5595 AV Leende
 tel: 040 2065030/06 2325 06 53
 skype adres: frans.marcelissen
 email: frans.marcelis...@digipsy.nl
 
   [[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.


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

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


Re: [R] Memory usage bar plot

2013-08-30 Thread PIKAL Petr
Hi

From: mohan.radhakrish...@polarisft.com 
[mailto:mohan.radhakrish...@polarisft.com]
Sent: Friday, August 30, 2013 3:16 PM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: RE: [R] Memory usage bar plot

Hello,
This memory usage should be graphed with time. Are there 
examples of scatterplots that can clearly show usage vs time ?  This is for  
memory leak detection.

Hm, Actually I do not understand what do you want. No data, no code just some 
vague description. If you have data frame with variables usage and time you can 
plot

plot(time, usage)

Regards
Petr


Thanks,
Mohan



From:PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To:
mohan.radhakrish...@polarisft.commailto:mohan.radhakrish...@polarisft.com 
mohan.radhakrish...@polarisft.commailto:mohan.radhakrish...@polarisft.com, 
r-help@r-project.orgmailto:r-help@r-project.org 
r-help@r-project.orgmailto:r-help@r-project.org
Date:08/30/2013 05:33 PM
Subject:RE: [R] Memory usage bar plot




Hi

For reading data into R you shall look to read.table and similar.

For plotting ggplot could handle it. However I wonder if 100 times 50 bars is 
the way how to present your data. You shall think over what do you want to show 
to yourself or your audience. Maybe boxplots or scatterplots could be better.

Petr


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.org] On Behalf Of 
 mohan.radhakrish...@polarisft.commailto:mohan.radhakrish...@polarisft.com
 Sent: Friday, August 30, 2013 1:25 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] Memory usage bar plot

 Hi,
   I haven't tried the code yet. Is there a way to parse this
 data using R and create bar plots so that each program's 'RAM used'
 figures are grouped together.
 So 'uuidd' bars will be together. The data will have about 50 sets. So
 if there are 100 processes each will have about 50 bars.

 What is the recommended way to graph these big barplots ? I am looking
 for only 'RAM used' figures.


 Thanks,
 Mohan


  Private  +   Shared  =  RAM used   Program

  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 -
 453.9 MiB

 =
  Private  +   Shared  =  RAM used   Program

  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 --
 453.9 MiB
 =


 This e-Mail may contain proprietary and confidential information and is
 sent for the intended recipient(s) only.  If by an addressing or
 transmission error this mail has been misdirected to you, you are
 requested to delete this mail immediately. You are also hereby notified
 that any use, any form of reproduction, dissemination, copying,
 disclosure, modification, distribution and/or publication of this e-
 mail message, contents or its attachment other than by its intended
 recipient/s is strictly prohibited.

 Visit us at http://www.polarisFT.comhttp://www.polarisft.com/

  [[alternative HTML version deleted]]

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



This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only. If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited. Visit us at 
http://www.polarisFT.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list

Re: [R] strange conversion char to date

2013-08-30 Thread arun


Hi,

You may try:
x1- c(4/25/71,4/20/64)
fun1- function(x, year){
m1-as.numeric(format(as.Date(x1,%m/%d/%y),%y))
m1- ifelse(m1year%%100,1900+m1,2000+m1)
m2- paste0(gsub((.*\\/).*$,\\1,x),m1)
as.Date(m2,%m/%d/%Y)
}
fun1(x1,1950)
#[1] 1971-04-25 1964-04-20
 str(fun1(x1,1950))
# Date[1:2], format: 1971-04-25 1964-04-20

A.K.


- Original Message -
From: Frans Marcelissen frans.marcelis...@digipsy.nl
To: R-help@r-project.org R-help@r-project.org
Cc: 
Sent: Friday, August 30, 2013 9:12 AM
Subject: [R] strange conversion char to date

Hi R-friends,
Can anyone explain the following strange behavior to me?
 as.Date( 4/25/71,%m/%d/%y)
[1] 1971-04-25
 as.Date( 4/25/62,%m/%d/%y)
[1] 2062-04-25

so 71 is converted to 1971, while 62 is converted to 2062? Does anyone know
why? And is there a simple way to specify the date?
(does works the same way in R 2.01 as well as in 1.9)

---
dr F.H.G. (Frans) Marcelissen
DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/)
Pomperschans 26
5595 AV Leende
tel: 040 2065030/06 2325 06 53
skype adres: frans.marcelissen
email: frans.marcelis...@digipsy.nl

    [[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] Memory usage bar plot

2013-08-30 Thread PIKAL Petr
Hi

For reading data into R you shall look to read.table and similar.

For plotting ggplot could handle it. However I wonder if 100 times 50 bars is 
the way how to present your data. You shall think over what do you want to show 
to yourself or your audience. Maybe boxplots or scatterplots could be better.

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of mohan.radhakrish...@polarisft.com
 Sent: Friday, August 30, 2013 1:25 PM
 To: r-help@r-project.org
 Subject: [R] Memory usage bar plot
 
 Hi,
   I haven't tried the code yet. Is there a way to parse this
 data using R and create bar plots so that each program's 'RAM used'
 figures are grouped together.
 So 'uuidd' bars will be together. The data will have about 50 sets. So
 if there are 100 processes each will have about 50 bars.
 
 What is the recommended way to graph these big barplots ? I am looking
 for only 'RAM used' figures.
 
 
 Thanks,
 Mohan
 
 
  Private  +   Shared  =  RAM used   Program
 
  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 -
 453.9 MiB
 
 =
  Private  +   Shared  =  RAM used   Program
 
  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 --
 453.9 MiB
 =
 
 
 This e-Mail may contain proprietary and confidential information and is
 sent for the intended recipient(s) only.  If by an addressing or
 transmission error this mail has been misdirected to you, you are
 requested to delete this mail immediately. You are also hereby notified
 that any use, any form of reproduction, dissemination, copying,
 disclosure, modification, distribution and/or publication of this e-
 mail message, contents or its attachment other than by its intended
 recipient/s is strictly prohibited.
 
 Visit us at http://www.polarisFT.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] ddply for comparing simulation results

2013-08-30 Thread jim holtman
This might do it:


 lhs=c('a','a','a','b')
 rhs=c('a','b','b','b')


 # function to determine differences
 f_diff - function(l, r){
+ t_l - table(l)
+ t_r - table(r)
+ # compare 'l' to 'r'
+ sapply(names(t_l), function(x){
+ if (is.na(t_r[x])) return(t_l[x])
+ t_l[x] - t_r[x]
+ })
+ }

 f_diff(lhs, rhs)
a.a b.b
  2  -2



Jim Holtman
Data Munger Guru

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


On Fri, Aug 30, 2013 at 1:28 PM, john doe anon.r.u...@gmail.com wrote:
 Hi Jim,

 Thanks for the quick reply!  Data.table sounds like it will help me with my
 performance problem.  However, I think that setdiff does not do quite what I
 need.  Consider this example:

 lhs=c('a','a','a','b')
 rhs=c('a','b','b','b')
 setdiff(lhs,rhs)
 character(0)

 I need to do an operation between lhs and rhs which gives this result:
   a: 2
   b: -2

 It looks like base set operations call unique on their vectors before
 performing the intersection, which does not allow me to measure the
 magnitude of the difference between the sets.

 Ari




 On Fri, Aug 30, 2013 at 5:10 AM, jim holtman jholt...@gmail.com wrote:

 try the 'data.table package.  It gives the answer in less than a second.

  # 1 million leads, half of which were simulated, half of which were not
  id=1:100
  isSimulated = c(rep(0,50), rep(1, 50))
  userId=sample(1:10, 100, replace=T)
  df_leads=data.frame(id, isSimulated, userId)
  require(data.table)
 Loading required package: data.table
 data.table 1.8.8  For help type: help(data.table)
  system.time({
 + df_leads - data.table(df_leads)
 + df_leads_sum - df_leads[
 + , list(count = .N)
 + , keyby = c('isSimulated', 'userId')
 + ]
 + })
user  system elapsed
0.750.010.76
 
  head(df_leads_sum)
isSimulated userId count
 1:   0  1 5
 2:   0  2 9
 3:   0  3 5
 4:   0  4 4
 5:   0  5 3
 6:   0  6 7


 you can use 'setdiff' to find userIDs that are missing from one group
 or the other:

  #see which userIDs are missing between the groups
  not_in - setdiff(df_leads_sum$userId[df_leads_sum$isSimulated == 0]
 +   , df_leads_sum$userId[df_leads_sum$isSimulated == 1]
 +   )
  str(not_in)
  int [1:697] 59 100 204 584 656 828 840 999 1012 1046 ...
 
 Jim Holtman
 Data Munger Guru

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


 On Thu, Aug 29, 2013 at 11:33 PM, john doe anon.r.u...@gmail.com wrote:
  I am trying to use R and plyr to compare the effectiveness of various
  algorithms for online advertising.  At the core, I am simply counting
  when a
  user receives a lead: this is measured with the userId column.  Leads
  that
  were sent in production have a 0 in the isSimulated column, and leads
  that
  were sent in our simulation have isSimulated=1.  I have two questions:
  one
  about performance and one about how to use plyr to get the data in a
  form
  that I want.
 
  Here is an example of my code:
 
  # 1 million leads, half of which were simulated, half of which were not
  id=1:100
  isSimulated = c(rep(0,50), rep(1, 50))
  userId=sample(1:10, 100, replace=T)
  df_leads=data.frame(id, isSimulated, userId)
 
  # split by simulated and userid, and then sum
  system.time(df_leads_sum - ddply(df_leads, .(isSimulated, userId),
  nrow))
 user  system elapsed
   38.167   0.212  38.386
 
  The above call to ddply is great because it allows me to create
  histograms
  of how many people receive just a few leads, or a lot of leads, both in
  production and in the simulator.
 
  Question 1: The above ddply call takes a while to execute.  With
  production
  data it takes several minutes in R, but only a few seconds in MySQL.  Is
  there a way to improve the performance of the above call?
 
  Question 2: What I would really like to do is create a histogram which
  measures the distribution of change in leads between non-simulated and
  simulated data.  A complicating fact is that some users might only
  appear in
  simulated or non-simulated data, so I need to correclty handle the
  absense
  of a userId.  (In production, users are actually guaranteed to appear in
  production - but the crux of the problem is the same: userIds might be
  missing in one of the splits).  Can someone help me with this?  I've
  read
  the documentation a few times, and think that the summarize function
  might
  be able to help, but I'm not quite sure how to do this.
 
  Thanks.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  manipulatr group.
  To unsubscribe from this group and stop receiving emails from it, send
  an
  email to manipulatr+unsubscr...@googlegroups.com.
  To post to this group, send email to manipul...@googlegroups.com.
  Visit this 

Re: [R] problem with newline using bquote(paste())

2013-08-30 Thread Gerard Smits
That explains it.  Thanks for the info.  Gerard


On Aug 30, 2013, at 8:42 AM, Marc Schwartz marc_schwa...@me.com wrote:

 
 On Aug 30, 2013, at 10:26 AM, Gerard Smits g_sm...@verizon.net wrote:
 
 Hi All,
 
 This is a variant of a problem I posted yesterday (see below) where I found 
 I had a large gap between my N= and he number I had evaluated using .(x).  I 
 seem to have trouble with newlines in a main title.  I find now that all 
 works as expected (no unsightly gap between my N= and the value, if all of 
 the title is put on the same line.  Whenever I try the newline, I run into 
 problems.
 
 Below, I have one example that gives me no syntax errors, but simply does 
 not print the information after the \n (the N= xxx) part.
 
 Any help appreciated.
 
 Thanks,
 
 Gerard
 
 PS using R 3.0.0
 
 
 ss-n(m18_das28*b_dascore)
 par(oma=c(2,2,2,2))
 scatterplot(m18_das28~b_score,
jitter=list(x=1, y=1),
grid=F,
smooth=F,
las=1,
pch=c(1),
col='blue',
main=as.expression(bquote(paste(Baseline xyz with Month 18 DAS28\n)), 
 bquote(paste((N=,.(ss),,
xlab=Baseline xyz, 
ylab=Month 18 DAS28,
legend.plot=F)
 
 
 
 
 Prior, related post:
 
 On Aug 29, 2013, at 2:00 PM, Gerard Smits g_sm...@verizon.net wrote:
 
 Hi All,
 
 I'm using R 3.0.0.  I'm trying to add the sample size of the paired data 
 (calculated by a function n(), which returns a value of 70, correctly).
 
 My main title works fine except that the '70' appears far to the right on 
 the line as in:
 
 at Month 18 (N=   70)
 
 Is there a way of left justifying the result of .(ss)?  or some other way 
 of removing with whitespace between n= and 70?.
 
 Thanks for any suggestions.
 
 Gerard
 
 
 
 
 library (car)
 data-read.csv(//users//smits//r_work//data.csv, header = TRUE)
 attach(data);
 
 ##
 ss-n(m18_das28*b_score)
 
 scatterplot(m18_das28~b_score,
   jitter=list(x=1, y=1),
   grid=F,
   smooth=F,
   las=1,
   pch=c(1),
   col='blue',
   main=bquote(paste(Hypothesis 9.4.1\nBaseline XYZ with Disease Activity 
 (DAS28)\nat Month 18 (N=,.(ss),))),
   xlab=Baseline XYZ, 
   ylab=Month 18 DAS28,
   legend.plot=F)
 
 
 
 
 You cannot use newlines in plotmath expressions. You will need to create each 
 line of the plot title text separately using ?mtext instead of specifying 
 'main' in the plot call.
 
 Regards,
 
 Marc Schwartz
 

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


Re: [R] calculate with different columns from different datasets

2013-08-30 Thread laro
Thank you a lot A.K.!

One more question:

I'd like to compute the Spearman's rank correlation coefficients for V1
(from dat1) and V1 (from dat2) and so on... Do you know how to do that?
I managed to write the Pearson's correlation product moment coefficient with
your sapply-approach, but I have no idea how to rank it.

Kind regards



--
View this message in context: 
http://r.789695.n4.nabble.com/calculate-with-different-columns-from-different-datasets-tp4674918p4675034.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] Memory usage bar plot

2013-08-30 Thread Richard M. Heiberger
## Here is a plot.  The input was parsed with Jim Holtman's code.
## The panel.dumbell is something I devised to show differences.

## Rich


input - readLines(textConnection(
 Private  +   Shared  =  RAM used   Program

 96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
-
453.9 MiB

=
 Private  +   Shared  =  RAM used   Program

 96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
--
453.9 MiB
=))

# keep only the data
input - input[grepl('=', input)]

# separate into groups
grps - split(input, cumsum(grepl(=  RAM, input)))

# parse the data (not sure if there is also 'MiB')
parsed - lapply(grps, function(.grp){
# parse ignoring first and last lines
.data - sub(.*= ([^ ]+) ([^ ]+)\\s+(.*), \\1 \\2 \\3
, .grp[2:(length(.grp) - 1L)]
)
# return matrix
do.call(rbind, strsplit(.data, ' '))
})



parsed

tmp1 - do.call(rbind, lapply(parsed, function(x) data.frame(x)))
names(tmp1) - c(RamUsed, units, Program)
tmp1$Time - factor(rep(1:2, each=7))
tmp1$RamUsed - as.numeric(tmp1$RamUsed)

library(lattice)
dotplot(Program ~ RamUsed, groups=Time, data=tmp1)
## this is silly.  Let me construct a more interesting example with
different values at each time.
tmp1$RamUsed[8:14] - tmp1$RamUsed[1:7] + 10*(sample(1:7))
tmp1
dotplot(Program ~ RamUsed, groups=Time, data=tmp1,
auto.key=list(title=Time, border=TRUE, columns=2))

panel.dumbell - function(x, y, ..., lwd=1) {
  n - length(x)/2
  panel.segments(x[1:n], as.numeric(y)[n+(1:n)], x[n+(1:n)],
as.numeric(y)[n+(1:n)], lwd=lwd)
  panel.dotplot(x, y, ...)
}

dotplot(Program ~ RamUsed, groups=Time, data=tmp1,
auto.key=list(title=Time, border=TRUE, columns=2),
panel=panel.dumbell,
par.settings=list(superpose.symbol=list(pch=19)),
)



On Fri, Aug 30, 2013 at 9:44 AM, jim holtman jholt...@gmail.com wrote:

 Here is how to parse the data and put it into groups.  Not sure what
 the 'timing' of each group is since not time information was given.
 Also not sure is there is an 'MiB' qualifier on the data, but you have
 the matrix of data which is easy to do with as you want.


  input - readLines(textConnection(
 +  Private  +   Shared  =  RAM used   Program
 +
 +  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 + 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 + 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 + 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 + 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 + 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 + 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 + -
 + 453.9 MiB
 +
 + =
 +  Private  +   Shared  =  RAM used   Program
 +
 +  96.0 KiB +  11.5 KiB = 107.5 KiB   uuidd
 + 108.0 KiB +  12.5 KiB = 120.5 KiB   klogd
 + 124.0 KiB +  17.0 KiB = 141.0 KiB   hidd
 + 116.0 KiB +  30.0 KiB = 146.0 KiB   acpid
 + 124.0 KiB +  29.5 KiB = 153.5 KiB   hald-addon-storage
 + 144.0 KiB +  15.0 KiB = 159.0 KiB   gpm
 + 136.0 KiB +  26.5 KiB = 162.5 KiB   pam_timestamp_check
 + --
 + 453.9 MiB
 + =))
 
  # keep only the data
  input - input[grepl('=', input)]
 
  # separate into groups
  grps - split(input, cumsum(grepl(=  RAM, input)))
 
  # parse the data (not sure if there is also 'MiB')
  parsed - lapply(grps, function(.grp){
 + # parse ignoring first and last lines
 + .data - sub(.*= ([^ ]+) ([^ ]+)\\s+(.*), \\1 \\2 \\3
 + , .grp[2:(length(.grp) - 1L)]
 + )
 + # return matrix
 + do.call(rbind, strsplit(.data, ' '))
 + })
 
 
 
  parsed
 $`1`
  [,1][,2]  [,3]
 [1,] 107.5 KiB uuidd
 [2,] 120.5 KiB klogd
 [3,] 141.0 KiB hidd
 [4,] 146.0 KiB acpid
 [5,] 153.5 KiB hald-addon-storage
 [6,] 159.0 KiB gpm
 [7,] 162.5 KiB pam_timestamp_check

 $`2`
  [,1][,2]  [,3]
 [1,] 107.5 KiB uuidd
 [2,] 120.5 KiB klogd
 [3,] 141.0 KiB hidd
 [4,] 146.0 KiB acpid
 [5,] 153.5 KiB 

Re: [R] problem in while loop?

2013-08-30 Thread Amen Alyaari

Thanks Berend.
Yes that is right. I should get 5 values(results) of x_e because I have 
five values of X. I wonder how can I fix it?

On 30/08/2013 13:13, Berend Hasselman wrote:

On 30-08-2013, at 09:44, Jonssonamen.alya...@bordeaux.inra.fr  wrote:


I have three datasets that I want to compute the errors between them using
linear regression.for this, I want to iterate to reach certain criteria for
the calibration. if changes become smaller than eps the iteration is
successful, hence stop and write parameters into cal:eps=0.1 if number
of iterations is  itermax the iteration failed, hence stop and fill cal
with missing value itermax=400

So I tried this code:

  x= c(5,2,4,2,1)
  y= c(5,3,4,6,9)
  z= c(5,8,4,7,3)
  itermax=400
get initial calibration parameters, here we assume that:x is the reference
dataset offset x_a=0, slope x_b=1 the other two datasets y, z are
calibrated to x using a simple linear regression

 res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
  res1=lm(x~z)
  z_a=coef(res1)[1] ; z_b=coef(res1)[2]
  y_t = y/y_b - y_a/y_b  # calibrate y
  z_t = z/z_b - z_a/z_b  #calibrate z
  x_e = sqrt(mean((x-y_t)*(x-z_t)))#calculate error of x
   iter- 0
   while(((x_e-x)  0.1)  (iter  itermax)) {
  iter- 0  ##start iteration
   x = x_e
   res=lm(x~y)
   y_a=coef(res)[1] ; y_b=coef(res)[2]
   res1=lm(x~z)
   z_a=coef(res1)[1] ; z_b=coef(res1)[2]
   y_t = y/y_b - y_a/y_b  # calibrate y
   z_t = z/z_b - z_a/z_b  #calibrate z
   x_e = sqrt(mean((x-y_t)*(x-z_t)))
iter- iter + 1 # increase iteration counter
}
But I got the same result for X_e before and after the loop:


x_e

 [1] 6.454089


I tried your code and got this error message:

Error in model.frame.default(formula = x ~ y, drop.unused.levels = TRUE) :
   variable lengths differ (found for 'y')
Calls: lm -  eval -  eval -  Anonymous  -  model.frame.default

And looking at your code:  x is a vector, x_e is a scalar and in the while loop 
you are assigning x_e to x so x is then a scalar.

Berend




--
Amen Alyaari, UPMC
PhD student
Unit of Functional Ecology  Environmental Physics [EPHYSE]
National Institute of Agricultural Research [INRA].
71, Avenue Edouard Bourlaux
33140 Villenave d'Ornon
Téléphone : +33(0) 5 57 12 24 27
Fax : +33 (0)5 57 12 24 20
FRANCE

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


Re: [R] mean

2013-08-30 Thread arun
Hi,
In case, some of the list elements are vectors, this procedure would not work.
 a1- list(c(3,5),4,5:6)
as.numeric(a1)
#Error: (list) object cannot be coerced to type 'double'

The OP didn't provide any info as to how the data looks like.  So, these are 
just assumptions.
 mean(unlist(a1)) #if the overall mean is needed. 
#[1] 4.6
#or mean of each list element

sapply(a1,mean)
#[1] 4.0 4.0 5.5

#or if it includes data.frame or matrix.
a2- list(4, as.data.frame(matrix(1:10,5,2)),4:6)


a3- list(4, matrix(1:10,5,2),4:6)
mean(unlist(a2))
#[1] 5.285714

mean(unlist(a3))
#[1] 5.285714


A.K.

- Original Message -
From: Albyn Jones jo...@reed.edu
To: agnes69 fes...@gredeg.cnrs.fr
Cc: r-help@r-project.org
Sent: Friday, August 30, 2013 11:59 AM
Subject: Re: [R] mean

It would be easier to diagnose the problem if you included an example
illustrating exactly what you did.  I'll guess:

 a - list(3,4,5)
 mean(a)
[1] NA
Warning message:
In mean.default(a) : argument is not numeric or logical: returning NA

 mean(as.numeric(a))
[1] 4

But that's just a guess, as I don't know the actual contents of your list!

albyn


On Fri, Aug 30, 2013 at 5:18 AM, agnes69 fes...@gredeg.cnrs.fr wrote:

 When I try to apply mean to a list, I get the answer :

 argument is not numeric or logical: returning NA

 Could you help me?

 (I am a very beginner)



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

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


    [[alternative HTML version deleted]]

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


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


Re: [R] writing spdiags function for R

2013-08-30 Thread moreno
I am posting here the brilliant solutions, gently provided by  Prof JC Nash
nashjc at uottawa.ca, to me; so that people struggling in the future with
the same issue can find a way through. 

FYI, compared to the original Matlab implementation: 1) it does not handle
the case with more than one input, and  
2) (m  n) matrices give the B matrix columns in a different order, but the
d vector of indices will also be changed
accordingly, so the set of columns is OK, just ordered differently cif. JN.

Copied below the .R version of the spdiags code, a Fortran implementation of
it, and an R wrapper to run the .f

thanks again JN, your help was really invaluable :)

#
 

R version

#
spdiagsj - function(A) { # A is a matrix
   m - dim(A)[[1]]
   n - dim(A)[[2]]
   k - min(m, n) # length of diagonals
   Bdata-NULL # start with nothing in B matrix (as vector)
   jb-0 # column index of last column saved for B
   d-NULL # index vector of diagonals from A 
   # d contains 0 for the principal diagonal, -i for i'th lower
   # diagonal (prefaced with zeros), +j for j'th upper diagonal
   # (suffixed by zeros)
   q-(m-1)+n # There are m-1 subdiagonals and n-1 superdiagonals + main
diagonal

   if (m  n) { # tall matrix
  Adata - as.vector(t(A)) # convert to vector BY ROWS
   } else { # fat or square matrix (m = n)
  Adata - as.vector(A) # convert to vector BY COLUMNS 
   }
   # Augment the data with columns of zeros fore and aft
   Adata-c(rep(0,(k-1)*k), Adata, rep(0,(k-1)*k))
   cat(Augmented Adata with ,length(Adata), elements:\n)
   print(Adata)
   for (i in 1:q) {
   tv - c(Adata[[k*(i-1)+1]], rep(0,k-1)) # top element of augmented
column
  # plus enough zeros to pad it out (some zeros may be replaced
below)
  # i.e., start at 1, then m+1, 2*m+1 etc.
  qx-min((q-i), (k-1)) # 
  cat( qx=,qx,\n)
  if (qx  0) { # qx will be 0 when we are at last
superdiagonal,i.e., i == q
 for (j in 1:qx) { # get the rest of the diagonal elements
 tv[[j+1]] - Adata[[k*(i+j-1)+j+1]]
 }
  }
  if (any(tv != 0)){ # check for non-zeros, if there are, then save
 jb-jb+1 # next column of B
 d-c(d,(i-k)) # record the index
 Bdata-c(Bdata, tv) # save the diagonal as column of B in
vector form
  }
  }
   if (m  n) d - -d # reset index
   cat(Bdata:);  print(Bdata)

   B - matrix(Bdata, nrow=k, byrow=FALSE) # convert to matrix form
   result-list(B=B, d=d)
}

cat(Matlab example 1\n)
dta - c(0, 5, 0, 10, 0, 0, 0, 0, 6, 0, 11, 0, 3, 0, 0, 7, 0, 12, 1, 4, 0,
0, 8, 0, 0, 2, 5, 0, 0, 9)
A1 - matrix(dta, nrow=5, ncol=6, byrow=TRUE)

print(A1)
res1-spdiagsj(A1)
print(res1)
tmp-readline(Next)

cat(Matlab example 2\n)
n-10 # choose 10 for an example
A2-matrix(rep(0, n*n), nrow=n, ncol=n)

for (i in 1:n) {
for (j in 1:n) {
   if (i == j) A2[i, j] - -2
   if ( (i == (j-1)) || (i == (j+1))) A2[i,j] - 1
}
}
print(A2)
res2-spdiagsj(A2)
print(res2)
tmp-readline(Next)

cat(Matlab example 3\n)
dta3 - c(11, 0, 13, 0, 0, 22, 0, 24, 0, 0, 33, 0, 41, 0, 0, 44,
0, 52, 0, 0, 0, 0, 63, 0, 0, 0, 0, 74)
A3 - matrix(dta3, nrow=7, ncol=4, byrow=TRUE)

print(A3)
res3-spdiagsj(A3)
print(res3)
tmp-readline(Next)

cat(try transpose\n)
A3T-t(A3)
print(A3T)
res3T-spdiagsj(A3T)
print(res3T)
tmp-readline(Next)

cat(Example 5B \n)
dta5b1-c(6, 0, 13, 0, 0, 0, 7, 0, 14, 0, 1, 0, 8, 0, 15, 0, 2, 0, 9, 0, 0,
0, 3, 0, 10)
A5b1-matrix(dta5b1, nrow=5, ncol=5, byrow=TRUE)
print(A5b1)
res5b1-spdiagsj(A5b1)
print(res5b1)

#
 

Fortran version

#

  subroutine jspd(m, n, k, Adata, jb, Bdata, d, tv, na, nb, nd)
C   Central part of spdiags for R
C m and n are row and column sizes of A (underlying matrix)
C jb will be number of returned diagonals
C returns jb, Bdata, d
  integer m, n, na, nb, nd, jb, d(nd)
  integer i, j, k, kend, q, mn, kk1, js, je, qx
  double precision Adata(na), Bdata(nb), tv(k)
  LOGICAL not0
C  k = min(m, n)
C ??  check if k=1
C  Bdata-NULL # start with nothing in B matrix (as vector)
  jb = 0 
  kend=0
C column index of last column saved for B
C   d = NULL # index vector of diagonals from A 
C   # d contains 0 for the principal diagonal, -i for i'th lower
C   # diagonal (prefaced with zeros), +j for j'th upper diagonal
C   # (suffixed by zeros)
  q = (m-1)+n 
C  There are m-1 subdiagonals and n-1 superdiagonals + main diagonal
C   assume we have already built Adata for tall or fat matrix
C   # Augment the data with columns of zeros fore and aft
  mn = m*n
C  print *,Original Adata
C  print 

Re: [R] Validating data type

2013-08-30 Thread John Kane
It sounds like that column of data is not of type date at all. You cannot 
have one element of a column different from the rest of the column.  In a 
data.frame you can have different types of data in different columns but not in 
the same column.

Where mydata is your data.frame do :

str(mydata)

This will give you a listing of the type of data in each column in your 
data.frame.  

My guess would be that R has read in that column as character or factor.  Just 
because it looks like a date on the screen does not mean it is one. You 
probably will have to convert it to a date. 

See ?as.Date for one way to do this.

  You might also want to have a look at the lubridate package.

For further reference 
https://github.com/hadley/devtools/wiki/Reproducibility
 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

In particular for a question like yours, supplying some sample data using 
dput() would have really helped.  If you are still having a problem do : 
dput(mydata) and paste the output into the email. The reader  can then paste 
the data into their version of R and see exactly what you are working with.  
For large datasets usually a sample amoutnt will do  , so  dput(head(mydata, 
100) for example will supply 100 rows of data.

Below is a example of a data.frame in dput format. Just copy and paste it into 
R and you will have a new date.frame

John Kane
Kingston ON Canada

##dput file===
dat1  -  structure(list(xx = structure(c(5L, 6L, 10L, 9L, 17L, 10L, 15L, 
16L, 5L, 14L, 5L, 7L, 17L, 6L, 11L, 8L, 5L, 3L, 1L, 17L, 7L, 
10L, 5L, 15L, 15L, 16L, 17L, 14L, 8L, 13L, 12L, 13L, 18L, 9L, 
5L, 2L, 1L, 16L, 1L, 1L, 1L, 16L, 4L, 10L, 1L, 18L, 18L, 14L, 
13L, 4L), .Label = c(a, b, d, f, g, h, i, j, 
k, l, m, n, o, p, q, r, s, t), class = factor), 
yy = c(0.332304663767243, -1.77867401940838, 0.828612337938625, 
0.481702424196278, 0.0825987297345907, -1.40224568135063, 
-0.24334456876, 0.0865304079310024, -0.124012796374592, 
-0.0107544463484595, -0.542307211820575, 0.0129727866797914, 
-0.478553152291621, -1.63895681984396, 0.0911014618211326, 
-0.890215628553797, -1.42140590396317, 0.202337039384179, 
1.30089052407852, 0.07517013402338, -0.807355878474237, 1.12978841894929, 
0.154740986108198, 0.21209595540936, 0.65345449749952, 0.533479658343466, 
0.665882552612018, -0.60572360781, -0.0971202279326936, 
-0.862179166296771, -0.977706435316816, 0.559634439503645, 
0.0320050874597674, -1.65502174652502, 0.853046541850183, 
-0.801904205812903, -0.820335448022446, -0.912451936657161, 
0.222469916395761, 0.0168002536713376, -0.218537143966283, 
1.00191128410043, -0.430912734152427, -1.1327880971227, -0.664284053548425, 
1.3082467197158, 1.46148850229679, -1.11954785811615, -1.61706514557631, 
0.604530320200236)), .Names = c(xx, yy), row.names = c(NA, 
-50L), class = data.frame)
##===end dput file


 -Original Message-
 From: jeffj...@worldvision.org
 Sent: Thu, 29 Aug 2013 20:29:54 -0700
 To: r-help@r-project.org
 Subject: [R] Validating data type
 
 
 
 I'm very new to R. I have a data file that I have read in via read.csv. I
 expect one of the columns to be of type date for example. However at
 least one value in that column is not of date type. I know this because
 another program I am trying to process the file with is erroring, yet it
 doesn't tell me what row/value is erroring. Does R have a way to: treat
 column x as date type, and print out all values/row numbers do not
 conform
 to that type for that specified column?
 
 Many thanks!
 Jeff
   [[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.


TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!

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


Re: [R] delete repeated values in array

2013-08-30 Thread arun
Hi,

May be this helps:
rle(try)$values
#[1] 1 2 3 1 2 4


#or
 aggregate(try,list(cumsum(c(1,abs(diff(try),unique)[,2]
#[1] 1 2 3 1 2 4
#or
res-tapply(try,cumsum(c(1,abs(diff(try,head,1)
attr(res,dimnames)-NULL
 res
#[1] 1 2 3 1 2 4


A.K.


I am trying to delete repeated values in an array. 

try - c(1,1,1,1,1,2,2,2,3,3,3,1,1,1,2,2,4,4,4) 

what I want back is: 

1 2 3 1 2 4 

so unique() doesn't work for my purposes as it would give me: 
1 2 3 4

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: XML content does not seem to be XML: ''

2013-08-30 Thread Anil Kumar
Hi there,
I am attempting to access an Allegro Graph site, using SPARQL function in 
RStudio and am getting this error message Error: XML content does not seem to 
be XML: ''. However, the same query that I am using within the SPARQL function 
can get back the results when directly from the browser.

Please advise.

Cheers,
Anil
[[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] Basic Error I'm sure

2013-08-30 Thread Casey Zhang
Hi,

I'm just starting to learn how to use R and I'm trying to create a
histogram with 7 breaks. This is my code so far:

dat=read.table(titanic.csv,header=TRUE,sep=,,na.string=.)
age=dat$Age
breaks=seq(min(age),max(age),length=7)
hist(age,breaks,freq=FALSE)

I don't know why, but on the fourth line it always gives this error:

Error in if (from == to) rep.int(from, length.out) else as.vector(c(from,  :
  missing value where TRUE/FALSE needed

What am I doing wrong? I know the data itself does have a lot of NA
values for age, would this be the problem?


Thanks,

CZ

[[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] does rstudio-server support named configuration

2013-08-30 Thread qiulin
I appreciate your time, thank you in advance  :)

I'd like to start 2 rstudio-server in one Linux machine, one daemon listen port 
8787  running R-2.15, on daemon listen port 8788 running R-3.01.
Can I have named rstudio-server configurations so I can start rstudio-server  
like this :
:rstudio-server --config-file = R-2.15.conf  start,   it runs  R-2.15 
listening  port 8787
:rstudio-server --config-file = R-3.01.conf  start,   it runs  R-3.01 
listening  port 8788

Ipython-notebook support named configuration, does  rstudio-server have this 
feature ?

Cheers, Choulin.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] for loop of a geometric sequence

2013-08-30 Thread BJN1417
so I have to create a for loop of the geometric sequence
h(x,n)=1+x+x^2+x^3^4...x^n.  I know that it would be easier to simply
vectorize the sequence to x^(0:n), but I am required to make the loop, and I
can't wrap my brain around how to loop it because the equation  is so
simple.



--
View this message in context: 
http://r.789695.n4.nabble.com/for-loop-of-a-geometric-sequence-tp4675035.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] Basic Error I'm sure

2013-08-30 Thread Ista Zahn
Hi Casey,

Yes, if there are missing values than you don't strictly speaking know
what the minimum value is. You need to tell min() and max() to exclude
missing, i.e.,

breaks=seq(min(age, na.rm=TRUE),max(age, na.rm=TRUE),length=7)

Best,
Ista

On Fri, Aug 30, 2013 at 9:41 PM, Casey Zhang casey1...@gmail.com wrote:
 Hi,

 I'm just starting to learn how to use R and I'm trying to create a
 histogram with 7 breaks. This is my code so far:

 dat=read.table(titanic.csv,header=TRUE,sep=,,na.string=.)
 age=dat$Age
 breaks=seq(min(age),max(age),length=7)
 hist(age,breaks,freq=FALSE)

 I don't know why, but on the fourth line it always gives this error:

 Error in if (from == to) rep.int(from, length.out) else as.vector(c(from,  :
   missing value where TRUE/FALSE needed

 What am I doing wrong? I know the data itself does have a lot of NA
 values for age, would this be the problem?


 Thanks,

 CZ

 [[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] does rstudio-server support named configuration

2013-08-30 Thread Ista Zahn
The Rstudio support forum is at http://support.rstudio.com

Best,
Ista

On Fri, Aug 30, 2013 at 12:41 PM, qiulin qiulin.w...@gmail.com wrote:
 I appreciate your time, thank you in advance  :)

 I'd like to start 2 rstudio-server in one Linux machine, one daemon listen 
 port 8787  running R-2.15, on daemon listen port 8788 running R-3.01.
 Can I have named rstudio-server configurations so I can start rstudio-server  
 like this :
 :rstudio-server --config-file = R-2.15.conf  start,   it runs  R-2.15 
 listening  port 8787
 :rstudio-server --config-file = R-3.01.conf  start,   it runs  R-3.01 
 listening  port 8788

 Ipython-notebook support named configuration, does  rstudio-server have this 
 feature ?

 Cheers, Choulin.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Basic Error I'm sure

2013-08-30 Thread Pascal Oettli
Hello,

Check the result of

 min(c(1,2,3,4,NA,6))

And read

 ?min

Hope this helps,
Pascal




2013/8/31 Casey Zhang casey1...@gmail.com

 Hi,

 I'm just starting to learn how to use R and I'm trying to create a
 histogram with 7 breaks. This is my code so far:

 dat=read.table(titanic.csv,header=TRUE,sep=,,na.string=.)
 age=dat$Age
 breaks=seq(min(age),max(age),length=7)
 hist(age,breaks,freq=FALSE)

 I don't know why, but on the fourth line it always gives this error:

 Error in if (from == to) rep.int(from, length.out) else as.vector(c(from,
  :
   missing value where TRUE/FALSE needed

 What am I doing wrong? I know the data itself does have a lot of NA
 values for age, would this be the problem?


 Thanks,

 CZ

 [[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] does rstudio-server support named configuration

2013-08-30 Thread Pascal Oettli
Hello,

Here is the R-help mailing list. For Rstudio-sever support, please see
http://support.rstudio.org/help/discussions

Regards,
Pascal


2013/8/31 qiulin qiulin.w...@gmail.com

 I appreciate your time, thank you in advance  :)

 I'd like to start 2 rstudio-server in one Linux machine, one daemon listen
 port 8787  running R-2.15, on daemon listen port 8788 running R-3.01.
 Can I have named rstudio-server configurations so I can start
 rstudio-server  like this :
 :rstudio-server --config-file = R-2.15.conf  start,   it runs  R-2.15
 listening  port 8787
 :rstudio-server --config-file = R-3.01.conf  start,   it runs  R-3.01
 listening  port 8788

 Ipython-notebook support named configuration, does  rstudio-server have
 this feature ?

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