Re: [R] Count of entries in a row of a data frame

2010-03-18 Thread Phil Spector
Thomas - Two ways that come to mind are apply(dat,1,function(x)sum(x != 0)) and rowSums(dat!=0) (assuming your data frame is named "dat"). - Phil Spector Statistical Computin

[R] RODBC fails to read ArcGIS mdb shape table at 2.9.1; works at

2009-08-03 Thread Phil Hurvitz
ere: http://gis.washington.edu/phurvitz/R/rodbc_problem/ -P. ** Phil Hurvitz, MFR | PhD Student, Urban Planning | CBE 1107 NE 45th Street, Suite 535 | Box 354802 University of Washington, Seattle, Washington 98195-4802,

Re: [R] Conditional replacement of NA depending on value in the previous column

2010-03-23 Thread Phil Spector
] 1 1 1 1 NA 1 - Phil Spector Statistical Computing Facility Department of Statistics UC Berk

Re: [R] smart way to turn a vector into a matrix

2010-03-26 Thread Phil Spector
quot; "1" [2,] "B" "2" [3,] "B" "3" [4,] "B" "4" $C [,1] [,2] [1,] "C" "1" [2,] "C" "2" [3,] "C" "3" - Phi

Re: [R] replace id by running number

2010-03-27 Thread Phil Spector
The rle (run length encoding) function is ideal for problems like this: y <- c(4,4,4,2,45,12,12) rr = rle(y) rep(seq(along=rr$values),rr$lengths) [1] 1 1 1 2 3 4 4 - Phil Spector Statistical Computing Facil

Re: [R] t.test data in one column

2010-04-01 Thread Phil Spector
5 percent confidence interval: 1.001052 2.998948 sample estimates: mean in group F mean in group M 3.5 1.5 If you're uncomfortable with the formula notation, try with(df,t.test(x[y=='M'],x[y=='F']))

Re: [R] Summing data based on certain conditions

2010-04-02 Thread Phil Spector
Steve - Take a closer look at the help page for ave(), especially the ... argument. Try data_ave <- ave(data$rammday, data$month, data$year,FUN=mean) (Assuming you want to calculate the mean -- your example didn't specify a function.)

Re: [R] strange behavior of matrix

2010-04-05 Thread Phil Spector
x with a 2 column matrix, but it is a documented fact. - Phil Spector Statistical Computing Facility Department of Statistics U

Re: [R] how does one print code

2010-04-08 Thread Phil Spector
David - You can do what you want pretty easily using sink. Suppose you want the source code for function "blah" in the file "blah.func": sink('blah.func') print(blah) sink() - Phil Spector

Re: [R] Read data in sequences

2010-04-09 Thread Phil Spector
ULL) grp x1 x2 A.1 A 2.5 3.4 B.1 B 5.3 5.4 A.2 A 2.7 5.6 B.2 B 6.5 7.5 A.3 A 5.7 5.4 B.3 B 1.3 4.5 A.4 A 10.1 9.4 B.4 B 10.5 4.1 You could generalize the varying argument like this: mkvarying = function(n)list(paste('x',seq(1,n,by=

Re: [R] perhaps regular expression bug with | sign ??

2010-04-09 Thread Phil Spector
get around this restriction using readline: pat = readline() \t pat [1] "\\t" cat(pat,'\n') \t It also should be remembered that R will add an extra backslash when it prints a single backslash -- as can be seen, this is avoided when you use cat().

Re: [R] efficiently picking one row from a data frame per unique key

2010-04-12 Thread Phil Spector
unique values of x, and do.call(rbind,lapply(sdf,getone)) will return a data frame with one row for each unique value of x. - Phil Spector Statistical Computing Facility

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Phil Spector
";) two[1:3] [1] "Date,Open,High,Low,Close,Volume,Adj Close" [2] "2010-04-15,592.17,597.84,588.29,595.30,6716700,595.30" [3] "2010-04-14,590.06,592.34,584.01,589.00,3402700,589.00" This shows that the dates have been faithfully copied from the csv file

Re: [R] Exporting PDF

2010-04-20 Thread Phil Spector
Since R provides the file.exists() function for exactly this purpose, I would recommend avoiding using shell scripts for such a simple task. file.exists() is a multiplatform solution to the problem. - Phil Spector

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Phil Spector
If I understand what you're looking for, I think this may work: seq=c(2,3,4) v=c(4,2,5,8,9,2,3,5,6,1,7,2,3,4,5) lseq = length(seq) lv = length(v) matches = sapply(1:(lv-lseq+1),function(i)all(v[i:(i+lseq-1)] == seq)) sum(matches) [1] 1 - Phil Sp

Re: [R] Table to List Transformation Scenario

2010-04-21 Thread Phil Spector
ar='Hour',idvar='Date',direction='long') dfnew = dfnew[order(dfnew$Date,dfnew$Hour),] - Phil Spector Statistical Computing Facility

[R] How to rbind listed data frames?

2010-05-04 Thread Phil Wieland
I made a list (dataList) of data frames. The list looks like this (the first two elements): [[1]] est cond targets 1 400 exo_depth_65Hautklinik 2 300 exo_depth_65 Ostturm_UKM 3 200 exo_depth_65 Kreuzung_Ro

Re: [R] keeping all rows with the same values, and not only unique ones

2009-09-24 Thread Phil Spector
Dimitri - Use %in% instead of ==: test[test$total %in% needed,] x y total 1 1 2 7 2 2 3 7 5 5 6 9 6 6 7 9 - Phil Spector Statistical Computing Facility

Re: [R] Row to Column help

2009-10-04 Thread Phil Spector
('id','author'),timevar='time',direction='wide') should give you what you want. - Phil Spector Statistical Computing Facility

Re: [R] No funtions for character code?

2009-10-13 Thread Phil Spector
arToInt('7') [1] 55 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] performing function on lists where each element is a data frame

