Re: [R] figure-definition and heatmap question

2007-08-24 Thread Antje
There is no one who could help me with this?

Antje schrieb:
 Hello,
 
 I have two questions. I'd like to visualize data with a heatmap and I have 
 the 
 following testcase:
 
 x - rnorm(256)
 nx - x + abs(min(x))
 nnx - 255/max(nx) * nx
 x - matrix(nnx, 16, 16)
 rownames(x) - 
 c(A,B,C,D,E,F,G,I,H,J,K,L,M,N,O,P)
 par(fin=c(8.0,8.0))
 cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
 heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))
 
 I defined the figure region to make sure that each position is a square. But 
 with these settings I get the following output (though it looks nice):
   x - rnorm(256)
   nx - x + abs(min(x))
   nnx - 255/max(nx) * nx
   x - matrix(nnx, 16, 16)
   rownames(x) - 
 c(A,B,C,D,E,F,G,I,H,J,K,L,M,N,O,P)
   par(fin=c(8.0,8.0))
   cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
   heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))
   Fehler in par(op) : ungültiger Wert für den Grafikparameter fig 
 spezifiziert
   par(fin=c(8.0,8.0))
   cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
   heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))
   Fehler in par(op) : ungültiger Wert für den Grafikparameter fig 
 spezifiziert
   par()$fig
 [1]  7.267443e-04  1.305448e-02 -2.862294e-17  9.876543e-01
   par()$fin
 [1] 0.08834875 7.06790021
 
 Why do I get this error? Why does the parameters have these strange values 
 (though I set the fin parameter before...)
 
 And another question concerning the heatmap: May I force the funtion to plot 
 A1 
 at the upper left corner instead of the lower left?
 
 I'll be glad about any idea how to solve these problems...
 
 Ciao,
 Antje
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Package installation

2007-08-24 Thread Antje
Hello,

I'm running R with windows. Could anybody help me how to install the package 
biOps (http://cran.mirroring.de/src/contrib/Descriptions/biOps.html) ?
I cannot find it at any mirror provided by the GUI; I just found it as tar.gz 
which cannot be installed with the installation method...
Maybe, I simply do something wrong?

Thanks for any hint!

Antje

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


Re: [R] figure-definition and heatmap question

2007-08-24 Thread Antje
Hi Paul,

  You are getting the error because you are setting the figure region to
  be larger than the current device (typically 6 or 7 inches wide/high).
  You SHOULD be getting the error when you try par(fin), BUT there is a
  check missing in the C code, so what happens is that heatmap saves your
  par settings and then tries to reset them (this is where par(op) comes
  from), and because it saves BOTH par(fig) and par(fin) it resets both of
  them, and when it resets par(fig) there IS a check on the values, the
  values are larger than the current device and you get the error.  Now,
  because there is an error in resetting par(fig), that parameter is not
  reset, so when you type par()$fin (or, equivalently, par(fin)) after
  the heatmap() call, you get the last setting that heatmap() did, which
  was from a layout inside heatmap, and so par(fig) is NOT what you set.
   Finally, there is no point in setting par(fig) before heatmap() because
  heatmap() is one of those functions that takes over the whole device
  anyway, so your par(fig), even if it was valid, would have no effect.
  If you want to make the heatmap() plot take up less of the page, you
  could set outer margins (see par(oma)), e.g., ...
 
  par(oma=rep(4, 4))
  heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))

thank you very much for the explanation. Now I understand at least the strange 
fig/fin values ;) There is only one question left:

 If you want to make sure that each position in the heatmap is square, DO 
 NOTHING, because the layout that heatmap() sets up is using respect so 
 the image will be square no matter what you do.

Okay, for the example, I've chosen it might be true. My initial reason to try 
to force it to squares has been the visualization of matrix which is not 
quadratic (e.g. 12x8). In this case heatmap stretches the coloured areas to 
rectangles. I planned to set the figure region with the same length/width ratio 
  as the matrix is to get squares...
If I understood everything now, I have to think about something else than 
heatmap to make sure to get squares, right?

Thanks, Jim, I'll test this method for my purpose :)

Ciao,
Antje

 
 Paul
 
 
 And another question concerning the heatmap: May I force the funtion 
 to plot A1 at the upper left corner instead of the lower left?

 I'll be glad about any idea how to solve these problems...

 Ciao,
 Antje

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] figure-definition and heatmap question

2007-08-23 Thread Antje
Hello,

I have two questions. I'd like to visualize data with a heatmap and I have the 
following testcase:

x - rnorm(256)
nx - x + abs(min(x))
nnx - 255/max(nx) * nx
x - matrix(nnx, 16, 16)
rownames(x) - 
c(A,B,C,D,E,F,G,I,H,J,K,L,M,N,O,P)
par(fin=c(8.0,8.0))
cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))

I defined the figure region to make sure that each position is a square. But 
with these settings I get the following output (though it looks nice):
  x - rnorm(256)
  nx - x + abs(min(x))
  nnx - 255/max(nx) * nx
  x - matrix(nnx, 16, 16)
  rownames(x) - 
c(A,B,C,D,E,F,G,I,H,J,K,L,M,N,O,P)
  par(fin=c(8.0,8.0))
  cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
  heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))
Fehler in par(op) : ungültiger Wert für den Grafikparameter fig 
spezifiziert
  par(fin=c(8.0,8.0))
  cp - colorRampPalette(c(white,springgreen,darkgreen),space=Lab)
  heatmap(x, Rowv = NA, Colv = NA, scale=none, col=cp(200))
Fehler in par(op) : ungültiger Wert für den Grafikparameter fig 
spezifiziert
  par()$fig
[1]  7.267443e-04  1.305448e-02 -2.862294e-17  9.876543e-01
  par()$fin
[1] 0.08834875 7.06790021

Why do I get this error? Why does the parameters have these strange values 
(though I set the fin parameter before...)

And another question concerning the heatmap: May I force the funtion to plot A1 
at the upper left corner instead of the lower left?

I'll be glad about any idea how to solve these problems...

Ciao,
Antje

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


Re: [R] need help with pdf-plot

2007-08-13 Thread Antje
Thank you both!
The hint with the pty=s was very useful. I did not know it before.

Ciao,
Antje


Ivar Herfindal schrieb:
 Dear Antje
 
 I cannot see that you have got any replies yet, so I will make and 
 attempt. However, I am sure other have more formally correct solutions.
 
 When you call the pdf(), you can set paper=a4 (or a4r for 
 landscape). However, the width and the height of your plot should then 
 not exceed the size of the paper (which is approximately 8.27*11.69 
 inches for a4). Try (I have only tested on windows XP, R 2.5.0):
 
 pdf(test1.pdf, width=10, heigh=5, paper=a4r)
 par(mfrow=c(1,3), pty=s) #pty=s gives square plotting regions
 plot(rnorm(100))
 plot(rnorm(100))
 plot(rnorm(100))
 dev.off()
 
 Hope this helps
 
 Ivar
 
 
 Antje skrev:
 I still have this problem. Does anybody know any solution?

 Antje

 Antje schrieb:
  
 Hello,

 I'm trying to plot a set of barplots like a matrix (2 rows, 10 
 columns fromreduced_mat) to a pdf. It works with the following 
 parameters:

 pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, 
 pointsize = 12)

 par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
 lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)

 The I get a long narrow page format with the quadratic barplots.

 But I would like to have a A4 format in the end and the plots not 
 filling the whole page (they should stay somehow quadratic and not be 
 stretched...).

 What shall I look for to achieve this?

 Antje

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


