Re: [R] Extracting a dataframe column as a dataframe

2010-12-25 Thread Phil Spector
x['price'] price 1 321.0 2 323.5 - Phil Spector Statistical Computing Facility Department of Statistics U

Re: [R] Drop column from a data frame

2010-12-26 Thread Phil Spector
John - You can use a syntax similar to what you've tried with the select= argument of the subset function: subset(dfxyz,select=-y) x z 1 1 0 2 2 0 . . . subset(dfxyz,select=-z) x y 1 1 11 2 2 12 . . . - Phil Sp

Re: [R] Finding indexes of minum and maximum elements of an array

2010-12-27 Thread Phil Spector
Here's one way: H = array(c(8:5,1:4),dim=c(2,2,2)) which(H==min(H),arr.ind=TRUE) dim1 dim2 dim3 [1,]112 which(H==max(H),arr.ind=TRUE) dim1 dim2 dim3 [1,]111 - Phil Sp

Re: [R] using lapply and split to plot up subsets of a vector

2010-12-28 Thread Phil Spector
~lnbm|sp.id,data=one) which might be more useful. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] error in calling source(): invalid multibyte character in parser

2011-01-02 Thread Phil Spector
Luca - What happens why you type Sys.setlocale('LC_ALL','C') before issuing the source command? - Phil Spector Statistical Computing Facility Depa

Re: [R] Reading large SAS dataset in R

2011-01-05 Thread Phil Spector
hich would explain the error more thoroughly, is included in the error message. - Phil Spector Statistical Computing Facility Department of

Re: [R] filtering a dataframe with a vector of rownames

2011-01-14 Thread Phil Spector
[rows.to.keep,] [,1] [,2] a12 c34 d45 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Rounding variables in a data frame

2011-01-14 Thread Phil Spector
55148 -4 9 11 5 2.4037376 -6 10 11 5 3.4295063 -5 - Phil Spector Statistical Computing Facility Department of Statistics U

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Phil Spector
Marius - Do you get the behaviour you want if you substitute if(i == 5){cat('i==5\n');quit(save='n')} for the line with the call to stop? - Phil Spector Statistica

Re: [R] matrix manipulations

2011-01-17 Thread Phil Spector
u include all possible levels in a factor, R will automatically put zeroes in the right places when you use table(): table(d1$group,d1$cat) cat1 cat2 cat3 cat4 cat5 cat6 land 0 1700 19 23 water0 1500

Re: [R] Using subset to filter data table

2011-01-19 Thread Phil Spector
Ben - droplevels was introduced in R version 2.12.0. Since you are running version 2.10.1, it won't be available. You might want to upgrade to a more recent version. - Phil Spector Statistical Comp

Re: [R] Problem reading PostgreSQL data with RODBC

2011-01-23 Thread Phil Spector
Robert - If sqlTables() works, then R already knows the name of your database. Do you get a different result if you try seiz.df <- sqlFetch(chnl, 'MAIN') - Phil Spector Statistical Compu

Re: [R] function application

2011-01-25 Thread Phil Spector
?do.call Please provide a reproducible example if the help file is not sufficient. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] FW: question about the pt() calculation

2011-01-25 Thread Phil Spector
e information that you want. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] return object from loop inside a function

2011-01-25 Thread Phil Spector
=pop,grid.dens)) and you can access the two parts like this: result = UUU(pop,grid.dens) result$pop# updated pop result$grid.dens # updated grid.dens Hope this helps. - Phil Spector Statistical Computing

Re: [R] xyplot with all columns of a data.frame on a single plot

2010-07-27 Thread Phil Spector
',sep='~')),data) will do what you want. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] read.delim()

2010-07-28 Thread Phil Spector
Harold - If there aren't any true quoted fields in the file, you could pass the quote="" option to read.delim(). - Phil Spector Statistical Com

Re: [R] Equality of Vectors

2010-08-13 Thread Phil Spector
?all - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec

Re: [R] 'panel.smooth' error

2010-08-18 Thread Phil Spector
,...)}) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec

Re: [R] Different way of aggregating