2009-10-15 Thread Phil Spector
Are you saying that sapply(xx,function(x)weighted.mean(x$H,x$N)) assuming the list of data frames was called xx, doesn't give the result you want? Could you please elaborate as to why sapply doesn't give the correct result? - Ph

Re: [R] Change positions of columns in data frame

2009-10-23 Thread Phil Spector
Joel - Suppose the columns are named x1, x2, x3, x4, and x5. You can use subscripting: x[c('x2','x4','x1','x3','x5')] or, to save typing the quotes subset(x,select=c(x2,x4,x1,x3,x5))

Re: [R] data.frame tall skinny transformation

2009-10-23 Thread Phil Spector
re cell.line value 1 feature1 5637 -0.56 2 feature2 5637 -0.91 3 feature3 5637 0.44 4 feature11321N1 -0.93 5 feature21321N1 -0.94 6 feature31321N1 -0.25 - Phil Spector Statistica

Re: [R] data.frame tall skinny transformation

2009-10-24 Thread Phil Spector
happy to take a look. - Phil On Sat, 24 Oct 2009, Michael Jones wrote: If I make the data from smaller: featureDataHead = head(featureData) featureDataHead = featureDataHead[ , 1:4] melt(featureDataHead,id.var='feature',variable_name='cell.line') It works fine

[R] question about difference in date objects

2009-11-02 Thread Phil Smith
Hi R Community: I want to take the difference in two dates: dt2 - dt1. But, I want the answer in months between those 2 dates. Can you advise me? Please respond to: p...@cdc.gov Thank you! Phil Smith Centers for Disease Control and Prevention

Re: [R] reshaping pairs of columns

2009-11-03 Thread Phil Spector
latA longA id 1.A 1A 41.68 82.85 1 2.A 2A 41.90 82.52 2 3.A 3A 42.25 81.92 3 4.A 4A 42.55 80.03 4 5.A 5A 44.05 83.03 5 . . . - Phil Spector

Re: [R] How to add a top level title to multiple plots

2009-11-20 Thread Phil Spector
Jason - I've found the mult.fig.p function in the cwhmisc package to be very handy for this sort of thing. - Phil Spector Statistical Computing Facility Departme

Re: [R] mac os X: mprobit fails to install

2009-11-22 Thread Phil Spector
R CMD INSTALL mprobit_0.9-2.tar.gz They'll be some warning messages, but the package should get built. - Phil Spector Statistical Computing Facility Department of

Re: [R] Assign palette (e.g. rainbow) to a series of points on 1 plot

