[R] List extraction

2011-03-29 Thread chipmaney
I have created a list of tables with the same columns but different number of row. Example (actual list has ~200 elements): temp1- data.frame(ID=c(Herb,Shrub),stat=c(4,5),pvalue=c(.03,.04)) temp2- data.frame(ID=c(Herb,Shrub, Tree),stat=c(12,15,13),pvalue=c(.2,0.4,.3))

[R] Non-standard sorts on vectors

2010-08-26 Thread chipmaney
I have a dataset I need to sort: test.df-data.frame(Zone=c(Floodplain, Lake, Shoreline),Cover=c(50,60,70)) However, I don't want it sorted ascending/descending but in an order that I define via a vector: sort.v-data.frame(c(Lake,Shoreline,Floodplain)) I realize I could probably just create

[R] Using '[' as a function

2010-07-29 Thread chipmaney
I am learning R, and instead of learning by rote, I am trying to better understand the language in order to improve my programming. So any meta-information on why the following code works would be greatly appreciated... I obtained this code to extract the first record from each of a series of

[R] Convert Row Names to data.frame column

2010-07-23 Thread chipmaney
Here is an example dataset: ZoneCover.df- data.frame(Value=c(1,2)) row.names(ZoneCover.df) - c(Floodplain1.Tree, Floodplain1.Shrub) I want to Export the Row.Names to a column in the dataframe: ZoneCover.df$ID - names(ZoneCover.df) which yields this: ZoneCover.df Value

[R] Reconciling 2 datasets

2010-07-23 Thread chipmaney
I have a dataframe: Empirical.df - data.frame(ID=c(MCUP1-2,MCUP2-5, MCUP3-3, MCUP4-3,MCUP5-9), Cover=c(60,40,45,68,72)) However, I only want to use a subset of Cover.df for my analysis. The samples I want to use are: Samples.v - c(MCUP1-2, MCUP4-3,MCUP5-9) How do I use indexing Empirical.df

[R] extracting results from wilcox_test (package::coin)

2010-02-24 Thread chipmaney
Recently, I ran a series of Kruskal-Wallace tests [kruskal.test()] using by() to group by site Output is a list: Herb.KW Herb.df$ID: 10-1 Kruskal-Wallis rank sum test data: Indicator_Rating by Year Kruskal-Wallis chi-squared = 15.24, df = 7, p-value = 0.03302

[R] subset() for multiple values

2010-02-18 Thread chipmaney
This code works: subset(NativeDominant.df,!ID==37-R17) This code does not: Tree.df-subset(NativeDominant.df,!ID==c(37-R17,37-R18,10-R1,37-R21,37-R24,R7A-R1,3-R1,37-R16)) how do i get subset() to work on a range of values? -- View this message in context:

[R] Extracting values from a list

2010-02-18 Thread chipmaney
I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841 Herb.df$ID: 44-1

Re: [R] Extracting values from a list

2010-02-18 Thread chipmaney
, '[', 'p.value') On Thu, Feb 18, 2010 at 5:21 PM, chipmaney [hidden email] wrote: I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841

[R] How do I vectorize this loop....

2009-10-21 Thread chipmaney
Basically I need to use the following data to calculate a squared error for each Sample based on the expected Survival for the zone. Basically, this code has Live/Dead for each sample, and I need to calculate the square error based on the Expected Mean (ie, Survival). The code looks up the

[R] axis scale issues....

2009-09-29 Thread chipmaney
I have read all the help on axis scales, which seems to be much harder to deal with than it should be, given how common the need to alter axes. Anywayyeah, suppress the axis using yaxt then call and define the new scale using axis(). The problem is, this doesn't change the actual axis,

[R] vectors levels are carried through to subsets...

2009-09-29 Thread chipmaney
I have a dataset. Initially, it has 25 levels for a certain factor, Description. However, I then subset it, because I am only interested in 2 of the 25 factors. When I subset it, I get the following. The vector lists only the two factors, yet there remain 25 levels: Quadrats.df$Description

[R] Interesting function in a function problem....

2009-09-29 Thread chipmaney
#I have these data. Basically, I want to run a tapply to calculate the mean and st. err. by factor. #The problem is, I want to add a finite correction to the variance prior to calculating the standard error. #Now I know I could just do this in 3/4 steps by calculating the var, applying the

[R] how do i vectorize relational queries in R

2009-08-19 Thread chipmaney
I am basically trying to append a value(vector) to one dataframe using a relational value from another dataframe. Obviously, I can use a loop to accomplish this. However, is there a way to vectorize it? Example: data - data.frame(c(1,1,1,2,2,2,3,3,3),rep(2,9)); names(data) - c(Sample,Score)

[R] How do I run the by function on an object of class by???

2009-07-17 Thread chipmaney
I wrote a function with some loops and avoided a third loop by using the by function. The output object is an array (or list) of class by that looks like this: StationCover.df Empirical.df$Quadrat: VFFF9-21 Station Shrub Tree Woody Invasive Herb Litter Bare [1,] 0.0 11

[R] Help get this simple function to work...

2009-07-13 Thread chipmaney
I have a function (see below). This function has one object, ID. If I run the loops by themselves using a character value (ie,VFFF1-7) instead of the function object, then the loops work fine. However, when I try to insert the character value via the function call, it doesn't work. I don't get