Re: [R] need help with pdf-plot

2007-08-10 Thread Antje
I still have this problem. Does anybody know any solution?

Antje

Antje schrieb:
 Hello,
 
 I'm trying to plot a set of barplots like a matrix (2 rows, 10 columns 
 fromreduced_mat) to a pdf. It works with the following parameters:
 
 pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, 
 pointsize 
 = 12)
 
 par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
 lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)
 
 The I get a long narrow page format with the quadratic barplots.
 
 But I would like to have a A4 format in the end and the plots not filling the 
 whole page (they should stay somehow quadratic and not be stretched...).
 
 What shall I look for to achieve this?
 
 Antje
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] need help with pdf-plot

2007-08-01 Thread Antje
Hello,

I'm trying to plot a set of barplots like a matrix (2 rows, 10 columns 
fromreduced_mat) to a pdf. It works with the following parameters:

pdf(test.pdf,width=ncol(reduced_mat)*2, height=nrow(reduced_mat)*2, pointsize 
= 12)

par(mfcol = c(nrow(reduced_mat),ncol(reduced_mat)), oma = c(0,0,0,0), 
lwd=48/96, cex.axis = 0.5, las = 2, cex.main = 1.0)

The I get a long narrow page format with the quadratic barplots.

But I would like to have a A4 format in the end and the plots not filling the 
whole page (they should stay somehow quadratic and not be stretched...).

What shall I look for to achieve this?

Antje

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


Re: [R] how to combine data of several csv-files

2007-07-31 Thread Antje
Hi Jim,

that's exactly what I'm looking for. Thank you so much. I think, I should look 
for some further documentation on list handling.
Many thanks also to [EMAIL PROTECTED] ;) for spending time in 
finding a solution...

Have a nice day!
Antje


jim holtman schrieb:
 This should do it:
 
 v1 - NA
 v2 - rnorm(6)
 v3 - rnorm(6)
 v4 - rnorm(6)
 v5 - rnorm(6)
 v6 - rnorm(6)
 v7 - rnorm(6)
 v8 - rnorm(6)
 v8 - NA

 list - list(v1,v2,v3,v4,v5,v6,v7,v8)
 categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA)

 # create partitioned list
 list.cat - split(list, categ)
 # combine each partition into a matrix
 list.mat - lapply(list.cat, function(x) do.call('rbind', x))
 # now take the means of each column
 lapply(list.mat, colMeans)
 $cat1
 [1] -0.5699080  0.3855693  1.1051809  0.2379324  0.6684713  0.3240003
 
 $cat2
 [1]  0.38160462 -0.10559496 -0.40963090 -0.09507354  0.95021406 -0.31491450
 
 
 
 On 7/30/07, Antje [EMAIL PROTECTED] wrote:
 okay, I played a bit around and now I have some kind of testcase for you:

 v1 - NA
 v2 - rnorm(6)
 v3 - rnorm(6)
 v4 - rnorm(6)
 v5 - rnorm(6)
 v6 - rnorm(6)
 v7 - rnorm(6)
 v8 - rnorm(6)
 v8 - NA



 list - list(v1,v2,v3,v4,v5,v6,v7,v8)
 categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA)

   list
 [[1]]
 [1] NA

 [[2]]
 [1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750

 [[3]]
 [1]  0.02354036 -1.36186952 -0.42197792  1.50445971 -1.76763996  0.53722404

 [[4]]
 [1] -1.40362589  0.13045724 -0.84651458  1.57005071  0.06961015  0.25269771

 [[5]]
 [1] -1.1829260  2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698

 [[6]]
 [1]  1.17099178  0.49248118 -0.18690065  1.50050976 -0.65552410 -0.01243247

 [[7]]
 [1] -0.046778203 -0.233788840  0.443908897 -1.649740180  0.003991354 
 -0.228020092

 [[8]]
 [1] NA

 now, I need the means (and sd) of element 1 of list[2],list[3],list[4] 
 (because they belong to cat1) and

 = mean(-0.6442149, 0.02354036, -1.40362589)

 the same for element 2 up to element 6 (-- I would the get a vector 
 containing the means for cat1)
 the same for the vectors belonging to cat2.

 does anybody now understand what I mean?

 Antje

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


Re: [R] how to combine data of several csv-files

2007-07-31 Thread Antje
Hey,

I had the same question concerning the sd calculation and I got the following 
solution:

list - split(list, class_vec)
list - lapply(list, function(x) do.call('rbind', x))

my.mean - lapply(ret, FUN = function(x) {
t - as.matrix(x)
rm - as.matrix(apply( t, 1, FUN = function(w) { length(which(is.na(w) 
== 
TRUE)) } ))
t - matrix(t[rm == 0,], ncol=7)

# I had to do the 2 lines above to remove rows belonging to a class but 
containing NA values... (cannot exclude)

if(nrow(t)  1) {
apply(t, 2, mean)
} else {
if(nrow(t) == 1) { as.vector(t) }
else { NA }
}
})


Probably, there is a simpler solution to remove the NA rows, but it works ;); 
also with sd.

Ciao,
Antje


8rino-Luca Pantani schrieb:
 Hi Jim,
 that's exactly what I'm looking for. Thank you so much. I think, I 
 should look for some further documentation on list handling.
 I think I will do the same...
 Thanks to Jim I learned textConnection and rowMeans.
 
 Jim, could you please go a step further and tell me how to use lapply to 
 calculate
 the sd instead of the mean of the same items?
 I mean
 sd(-0.6442149 0.02354036 -1.40362589)
 sd(-1.1829260 1.17099178 -0.046778203)
 sd(-0.2047012 -1.36186952 0.13045724)
 etc
 
 x - read.table(textConnection(  v1 v2 v3  v4 v5  v6 v7 v8
 NA -0.6442149  0.02354036 -1.40362589 -1.1829260  1.17099178 
 -0.046778203 NA
 NA -0.2047012 -1.36186952  0.13045724  2.1411553  0.49248118 
 -0.233788840 NA
 NA -1.1986041 -0.42197792 -0.84651458 -0.1327081 -0.18690065  
 0.443908897 NA
 NA -0.2097442  1.50445971  1.57005071 -0.1053442  1.50050976 
 -1.649740180 NA
 NA -0.7343465 -1.76763996  0.06961015 -0.8179396 -0.65552410  
 0.003991354 NA
 NA -1.3888750  0.53722404  0.25269771 -1.2342698 -0.01243247 
 -0.228020092 NA), header=TRUE)
 
 
 
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] remove NA rows and columns

2007-07-31 Thread Antje
Hello,

I guess, it's a rather simple thing but I cannot find a short way to reduce a 
matrix, removing all rows and columns having just NA elements.