2009-11-30 Thread Phil Spector
uot;, xlab="Day of adult life",ylab='lx',lwd=2.2) mapply(function(x,y,col)points(x,y,type='b',col=col),day,lx,rainbow(length(lx))) legend('topright',names(lx),pch=1,lty=1,col=rainbow(length(lx))) title('Survival vs. Ti

Re: [R] Standard deviation for each element in a set of matrices

2009-12-04 Thread Phil Spector
;File2','File3') themats = lapply(files,read.table) ans = outer(1:3,1:3,Vectorize(function(i,j)sd(sapply(themats,function(x)x[i,j] - Phil Spector Statistical Computing Faci

Re: [R] User's function

2009-12-04 Thread Phil Spector
Lisa - I think this is what you're looking for: myfunction = function(...)do.call(cbind,list(...)) - Phil Spector Statistical Computing Facility Department of Stati

Re: [R] How to duplicate each row in a data.frame?

2009-12-04 Thread Phil Spector
df[rep(1:nrow(df),each=3),] - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Phil Spector
b <- a[rmask,,drop=FALSE] - Phil Spector Statistical Computing Facility Department of Statistics UC Berke

Re: [R] Regular expression help

2009-12-07 Thread Phil Spector
ngs. Since you said the numbers could occur anywhere in the string, you could have provided some examples where the numbers weren't the last part of the string. - Phil Spector Statistical Computing Facility

Re: [R] Split comma separated list

2009-12-08 Thread Phil Spector
(y,1,function(x)as.numeric(strsplit(x[3],',')[[1]])) names(res) = y[,1] boxplot(res) - Phil Spector Statistical Computing Facility

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread Phil Spector
more readable form: v1 = sapply(output,function(x)x$vec) v2 = sapply(output,function(x)x$other)) Notice that if the objects returned by sapply are not conformable, it will return its result in a list. - Phil Spector

Re: [R] read dataset in R language.

2009-12-15 Thread Phil Spector
Nancy - The separator in these files is the comma, not the semicolon. Try train = read.csv('trainingset.txt',check.names=FALSE) test = read.csv('testset.txt',check.names=FALSE) - Phil Spector

Re: [R] A potential bug for paste() ?

2009-05-07 Thread Phil Spector
ata* [7] lme.groupedData* lmList.groupedData* [9] print.groupedData* update.groupedData* Thus subscripting for these objects is performed differently when the nlme package is loaded. - Phil Spector

Re: [R] Discovery on packages

2009-05-26 Thread Phil Spector
Janna - Another thing that's sometimes useful with a new package is to run the example function, like example(TTR) This will run the examples from the documentation to give you a quick idea of what the package can do. - Phil Sp

Re: [R] Separating variables in read.table

2009-04-17 Thread Phil Spector
column of a matrix or data frame. So if you wanted the means of each column of test, you could write apply(test,2,mean) - Phil Spector Statistical Computing Facility

Re: [R] Using JRI and Java 1.6 on MAC OS X

2009-04-24 Thread Phil Robinson
if you wish to use jni with java 1.6 on a mac you have to compile the native code as a 64 bit application (-m64 on a gcc command line) hope this helps [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.

Re: [R] omit empty cells in crosstab?

2009-04-24 Thread Phil Spector
1 11 7 6 4 4 8 3 8 8 10 61 12 9 2 6 2 8 7 5 4 2 11 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] R2

2009-12-29 Thread Phil Spector
Nancy - Please notice that ** is not an R operator. The caret (^) is the exponentiation operator in R. - Phil On Tue, 29 Dec 2009, Nancy Adam wrote: Hi everyone, I tried to write the code of computing R2 for a regression system but I failed. This

Re: [R] Bulk Match/Replace

2010-01-26 Thread Phil Spector
Nathan - One way would be df$id[match(v,df$Name)] - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Deleting many columns of a data frame with the same name in a row

2010-02-02 Thread Phil Spector
Anna - You could also look at the problem from the other direction: data[,names(datas) != 'A'] - Phil Spector Statistical Computing Facility Department of

Re: [R] Extracting Numeric Columns from Data Fram

2013-02-16 Thread Phil Spector
Barry = Suppose your data frame is called "mydat". Then something like mydat[,sapply(mydat,class) %in% c('numeric','integer')] might do what you want. - Phil On Sat, 16 Feb 2013, Barry DeCicco wrote:

Re: [R] help with calculation from dataframe with multiple entries per sample

2012-09-17 Thread Phil Spector
pecial characters like dashes in variable names. Hope this helps. - Phil Spector Statistical Computing Facility Department of Statistics

[R] coxph with time-dependent covariates

2014-01-13 Thread Phil Stevenson
event due to the missing time-dependent covariate at day 6. Is there a way I can keep this event without filling in a covariate value at day 6? -Phil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.

