0

This is my data https://www.dropbox.com/s/msf0ro8saav7wbl/data1.txt?dl=0 (dataA), i want to extract "Habitat" to have frequency table so that i can calculate any statistical analysis such as mean and variance, and also to plot such as boxplot using ggplot2

I tried to use solution in duplicate question here R: How to get common counts (frequency) of levels of two factor variables by ID Variable (as new data frame) but i think it does not help my problem

user112231
  • 47
  • 8

1 Answers1

1

Here's the easiest way to get a data.frame with frequencies using table. I'm using t to transpose and as.data.frame.matrix to transform it into a data.frame.

as.data.frame.matrix(t(table(data1)))
         A B C
Adult    1 2 1
Juvenile 2 0 0
Pierre Lapointe
  • 16,017
  • 2
  • 43
  • 56
  • Hye. i have edited my question. Let say i have big data, dataA here (you can refer my link) and have another subset of data1 that contain "Habitat" how do i transpose and make frequency table – user112231 Apr 21 '17 at 20:54