[R] sqlFetch and factor conversion

2011-06-14 Thread Hosack, Michael
R users, Hello, I used sqlFetch to import a data table from MS Access 2007 and I set as.is = TRUE to prevent character vectors from becoming factors. However, I can't figure out how to prevent the $ operator from being added by sqlFetch to the end of each character vector(e.g. TD$ and SITE$).

[R] Infinite loop

2011-03-22 Thread Hosack, Michael
R experts, Hello, I am trying to sample a vector 1:40 without replacement such that no element in the new vector is within 7 units of either of its immediate neighbors. This is part of a larger program I am working on. The following code works well about 65 % of the time (14/40). The problem

Re: [R] Infinite loop

2011-03-22 Thread Hosack, Michael
could not find any info. on them in the R archives. Thanks again Mike -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Tuesday, March 22, 2011 1:00 PM To: Hosack, Michael Cc: r-help@R-project.org Subject: Re: [R] Infinite loop The simple thing to do is to put

Re: [R] Infinite loop

2011-03-22 Thread Hosack, Michael
Thank you so much Martyn. Now I can most likely avoid having to rerun my program multiple times. Mike -Original Message- From: Martyn Byng [mailto:martyn.b...@nag.co.uk] Sent: Tuesday, March 22, 2011 1:21 PM To: Hosack, Michael Cc: r-help@R-project.org Subject: RE: [R] Infinite loop

[R] Data frame loop

2011-03-16 Thread Hosack, Michael
R users, I am trying to use a numeric vector to extract rows from a data frame. I want to extract two rows per unique WEEK (27 weeks) based on variable DOW_NUM by using pairs of vector (s3) elements in the order they appear. For example, vector initial elements 7 and 5 will be used to

[R] Data frame loop

2011-03-16 Thread Hosack, Michael
R users, I found a solution to my own question. I just needed to insert (j+(j-1)):(2*j) as the indices for vector s3. No need to respond. Thank you __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] Complex sampling?

2011-03-09 Thread Hosack, Michael
R users, I am trying to generate a randomized weekday survey schedule that ensures even coverage of weekdays in the sample, where the distribution of variable DOW is random with respect to WEEK. To accomplish this I need to randomly sample without replacement two weekdays per week for each of

[R] Complex sampling?

2011-03-09 Thread Hosack, Michael
-Original Message- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Hosack, Michael Sent: Wednesday, March 09, 2011 7:34 AM To: r-help at R-project.org Subject: [R] Complex sampling? R users, I am trying to generate a randomized

Re: [R] Complex sampling?

2011-03-09 Thread Hosack, Michael
to 3:7 (i.e. DOW_NUMs). I know that this must be relatively simple for someone out there and I would really appreciate some help. Thank you, Mike From: ajmac...@gmail.com [mailto:ajmac...@gmail.com] On Behalf Of Aaron Mackey Sent: Wednesday, March 09, 2011 1:30 PM To: Hosack, Michael Cc: r

[R] Data frame sampling

2011-02-17 Thread Hosack, Michael
R users, I have been trying to write a program in R that will extract rows from a data frame and combine the rows into a new smaller data frame while meeting several criteria. I would greatly appreciate any advice that could help me get started down the right path. What I want to do is to

[R] Conditional sampling

2011-02-10 Thread Hosack, Michael
R experts, I need to sample two rows without replacement from the following data frame such that neither row contains the same 'DOW'. For example, I cannot select both a Monday morning and a Monday afternoon. I am using STRATA_NUM as an index to randomly select rows from, since this

[R] Reshape package and variable assignment