testmatrix - matrix(nrow=6, ncol=4)
testmatrix[2:5,2:3] - seq(2)

  testmatrix
  [,1] [,2] [,3] [,4]
[1,]   NA   NA   NA   NA
[2,]   NA11   NA
[3,]   NA22   NA
[4,]   NA11   NA
[5,]   NA22   NA
[6,]   NA   NA   NA   NA

the new matrix should look like this (by the way, I don't know which rows and 
columns are the one to be deleted...

  testmatrix
  [,1] [,2]
[1,]   11
[2,]   22
[3,]   11
[4,]   22

Ciao,
Antje

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


Re: [R] remove NA rows and columns

2007-07-31 Thread Antje
Hello,

thank you both very much!
It is as easy as expected... (I think I still have to learn a lot!)

Have a nice day!
Antje



Vladimir Eremeev schrieb:
 Or, these operations can be called in one command:
 
 testmatrix[-which(apply(testmatrix,1,function(x)all(is.na(x,-which(apply(testmatrix,2,function(x)all(is.na(x]
  [,1] [,2]
 [1,]11
 [2,]22
 [3,]11
 [4,]22
 
 
 
 Vladimir Eremeev wrote:
 testmatrix
  [,1] [,2] [,3] [,4]
 [1,]   NA   NA   NA   NA
 [2,]   NA11   NA
 [3,]   NA22   NA
 [4,]   NA11   NA
 [5,]   NA22   NA
 [6,]   NA   NA   NA   NA

 tm1-testmatrix[,-which(apply(testmatrix,2,function(x)all(is.na(x]
 tm1
  [,1] [,2]
 [1,]   NA   NA
 [2,]11
 [3,]22
 [4,]11
 [5,]22
 [6,]   NA   NA

 tm2-tm1[-which(apply(testmatrix,1,function(x)all(is.na(x,]
 tm2
  [,1] [,2]
 [1,]11
 [2,]22
 [3,]11
 [4,]22
  

 Antje wrote:
 I guess, it's a rather simple thing but I cannot find a short way to
 reduce a 
 matrix, removing all rows and columns having just NA elements.

 testmatrix - matrix(nrow=6, ncol=4)
 testmatrix[2:5,2:3] - seq(2)

   testmatrix
   [,1] [,2] [,3] [,4]
 [1,]   NA   NA   NA   NA
 [2,]   NA11   NA
 [3,]   NA22   NA
 [4,]   NA11   NA
 [5,]   NA22   NA
 [6,]   NA   NA   NA   NA

 the new matrix should look like this (by the way, I don't know which
 rows and 
 columns are the one to be deleted...

   testmatrix
   [,1] [,2]
 [1,]   11
 [2,]   22
 [3,]   11
 [4,]   22




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


[R] how to combine data of several csv-files

2007-07-30 Thread Antje
Hello,

I'm looking for a solution for the following problem:

1) I have a folder with several csv files; each contains a set of 
measurement values
2) The measurements of each file belong to a position in a two 
dimensional matrix (lets say B02.csv belongs to position 2,2
3) The size of the matrix is fix
4) I cannot assure to have a csv file for each position
5) Each position belongs to one category; This information is available 
in a file (means 2,2 and 2,3 may belong to category c1; 3,2 and 3,3 
may belong to category c2)

Now, I process each available file and get a vector of 6 values or NA back.

The aim is to calculate mean and sd for vectors (element wise) coming 
from the same category (means if vec1 - c(1,2,3,4,5,6) and vec2 - 
c(6,7,8,9,10,11) belong to the same category, I would like to get mean 
- c(3.5, 4.5, 5.5, 6.5, 7.5, 8.5))

... but I'm not sure how to proceed. I end up with a list containing 
these vectors for each processed file and I don't know how to combine 
them easily...

Does anybody have a suggestion for me?

What I've got so far:

folder - choose.dir(getwd(), Choose folder containing csv files)
setwd(folder)

rowString - LETTERS[1:8]; cols - 12

mat - outer(rowString, formatC(seq(2,length=cols), flag = 0, width = 
2), paste, sep = )
mat - paste(mat, .csv, sep = _)

layoutfilename - file.choose()
layoutfile - read.csv(layoutfilename, sep=;, header=F, na.strings = )

classmatrix - sapply(layoutfile,as.character)
classes - factor(classmatrix)

colnames(classmatrix) - c(1:cols)
rownames(classmatrix) - rowString

ret - sapply(mat, calcHist)

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


Re: [R] how to combine data of several csv-files

2007-07-30 Thread Antje
Hello,

sorry for this confusion but I don't know a better way to explain...
I have no problems to read in the files and to process them. I end up 
with a list of results like this:

  ret
$A02.csv
[1] NA

$B02.csv
[1] 89.130435  8.695652  2.173913  0.00  0.00  0.00  9.892473

$C02.csv
[1] 86.842105 10.526316  2.631579  0.00  0.00  0.00 10.026385

$D02.csv
[1] 85.00 10.00  5.00  0.00  0.00  0.00  4.474273

$E02.csv
[1] 70.786517 13.483146  7.865169  5.617978  2.247191  0.00 12.125341

$F02.csv
[1] 70.8 14.16667 10.0  2.5  2.5  0.0 17.26619

$G02.csv
[1] 64.772727 13.636364  7.954545 11.363636  2.272727  0.00 12.735166

$H02.csv
[1] NA

$A03.csv
[1] NA

and I have a matrix with categories like this:


  classmatrix
   1  2
A NA NA
B NA cat1
C NA cat1
D NA cat1
E NA cat2
F NA cat2
G NA cat2
H NA NA


Now, I'm looking for a way to calculate the mean element wise for all 
results coming from the same category:

in this case the mean of the elements:

$B02.csv
$C02.csv
$D02.csv

(belonging to cat1)

I just don't know, how to combine the result list with the categories...

Does it become clearer? Probably, I try to provide a simple example but 
this will take some time to prepare...

Thanks anyway!

Antje




8rino-Luca Pantani schrieb:
 I'm unclear to what it is your problem.
 Import files into data frame?
 Combine them in one dataframe?
 Some (written) examples of the files would help people to help you out.
 
 An example on how to get help better and faster
  
 I have several csv files in the following form
 V1 V2
 1   4
 0.3   56
 
 V1   V2
 2.5   25
 4.5  45
 .
 
 I would like to import them in only one dataframe, and then recode a 
 column in order to get
 V1 V2 V3
 1   4   file1
 0.3   56   file1
 2.5   25   file2
 4.5  45   file2
 .
  
 Antje ha scritto:
 Hello,

 I'm looking for a solution for the following problem:

 1) I have a folder with several csv files; each contains a set of 
 measurement values
   


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


Re: [R] how to combine data of several csv-files

2007-07-30 Thread Antje
okay, I played a bit around and now I have some kind of testcase for you:

v1 - NA
v2 - rnorm(6)
v3 - rnorm(6)
v4 - rnorm(6)
v5 - rnorm(6)
v6 - rnorm(6)
v7 - rnorm(6)
v8 - rnorm(6)
v8 - NA

list - list(v1,v2,v3,v4,v5,v6,v7,v8)
categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA)

  list
[[1]]
[1] NA

[[2]]
[1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750

[[3]]
[1]  0.02354036 -1.36186952 -0.42197792  1.50445971 -1.76763996  0.53722404

[[4]]
[1] -1.40362589  0.13045724 -0.84651458  1.57005071  0.06961015  0.25269771

[[5]]
[1] -1.1829260  2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698

[[6]]
[1]  1.17099178  0.49248118 -0.18690065  1.50050976 -0.65552410 -0.01243247

[[7]]
[1] -0.046778203 -0.233788840  0.443908897 -1.649740180  0.003991354 
-0.228020092

[[8]]
[1] NA

now, I need the means (and sd) of element 1 of list[2],list[3],list[4] (because 
they belong to cat1) and

= mean(-0.6442149, 0.02354036, -1.40362589)

the same for element 2 up to element 6 (-- I would the get a vector containing 
the means for cat1)
the same for the vectors belonging to cat2.

does anybody now understand what I mean?

Antje

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


Re: [R] how to combine data of several csv-files

2007-07-30 Thread Antje
Hello,

thank you for your help. But I guess, it's still not what I want... printing 
df.my gives me

df.my
   v1 v2  v3  v4 v5  v6   v7 v8
1 NA -0.6442149  0.02354036 -1.40362589 -1.1829260  1.17099178 -0.046778203 NA
2 NA -0.2047012 -1.36186952  0.13045724  2.1411553  0.49248118 -0.233788840 NA
3 NA -1.1986041 -0.42197792 -0.84651458 -0.1327081 -0.18690065  0.443908897 NA
4 NA -0.2097442  1.50445971  1.57005071 -0.1053442  1.50050976 -1.649740180 NA
5 NA -0.7343465 -1.76763996  0.06961015 -0.8179396 -0.65552410  0.003991354 NA
6 NA -1.3888750  0.53722404  0.25269771 -1.2342698 -0.01243247 -0.228020092 NA

now, I have to combine like this:

   v1 v2  v3  v4 v5  v6   v7
 v8
   NAcat1cat1cat1   cat2cat2 cat2   
NA

--

mean(df.my$v2[1],df.my$v3[1],df.my$v4[1])
mean(df.my$v2[2],df.my$v3[2],df.my$v4[2])
mean(df.my$v2[3],df.my$v3[3],df.my$v4[3])
mean(df.my$v2[4],df.my$v3[4],df.my$v4[4])
mean(df.my$v2[5],df.my$v3[5],df.my$v4[5])
mean(df.my$v2[6],df.my$v3[6],df.my$v4[6])

the same for v5, v6 and v7

further, I'm not sure how to avoid the list, because this is the result of the 
processing I did before...

Ciao,
Antje


8rino-Luca Pantani schrieb:
 I hope I see.
 
 Why not try the following, and avoid lists, which I'm not still able to 
 manage properly ;-)
 v1 - NA
 v2 - rnorm(6)
 v3 - rnorm(6)
 v4 - rnorm(6)
 v5 - rnorm(6)
 v6 - rnorm(6)
 v7 - rnorm(6)
 v8 - rnorm(6)
 v8 - NA
 (df.my - cbind.data.frame(v1, v2, v3, v4, v5, v6, v7, v8))
 (df.my2 - reshape(df.my,
  varying=list(c(v1,v2,v3, v4,v5,v6,v7,v8)),
  idvar=sequential,
  timevar=cat,
  direction=long
))
 aggregate(df.my2$v1, by=list(category=df.my2$cat), mean)
 aggregate(df.my2$v1, by=list(category=df.my2$cat), function(x){sd(x, 
 na.rm = TRUE)})
 
 
 Antje ha scritto:
 okay, I played a bit around and now I have some kind of testcase for you:

 v1 - NA
 v2 - rnorm(6)
 v3 - rnorm(6)
 v4 - rnorm(6)
 v5 - rnorm(6)
 v6 - rnorm(6)
 v7 - rnorm(6)
 v8 - rnorm(6)
 v8 - NA

 list - list(v1,v2,v3,v4,v5,v6,v7,v8)
 categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA)

  list
 [[1]]
 [1] NA

 [[2]]
 [1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750

 [[3]]
 [1]  0.02354036 -1.36186952 -0.42197792  1.50445971 -1.76763996  
 0.53722404

 [[4]]
 [1] -1.40362589  0.13045724 -0.84651458  1.57005071  0.06961015  
 0.25269771

 [[5]]
 [1] -1.1829260  2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698

 [[6]]
 [1]  1.17099178  0.49248118 -0.18690065  1.50050976 -0.65552410 
 -0.01243247

 [[7]]
 [1] -0.046778203 -0.233788840  0.443908897 -1.649740180  0.003991354 
 -0.228020092

 [[8]]
 [1] NA

 now, I need the means (and sd) of element 1 of list[2],list[3],list[4] 
 (because they belong to cat1) and

 = mean(-0.6442149, 0.02354036, -1.40362589)

 the same for element 2 up to element 6 (-- I would the get a vector 
 containing the means for cat1)
 the same for the vectors belonging to cat2.

 does anybody now understand what I mean?

 Antje





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


Re: [R] Readline - wait for user input

2007-06-18 Thread Antje
Hello,

I also have problems to get to run the following lines. If I run the 
block instead of every single line, it simply does not wait for the input.
Can anybody help me?


pos_name - readline(Please type: )

r - substr(pos_name, 1,1)
c - substr(pos_name, 2,nchar(pos_name))



Thank you!
Antje


Peter Dalgaard schrieb:
 Forest Floor wrote:
 Hi,

 I've seen various posts on this question, but still can't get the code 
 right. 

 If I run the following code one line at a time, it works fine.  If I run 
 it together as a block, however, it doesn't wait for the input and gives 


 an error.

 There must be a way to have are pause/wait for an answer, but I can't 
 seem to find it.  Thanks!  J

 Code:

 choosefunction - function(){readline(1. linear, 2. linear with lag, 3. 
 nonlinear )}
 ans - as.integer(choosefunction())
 if (ans==1){K2=x1}
 if (ans==2){K2=x2 }
 if (ans==3){K2=x3 }
 ans

 Error text:
   ans - as.integer(choosefunction())
 1. linear, 2. linear with lag, 3. nonlinear if (ans==1) {K2=x1}]}
 Warning message:
 NAs introduced by coercion
   if (ans==2){K2=x2) }
 Error in if (ans == 2) { : missing value where TRUE/FALSE needed
   if (ans==3){K2=x3}
 Error in if (ans == 3) { : missing value where TRUE/FALSE needed
   ans
 [1] NA
   
 As you may have realized already, the issue is that choosefunction()
 takes the next command as its input. Since if (ans==1){K2=x1} isn't an
 integer ans becomes NA, and it just goes downhill from there.
 
 An extra set of braces may help
 
 choosefunction - function(){readline(1. linear, 2. linear with lag, 3.
 + nonlinear )}
 {ans - as.integer(choosefunction())
 + if (ans==1){K2=x1}
 + if (ans==2){K2=x2 }
 + if (ans==3){K2=x3 }
 + ans}
 1. linear, 2. linear with lag, 3.
 nonlinear 3
 Error: object x3 not found
 
 It still doesn't quite work, but the reason(s) for that should be plain
 to see.


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

2007-06-18 Thread Antje
Hello,

I also have problems to get to run the following lines. If I run the
block instead of every single line, it simply does not wait for the input.
Can anybody help me?


pos_name - readline(Please type: )

r - substr(pos_name, 1,1)
c - substr(pos_name, 2,nchar(pos_name))



Thank you!
Antje


Peter Dalgaard schrieb:
   Forest Floor wrote:
   Hi,
  
   I've seen various posts on this question, but still can't get the 
code
   right.
  
   If I run the following code one line at a time, it works fine. 
If I run
   it together as a block, however, it doesn't wait for the input 
and gives


   an error.
  
   There must be a way to have are pause/wait for an answer, but I 
can't
   seem to find it.  Thanks!  J
  
   Code:
  
   choosefunction - function(){readline(1. linear, 2. linear with 
lag, 3.
   nonlinear )}
   ans - as.integer(choosefunction())
   if (ans==1){K2=x1}
   if (ans==2){K2=x2 }
   if (ans==3){K2=x3 }
   ans
  
   Error text:
 ans - as.integer(choosefunction())
   1. linear, 2. linear with lag, 3. nonlinear if (ans==1) {K2=x1}]}
   Warning message:
   NAs introduced by coercion
 if (ans==2){K2=x2) }
   Error in if (ans == 2) { : missing value where TRUE/FALSE needed
 if (ans==3){K2=x3}
   Error in if (ans == 3) { : missing value where TRUE/FALSE needed
 ans
   [1] NA
  
   As you may have realized already, the issue is that choosefunction()
   takes the next command as its input. Since if (ans==1){K2=x1} 
isn't an
   integer ans becomes NA, and it just goes downhill from there.
  
   An extra set of braces may help
  
   choosefunction - function(){readline(1. linear, 2. linear with 
lag, 3.
   + nonlinear )}
   {ans - as.integer(choosefunction())
   + if (ans==1){K2=x1}
   + if (ans==2){K2=x2 }
   + if (ans==3){K2=x3 }
   + ans}
   1. linear, 2. linear with lag, 3.
   nonlinear 3
   Error: object x3 not found
  
   It still doesn't quite work, but the reason(s) for that should be plain
   to see.
  

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] choose.dir

2007-06-08 Thread Antje
Hi all,

I have written a R-script under Windows using choose.dir. Now, I have 
seen that this function is missing at MacOS. Does anybody know an 
alternative?

Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] choose.dir

2007-05-02 Thread Antje
Hi all,

I have written a R-script under Windows using choose.dir. Now, I have
seen that this function is missing at MacOS. Does anybody know an
alternative?

Antje

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


Re: [R] choose.dir

2007-05-02 Thread Antje
Thank you. For Windows it works, I'll check whether it also works for Mac :)


Gabor Grothendieck schrieb:
 I don't have a Mac but perhaps this works:
 
 library(tcltk)
 tclvalue(tkchooseDirectory())
 
 On 5/2/07, Antje [EMAIL PROTECTED] wrote:
 Hi all,

 I have written a R-script under Windows using choose.dir. Now, I have
 seen that this function is missing at MacOS. Does anybody know an
 alternative?

 Antje

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


Re: [R] tapply, levelinformation

2007-02-16 Thread Antje
Hi Jim,

jim holtman schrieb:
 Here is one way:
  
 t - split(mat, classes)
 for (i in names(t)) plotdensity(t[[i]], main=i)
 

But then I don't use the advantages of the tapply anymore...

 What is the problem you are trying to solve?

I have a set of data (multiple files), which belong to different
conditions (one or more files per condition). I wanted to read the data
set and a description of the conditions and then automatically create
plots for data of the same condition.

Maybe it's much to complicate the way I do...

Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] sapply again return value

2007-02-16 Thread Antje
Hello,

I used an sapply to get some data back (s - sapply(...) ). The output 
of s would then deliver something like this:

  B06_lamp.csv C06_lamp.csv D06_lamp.csv
[1,] NULL NULL Numeric,512
[2,] NULL NULL Numeric,512
[3,] NULL NULL 2
  mode(s)
[1] list
  dim(s)
[1] 3 3
 

Now, I'd like to remove the columns which contain NULL (it's alway the 
whole column).
How can I do this???

Antje

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


Re: [R] sapply again return value

2007-02-16 Thread Antje
Henrique Dallazuanna schrieb:
 Hi,
 A simple way is:
 
 s - s[3]

but what if I don't know how many and which columns are NULL?

Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] sapply and its return value

2007-02-15 Thread Antje
Hello,

I have some problems with sapply. I wanted to do the following:

s - sapply(filelist, function(x) {
if(file.exists(x))
{
...
return( list(density(file$V1)$x, density(file$V1)$y))
}
else
{
print(paste(plotDensity ERROR - File does not exist: 
,x,sep=))
return( NULL)
}
})

if(is.null( - ??? - ))
{
print(no plot)
}

That means, I try to read every file and to get some data from it. It 
may happen, that the file does not exist and then I don't want to plot 
anything. As return, I get a list and I have quite a lot of problems to 
access its content... (I did not really understand how this works, I 
guess...)
Could anybody give me a hint?

Thank you!
Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] tapply, levelinformation

2007-02-15 Thread Antje
Hello,

I have another question. I would like to plot something within a self 
written function (plotdensity) called by tapply

t - tapply(mat, classes, plotdensity)

Now I would like to add each plot the class/level as title.
How can I do this?

Antje

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


[R] Error in plot.new() : Figure margins too large

2007-01-11 Thread Antje

Hello,

was could be the reason for such an error message???
I'd like to create a window with 10x6 barplot and save it as pdf.

I tried:

pdf(histogram.pdf,width=7, height=7)

windows(cols, rows)
par(mfcol = c(rows,cols))

sapply(mat, calcHist)

dev.off()

Within the method of sapply, I call barplot

What is wrong???

Antje

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


Re: [R] Error in plot.new() : Figure margins too large

2007-01-11 Thread Antje
Hmm, but what can be the solution? Any idea? Or any documentation on 
that which I could read to find a solution by myself?

with the windows statement, I wanted to achive a format which fits for 
my plots, so that each plot will have a quadratic area.

I guess, I did not unstand that much of windows / margins and plotting 
areas. Maybe someone can help me (even with a good overview on these 
basics...)

Antje



Peter Dalgaard schrieb:
 Antje wrote:
 Hello,

 was could be the reason for such an error message???
   
 Generically, that the (per-subplot) figure region is so small that
 subtracting margins leaves nowhere to plot. Reasons include: Plotting
 area too small, too many subplots, too many lines of text in margins,
 too large font size in margins.
 
 I'd like to create a window with 10x6 barplot and save it as pdf.

 I tried:

 pdf(histogram.pdf,width=7, height=7)
   
 What did you expect the following line to do? I think it doesn't...
 windows(cols, rows)
   
 
 
 par(mfcol = c(rows,cols))

 sapply(mat, calcHist)

 dev.off()

 Within the method of sapply, I call barplot

 What is wrong???

 Antje

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] tapply, how to get level information

2007-01-08 Thread Antje

Hello,

I'm applying a self-written function to a matrix on basis of different 
levels.
Is there any way, to get the level information within the self-written 
function???

t - tapply(mat, levels, plotDensity)

plotDensity - function(x) {
??? print(level(x)) ???
}

Antje

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


[R] Multiple plots via sapply or lapply?

2007-01-07 Thread Antje
Hi all,

I've got the following problem. I have a vector containing file names. I 
want to read these files as csv and calculate the density-function for 
each file (has just one column with data). Then, I'd like to plot all 
density functions into one window. I did the following to calculate the 
density data:

s - sapply(filelist, function(x) {
if(file.exists(x))
{
file - read.csv(x, sep=\t, header=F)
return( list(density(file$V1)$x, density(file$V1)$y))
}
})

Now I would like to plot these x,y data in a similar way but my result 
s is a matrix containing lists...

  File1.csv File2.csv   File3.csv
[1,] Numeric,512Numeric,512 Numeric,512
[2,] Numeric,512Numeric,512 Numeric,512

Now I don't know how to handle the x,y values for each plot into an 
sapply (or lapply, I don't know)

Any idea? Maybe, I should somehow change the return type?

Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] barplot help needed

2006-11-24 Thread Antje
hello,

I would like to create the following barplot:

I have 4 different data sets (same length + stddev for each data point)

data1
sd1
data2
sd2
data3
sd3
data4
sd4

now, I'd like to plot in the following way:

data1[1],data2[1],data3[1],data4[1] with it's sd-values side-by-side at 
one x-axis label (named position 1) and each bar in different colors.

data1[2],data2[2],data3[2],data4[2] at the next x-axis label (named 
position 2) with the same color scheme

and so on over the whole length.

I managed to plot one set in the following way:

par(mai=c(1.5,1,1,0.6))
plotInfo - barplot(data1, las=2, ylim = c(0,plotMax+1), ylab = 
Percentage)
arrows(plotInfo,data1,plotInfo,  data1 + sd1, length=0.1, angle=90)
arrows(plotInfo,data1,plotInfo,  data1 - sd1, length=0.1, angle=90)

could anybody give me a help on this?

Antje

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


Re: [R] barplot help needed

2006-11-24 Thread Antje
Thank you very much for your help.
I just don't understand the following line (which also gives me a 
dimension error later in the arrows command)

etype - rep(c(sd1, sd2, sd3, sd4), length(data1))

Antje

(I don't see my emails to the mailinglist anymore... just the answers 
from other people... I don't understand???)


Jacques VESLOT schrieb:
 tab - do.call(rbind, list(data1, data2, data3, data4))
 etype - rep(c(sd1, sd2, sd3, sd4), length(data1))
 b - barplot(tab, beside=T)
 arrows(unlist(b), unlist(tab) - etype, unlist(b),  unlist(tab) + etype, 
 code=3)
 ---
 Jacques VESLOT
 
 CNRS UMR 8090
 I.B.L (2ème étage)
 1 rue du Professeur Calmette
 B.P. 245
 59019 Lille Cedex
 
 Tel : 33 (0)3.20.87.10.44
 Fax : 33 (0)3.20.87.10.31
 
 http://www-good.ibl.fr
 ---
 
 Antje a écrit :
 hello,

 I would like to create the following barplot:

 I have 4 different data sets (same length + stddev for each data point)

 data1
 sd1
 data2
 sd2
 data3
 sd3
 data4
 sd4

 now, I'd like to plot in the following way:

 data1[1],data2[1],data3[1],data4[1] with it's sd-values side-by-side 
 at one x-axis label (named position 1) and each bar in different 
 colors.

 data1[2],data2[2],data3[2],data4[2] at the next x-axis label (named 
 position 2) with the same color scheme

 and so on over the whole length.

 I managed to plot one set in the following way:

 par(mai=c(1.5,1,1,0.6))
 plotInfo - barplot(data1, las=2, ylim = c(0,plotMax+1), ylab = 
 Percentage)
 arrows(plotInfo,data1,plotInfo,  data1 + sd1, length=0.1, angle=90)
 arrows(plotInfo,data1,plotInfo,  data1 - sd1, length=0.1, angle=90)

 could anybody give me a help on this?

 Antje

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


Re: [R] barplot help needed

2006-11-24 Thread Antje
Still, there is one problem. The SD-Values don't fit to the bar they 
belong to. I made the following experiment:

  data1 - c(2,4,6,2,5)
  data2 - data1
  sd1 - c(0.5,1,1.5,1,2)
  sd2 - sd1
  tab - do.call(rbind, list(data1, data2))
  etype - c(sd1,sd2)
  b - barplot(tab, beside=T)
  arrows(unlist(b), unlist(tab) - etype, unlist(b),  unlist(tab) + 
etype, code=3)

I expect the bars with the same height and the same stddev. The height 
is okay, but the stddev is messed up...

if I do it like this:

etype - matrix(c(sd1,sd2), nrow=2, byrow=TRUE)

it works (but maybe there is an easier way...)

Antje




Jacques VESLOT schrieb:
 thought sd1, sd2... were scalars but if not just do:
 etype - c(sd1, sd2, sd3, sd4)
 ---
 Jacques VESLOT
 
 CNRS UMR 8090
 I.B.L (2ème étage)
 1 rue du Professeur Calmette
 B.P. 245
 59019 Lille Cedex
 
 Tel : 33 (0)3.20.87.10.44
 Fax : 33 (0)3.20.87.10.31
 
 http://www-good.ibl.fr
 ---
 
 
 Antje a écrit :
 Thank you very much for your help.
 I just don't understand the following line (which also gives me a 
 dimension error later in the arrows command)

 etype - rep(c(sd1, sd2, sd3, sd4), length(data1))

 Antje

 (I don't see my emails to the mailinglist anymore... just the answers 
 from other people... I don't understand???)


 Jacques VESLOT schrieb:

 tab - do.call(rbind, list(data1, data2, data3, data4))
 etype - rep(c(sd1, sd2, sd3, sd4), length(data1))
 b - barplot(tab, beside=T)
 arrows(unlist(b), unlist(tab) - etype, unlist(b),  unlist(tab) + 
 etype, code=3)
 ---
 Jacques VESLOT

 CNRS UMR 8090
 I.B.L (2ème étage)
 1 rue du Professeur Calmette
 B.P. 245
 59019 Lille Cedex

 Tel : 33 (0)3.20.87.10.44
 Fax : 33 (0)3.20.87.10.31

 http://www-good.ibl.fr
 ---

 Antje a écrit :

 hello,

 I would like to create the following barplot:

 I have 4 different data sets (same length + stddev for each data point)

 data1
 sd1
 data2
 sd2
 data3
 sd3
 data4
 sd4

 now, I'd like to plot in the following way:

 data1[1],data2[1],data3[1],data4[1] with it's sd-values side-by-side 
 at one x-axis label (named position 1) and each bar in different 
 colors.

 data1[2],data2[2],data3[2],data4[2] at the next x-axis label (named 
 position 2) with the same color scheme

 and so on over the whole length.

 I managed to plot one set in the following way:

 par(mai=c(1.5,1,1,0.6))
 plotInfo - barplot(data1, las=2, ylim = c(0,plotMax+1), ylab = 
 Percentage)
 arrows(plotInfo,data1,plotInfo,  data1 + sd1, length=0.1, angle=90)
 arrows(plotInfo,data1,plotInfo,  data1 - sd1, length=0.1, angle=90)

 could anybody give me a help on this?

 Antje

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] barplot - x-axis

2006-11-23 Thread Antje
Hi there,

I have a barplot and the labels at the x-axis are strings, which are 
rotated by 90°. But now the sub-title of the barplot is in between these 
labels, which does not look very nice...
Could anybody help me finding the parameter-setting to prevent this?

par(mai=c(1.5,1,1,0.6))
barplot(data, las=2, ylim = c(0,plotMax+1), ylab = Percentage, main = 
filename, sub = subtitle)

Thank you!
Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] extract values from a vector

2006-11-01 Thread Antje
Hello,

I'm looking for a solution for the following problem:
I have two vectors

V1 - c(apple,honey,milk,bread,butter)
V2 - c(bread,milk)

now, I would like to know for each element in V1 if it's equal to one of 
the elements in V2
I could do:
which(V1 == V2[1] | V1 == V2[2])

but what if I don't know the length of V2 and it's content???

Thank you in advance!

Antje

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


Re: [R] extract values from a vector

2006-11-01 Thread Antje
Bernd Weiss schrieb:
 Am 1 Nov 2006 um 14:49 hat Antje geschrieben:

 Date sent:Wed, 01 Nov 2006 14:49:43 +0100
 From: Antje [EMAIL PROTECTED]
 To:   R-help@stat.math.ethz.ch
 Subject:  [R] extract values from a vector

   
 Hello,

 I'm looking for a solution for the following problem:
 I have two vectors

 V1 - c(apple,honey,milk,bread,butter)
 V2 - c(bread,milk)

 now, I would like to know for each element in V1 if it's equal to one
 of the elements in V2 I could do: which(V1 == V2[1] | V1 == V2[2])

 but what if I don't know the length of V2 and it's content???

 

   
 V1%in%V2
 
 [1] FALSE FALSE  TRUE  TRUE FALSE

 Is this what you are looking for?

 HTH,

 Bernd

   

Thank you very much, that's what I need (I'm sorry for asking so stupid 
questions)