2010-08-18 Thread Phil Spector
ects: aggregate(thedata$value,list(hour=hours(thedata$date)),mean) For POSIXct objects: aggregate(thedata$value,list(hour=format(thedata$date,'%H')),mean) If I made the wrong assumptions, please provide a reproducible example. - Phil Spector

Re: [R] Aggregate Help

2010-08-19 Thread Phil Spector
data frame from aggregate. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Converting sparse matrix to data.frame in Matrix package

2010-08-19 Thread Phil Spector
This seems to work, although it eliminates the sparseness of the storage: dimnames(a) = list(NULL,letters[1:5]) as.data.frame(as.matrix(a)) a b c d e 1 0 0 0 1 0 2 2 1 0 0 0 3 0 0 3 0 1 - Phil Spector

Re: [R] Index list by other list (w/ logical elements)?

2010-08-24 Thread Phil Spector
Marianne - The function you're looking for is mapply: mapply(function(one,two)one[two],x,y) [[1]] [1] "one" [[2]] [1] "four" "five" - Phil Spector

Re: [R] Non-standard sorts on vectors

2010-08-26 Thread Phil Spector
Here's one possibility: sort.v<-c(Lake=1,Shoreline=2,Floodplain=3) test.df[order(sort.v[as.character(test.df$Zone)]),] Zone Cover 2 Lake60 3 Shoreline70 1 Floodplain50 - Phil

Re: [R] interpreting date-related error message

2010-08-27 Thread Phil Spector
the dates are in the current year, and return a POSIXlt object. Alternatively, you could pass an origin to as.Date: as.Date(dat$doy,origin='2009-12-31') to get a similar Date object. - Phil On Fri, 27 Aug 2010, Toby Gass wrote: Hello

Re: [R] listing files recursively

2010-08-30 Thread Phil Spector
Hyunchul - You don't have to rely on the operating system to provide information about the file system. Look at ?list.files For example, list.files('/path/to/directory',recursive=TRUE)

[R] Immutable ticks using ts.plot?

2011-04-26 Thread Phil Morefield
as no effect, nor does xaxt = 'n'. However I can add ticks with with yaxp or xaxp; I just can't remove the existing ticks. Is this known/correct behavior? Am I overlooking some way to remove those default ticks?   Thanks,   Phil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] paste function by INDICES

2011-04-27 Thread Phil Spector
a,list(ID=df$ID),paste,collapse='') - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Question on list object

2011-04-27 Thread Phil Spector
NA [3,] -2.5787357 1.381395 -1.6545857 0.8239982 -1.169961 - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] How to define specially nested functions

2011-04-28 Thread Phil Spector
Here's one possibility: funmaker = function(x,y,z)function(z)x + y + (x^2 - z) uniroot(funmaker(1,3,z),c(0,10))$root [1] 5 uniroot(funmaker(5,2,z),c(30,40))$root [1] 32 (The third argument to the function doesn't really do anything.) - Ph

Re: [R] Regression Summary for a List

2011-04-29 Thread Phil Spector
Ryan - summary expects an lm object, and fit is a list. So you need to use something like lapply(fit,summary) to pass each list element to the summary function. - Phil Spector Statistical Computing Facility

Re: [R] Help converting a data.frame to ordered factors

2011-05-02 Thread Phil Spector
creating the 96x34 array, there might be a better solution. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] simulate AR(1) process

2011-05-05 Thread Phil Spector
?arima.sim - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] help with mysql and R: partitioning by quintile

2011-05-08 Thread Phil Spector
One way to get the ratings would be to use the ave() function: rating = ave(x$freq,x$track, FUN=function(x)cut(x,quantile(x,(0:5)/5),include.lowest=TRUE)) - Phil Spector Statistical Computing Facility

Re: [R] Saving misclassified records into dataframe within a loop

2011-05-12 Thread Phil Spector
John - In your example, the misclassified observations (as defined by your predict.function) will be kyphosis[kyphosis$Kyphosis == 'absent' & prediction[,1] != 1,] so you could start from there.

Re: [R] about vector to the power of a decimal

2011-05-12 Thread Phil Spector
lex number (-2)^2.1 [1] NaN complex(real=-2)^2.1 [1] 4.077269+1.324785i - Phil Spector Statistical Computing Facility Department of

