[R] regexpr virtue

2009-07-29 Thread Petr PIKAL
Hi all I have got something like that (actually those are column names) [51] "X19.2.300b...80" "X19.2.400v...80" "X19.2.400b...80" "X19.2.300v...90" "X19.2.300b...90" [56] "X19.2.400v...90" "X19.2..400b..90" "X19.2.300v...100" "X19.2.300b...100" "X19.2.400v

Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
> > x > [1] "X19.2.400v...80" > > strsplit(x,"\\...")[[1]][3] > [1] "80" > > HTH, > > Jorge > > On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL wrote: > Hi all > > I have got something like that (actually those are colum

Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
trapply(s, "[0-9]*$", simplify = c) > > > > On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL wrote: > > Hi all > > > > I have got something like that (actually those are column names) > > > > [51] "X19.2.300b...80" "X19.2.

Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
returns the position in the string x where that regular > expression begins. Feed that to substring() and you get the desired > result. Both substring() and regexpr() work on vectors of strings. > > Best regards, > Chuck Taylor > TIBCO Spotfire Seattle > > > -Origi

[R] Odp: What is the best method to produce means by categorical factors?

2009-07-30 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 30.07.2009 10:19:21: > I am attempting to replicate some of my experience from SAS in R and assume > there are best methods for using a combination of summary(), subset, and > which() to produce a subset of mean values by categorical or ordinal > factor

Re: [R] package lattice can't be loeaded

2009-07-31 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 31.07.2009 08:27:24: > The error message is: "Error in library(lattice) : there is no package called 'lattice'" > > I have installed it twice because it did not work the first time, so I was not > sure if it worked. > And YES, the folder lattice is in

[R] Odp: Lattice in a loop does not produce output

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.08.2009 14:13:12: > I cannot understand why xyplot does not work within a simple for loop. > > This works up to the for loop; inside the for loop the png files are > opened and closed, but nothing is plotted. No error messages are written > to the co

[R] Odp: vector replacement 1/0 to P/A

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.08.2009 16:22:39: > Hi, > Can someone suggest an efficient way to substitute a vector/matrix > which contains 1's and 0's to P's and A's (resp.)? vec<-sample(0:1, 20, replace=T) vec [1] 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0 vec<-ifelse(vec==0, "A",

[R] Odp: function merge()

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.08.2009 14:32:43: > Hi, > > Actually, i use the function merge like this: > > (Data1 <- Data1[1:7,1:3]) > Policy.Number AXA.Entity Country > 1106077BNL BNL > 2 4001023 CH BNL > 3106006 UK B

[R] Odp: Polygon function

2009-08-18 Thread Petr PIKAL
r-help-boun...@r-project.org napsal dne 17.08.2009 16:18:43: > Dear all, > I would like to plot credible interval for a function estimate in R. I > would like to plot the credible intervals as shaded region using polygon > function. Does anyone ever used that? I tried several times but I could > n

[R] Odp: how to draw pentagon?

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.08.2009 06:13:09: > Hi everyone, > I want you all help me to give an idea, how to draw pentagon with points? > Maybe can use function, but I'm stuck. Maybe. Maybe you can use a pencil, instead. Basically this plot(1:10, type="n") polygon(c(2,3,5,6

[R] Odp: (no subject)

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.08.2009 10:35:11: > Dear all, > > I have a problem with the function read.xls from the gdata package, error > message see below. Two examples: > > First, I try to read my data, which does not work; > Secondly, I tried the example code/data with th

[R] Odp: How to use R to perform prediction based on history data

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 15.08.2009 04:27:39: > Say I have a csv file, each row contains several fields, one of them > are whether the row is success. > > In history data, I have all the fields including the result of whether > it is success. In future data, I only have fields

[R] Odp: Replacing NA values in one column of a data.frame

2009-08-18 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.08.2009 17:41:59: > > Dear all, > > I'm trying to replace NA values with - in one column of a data frame. I've Well, Jim sent you a solution but I would rise a question, why do you want to do that. R has many instruments how to smoothly handl

Re: [R] vector replacement 1/0 to P/A

2009-08-18 Thread Petr PIKAL
Hi As matrix is vector with dim attribute mymat<-ifelse(mymat==0, "A","P") should be sufficient. Even with data frame it works mydf<-data.frame(mymat) mydf<-ifelse(mydf==0, "A","P") mydf X1 X2 X3 [1,] "P" "P" "A" [2,] "A" "A" "A" [3,] "A" "A" "P" [4,] "A" "A" "P" [5,] "P" "P" "P" R

[R] Odp: Remove columns

2009-08-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 18.08.2009 10:14:26: > Hi Everbody > > Could somebody help me.? > > I need to remove the columns where the sum of it components is equal to > zero. > > For example > > > a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) > > a >

[R] scale or not to scale that is the question - prcomp

2009-08-19 Thread Petr PIKAL
"ano" while highest group has low value of sio2. But when I do the same with scale=T fit<-prcomp(~iep+sio2+al2o3+p2o5+as.numeric(dus), data=rglp, factors=2, scale=T) biplot(fit, choices=2:3,xlabs=rglp$vzorek, cex=.8) I get completely different picture which is not possible t

Re: [R] Embedding lists in matrices and matrices in lists

2009-08-19 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 19.08.2009 13:04:39: > Strange, it doesn't work for me: > > Error in database[4, 4][[1]][1, ] : incorrect number of dimensions > Execution halted > > R version 2.9.0 (2009-04-17) on Arch Linux, no additional packages > installed. database[4,4][[1]][,

Re: [R] scale or not to scale that is the question - prcomp

2009-08-19 Thread Petr PIKAL
Thank you Duncan Murdoch napsal dne 19.08.2009 14:49:52: > On 19/08/2009 8:31 AM, Petr PIKAL wrote: > > Dear all > > > > I would say the answer depends on the meaning of the variables. In the > unusual case that they are measured in dimensionless units, it mi

Re: [R] scale or not to scale that is the question - prcomp

2009-08-19 Thread Petr PIKAL
Duncan Murdoch napsal dne 19.08.2009 15:25:00: > On 19/08/2009 9:02 AM, Petr PIKAL wrote: > > Thank you > > > > Duncan Murdoch napsal dne 19.08.2009 14:49:52: > > > >> On 19/08/2009 8:31 AM, Petr PIKAL wrote: > >>> Dear all > >>&g

Re: [R] scale or not to scale that is the question - prcomp

2009-08-19 Thread Petr PIKAL
Ok Thank you for your time. Best regards Petr Pikal Duncan Murdoch napsal dne 19.08.2009 16:29:07: > On 8/19/2009 10:14 AM, Petr PIKAL wrote: > > Duncan Murdoch napsal dne 19.08.2009 15:25:00: > > > >> On 19/08/2009 9:02 AM, Petr PIKAL wrote: > >> > Tha

Re: [R] scale or not to scale that is the question - prcomp

2009-08-19 Thread Petr PIKAL
OIS Thank you both for pointing me to it. I did not notice this as the unscaled position of points was quite clear and strightforward according to my knowledge of data. The scaled plot is slightly more distorted and the relationships are not so obvious. Thank you both Petr Pikal petr.pi

Re: [R] Embedding lists in matrices and matrices in lists

2009-08-19 Thread Petr PIKAL
ons for manipulation with lists. E.g. structure lm(...) results in list and summary(lm(...)) is again a list with quite complicated structure. If I understand it correctly, during your computation you will have as a result matrices with arbitrary dimensions. I would make a list lll<-vec

Re: [R] Embedding lists in matrices and matrices in lists

2009-08-20 Thread Petr PIKAL
ur procedures. Regards Petr > http://paste.ubuntuusers.de/396117/ It even runs (though errors occur if > I add th process r into the main loop, but I'm still not done with it...). > > Petr PIKAL schrieb: > > Hi > > > > > > No. It is the problem of scoping. AFAIK function

[R] Odp: Histogram problem

2009-08-20 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 20.08.2009 15:33:38: > I'm trying to create a histogram from the following code, but my data keeps > adding the Num vector and plotting that. My data in the CSV file is just > one vector. Does anyone know why? Well, I think that only you know why CS

Re: [R] Histogram problem

2009-08-20 Thread Petr PIKAL
making your own histogram function it is hard to say what do you want. I am pretty sure you are inventing a wheel. Regards Petr Conrad Addo napsal dne 20.08.2009 16:29:36: > Petr > > Actually I wanted to find why the NUm vector was adding incrementally, not > about the CSV. &

[R] Odp: A question on List

2009-08-21 Thread Petr PIKAL
Hi mapply("*", vect, mat, SIMPLIFY=F) Regards Petr r-help-boun...@r-project.org napsal dne 21.08.2009 10:53:19: > > Suppose I have following list : > > mat <- vector("list") > for (i in 1:4) mat[[i]] <- matrix(rnorm(25),5) > mat > > > mat > [[1]] > [,1] [,2] [,3]

[R] Odp: When factor is better than other types, such as vector and frame?

2009-08-24 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.08.2009 05:00:11: > Hi, > > It is easy to understand the types vector and frame. > > But I am wondering why the type factor is designed in R. What is the > advantage of factor compare with other data types in R? Can somebody > give an example in whi

Re: [R] Convert list to data frame while controlling column types

2009-08-24 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.08.2009 17:29:48: > On 8/23/2009 9:58 AM, David Winsemius wrote: > > I still have problems with this statement. As I understand R, this > should be impossible. I have looked at both you postings and neither of > them clarify the issues. How can you ha

[R] Odp: Re : table function

2009-08-25 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36: > Hi Mark, > > > Thank you for your answer !! it works but if i have "NA" in the vector z what > i shoud do to count its number in Z? You do not have NA in z, you manage to convert it somehow to factor. Please try to read about

[R] Odp: Fw: Re: Simulating data for sampling (stupid question)

2009-08-25 Thread Petr PIKAL
Well you shall consult (surprisingly :-) ?sample function and for rating ?runif function as was pointed out earlier Regards Petr r-help-boun...@r-project.org napsal dne 25.08.2009 05:14:00: > Dear All > Â > I know that you do not have to help me (as this is not a pure R problem)Â but > p

Re: [R] Creating a simple line graph

2009-08-25 Thread Petr PIKAL
Hi Do not use cbind as it results in matrix and it can have only data of one type, in your case character. Use MeanEst2000.Sz=data.frame(Sz,Pred) instead. And you probably could go step further to put everything into one data frame DF <- data.frame(Sz,Pred, Obs) then with(DF, plot(Pred, O

[R] Odp: Re : Odp: Re : table function

2009-08-25 Thread Petr PIKAL
> the goal of this exercice that to count the number of missing value, number > betwwen 0-1000 , 1000-3000, >3000. > > Thank you again for your help > > > > > > De : Petr PIKAL > > Cc : r-help@r-project.org > Envoy

[R] Odp: table, sum, cat function

2009-08-25 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 25.08.2009 12:07:11: > Hi, > > the second step in my exercice is to calculate the sum of the amout for each > class et not the frequency > > i have this vector > > x y > 1 100 > 2 1500 > 3 3250 > 4 625

[R] Odp: Select top three values from data frame

2009-08-26 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 26.08.2009 10:36:22: > Hi, > > I'm trying to find an easy way to do this. > > I want to select the top three values of a specific column in a subset > of rows in a data.frame. I'll demonstrate. > > ABC > x21 > x41 > x3

[R] Odp: draw n-1 lines with n X and n Y

2009-08-26 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 25.08.2009 18:15:25: > > I want to draw lines using a matrix with the X-axe on the first column, and > the the Y-axe on the second column. > These lines have to link the n points of a graph, so they are n-1, but the > resout using these two commands:

Re: [R] Best R text editors?

2009-08-28 Thread Petr PIKAL
Tinn-R Petr r-help-boun...@r-project.org napsal dne 28.08.2009 09:16:38: > On Thu, 27 Aug 2009 12:43:41 -0700 Jonathan Greenberg > wrote: > > JG> Quick informal poll: what is everyone's favorite text editor for > JG> working with R? I'd like to hear from people who are using editors > JG> tha

Re: [R] Sequence generation

2009-08-31 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 29.08.2009 21:49:54: > On Sat, Aug 29, 2009 at 8:14 PM, njhuang86 wrote: > > > > Hey guys, > > > > I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, > > 2, 3... with the '1, 2, 3' repeated over 10 times. > > rep(1:3,10) # rep

[R] Odp: data frame

2009-09-01 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 01.09.2009 10:39:42: > > HI, R user, > > I generate the vectors with the same length. I want to put each vector into > each column of data frame. Why it doesnt work`? > > rm<-data.frame() > > for(a in 1:6){ > rm[,a]<-getmeasure(p1,a,speech) > >

[R] Odp: Normalized Y-axis for Histogram Density Plot

2009-09-02 Thread Petr PIKAL
Hi that is a question which comes almost so often as "why R does not think that my numbers are equal". So even I, non statistician, can deduct that hist with probability =T can have any y axis range but the sum below curve has to be below 1. Regards Petr r-help-boun...@r-project.org napsal dn

[R] Odp: "biplot" graphical options?

2009-09-02 Thread Petr PIKAL
Hi I had similar problem some time ago. I was advised to use eqscplot but it did not suite my purpose so I used a little twist of biplot. (I added a result) fit<-princomp(some.data, cor=T) biplot(fit, xlabs=rep("", no.of.poins)) #biplot without points #some scaling of plot parameters rrr<-a

[R] Odp: How can I appoint a small part of the whole data

2009-09-03 Thread Petr PIKAL
Hi use any of suitable selection ways that are in R. E.g. data[data$gender==1, ] selects only female values data$wage[(data$gender==1) & (data$race=1)] selects black female wages. and see also ?subset Regards Petr r-help-boun...@r-project.org napsal dne 03.09.2009 10:51:59: > Dear all, >

Re: [R] Problems with Boxplot

2009-09-04 Thread Petr PIKAL
Hi it is rather difficult to understand what you mean by your questions/answers without real reproducible code. r-help-boun...@r-project.org napsal dne 03.09.2009 13:41:11: > > I'm posting answers to my own Q's here - as far as I have answers - first so > that people don't spend time on them,

Re: [R] saving large matrices with decimal numbers

2009-09-04 Thread Petr PIKAL
Hi image<-matrix(0.1, 768,1024) > image[1:10, 1:10] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [2,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [3,] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 [4,] 0.1 0.1 0

Re: [R] Party plots

2009-09-04 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 04.09.2009 13:53:24: > > Nordlund, Dan (DSHS/RDA) wrote: > > > > > > You need to put the filename in quotes > > > > file = "C:/Documents and Settings/aelmore/Desktop/foo.pdf" > > > > Hope this is helpful, > > > > Dan > > > Oh yes, this was very h

Re: [R] Problems with Boxplot

2009-09-07 Thread Petr PIKAL
the formats shown are more scientific > in focus. I still haven't been able to find a way of getting a "comma > style". AFAIK you can not format these in boxplot directly. You need to plot without y axis and in axis you can use formating with prettyNum. I found quite easily from s

[R] Andrews plot

2009-09-07 Thread Petr PIKAL
Dear all Colleague of mine ask me if R is capable of Andrews plot like andrewsplot(x) in Matlab. Quick search did not reveal anything but before I start to write any routine I would like to ask this ingenious audience if there is any implementation of Andrews plots somewhere. I know about p

Re: [R] Andrews plot

2009-09-07 Thread Petr PIKAL
Thank you. hadley wickham napsal dne 07.09.2009 15:50:03: > On Mon, Sep 7, 2009 at 8:36 AM, Petr PIKAL wrote: > > Dear all > > > > Colleague of mine ask me if R is capable of Andrews plot like > > andrewsplot(x) in Matlab. > > > > Quick search did no

Re: [R] Data separated by spaces, getting data into R using field lengths

2009-09-08 Thread Petr PIKAL
Hi what about reading each line by readLine and then split it to desired portions? x<-paste(letters, collapse="") substring(x, c(1,3,5),c(2,4,15)) Regards Petr r-help-boun...@r-project.org napsal dne 08.09.2009 14:21:53: > This data is from database and the maximum length of a field is > def

Re: [R] cbind formula definition

2009-09-09 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 09.09.2009 10:07:49: > Hi Henrique, > > Thanks for your reply. > I tried you suggestion but it didn't work with the poLCA package. > > Maybe i didn't express myself good. > > The normal syntax is: > > f <- cbind(V1,V2,V3)~1 > poLCA(f,data) You compl

[R] change character to factor in data frame

2009-09-09 Thread Petr PIKAL
Dear all I have a simple problem which I thought is easy to solve but what I tried did not work. I want to change character variables to factor in data frame. It goes easily from factor to character, but I am stuck in how to do backwards conversion. Here is an example irisf<-iris irisf[,2]<-f

[R] Odp: boxplot

2009-09-17 Thread Petr PIKAL
Hi I do not know rma but from help page boxplot requires as input a formula, list (only some list of numerics), data frame or numeric vector. I am not sure if your object is one of these. If not you need to convert it to object which is acceptable for boxplot. Regards Petr r-help-boun...@r-p

[R] Odp: What is the best way to get a subset of a data.frame?

2009-09-17 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.09.2009 04:14:24: > Hi, > > I want to construct a data.frame 'y' by using x$x and x$y. I think > that there might be better ways to do it (because, for example, we can > use a_matrix[3:5,] to extract certain rows, where 'a_matrix' is a > matrix). Can

Re: [R] Maximum No.of code in R

2009-09-21 Thread Petr PIKAL
Well, code with 50+ ifelse statements (probably nested) seems to me quite weird. I believe that such scheme could be solved differently but without real code it is nothing to suggest. r-help-boun...@r-project.org napsal dne 18.09.2009 13:51:45: > On 9/18/2009 5:49 AM, premmad wrote: > > I tried

[R] Odp: Selecting data based on date-Data manupulation

2009-09-21 Thread Petr PIKAL
Hi see ?format output of format can be transferred to numeric and you can use logical operators to select only desired data. x[as.numeric(format(x, "%Y")) > 2008,] another option is to compare it to some date like x > as.Date("2008-1-1") this assumes that x has class "Date". If not you can ch

[R] Odp: Handling missing data

2009-09-21 Thread Petr PIKAL
Hi did you try ?complete.cases or ?na.omit? nadata[complete.cases(nadata),] Regards Petr r-help-boun...@r-project.org napsal dne 21.09.2009 08:16:04: > > I have to remove missing data both in character and numeric datatype.I tried > using NA condition but it is not working ,please help me t

Re: [R] Replacing values in dataframes

2009-09-21 Thread Petr PIKAL
Hi I believe you are quite near. r-help-boun...@r-project.org napsal dne 21.09.2009 11:38:29: > > Thank you so much for trying to help me. > Thus, I still can't get it to work. > I will clearify a bit. If you somehow have time helping me I would much appreciate it. > NAD and Prot.amount are

Re: [R] weird "vector size cannot be NA/NaN" problem

2009-09-21 Thread Petr PIKAL
Hi I tried but > describe(c(5,3,76,4/0)) Error: could not find function "describe" > What shall I do? Quick search did not find function on CRAN and I do not have enough time to dig it from somewhere. Regards Petr r-help-boun...@r-project.org napsal dne 21.09.2009 12:06:09: > Hi, > > I hav

[R] Odp: use of class variable in r as in Proc means of sas

2009-09-22 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 22.09.2009 11:51:18: > > Hi,everyone i need to calculate quartile values of a variable grouped by the > other variable . > same as in aggregate function(only median,mean or functions is possible-i > think so) > Could you please help me to achieve the

[R] Odp: converting a character vector to a function's input

2009-09-22 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 22.09.2009 14:57:59: > Hi all, I have been trying to solve this problem and have had no luck so far. > > I have numeric vectors VAR1, VAR2, and VAR3 which I am trying to cbind. I also > have a character vector "VAR1,VAR2,VAR3". How do I manipulate th

[R] Odp: Sum of Product in a Matrix

2009-09-23 Thread Petr PIKAL
Hi I am not sure if I understand what you want but if your matrix is not so big you can try > x[,1]*x[,2] [1] 5 12 21 32 > cumsum(x[,1]*x[,2]) [1] 5 17 38 70 > and than check value of cumsum according to your condition. Regards Petr r-help-boun...@r-project.org napsal dne 23.09.2009 05:25

Re: [R] strange split behavior?

2009-09-23 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.09.2009 14:49:38: > On Wed, Sep 23, 2009 at 07:29:30AM -0500, Peng Yu wrote: > > On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard > > wrote: > > > Peng Yu wrote: > > > > Is there an operation on a factor to get a subset and keep only the > > correspo

Re: [R] compute differences

2009-09-23 Thread Petr PIKAL
Hi You can use outer. If your data are in data frame test then DIFF <- as.vector(t(outer(test$val, test$val, "-"))) returns a vector, You just need to add suitable names to rows. CASE <- as.vector(t(outer(test$ID, test$ID, paste, sep="-"))) data.frame(CASE, DIFF) will put it together. Regard

[R] Odp: Box plot

2009-09-24 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.09.2009 21:17:10: > > Hi, > > Is there a way I can plot the median as well as the quantiles in the actual > boxplot using the "boxplot" command? AFAIK boxplot produces box which marks upper and lower quartile and median. So you shall be more prec

[R] Odp: Re tain current graphs in figure

2009-09-24 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 25.09.2009 05:31:58: > > I want to know, how do I retain the current plot and axes properties such > that subsequent graphing commands add to the existing graph. Are you looking for ?lines, ?points Regards Petr > > Thank you very much!! > > --

Re: [R] tapply with cbinded x

2009-06-16 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 16.06.2009 12:45:04: > Stefan Uhmann wrote: > > Dear List, > > > > why does this not work? > > > > df <- data.frame(var1 = c(3,2,1), var2 = c(6,5,4), var3 = c(9,8,7), > > fac = c('A', 'A', 'B')) > > tapply(cbind(df$var1, df$var2, df$var3), df$fac, me

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 16.06.2009 14:31:21: > Hi Jim, > > What you are saying is correct. Although, my computer might not have > same speed and I am getting the following for 10M entries: > >user system elapsed > 0.559 0.038 0.607 With numbers you may speed it a

Re: [R] ifelse(is.na), with function inside

2009-06-17 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.06.2009 07:51:27: > > 2 - is.na(a) - it's superb! but I need call a function: wy[i]<- > ifelse(((is.na(a))), call_fun1(x), call_fun2(x) You did not grasp how to use ifelse. It goes not cycle through logical vector is.na(a). from help page Argum

<    1   2   3   4   5