Antje

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


Re: [R] variables with dynamic names?

2006-10-25 Thread Antje
Thanks very much for your help.
I found the solution. I created a matrix with Strings and within a loop 
I read the files and processed them

wellInfo - matrix(nrow = rows, ncol = cols)
for(i in 1:rows) {
tempRow - paste(rowString[i], formatC(c(1:cols), flag=0, 
width=2), sep=)
print(tempRow)
wellInfo[i,] - tempRow
}

for(i in 1:rows) {
for(j in 1:cols) {
filename - paste(wellInfo[i,j],.csv,sep=)
if( file.exists(filename)) {
file - read.csv(filename, sep=\t, header=F)
 ...
  }
  }
}

(It was quite simple, but I did not find the paste command before...)
If there is something which could be done easier, just let me know.

Ciao,
Antje



Antje schrieb:
 Hello,

 I have the following problem. I have a set of CSV files and they are 
 named for a special position in a matrix (e.g. A01.csv, F06.csv, 
 H11.csv)

 Now, I would like to read in the data of all these files and eveluate 
 something for each set (and write it at the position in a result matrix).
 How can I realize this with R?

 Ciao,
 Antje

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] variables with dynamic names?

2006-10-24 Thread Antje
Hello,

I have the following problem. I have a set of CSV files and they are 
named for a special position in a matrix (e.g. A01.csv, F06.csv, 
H11.csv)