Re: [R] Creating dataframes

2011-05-13 Thread Phil Spector
with the data frames you're creating. - Phil On Fri, 13 May 2011, Woida71 wrote: I would like to create a certain number of dataframes out of one dataframe where each of the dataframes is related to a factor. This should be possible with

Re: [R] File to MYSQL

2011-05-16 Thread Phil Spector
t of the final query. You might also familiarize yourself with dbGetQuery, which may be more suited to your needs. - Phil Spector Statistical Computing Facility Depar

Re: [R] trouble with summary tables with several variables using aggregate function

2011-05-19 Thread Phil Spector
1 S1 T1 2 2 2 S2 T1 2 2 3 S1 T2 2 2 7 S2 T2 NA 4 - Phil Spector Statistical Computing Facility

Re: [R] Multiple count if style "queries"

2011-05-20 Thread Phil Spector
1 1 result[['Biak-Numfoor rain forests']]$Genus Bromheadia Homalomena 1 1 Hope this helps. - Phil Spector Statistical Computing Facility

Re: [R] Extracting day of month from Date objects

2011-05-24 Thread Phil Spector
< 10 < 11 < 12 < 13 < ... < 31 Notice that it returns the days as factors. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Count of rows while looping through data

2011-05-24 Thread Phil Spector
= subset(x,seq == use) Hope this helps. Take a look at the help page for the ave function to understand how it works. - Phil Spector Statistical Computing Facility

Re: [R] Trouble Combining With Paste

2011-05-25 Thread Phil Spector
John - Try infert[,toolong] = sapply(infert[,toolong],cut2,g=10,levels.mean=TRUE) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Applying "toupper" to only portions of text strings

2011-05-26 Thread Phil Spector
27;,'\\U\\1\\2\\L\\3',TEXT,perl=TRUE) [1] "" "BBB|cc" "|ddd" - Phil Spector Statistical Computing Facility

Re: [R] Count of rows while looping through data

2011-05-27 Thread Phil Spector
reproducible example. - Phil On Fri, 27 May 2011, Jeanna wrote: I may have prematurely excited... I ended up using the split method since my family indicators are alphanumeric so my issue is as follows. I'm applying this to different subsets of my

Re: [R] Arrange a multi-level list to a one-level list

2011-05-27 Thread Phil Spector
00 [2,]10 [[2]] [,1] [,2] [1,]32 [2,]32 [[3]] [,1] [,2] [,3] [1,]101 [2,]010 [[4]] [,1] [,2] [,3] [1,]222 [2,]223 - Phil Spec

Re: [R] Installing package rgdal

2011-05-28 Thread Phil Spector
s. Hope this helps. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.b

Re: [R] Oddity: I seem to have a variable in a dataframe that doesn't show in colnames() - can anyone advise?

2011-05-29 Thread Phil Spector
'PHQ'] Error in `[.data.frame`(x, , "PHQ") : undefined columns selected x[['PHQ']] NULL So if you don't want this "feature", you can use brackets instead of the dollar sign for extraction.

Re: [R] how to combine two data frames via factors (or somehow else)

2011-05-29 Thread Phil Spector
Philipp - I believe you're looking for the merge function. If you need more guidance, please provide a meaningful reproducible example. - Phil Spector Statistical Computing Fac

Re: [R] cbind 3 or more matrices

2011-06-04 Thread Phil Spector
[,7] [,8][,9] [1,] -1.7481451 0.4467964 -0.41358420 [2,] -0.2882922 1.0243662 -0.48263684 [3,] 0.9402479 0.5467952 -0.01922035 [4,] 0.6795783 1.4560765 -0.23013826 [5,] 0.9800312 -1.3462175 -0.77064872 - Phil Spector

Re: [R] Converting dollar value (factors) to numeric

2010-05-05 Thread Phil Spector
handled correctly. There's certainly no need to create a new input file. It may be easier to understand as as.numeric(sub('$','',as.character(x),fixed=TRUE)) which gives the same result. - Phil Spec

Re: [R] any function in R similar to the "scan" function in SAS?

