Hi all, I am using ftable and xtabs to get total counts of species per location
per hight category (understory, midstory and overstory). i can save the data in
almost the format i would like it to be - but not quite. Here it is an example
of what i get: x - is a dataframe with the following columns: LocationID,
Species, PercentCover, Categorywhere Category tells if the Species belongs to
understory, midstory or overstory
y1 <- ftable(xtabs(PercentCover ~ LocationID + Species + Category, data=x))y2
<- format(y1, quote = FALSE, sep = “,”)write.table(y2, “test1.csv”, row.names
= FALSE, col.names = FALSE, sep = “,”)If i read the test1.csv it will look like
that: Category
Midstory Overstory Understory
LocationID Species
Loc1 A
0 0 10
B
10 20 0
C
55 0 10
….
… … …
Loc2 A
0 0 0
B
5 60 0
C
35 0 25
…
… … …
What i would like: (1) eliminate the column (Category) because it is empty
anyway (i suppose i can create a new data.frame from y2 in which i skip column
"Category"); (2) have LocationID, Species, Midstory, Overstory, and
Understory on the same row; (3) have the column LocationIDfilled in between Loc1
and Loc2 with Loc1 and not an empty string, and so on for each location.Any
suggestions will be very greatly appreciated, thanks,Monica
_________________________________________________________________
PC_MediaCtr_bigscreen_012008
[[alternative HTML version deleted]]