Now, I would like to read in the data of all these files and eveluate 
something for each set (and write it at the position in a result matrix).
How can I realize this with R?

Ciao,
Antje

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


[R] two density curves in one plot?

2006-08-23 Thread Antje
Hello,

I was wondering if I can plot two curves I get from density(data) into 
one plot. I want to compare both.
With the following commad, I just get one curve plotted:

plot( density(mydata) )

Sorry for this stupid question but I could not find a solution until now...

Antje

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


Re: [R] two density curves in one plot?

2006-08-23 Thread Antje
Thank you both very much.
It works!

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] run self written functions

2006-08-03 Thread Antje
Hello,

I'm not sure if I'm in the right place with my question...
I'm running R on Windows and wrote a function and saved it as .R file.
It looks like this:

bmi - function(weight, height) {
bmi - weight / height^2
bmi
}

If I want to use this function, I have to mark everything and then press 
Ctrl-R. But then everything single line is executed on the command line, 
which means that I will loose my history when the code becomes longer.
Further, I wonder if there is any way to do some output for control 
within the function (or any other possibilities to debug in a way).

Maybe, I have chosen a completely wrong way? I only want to make it easy 
to create some graphical visualizations of data which will be read in by 
csv. files, has to be converted and then displayed depending on some 
displaying parameters.