Re: [R] Capturing output of a C executable

2014-02-03 Thread Phil Spector
://www.stat.berkeley.edu/classes/s243/calling.pdf - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Are any values in one list contained within a second list

2010-06-13 Thread Phil Spector
','u','b') any(list2 %in% list1) [1] TRUE list2 = c('z','y','x','w','v','u','t') any(list2 %in% list1) [1] FALSE - Phil Spector Statistical Computing Facility

Re: [R] multiple plots without for loops

2010-06-15 Thread Phil Spector
Sherri - Perhaps calling par(ask=TRUE) before plotting would be useful. (You'll be prompted to hit Return to see the next plot in the series.) - Phil Spector Statistical Computing Fac

Re: [R] Decile

2010-06-16 Thread Phil Spector
Arturo - Something like cut(x,quantile(x,(0:10)/10),labels=FALSE,include.lowest=TRUE) should give you what you want. - Phil Spector Statistical Computing Facility

Re: [R] tables

2010-06-21 Thread Phil Spector
00 100 * prop.table(tt,2) # total of column percentages = 100 AB a 22.58065 18.25397 b 24.19355 13.49206 c 14.51613 20.63492 d 21.77419 26.19048 e 16.93548 21.42857 - Phil Spector Stati

Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Phil Spector
eriod) lapply(names(my.data)[1:2], +function(y)boxplot(formula(paste(y,'TimePeriod',sep='~')), +main=y,data=my.data)) - Phil Spector Stati

Re: [R] constructing a data frame from ftable

2010-06-22 Thread Phil Spector
c,sep='.') tt$b=NULL tt$c=NULL answer = reshape(tt,idvar='a',timevar='bc',direction='wide') - Phil Spector Statistical Computing Facility

Re: [R] subset dataset using factor levels instead of factor names

2010-06-22 Thread Phil Spector
Rachel - Not exactly a reproducible example, but maybe t1 <- subset(nih2009, ic_name %in% levels(nih2009$ic_name)[c(27,51)]) - Phil Spector Statistical Computing Facil

Re: [R] Generation of binomial numbers using a loop

2010-06-23 Thread Phil Spector
Sarah - If you're willing to forgo the loop, res = unlist(mapply(rbinom,frequency,no_trials,prob)) res[res == 0] = 1 will give you what you want. - Phil Spector Statistical Computing Fac

Re: [R] list operation

2010-06-23 Thread Phil Spector
Yuan - There may be faster ways, but names(lst)[sapply(lst,function(i)'a' %in% i && 'c' %in% i)] seems to do what you want. - Phil Spector St

Re: [R] ask a question about list in R

2010-06-24 Thread Phil Spector
Song - Set the element to NULL: al=list(c(2,3),5,7) al[[2]] = NULL al [[1]] [1] 2 3 [[2]] [1] 7 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] fatal error: unable to restore saved data

2010-06-25 Thread Phil Spector
; enters into the picture. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.

Re: [R] Average 2 Columns when possible, or return available value

2010-06-25 Thread Phil Spector
75.00NaN 18.00NaN 12.90 If this isn't suitable for your larger problem, please describe that problem in greater detail. - Phil Spector Statistical Computin

Re: [R] data frame row statistics (mean)?

2010-06-28 Thread Phil Spector
see why your program doesn't work properly.) - Phil Spector Statistical Computing Facility Department of Statistics UC Ber

Re: [R] Not-In operator

2010-06-28 Thread Phil Spector
Colton - Have you looked at the invert= argument of grep()? (In regular expressions, ^ means "beginning of string", and ! has no special meaning.) - Phil Spector Statistical Computin

Re: [R] Identify and extract a whole word of variable length using regular expressions

2010-06-28 Thread Phil Spector
Giulio - This sub('^.* ?(Rv[^ ]*) ?.*$','\\1',a) [1] "Rv3018c" "Rv1135c" "Rv1548c" "Rv0755c" "Rv3367" seems to do what you want. - Phil Spector

Re: [R] formating chron date times for printing

2010-06-29 Thread Phil Spector
Stephen - format(as.POSIXct(x),"%Y-%m-%d %H:%M:%S") [1] "2009-08-07 17:00:00" "2009-08-07 17:15:00" "2009-08-07 17:29:59" [4] "2009-08-07 17:45:00" "2009-08-07 18:00:00" - Phil Spector

Re: [R] string question

