[R] error message

2011-01-18 Thread wangwallace
I was running a sampling syntax based on a data frame (ago) of 160 rows and 25 columns. Below are the column names: names(ago) [1] SubID AGR1 AGR2 AGR3 AGR4 AGR5 AGR6 AGR7 AGR8 [10] AGR9 AGR10 WAGR1 WAGR2 WAGR3 WAGR4 WAGR5 WAGR6 WAGR7 [19] WAGR8 WAGR9 WAGR10 ocbi

Re: [R] error message

2011-01-18 Thread wangwallace
I tried it several times. it still gives me the same error. I also used traceback() here is what I got: traceback() 3: `[.data.frame`(df, -s1$SubID, ) 2: df[-s1$SubID, ] 1: crossed1(agr) But I don't think there is anything wrong with it.. -- View this message in context:

Re: [R] error message

2011-01-18 Thread wangwallace
Peter, I found it. There is a missing value under column SubID. I filled it out with an ID number, and the error message never occur again. Although I found the problem, I have no idea why would this be associated with such an error message. If anybody else have some input, I would really

[R] how to sort new data frame based on the original data frame

2011-01-11 Thread wangwallace
I have a really simple question I have a data frame of 8 variables (the first column is the subjects' id): SubID G1G2 G3 G4W1W2 W3W4 1 6 5 6 2 6 22 4 2 6 4 7 2 6

Re: [R] how to run linear regression models at once

2011-01-10 Thread wangwallace
hey, Dennis, I applied your syntax into my data frame with different variable names. Specifically, I replaced y1 and y2, with ocbi and ocbo. I got the following error message. Could you please explain why would this happen? Again, thanks! for(i in

Re: [R] how to run linear regression models at once

2011-01-10 Thread wangwallace
I am too negligent... thank you very much for pointing out that! -- View this message in context: http://r.789695.n4.nabble.com/how-to-run-linear-regression-models-at-once-tp3179256p3207823.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] how to run linear regression models at once

2011-01-08 Thread wangwallace
cool, it worked. thank you very much for your help!! :) -- View this message in context: http://r.789695.n4.nabble.com/how-to-run-linear-regression-models-at-once-tp3179256p3205186.html Sent from the R help mailing list archive at Nabble.com. __

[R] how to run linear regression models at once

2011-01-07 Thread wangwallace
hey, folks, I have two very simple questions. I am not quite sure if I can do this using R. so, I am analyzing a large data frame with thousands of variables. For example: Dependent variables: d1, d2, d3 (i.e., there are three dependent variables) Independent variables: s1, s2, s3,

Re: [R] how to apply sample function to each row of a data frame?

2010-11-22 Thread wangwallace
I tried it. it works out perfectly. you save my life. -- View this message in context: http://r.789695.n4.nabble.com/Re-how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050933p3054117.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] how to apply sample function to each row of a data frame?

2010-11-21 Thread wangwallace
it works. I really appreciate the help! :) -- View this message in context: http://r.789695.n4.nabble.com/Re-how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050933p3052098.html Sent from the R help mailing list archive at Nabble.com. __

[R] use sample function to create new data frame

2010-11-21 Thread wangwallace
here is my original data frame a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables how can I create a new data frame in which: 1) in each row, there are one random number from type I

Re: [R] use sample function to create new data frame

2010-11-21 Thread wangwallace
Gong, thanks!! but your syntax did work out as I would expect. here following are the reasons: each row from my original data frame represents data from one subject. when the one type I number and the two type II numbers are drawn from the original data frame, both type I number and type II

Re: [R] how to apply sample function to each row of a data frame?

2010-11-21 Thread wangwallace
Hey, PS, I revised your syntax and used it to another one of my data frames (df). here is the data frame: a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables each row represent the

[R] how to apply sample function to each row of a data frame?

2010-11-19 Thread wangwallace
this is a simple question, but I wasn't able to figure it out myself. here is the data frame: M P Q 1 2 3 4 5 6 7 8 9 M, P, Q each represent a variable I want to draw 2 random sample from each row separately to create a new data frame. how can I do it? thanks!! -- View this message in

Re: [R] how to apply sample function to each row of a data frame?

2010-11-19 Thread wangwallace
this is a simple question, but I wasn't able to figure it out myself. here is the data frame: M P Q 1 2 3 4 5 6 7 8 9 M, P, Q each represent a variable I want to draw 2 random sample from each row separately to create a new data frame. how can I do it? thanks!! sorry for the

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
Dear Ista Zahn-2, If you can give me some advice, I really appreciate it. I have been working on it for days. it seems hard for some novice of R like me to write flexible functions myself. This is for my dissertation. CSE and WSE are two scales of the same construct. The sampling strategy I

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
Also, I need some function at the end which would enable me to draw 1000 such random samples. thanks! :) -- View this message in context: http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3048958.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Odp: Sampling problem

2010-11-18 Thread wangwallace
I tried. yours works too. thanks a bounch!! Man -- View this message in context: http://r.789695.n4.nabble.com/Sampling-problem-tp3043804p3049013.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
Hi, Mike, thank you very much!!:) the following two functions are really helpful, which I didn't even know. Actually, I searched the forum for something like this, but failed. Now I am still trying to make up my own functions. :) sample(a[,2],2) #randomly draw two numbers from a column

Re: [R] New Sampling question

2010-11-18 Thread wangwallace
I spent the whole afternoon on it, but there is still no progress. I wish I could take some courses... :( -- View this message in context: http://r.789695.n4.nabble.com/New-Sampling-question-tp3047885p3049796.html Sent from the R help mailing list archive at Nabble.com.

[R] New Sampling question

2010-11-17 Thread wangwallace
I have another question about drawing samples from a data frame. This might sound really tricky. Let me use a data frame I have posted earlier as an example: SubIDCSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 22 4 2

Re: [R] Sampling problem

2010-11-16 Thread wangwallace
Michael, I really appreciate your help. but I got the following error message when I wan trying to run the function written by you: Error in out[i, ] - apply(help[, c(grp1 + 1, grp2 + 5)], 2, sample, 1) : number of items to replace is not a multiple of replacement length I am not quite sure

Re: [R] Sampling problem

2010-11-16 Thread wangwallace
yes, the data.frame is exactly the same as the one I posted earlier. I was trying to see if the loop function works. And I got that message. here below is the syntax I was trying to run, followed by the error message at the end: sampleX-function(X,nGrp1,nsamples){if(nGrp1=4)stop(can't sample

Re: [R] Odp: Sampling problem

2010-11-16 Thread wangwallace
Fabulicious! It worked!!! One more question, in the following data frame as posted above: SubIDCSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 22 4 2 6 4 7 2 6 6

Re: [R] Odp: Sampling problem

2010-11-16 Thread wangwallace
I figured it out myself. Again, Michael and Petr, many thanks to both of you!!! :) -- View this message in context: http://r.789695.n4.nabble.com/Sampling-problem-tp3043804p3046161.html Sent from the R help mailing list archive at Nabble.com. __

[R] Sampling problem

2010-11-15 Thread wangwallace
Hey, I am hoping someone can help me with a sampling question. I have a data frame of 8 variables (the first column is the subjects' id): SubIDCSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 22 4 2 6 4