2010-05-05 Thread Phil Spector
"2" "4" "6" You might want to use as.numeric to convert them back to numbers, since SAS doesn't care about that particular detail. - Phil Spector Statistical Computing Facility

Re: [R] How to rank matrix data by deciles?

2010-05-06 Thread Phil Spector
Vincent - I think apply(y,2,function(x) cut(x,quantile(x,(0:10)/10),label=FALSE,include.lowest=TRUE)) will give you what you want (although you didn't use set.seed so I can't verify it against your example.) - Ph

[R] Any way to apply TWO functions with tapply()?

2010-05-07 Thread Phil Wieland
I need to compute the mean and the standard deviation of a data set and would like to have the results in one table/data frame. I call tapply() two times and do then merge the resulting tables to have them all in one table. Is there any way to tell tapply() to use the functions mean and sd within

Re: [R] getting a weighted average from a table

2010-05-07 Thread Phil Spector
dat = c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) tt = table(dat) sum(as.numeric(names(tt))*tt)/ sum(tt) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Regex and gsub

2010-05-11 Thread Phil Spector
df3$DESCRIPTION = sub(' [a-z]{3}/[0-9]{2}','',df3$DESCRIPTION,ignore.case=TRUE) - Phil Spector Statistical Computing Facility Depa

Re: [R] Help with reading information of "summary"-Object

2010-05-13 Thread Phil Spector
rm(100)) df.lm = lm(y~x1+x2,df) sdf.lm = summary(df.lm) sdf.lm$coefficients[,4] (Intercept) x1 x2 0.7445605 0.8081874 0.2535098 or sdf.lm$coefficients[,"Pr(>|t|)"] (Intercept) x1 x2 0.7445605 0.8081874 0.2535098 Hope this helps

Re: [R] How to rank matrix data by deciles?

2010-05-13 Thread Phil Spector
abel=FALSE) [1] 10 6 7 5 9 1 3 7 4 2 9 4 2 10 5 8 1 It gives an answer, but it may not make sense for all data. - Phil On Thu, 13 May 2010, vincent.deluard wrote: Dear Phil, You helped me with a request to rand matri

Re: [R] operations between two aggregated data frames?

2010-05-14 Thread Phil Spector
split(df1,df1$category), split(df2,df2$category)) will return a list with the information you want. - Phil Spector Statistical Computing Facility Departmen

Re: [R] col allocation is not right

2010-05-19 Thread Phil Spector
ot;"magenta" "yellow" [8] "gray" You might get better results by specifying the colors that you want directly. - Phil Spector Statistical Computing Facility

Re: [R] predict

2010-05-21 Thread Phil Spector
ame, you'll find the modeling functions work much more smoothly. - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] File normalization

2010-05-25 Thread Phil Spector
enter= or scale= arguments can be omitted if you only want to divide or subtract. - Phil Spector Statistical Computing Facility Department of Stati

Re: [R] Get output values in a table

2010-05-25 Thread Phil Spector
Iurie - The help file for both functions has a "Values" section that describes in detail exactly what the function returns. In both cases, you'll see there is a component named "statistic", which is what you want.

Re: [R] why the dim gave me different results

2010-06-02 Thread Phil Spector
s(tmp)] ) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Interaction versus combinations

2010-06-03 Thread Phil Spector
Perhaps not the best or easiest way, but does: apply(t(combn(idx,2)),1,paste,collapse='.') [1] "1.3" "1.6" "1.9" "3.6" "3.9" "6.9" get you in the right direction? - Phil Spector

Re: [R] data-management: Rowwise NA

2010-06-03 Thread Phil Spector
?any Not really a reproducible answer, but I think you're looking for apply(tes[,sam],1,function(x)any(is.na(x))) - Phil Spector Statistical Computing Facility Depar

Re: [R] using string as variable name in model

2010-06-03 Thread Phil Spector
Roni - Try this: lm(formula(paste(outcome,'income + covariate1 + coviarate2',sep='~')), data=my.data) -> model - Phil Spector Statistical Computing Facility

Re: [R] Factor to variable

2010-06-05 Thread Phil Spector
Try z$Col3 = as.numeric(sub('^X','',as.character(z$Col3))) - Phil Spector Statistical Computing Facility Depa

Re: [R] restructuring "by" output for use with write.table

2010-06-08 Thread Phil Spector
know what SoilVegHydro is.) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@s

Re: [R] question about "mean"

2010-06-09 Thread Phil Spector
5.552 2.026 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] importing multidimensional matrix from MATLAB

2010-06-10 Thread Phil Spector
bject as a named element.) - Phil Spector Statistical Computing Facility Department of Statistics U

Re: [R] R: selecting and excluding files through a pattern

2010-06-10 Thread Phil Spector
Here's one possibility: allfiles = list.files() csvfiles = list.files(pattern='csv') allfiles[!allfiles %in% csvfiles] - Phil Spector Statistical Com

Re: [R] removing a non empty directory

2010-06-11 Thread Phil Spector
?unlink - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] Managing list elements

2010-06-11 Thread Phil Spector
Luis - I *think* that mapply(list,LHS,RHS,SIMPLIFY=FALSE) will give you what you want, but without a reproducible example it's hard to tell. - Phil Spector Statistical Computing Fac

Re: [R] Odp: Letters(V1, V2..) as row col indices instead of numbers

2011-01-28 Thread Phil Spector
Suppose your correlation matrix is called cc. One way to do what you want is result = cbind(as.vector(row(cc)),as.vector(col(cc)),as.vector(cc)) result = result[result[,1] != result[,2],] - Phil Spector

Re: [R] Extract subsets of different and unknown lengths from huge dataset

2011-01-30 Thread Phil Spector
1 if(rls$values[length(rls$values)] == TRUE)ind = ind[-length(ind)] start[ind] = 'start' To number the starts, you could use something like num = rep(0,length(vec)) num[start == 'start'] = 1:sum(start == 'start') - Phil Sp

Re: [R] identify subsets based on two grouping factors

2011-01-31 Thread Phil Spector
Rajarshi - It's not clear to me what you mean by "the distribution of levels obs.". Does as.data.frame(table(x$obs,cut.grp1,cut.grp2)) give you something like what you want? - Phil Spector

Re: [R] R string help

2011-02-01 Thread Phil Spector
Yan - Here's one way. It assumes there's exactly one set of brackets in the string, and they can be anywhere: aaa<- "up.6.11(16)" sub('^.*?\\((.*)\\).*$','\\1',aaa) [1] "16" - Phil Spector

Re: [R] "each" argument in rep (Bug?)

2011-02-01 Thread Phil Spector
ur is perfectly consistent with the documentation. - Phil Spector Statistical Computing Facility Department of Statistics UC Ber

Re: [R] Testing whether a number belong to a set

2011-02-02 Thread Phil Spector
;,'two','three','four','five','six','seven') test %in% S1 + 2 * test %in% S2 [1] 1 1 1 2 2 2 0 - Phil Spector Statistic

Re: [R] Help with one of "those" apply functions

2011-02-02 Thread Phil Spector
Robin - Does tapply(value,id,sum) do what you want? - Phil Spector Statistical Computing Facility Department of Statistics UC

Re: [R] testing randomness of random number generators with student t-test?

2011-02-02 Thread Phil Spector
ere are many other issues regarding random number generation, but I think what I've described addresses the issue of the t.test probabilities. - Phil Spector Statistical Computing Facility

Re: [R] tapply output as a dataframe

2011-02-03 Thread Phil Spector
Try as.data.frame(as.table(a)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] dataframes from a function

2011-02-04 Thread Phil Spector
jects in your workspace, you could look at the help page for the assign function. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] aggregate function - na.action

2011-02-04 Thread Phil Spector
alues. (The subtle distinction between na.action=na.omit and na.rm=TRUE is the function you're calling is that na.omit will remove the entire row of data when it encounters a missing value, while the na.rm=TRUE argument will remove missing values separately from eac

Re: [R] Multiplying elements of vectors

2011-02-05 Thread Phil Spector
400 outer(x,y) [,1] [,2] [,3] [,4] [1,] 25 50 75 100 [2,] 50 100 150 200 [3,] 75 150 225 300 [4,] 100 200 300 400 The outer() function will accepts a FUN= argument which defaults to '*'.

Re: [R] Applying 'cbind/rbind' among different list object

2011-02-06 Thread Phil Spector
Another possibility is mapply(rbind,list1,list2,SIMPLIFY=FALSE) - Phil Spector Statistical Computing Facility Department of Statistics

Re: [R] Using Aggregate for Date

2011-02-07 Thread Phil Spector
the format you want. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec.

Re: [R] Keep date, strip time?

2011-02-08 Thread Phil Spector
9-06-15" as.Date(sub('(\\d+/\\d+/\\d+) .*','\\1',dts),'%m/%d/%Y') [1] "2009-06-10" "2009-06-15" "2009-06-15" as.Date(sub('\\d+:\\d+:\\d+ [AP]M','',dts),'%m/%d/%Y') [1] "200

Re: [R] manipulating the Date & Time classes

2011-02-08 Thread Phil Spector
a loop by preallocating space for the result. - Phil On Tue, 8 Feb 2011, Mike Williamson wrote: Phil,     Thanks!  I am not sure why min & max sometimes work & other times don't work.  In fact, running the script as you had it did work for me.

Re: [R] delete a row in dataframe w/o changing indexing

2011-02-08 Thread Phil Spector
Nicolas - I don't think it can be done automatically, but you can use row.names(pop) = 1:nrow(pop) after deleting the column(s) to restore consecutive numbers for the row names. - Phil Spector Statis

Re: [R] Removing X and Y labels in graph error

2011-02-08 Thread Phil Spector
Contrast the behaviour of these two statements: plot(x,y,xlab=NULL,ylab=NULL) plot(x,y,xlab='',ylab='') In other words, use xlab='' to supress the label, not NULL. - Phil Spector

Re: [R] add mean and sd to dotplot in each panel using lattice

2011-02-09 Thread Phil Spector
s(c(i-.1,i+.1),rep(mns[i] + 1.96 * sds[i],2)); llines(c(i-.1,i+.1),rep(mns[i] - 1.96 * sds[i],2))} panel.dotplot(x,y,...) } dotplot(Score ~ Dose | Sex, groups=Sex, data=dat,panel=mypanel) - Phil Spec

Re: [R] Loop to find dates whithin dates

2011-02-10 Thread Phil Spector
time <= both$sunset,'day','night') both$date = both$sunrise = both$sunset = NULL Then both should be the data frame you want. - Phil Spector Statistical Computing Facility

Re: [R] highest and second highest value in row for each combination

2011-02-10 Thread Phil Spector
r from yours because you didn't specify a seed for the random number generator) I'm not exactly sure how to form your column "combination", though. - Phil Spector Statistical Computing Facility

Re: [R] accessing members from a data frame

2011-02-10 Thread Phil Spector
Try my.data.frame[my.data.frame$Buy==1 | my.data.frame$Sell ==1, ] or subset(my.data.frame,buy == 1 | sell == 1) Then take a look at the help page for || i.e., help("||") to see what you did wrong. - Ph

Re: [R] Calculating rowMeans from different columns in each row?

2011-02-10 Thread Phil Spector
Marine - Assuming your data frame is named "df", I think apply(df,1,function(x)mean(x[x[7]:x[8]])) will give you what you're looking for. - Phil Spector Statistical Com

Re: [R] Testing for empty result of which

2011-02-15 Thread Phil Spector
Francois - I think you're looking for the any function: x = c(1,2,3) y = c(4,5,6) any(x==y) [1] FALSE any(which(x==y)) [1] FALSE x = c(1,2,3) y = c(4,2,5) any(x==y) [1] TRUE any(which(x==y)) [1] TRUE - Phil Sp

Re: [R] Write File to Shared Drive

2011-02-15 Thread Phil Spector
use a call to file.choose() by itself to see what path R expects to see for a particular file or directory. - Phil Spector Statistical Computing Facility Department of

Re: [R] help with aggregate()

2011-02-15 Thread Phil Spector
a (most likely) easy solution. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

<    1   2   3   4   5   >