[R] How to obtain a cross tab count of unique values

2015-03-31 Thread Walter Anderson
number of unique parks for each project. If I using the standard table(df$PROJECT) it reports: A 3 B 2 C 2 ... where I need it to ignore duplicates and report: A 2 B 2 C 2 ... Anyone have any suggestions on how to do this within the R paradigm? Walte

[R] Calculating area of polygons created from a spatial intersect

2015-03-27 Thread Walter Anderson
matrix of each project/census block combination and only providing me a true/false indication. Is there any way to replicate the process from ArcInfo that I outlined above within R? Walter Anderson -BEGIN PGP SIGNATURE- Version: GnuPG v1 iQIcBAEBAgAGBQJVFWYWAAoJEHfnxjvhypCiMc8P/2Dsja+h4RK

Re: [R] Is this a bug or am I making a mistake?

2014-01-06 Thread Walter Anderson
d you don't need the dd$ in the arguments to subset(). But those don't explain your result given the information provided. Please provide more information. Sarah On Mon, Jan 6, 2014 at 12:06 PM, Walter Anderson wrote: I have a data frame that I am extracting some records from and notice

[R] Is this a bug or am I making a mistake?

2014-01-06 Thread Walter Anderson
I have a data frame that I am extracting some records from and noticed the following issue I originally used tmp <- subset(dd, dd$EVYEAR==2012 & dd$EVMONTH=='02') and noticed that I wasn't ending up with all of the records I should have; however, when I used tmp <- dd[dd$EVYEAR==2012 & dd$EV

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-10 Thread Walter Anderson
Petr, Thank you for you assistance. Particularly this last bit. It really helped me understand exactly how your solution worked and why I was confused by rapply processing rows. It was apply that could process rows (and/or columns) of a matrix, Anyway for anyone who wants the version of my

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-09 Thread Walter Anderson
Karen, Thank you for your reply. That approach makes the code for determining preference much clearer. Unfortunately, it appears I am still needing to use a for loop to process each row. For any who find these posts and may have similar questions, I am including my current code and sample da

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-09 Thread Walter Anderson
ot;,"Option 2","Option 3")) > > Then make the object matrix without first column > > sr<-survey.results[,-1] > > sr<-as.matrix(sr) > > Elaborate evaluation function > > fff <- function(x) names(which.max(table(x))) > > Apply function to

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-06 Thread Walter Anderson
hing else } used as > q1a.ans(1:3) [1] 1 2 0 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Walter Anderson [mailto:wandrso...@gmail.com] Sent: Friday, December 06, 2013 9:58 AM To: William Dunlap; r-help@r-project.org Subject: Re: [R]

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-06 Thread Walter Anderson
On 12/06/2013 10:43 AM, William Dunlap wrote: I have been researching and it appears that I should be using the sapply function to apply the evaluate.question function above to each row in the data frame like this Read the documentation more closely: sapply(dataFrame, func) applies func() to eac

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-06 Thread Walter Anderson
Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Walter Anderson Sent: Friday, December 06, 2013 4:44 PM To: r-help@r-project.org Subject: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined f

[R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-06 Thread Walter Anderson
I am having trouble understanding how to use sapply (or similar functions) with a user defined function with multiple parameters. I have the following functions defined q1.ans <- function(x) { retVal = 0 if (x == 1) { retVal = 1 } else if (x ==2) {

[R] Close with a ggplot chart but need a little assistance

2013-08-22 Thread Walter Anderson
I have the following code and data data.csv "","Goal","Frequency","Weight","Group" "1","Move",13,0.245283018867925,"Public" "2","Create",10,0.188679245283019,"Public" "3","Strengthen",30,0.566037735849057,"Public" "4","Move",6,0.6,"Board" "5","Create",0,0,"Board" "6","Strengthen",4,0.4,"Board" "

Re: [R] How to store and manipulate survey data like this?

2013-08-13 Thread Walter Anderson
On 08/13/2013 11:41 AM, Siraaj Khandkar wrote: On 08/13/2013 12:17 PM, Walter Anderson wrote: I have to process a set of survey data with questions that are formatted like this; 1) Pick your top three breeds (pick 3) 1 Rottweiler 2 Pit Bull 3 German Shepard 4 Poodle 5 Border

[R] Regression of categorical data

2013-08-13 Thread Walter Anderson
I have a set of survey data where I have answers to identify preference of three categories using three questions 1) a or b? 2) b or c? 3) a or c? and want to obtain weights for each of the preferences something like X(a) + Y(b) + Z(c) = 100% I am at a loss how how to calculate this from the

[R] How to store and manipulate survey data like this?

2013-08-13 Thread Walter Anderson
I have to process a set of survey data with questions that are formatted like this; 1) Pick your top three breeds (pick 3) 1 Rottweiler 2 Pit Bull 3 German Shepard 4 Poodle 5 Border Collie 6 Dalmation 7 Mixed Breed and the answers are formatted like this: Respondent, Question1 1,

Re: [R] Faster way to implement this search?

2012-03-17 Thread Walter Anderson
On 03/17/2012 12:53 AM, Jeff Newmiller wrote: for(indx in 1:(length(bin.05)-3)) >>> if ((bin.05[indx] == test.pattern[1])&& (bin.05[indx+1] == >>> test.pattern[2])&& (bin.05[indx+2] == test.pattern[3])) >>> return.values$count.match.pattern[1] = >>> return.values$coun

Re: [R] Faster way to implement this search?

2012-03-16 Thread Walter Anderson
ives. Sarah On Fri, Mar 16, 2012 at 12:59 PM, Walter Anderson wrote: I am working on a simulation where I need to count the number of matches for an arbitrary pattern in a large sequence of binomial factors. My current code is for(indx in 1:(length(bin.05)-3)) if ((bin.05[indx] == test

Re: [R] Faster way to implement this search?

2012-03-16 Thread Walter Anderson
age- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Walter Anderson Sent: Friday, March 16, 2012 10:00 AM To: R Help Subject: [R] Faster way to implement this search? I am working on a simulation where I need to count the number of matches for an arbitrary

[R] Faster way to implement this search?

2012-03-16 Thread Walter Anderson
better (more "R" way of achieving the same answer? Walter Anderson __ 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 provid

[R] How to eliminate for next loops in this script

2012-03-06 Thread Walter Anderson
I needed to compute a complicated cross tabulation to show weighted means and standard deviations and the only method I could get that worked uses a series of nested for next loops. I know that there must be a better way to do so, but could use some assistance pointing the way. Here is my working

[R] Need help using Melt and cast to compute correlation for a cross tabulation

2012-03-01 Thread Walter Anderson
y suggestions? Walter Anderson __ 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.

[R] How to process raw trip records to get number of persons per trip by vehicle

2011-05-27 Thread Walter Anderson
esn't make use of any of the R features. Does anyone have any suggestions for how they would implement this analysis in R? Walter Anderson __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the pos

[R] Need a more efficient way to implement this type of logic in R

2011-04-06 Thread Walter Anderson
I have cobbled together the following logic. It works but is very slow. I'm sure that there must be a better r-specific way to implement this kind of thing, but have been unable to find/understand one. Any help would be appreciated. hh.sub <- households[c("HOUSEID","HHFAMINC")] for (indx i

[R] How to regress data into coefficients for a gamma function

2011-03-29 Thread Walter Anderson
Hello, I need to regress data like the example below. The data points represent friction factors derived from observed trip length data. The function used to describe this data is a gamma function of the form, f(t) = a * t^b * e^(c*t) and I need to regress the data to obtain the a,b, and