2010-08-20 Thread Hosack, Michael
R Experts, I would like to create a series of variables without having to assign a separate line of code for each new variable. My abbreviated dataframe (DF) contains two groups of linked variables (SP1:SP3) and (CAU1:CAU3). Within SP1:SP3 are character codes (full dataframe contains 26

Re: [R] assign multiple variables at once

2010-08-19 Thread Hosack, Michael
[mailto:dig...@ohsu.edu] Sent: Friday, August 13, 2010 4:11 PM To: Hosack, Michael Cc: r-help@r-project.org Subject: Re: assign multiple variables at once On 8/13/2010 11:08 AM, Hosack, Michael wrote: R Experts, I would like to create a series of variables without having to assign a separate

[R] assign multiple variables at once

2010-08-13 Thread Hosack, Michael
R Experts, I would like to create a series of variables without having to assign a separate line of code for each new variable. My dataframe (DF) contains two groups of linked variables (ESP1:ESP9) and (ECRL1:ECRL9). Within ESP1:ESP9 are abbreviated species codes (full dataframe contains 26

[R] ifelse() and missing values in test conditions

2010-07-20 Thread Hosack, Michael
R experts, I have been unable to get the following ifelse statement to work as desired when applied to my data frame. Example: DF$ANYEF - with(DF,ifelse(PSOUGHT1=='ANY'|PSOUGHT2=='ANY'|PSOUGHT3=='ANY',PEFF,0)) # this statement will be replicated 16 times for 16 unique _EF variables

Re: [R] ifelse() and missing values in test conditions

2010-07-20 Thread Hosack, Michael
...@gmail.com] Sent: Tuesday, July 20, 2010 1:41 PM To: Hosack, Michael Cc: r-help@r-project.org Subject: Re: [R] ifelse() and missing values in test conditions Hi Mike, Probably the simplest way from what you have done would be to just set any NA values in the column to 0: DF$ANYEF[is.na(DF$ANYEF

[R] Week number calculation

2010-04-19 Thread Hosack, Michael
R community, How could I extract the week number from a date vector (in class Date) such that week numbering (week 1...2...) begins (May 01) and ends (October 31) on the same specific dates each year? Thank you, Mike __ R-help@r-project.org mailing

[R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Hosack, Michael
Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid() successfully(?) to create my dataframe,

[R] Creating dataframe of all possible variable combinations

2010-03-25 Thread Hosack, Michael
Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid() successfully(?) to create my dataframe,

[R] Converting date format

2010-03-23 Thread Hosack, Michael
R community: Hello, I would to like to convert a character date variable from %m/%d/%Y to %m/%d/%y. Any advice would be greatly appreciated. I have tried functions for changing the formatting and removing the unnecessary digits without success. Mike

[R] Dataframe calculations

2010-03-19 Thread Hosack, Michael
Hi everyone, My question will probably seem simple to most of you, but I have spent many hours trying to solve it. I need to perform a series of sequential calculations on my dataframe that move across rows and down columns, and then repeat themselves at each unique 'MM' by 'DD' grouping.

Re: [R] Dataframe calculations

2010-03-19 Thread Hosack, Michael
Erich, Thank you so much for the effort you put into writing this code. I ran it and then assigned the two variables you created to the 'ARRIVE' and 'DEPART' variables of my dataframe as you directed and the resultant calculations were incorrect. I am not sure why it did not work, I do not yet

Re: [R] Dataframe calculations

2010-03-19 Thread Hosack, Michael
) delays-as.vector(t(cbind(waitVec,travelVec))) newtimes-format(start+cumsum(delays)*60,format=%H:%M:%S) list(departs=c(arriveTime,(evens(newtimes))[-1]), arrives=odds(newtimes)) } Using the new definition of addDelays above should do the trick. On 3/19/2010 5:30 PM, Hosack, Michael

Re: [R] offlist Re: Dataframe manipulation

2010-03-18 Thread Hosack, Michael
Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, March 18, 2010 10:31 AM To: Hosack, Michael Subject: offlist Re: [R] Dataframe manipulation Here's why I am not taking this one one. You've been posting similar problems for the last 6 months and you still have

[R] Adding minutes to 24 hour time

2010-03-17 Thread Hosack, Michael
Thank you Gustaf for your help! It worked perfectly. Now I just need to figure out how you did it. Petr, thank you for assisting me, but I could not get your approach to work. Mike __ R-help@r-project.org mailing list

[R] Randomly sampling subsets of dataframe variable

2010-03-12 Thread Hosack, Michael
Fellow R users, I am stumped on what would seem to be something fairly simple. I have a dataframe that has a variable named 'WEEK' that takes the numbers 1:26 (26 week time-period) with each number repeated five times consecutively (once for each weekday, Monday through Friday). Ex.

[R] How to assign week numbers to a time-series

2010-03-05 Thread Hosack, Michael
Hello everyone, My progress has stalled on finding a way of creating a somewhat complicated variable to add to my existing dataframe and I am hoping one of you could help me out. The dataframe below contains only a fraction of the data of my complete dataframe, but all of the variables. What I

[R] How to assign week numbers to a time-series

2010-03-05 Thread Hosack, Michael
Hello everyone, My progress has stalled on finding a way of creating a somewhat complicated variable to add to my existing dataframe and I am hoping one of you could help me out. The dataframe below contains only a fraction of the data of my complete dataframe, but all of the variables. What I