2010-06-30 Thread Phil Spector
c',str1,sep='') print(qr2) [1] "abc\"xyz\"" cat(qr2,'\n') abc"xyz" nchar(qr2) [1] 8 - Phil Spector Statistical Computing Facility

[R] editing/formatting stacked time series panels

2010-07-02 Thread Phil Morefield
Hello R-philes, I'm very new to R and hope this is a simple question to answer: I reading in 10 univariate time series and then using "plot()", which produces two columns of stacked plots showing the data. Perfect. Next, I want to add things using "lines()", but it's not working correctly. How

Re: [R] rows process in DF

2010-07-14 Thread Phil Spector
e=sum(x[-1][x[-1]<0])) t(apply(myDF,1,doit)) id sum_positive sum_negative [1,] 100 1.8 -2.2 [2,] 101 1.8 -1.7 - Phil Spector Statistical Co

Re: [R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Phil Spector
Juliet - Since you're operating on each column, apply() would be the appropriate function; mymat = apply(mymat,2,function(x){x[x<0] = min(x[x>0]);x}) - Phil Spector Statistical Computi

Re: [R] Repeated analysis over groups / Splitting by group variable

2010-07-15 Thread Phil Spector
results in a list. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Help with Reshaping from Wide to Long

2010-07-17 Thread Phil Spector
direction='long',timevar='color') two$shape=factor(two$shape,labels=c('Circle','Square','Triangle')) two$color=factor(two$color,labels=c('Blue','Red','Green')) names(two)[4] = '

Re: [R] how to collapse categories or re-categorize variables?

2010-07-17 Thread Phil Spector
'1','1')) [1] 0 1 1 library(car) recode(d,"c(1,2)='1'") [1] 0 1 1 - Phil Spector Statistical Computing Facility Department of Sta

Re: [R] Get distribution of positive/negative examples for each cluster

2010-07-21 Thread Phil Spector
='membership', + v.names='Freq',timevar='label',direction='wide') membership Freq.0 Freq.1 1 1 2 1 2 2 1 2 3 3 0 3 - Phil Spector

Re: [R] Question about allocMatrix error message

2010-07-21 Thread Phil Spector
art[2,] - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On We

Re: [R] subbing a string vector for another string vector

2010-09-08 Thread Phil Spector
image pattern url 1 http://$IMAGE_ID$ www.url.com/image.jpg http://www.url.com/image.jpg 2$IMAGE_ID$ http://www.blah.com/image.gif http://www.blah.com/image.gif - Phil Spector

Re: [R] problem with outer

2010-09-08 Thread Phil Spector
Does outer(p_11,p_12,Vectorize(guete)) do what you want? - Phil Spector Statistical Computing Facility Department of Statistics UC

Re: [R] filter a tab delimited text file

2010-09-10 Thread Phil Spector
TRUE, sep="\t", check.names=FALSE) expFC.TRUE <- expFC[expFC[dim(expFC)[2]]=="TRUE",] write.table(expFC.TRUE, file="test_TRUE.txt", row.names=FALSE, sep="\t", quote=FALSE ) - Phil Spector

Re: [R] average matrices across a list

2010-09-12 Thread Phil Spector
Gregory - Suppose your list is called "mymats". Then Reduce("+",mymats) does what you want. - Phil On Sun, 12 Sep 2010, Gregory Ryslik wrote: Hi, I have a list of several hundred 2 dimensional matrices, where each matrix is n x m.

Re: [R] average matrices across a list

2010-09-12 Thread Phil Spector
Gregory - Please provide a reproducible example. I have no idea what results is. - Phil On Sun, 12 Sep 2010, Gregory Ryslik wrote: Hi, Doing that I get the following: Browse[2]> Reduce["+",results] Error in Reduce["+", results] :

Re: [R] Question: Form a new list with the index replicated equal to the number of elements in that index

2010-09-13 Thread Phil Spector
Sunny - I don't think mapply is needed: lapply(1:length(mylist),function(x)rep(x,length(mylist[[x]]))) [[1]] [1] 1 1 1 [[2]] [1] 2 [[3]] [1] 3 3 - Phil Spector Statistical Computing Fac

Re: [R] Condition %in%

2010-09-13 Thread Phil Spector
!10 %in% x (or !(10 %in% x) if you don't believe in R's precedence rules. - Phil Spector Statistical Computing Facility Department of

Re: [R] proportion

2010-09-13 Thread Phil Spector
Maybe prop.table ? - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] rnorm using vector of means and SDs

