Hi,

I would do something like this:

## Create the table

DT        <- data.table(colour = rep(c("red", "blue", "green"), each= 3),
                        type = paste0('type', 1:3),
                        value = as.integer( rnorm(9, mean= 6, sd = 5)))

# Cast table and make it a contingence table
DT1 <- dcast.data.table(DT, colour ~ type, value.var = 'value', FUN = function(x) sum(x, na.rm = TRUE))


Den 12/03/17 kl. 04:49, skrev tuan173:
Dear All,
I am new to R, and trying to learn it.
I need help with some coding. I have tried to make it, but it did not word.
I have a data similar to this
   <http://r.789695.n4.nabble.com/file/n4729632/Data.png>
I want to make a table
<http://r.789695.n4.nabble.com/file/n4729632/table1.png>
And then fill the table with the values in the dataframe
<http://r.789695.n4.nabble.com/file/n4729632/data2.png>
My real data is much bigger than the example.
I need advice to code for making a table, and then fill in the table.
Thank you very much,
Tuan




--
View this message in context: 
http://r.789695.n4.nabble.com/Help-coding-tp4729632.html
Sent from the datatable-help mailing list archive at Nabble.com.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to