My question today refers to a data frame I\'m working on in R. The header of the data frame looks like the following: String(unique), Integer N[0-23]
Those 24 Integ
Use prop.table
on a matrix
containing the values:
x <- data.frame(id=letters[1:3],val0=1:3,val1=4:6,val2=7:9)
prop.table(as.matrix(x[-1]),margin=1)
val0 val1 val2
[1,] 0.08333333 0.3333333 0.5833333
[2,] 0.13333333 0.3333333 0.5333333
[3,] 0.16666667 0.3333333 0.5000000
Edit: A fully working example:
tt=read.table("topichitsperhod.csv",sep=",",header=TRUE)
tt=na.omit(tt[-1])
pt=prop.table(tt[-1],margin=NULL)
First column is being left out because it held the topic strings.