Ciao,
Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] label of second y-axis in xyplot (lattice)

2006-01-16 Thread Antje Schüle
Dear group,

 

First I provide you with an example, I found in the newsgroup. Then I'd like to 
explain my problem to you by means of the output.

 

enviro -
data.frame(Year = rep(2001:2002, each = 365),
   Day = rep(1:365, 2),
   Precip = pmax(0, rnorm(365 * 2)),
   Temp = 2 + 0.2 * rnorm(365 * 2))
 
 
xyplot(Precip + Temp ~ Day | Year, data=enviro,
   layout = c(1, 2),
   panel = panel.superpose.2,
   type = c('h', 'l'))

 

Now my question.

 

How can I achieve different labels for two y-axes? (Here this is not the case, 
but the example should just visualize my question.)

So here in this case I'd like to have two labels. On the normal y-side 
(axis2) the label = Precip, on the other side (axis4) the label Temp.

 

Thanks for your help.

 

Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] two y-axis in xy-plot

2006-01-10 Thread Antje Schüle

It is nearly the same example I wrote about in 
http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg54238.html. I'll print 
it out again:

In the first column I have numbers from 0 to 23 (hours of a day), the second 
column contains the name of a weekday (Day as factor) and the third column 
contains the number I am interested in. So as an example, the first five rows 
look like that:

 Hour Day Freq

