[R] Loop with random sampling and write.table

2011-09-03 Thread Pete Pete
Hi! I need to perform this simple sampling function several hundred times: x1=as.character(rnorm(1000, 100, 15)) x2=as.character(rnorm(1000, 150, 10)) y1=as.data.frame(x1,x2) sample1=as.data.frame(sample(y1$x1, 12, replace = FALSE, prob = NULL)) sample1 write.table(sample1, "sample1.txt", sep="

Re: [R] Reshape from long to wide format with date variable

2011-07-07 Thread Pete Pete
Thanks, Josh! The index variable (time) was my problem. My R skills are too low! :) Problem solved! -- View this message in context: http://r.789695.n4.nabble.com/Reshape-from-long-to-wide-format-with-date-variable-tp3648833p3650995.html Sent from the R help mailing list archive at Nabble.com.

[R] Reshape from long to wide format with date variable

2011-07-06 Thread Pete Pete
Hi, I need to reshape my dataframe from a long format to a wide format. Unfortunately, I have a continuous date variable which gives me headaches. Consider the following example: > id=c("034","034","016","016","016","340","340") > date=as.Date(c("1997-09-28", "1997-10-06", "1997-11-04", "2000-09-

Re: [R] Creating binary variable depending on strings of two dataframes

2011-05-06 Thread Pete Pete
Gabor Grothendieck wrote: > > On Tue, Dec 7, 2010 at 11:30 AM, Pete Pete <noxyp...@gmail.com> > wrote: >> >> Hi, >> consider the following two dataframes: >> x1=c("232","3454","3455","342","13") >>

[R] Creating binary variable depending on strings of two dataframes

2010-12-07 Thread Pete Pete
Hi, consider the following two dataframes: x1=c("232","3454","3455","342","13") x2=c("1","1","1","0","0") data1=data.frame(x1,x2) y1=c("232","232","3454","3454","3455","342","13","13","13","13") y2=c("E1","F3","F5","E1","E2","H4","F8","G3","E1","H2") data2=data.frame(y1,y2) I need a new column i