23 nov 2012
14 nov 2012
Una función útil para expandir columnas delimitadas en R
Siempre estamos en la búsqueda de esas funciones que nos ayudan a manipular de manera más ágil nuestros data.frame. Ésta es una que nos ayudara a expandir un vector de valores delimitados por comas para poder hacer cálculos en R con ella.
> data Name Score1 Score2 1 Bill 1,3,4,3,6,9 F1,F3,F2 2 Bob 3,2,3 F2,F2,F4 3 Sam 2,5,3 F5,F2,F4 > expand.delimited(data) Name Score1 1 Bill 1 2 Bill 3 3 Bill 4 4 Bill 3 5 Bill 6 6 Bill 9 7 Bob 3 8 Bob 2 9 Bob 3 10 Sam 2 11 Sam 5 12 Sam 3
# Descripción # Acepta una data.frame donde col1 representa un factor y representa col2
# valores delimitados por comas u otro a expandir de acuerdo con col1.
# Devuelve un data.frame. # Usage # expand.delimited(x, ...) # Default # expand.delimited(x, col1=1, col2=2, sep=",") # Arguments # x A data.frame # col1 Column in data.frame to act as factor # col2 Column in data.frame that is delimited and will be expanded # sep Delimiter #Download data #Read in data data<-read .table=".table" 1="1" apply="apply" as.data.frame="as.data.frame" c="c" cbind="cbind" col1="col1" col2="col2" data="data" df="df" do.call="do.call" example="example" expand.delimited="expand.delimited" expand="expand" expand_delimited.txt="expand_delimited.txt" expand_row="expand_row" expanded="expanded" factor="factor" factr="factr" function="function" header="T)" length="length" names="names" num="num" pre="pre" rbind="rbind" rep="rep" return="return" rnum="rnum" row.names="seq(rnum:(rnum+num)-1)))" sep="sep" strng="strng" strsplit="strsplit" to="to" tostring="tostring" unction="unction" x="x" y="y">#tomada de http://www.r-bloggers.com-read>
9 nov 2012
7 nov 2012
5 nov 2012
A review at the speeches of candidates in the U.S. elections 2012: Obama vs Romney.
How
can see from the graph of Barack Obama the words"Change",
"Jobs", "Folks" and "Kids", and the graph of Mitt
Romney's the words "Jobs", "Obama", "Economy",
"Business" and "Government "are some of the ones most
frequently and therefore are most prominent in the word cloud, ie
they are the most used in his speeches. Well, with this you can also draw your
own conclusions from these speech content according to their political
preferences. As you can see, politicians can give speeches interesting, and all
are filled with mere words!.
3 nov 2012
Suscribirse a:
Entradas
(
Atom
)