1 0  Mo23

2 1  Mo20

3 2  Mo14

4 3  Mo27

5 4  Mo26

 
To read: On Monday between 0 and 1 o'clock 23 things happened. 

Now I add a new parameter, so that the data looks somehow like that:

 Hour Day Freq Freq2

1 0  Mo23 874

2 1  Mo20   476

3 2  Mo14 201

4 3  Mo27   912

5 4  Mo26   172

Now I'd like to have a plot for every weekday containing the two frequencies as 
a line during the hours.

Is this possible with two y-axes?

Thanks for your help, 

Antje




-Ursprüngliche Nachricht-
Von: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 9. Januar 2006 18:08
An: Antje Schüle
Cc: r-help@stat.math.ethz.ch
Betreff: Re: two y-axis in xy-plot

On 1/9/06, Antje Schüle [EMAIL PROTECTED] wrote:
 Hi there,



 I am wondering if it is possible to do an xyplot with two y-axes. I'd like
 to print two parameters in a time series but they both have different
 scales.



 Which parameter in xyplot can I add to achieve this result?

The answer depends on the details of what you are doing, so please
provide us with a reproducible example.

Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] two y-axis in xy-plot

2006-01-10 Thread Antje Schüle

Hi all,

I think there is something I have forgotten to emphasize. I'd like to have an 
xyplot (with lattice library). A trellis graphic. For every weekday I like to 
have a graphic with all hours. And inside the graphic there are the two 
frequencies as lines.  

