Hi. Here are some examples that could be useful here:

set.seed(1)
x <- sample(1:2, 100, rep=T)
y <- sample(1:3, 100, rep=T)
TAB <- table(x,y)

#check the object class

class(TAB)
apply(TAB, 2, max)
apply(TAB[,2:3], 2, max)
apply(TAB, 1, max)

DF <- as.data.frame.matrix(TAB)
class(DF)
sapply(DF, max)

Look at ?class, ?table, ?"[" , ?apply, ?as.data.frame.matrix and read
posting guide.

Andrija


On Fri, Jul 6, 2012 at 5:03 PM, Amanduh320 <aadam...@uwo.ca> wrote:

> I have my data in a table
> table <- table(test2$Filename, test2$PREDICT)
>
> I need to convert this table so it keeps the same structure, but is a
> different format. The current output is count data by Filename and I want
> to
> get the max for each Filename.
>
> Columns are:
> Filename, 1, 2, 3, 4, 5, 6, 7
>
> When I try to convert it to a data.frame it reverts to Var1(Filename),
> Var2(1:7), Freq.
>
> My end goal is to find the max by row (Filename), then do ifelse(x<max, 0,
> max) for each value in columns 2:8
>
> My problem is that I don't understand what format the table is in.
> Thank you!
> Amanda
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/convert-a-table-tp4635615.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to