R- Convert data into matrix format same as other matrix -


I have data in Excel:

  Terms range weight email TV 1.00 acccount email 12.0 Accept phone 3.00   

I have other metrics and its format is:

  Terms TV Email Phone Contact Information Help ..... 1 Do it. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0>  

Now I want to convert the above data into the format like That

  Rule Tv Email Support to contact the phone email ..... email 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   

I want to do that any help in R will be appreciated. thank you in advanced.

You have to resize your data. If you do not already have it, then install the package "reshape2"

There is a code here to deny your data again

  is needed (reshape2) Df.reshape & lt; -melt (Df, id.var = c ("conditions", "category")) # where DF is your data. To repeat the string, use the # two words and classes to create the id variable # df.wide and lt; -Document (df.reshape, terms ~ category)   

Note that this will give you NA for the pair that does not exist in your data.

If you want you can easily change with zero

and reshape2 here to use a good Tutorial is

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -