Re: [R] stats::reshape question

2012-02-16 Thread Krishna Tateneni
nction transposes the data for the "y" and "x" variables in the long form of the data without any warning. So to avoid the error I was running into, it is necessary to either make sure the arguments to varying and v.names are sorted correctly, or to use a list argument as Dennis h

Re: [R] Hmisc label function applied to data frame

2010-12-05 Thread Krishna Tateneni
Hello again, I have found that if I use sapply, I do not get a warning, i.e., lbl1 = sapply(d[,var1],label) works correctly and gives no warning. I'm sorry this did not occur to me earlier, my apologies! --Krishna On Thu, Dec 2, 2010 at 11:36 AM, Krishna Tateneni wrote: > Hello,

[R] Hmisc label function applied to data frame

2010-12-02 Thread Krishna Tateneni
Hello, I'm attempting to create a data frame with correlations between every pair of variables in a data frame, so that I can then sort by the value of the correlation coefficient and see which pairs of variables are most strongly correlated. The sm2vec function in the corpcor library works very

[R] glm: formula vs character

2010-09-16 Thread Krishna Tateneni
Hello, This is a question motivated by curiosity, not a pressing problem. Any responses are much appreciated! In the following code, function reg1 calls glm with a formula object while reg2 uses a string. In both cases, glm works; however, in the second case, the add1 function fails with the fo

Re: [R] stats::reshape question

2010-08-06 Thread Krishna Tateneni
1.11 1 5 1 > 2.11 2 6 2 > 1.22 3 7 1 > 2.22 4 8 2 > > HTH, > Dennis > > On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni wrote: > >> Hello, >> >> A quick question for my edification. When I run the following (R 2.8.1 on >> Micros

[R] stats::reshape question

2010-08-06 Thread Krishna Tateneni
Hello, A quick question for my edification. When I run the following (R 2.8.1 on Microsoft Windows): > d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8)) > reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long") I found myself surprised by the results--the column labeled "y

[R] regex help: splitting strings with no separator

2010-05-19 Thread Krishna Tateneni
Greetings, I have a vector of values that are a word followed by a number, e.g., x = c("Apple12","HP42","Dell91"). The goal is to split this vector into two vectors such that the first vector contains just the words and the second contains just the numbers. I cannot use strsplit (or at least I d

Re: [R] Write a blank line to CSV

2010-01-06 Thread Krishna Tateneni
Perfect, thanks very much! On Wed, Jan 6, 2010 at 10:44 AM, Gabor Grothendieck wrote: > Try this: > > cat("\n", file = "tables.csv", append = TRUE) > > > On Wed, Jan 6, 2010 at 11:36 AM, Krishna Tateneni > wrote: > > Greetings and happy new ye

[R] Write a blank line to CSV

2010-01-06 Thread Krishna Tateneni
Greetings and happy new year! I'm attempting to write a series of tables to a CSV file, and would like to insert a blank line after each table. To do this, I use: > write.csv(NULL,"tables.csv",append=T) which appears to work, except that this warning is thrown: > Warning message: > In write.table(

Re: [R] Numbering sequences of non-NAs in a vector

2009-07-07 Thread Krishna Tateneni
Many thanks to all who responded, and especially for the promptness of your answers. The common thread in your solutions is the use of rle, a very useful function of which I was ignorant. --Krishna [[alternative HTML version deleted]] __ R-hel

[R] Numbering sequences of non-NAs in a vector

2009-07-07 Thread Krishna Tateneni
Greetings, I have a vector of the form: [10,8,1,3,0,8,NA,NA,NA,NA,2,1,6,NA,NA,NA,0,5,1,9...] That is, a combination of sequences of non-missing values and missing values, with each sequence possibly of a different length. I'd like to create another vector which will help me pick out the sequences