2010-09-14 Thread Phil Spector
I think t(mapply(rnorm,1000,vector_of_means,vector_of_sds)) will do what you want. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Phil Spector
Chien-Pang - Here's a *reproducible* example that should answer your question: k = list() n = 10 max = 10:19 for(i in 1:n) (k[i]=list(c(0:max[i]))) k[[1]] + 1 [1] 1 2 3 4 5 6 7 8 9 10 11 - Phil Sp

Re: [R] labeling outliers with subject numberss

2010-09-15 Thread Phil Spector
Kevin - Here's one way: z = boxplot(mydata$score,outline=FALSE,ylim=range(mydata$score)) text(1,z$out,SubNo[which(score == z$out)]) - Phil Spector Statistical Computing Fac

Re: [R] get top n rows group by a column from a dataframe

2010-09-16 Thread Phil Spector
B533 2.328799 . . . - Phil Spector Statistical Computing Facility Department of Statistics UC Ber

Re: [R] Weibull simulation- number of items to replace is not a multiple of replacement length

2010-09-16 Thread Phil Spector
t the estimates into the pth row (mymat[p,]) or pth column (mypat[,p]) of the matrix. - Phil Spector Statistical Computing Facility Department of Stati

Re: [R] If statements for multiple arrays

2010-09-16 Thread Phil Spector
50 when you meant 70.) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] grouping dataframe entries using a categorical variable

2010-09-17 Thread Phil Spector
Bastien - In what way did subset(yourdataframe,ESS %in% softwood) not work? - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] how to import this kind of data?

2010-09-17 Thread Phil Spector
Soyeon - I think scan() (combined with matrix and data.frame) is the easiest way. Suppose your text file is called "data.txt". Then data.frame(matrix(scan('data.txt'),byrow=TRUE,ncol=14)) should give you what you want.

Re: [R] Sorting and subsetting

2010-09-20 Thread Phil Spector
Harold - Two ways that come to mind: 1) do.call(rbind,lapply(split(tmp,tmp$index),function(x)x[1:5,])) 2) subset(tmp,unlist(tapply(foo,index,seq))<=5) - Phil Spector Statistical Computing Facil

Re: [R] Removing slected values from original vector and definning new vector with the rest?

2010-09-20 Thread Phil Spector
Anan - If you actually want the indices, you can use seq_along(sampWB)[-censidx] If you want the values themselves, then use sampWB[-censidx] - Phil Spector Statistical Computing Facility

Re: [R] Trouble installing pwr package

2010-09-21 Thread Phil Spector
.test" Those are the functions that are made available by loading the pwr package. Do you see something different after you load pwr? - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Lattice xyplot and groups

2010-09-21 Thread Phil Spector
Does using df = df[order(df$type,df$set,df$x),] before calling xyplot fix the problem? - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Extracting bins and frequencies from frequency table

2010-09-22 Thread Phil Spector
Ralf - Try bins = as.numeric(names(t1)) freqs = as.vector(t1) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Some questions about string processing

2010-09-24 Thread Phil Spector
')) data = resp_data ) . . . - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Splitting a time + duration into a series of periods

2010-09-24 Thread Phil Spector
function(tm)sum(dat$login_time <= tm & dat$login_end > tm))) time count 1 2010-01-01 10:00:00 1 2 2010-01-01 10:30:00 1 3 2010-01-01 11:00:00 2 4 2010-01-01 11:30:00 1 5 2010-01-01 12:00:00 1 6 2010-01-01 12:30:00 0 Hope this he

Re: [R] performing script on multiple files

2010-09-24 Thread Phil Spector
\.csv$'),readwrite,'/some/location') It will read all the .csv files in the current directory, and write out a file with the extension changed to .new in the directory /some/location . - Phil Spector

Re: [R] How to read this file into R.

2010-09-24 Thread Phil Spector
7;) Read 7 items [1] "H.2.C" "C.1.D" "C.3.R" "E.0.N" "C.2.S" "C.0.G" "H.3.G" Hope this helps. - Phil Spector Statistical Computing Facility

Re: [R] POSIXct: Extract the hour for a list of elements

2010-09-24 Thread Phil Spector
Matthew - It's a bit simpler than you think: as.POSIXlt(pk)$hour should return what you want. (If not, please provide a reproducible example.) - Phil Spector Statistical Computing Fac

<    1   2   3   4   5   >