[R] Extract cells and their adjacent cells that may appear anywhere in a dataframe.

Brian Leo leobriant at gmail.com
Tue May 9 06:33:25 CEST 2017


Hello,

I have a dataframe that contains information about vegetation cover and
percent coverage, collected using a quadrat.  The dataframe is set up so
that each row represents a single quadrat.  If there are multiple species
within one quadrat, they are all listed within the same row with respective
% coverage always following in next column.  Here is an example, species
are represented as 4 letter codes:

Quadrat_#

Date

Species_1

Species_2

covrage2

Species_3

covrage3

1

5/2/2017

unk1

2

bial

6

stgu

95

2

5/2/2017

bope

75

stja

4

ficy

9

3

5/2/2017

bope

100

stja

5



4

5/2/2017

stgu

87

stja

6

bope

20

5

5/2/2017

bg

13

stja

2

ficy

10

6

5/2/2017

bope

8

sirh

3

stgu

2



The problem is that the species were not recorded in any particular order,
and not all species occur in every quadrat.  There can also be any number
of species per quadrat.  I need to be able to extract each species AND it’s
respective coverage, and place them in into another dataframe for further
analysis

So the result for “bope” from above example data would look like this:

Quadrat#

% coverage bope

1

0

2

75

3

100

4

20

5

0

6

8



Any help greatly appreciated.

Brian

	[[alternative HTML version deleted]]



More information about the R-help mailing list