The problem finally is the use of the xyplot in library(lattice) in combination 
with the second y-axis.

Thanks.

Antje


---

It is nearly the same example I wrote about in 
http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg54238.html. I'll print 
it out again:

In the first column I have numbers from 0 to 23 (hours of a day), the second 
column contains the name of a weekday (Day as factor) and the third column 
contains the number I am interested in. So as an example, the first five rows 
look like that:

 Hour Day Freq

1 0  Mo23

2 1  Mo20

3 2  Mo14

4 3  Mo27

5 4  Mo26

 
To read: On Monday between 0 and 1 o'clock 23 things happened. 

Now I add a new parameter, so that the data looks somehow like that:

 Hour Day Freq Freq2

1 0  Mo23874

2 1  Mo20   476

3 2  Mo14201

4 3  Mo27   912

5 4  Mo26   172

Now I'd like to have a plot for every weekday containing the two frequencies as 
a line during the hours.

Is this possible with two y-axes?

Thanks for your help, 

Antje




-Ursprüngliche Nachricht-
Von: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 9. Januar 2006 18:08
An: Antje Schüle
Cc: r-help@stat.math.ethz.ch
Betreff: Re: two y-axis in xy-plot

On 1/9/06, Antje Schüle [EMAIL PROTECTED] wrote:
 Hi there,



 I am wondering if it is possible to do an xyplot with two y-axes. I'd like
 to print two parameters in a time series but they both have different
 scales.



 Which parameter in xyplot can I add to achieve this result?

The answer depends on the details of what you are doing, so please
provide us with a reproducible example.

Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] two y-axis in xy-plot

2006-01-09 Thread Antje Schüle
Hi there,

 

I am wondering if it is possible to do an xyplot with two y-axes. I'd like to 
print two parameters in a time series but they both have different scales.

 

Which parameter in xyplot can I add to achieve this result? 

 

Thanks a lot for any help. 

 

Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] panel order in xyplot

2005-12-22 Thread Antje Döring
Hi all,

 

I have a question concerning xyplot. My data is a data.frame looking like that:

 

In the first column I have numbers from 0 to 23 (hours of a day), the second 
column contains the name of a weekday (Day as factor) and the third column 
contains the number I am interested in. So as an example, the first five rows 
look like that:

 

Hour Day Freq

1 0  Mo23

2 1  Mo20

3 2  Mo14

4 3  Mo27

5 4  Mo26

 

To read: On Monday between 0 and 1 o'clock 23 things happened. 

 

The code of the xyplot looks like that:

 

trellis.device(new = FALSE, col = FALSE)

xyplot(Freq ~ Hour | Day, data = mydata,

   xlab = hour, ylab = number, main = xxx, ylim = 1:30,

   scales = list(x = list(at = seq(0,24,6), labels = c(0, 6, 12, 18, 24), 
cex = 0.7, relation = free), 

   y = list(tick.number = 5, cex = 0.7)), between = list(x = 0.5, y = 1.5), 

   layout = c(4,2), aspect = 1,

   panel = function(x,y){

 panel.grid()

  panel.barchart(x, y, horiz = F, aspect = 1, col = red)

   }

   )

 

Now my problem:

The plot is ordered by default, that in the first row I can see Friday, 
Saturday and Sunday, in the second row there is Monday, Tuesday, Wednesday and 
Thursday. I like to order the panels that way that in the first row there 
should be Monday-Thursday, the last row to contain Friday - Sunday. 

Is there any parameter in xyplot I can add to achieve this result? Any 
parameter where I can tell how the panels have to be arranged?

 

Thanks a lot for any help. 

 

Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to save an object list as txt?

2005-11-24 Thread Antje Döring
Hello everyone,

 

does somebody know how can I save an object list as a txt-file or as a  
csv-file? The problem is, that the elements of this list have different row 
length. So I cannot convert the list into a matrix or something else and then 
use write-matrix or so as usual. 

 

Thank you very much for your help.

 

Regards, Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] problem with parse

2005-11-22 Thread Antje Döring
Hi there again,

 

I have a problem with the parse-command. 

 

First of all, I show you in a simplified way, what I am trying to do and what 
R answers:

 

 test

 [1] u.g$par1, u.g$par2
 mode(test)

 [1] character

 ausdruck - parse(text = test)

 Error in parse(file, n, text, prompt) : syntax error in u.g$par1,

 

That is what I did and I can't find the mistake. I just want to have test 
without quotes (to do eval(ausdruck) later) but somehow it doesn't work.

 

Is there anything I have overlooked? Can't I put special characters like $ or 
, into this test-character?

 

Thanks a lot for your help.

 

Best, Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Comparing rows of matrices with different dimensions

2005-11-21 Thread Antje Döring
 

Hi there,

 

I have a question, which I thought is very easy to solve, but somehow I can't 
find a solution. Probably someone could help me quickly?

 

Here it is:

 

I have two matrices:

 

a

 [,1] [,2] [,3]

[1,]149

[2,]26   10

[3,]36   11

[4,]48   12

 

 

b

 [,1] [,2]

[1,]14

[2,]25

[3,]36

 

Now I want to find out which rows of b can also be found in a (without its last 
column). So the solution must be something like either TRUE FALSE TRUE or the 
rows where their is a match (rows 1 and 3)

 

Till now I have tried things like b %in% a[,1:2] or so but that doesn't work 
because I want to compare the WHOLE row of b with the whole row of a without 
column 3.

 

Thank you very much for any help.

 

Regards, Antje


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Using ComputerModern-Fonts with Matplot

2005-11-20 Thread Antje
Hi There,
I am trying to use ComputerModern Fonts with the matplot-command. Is 
that possible and what command do I have to use?

Thanks,
Antje

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R-help: conversion of long decimal numbers into hexadecimal

2005-11-10 Thread Antje Döring
Hi there,

 

could somebody help me to convert a decimal number into a hexadecimal number? I 
know that there is the function sprintf, but the numbers I want to convert 
consist of  20 or more numbers. Spintf is not able to convert these big 
numbers.

 

Thanks for any help.

 

Antje

 

 


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R-help: conversion of long decimal numbers into hexadecimal numbers

2005-11-10 Thread Antje Döring
Hi there,

 

could somebody help me to convert a decimal number into a hexadecimal number? I 
know that there is the function sprintf, but the numbers I want to convert 
consist of  20 or more numbers. Spintf is not able to convert these big 
numbers.

 

Thanks for any help.

 

Antje Döring

 

 


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html