Error in data.frame: arguments imply differing number of rows: 2, 5, 19, 7, 1, 11, 4, 6, 9, 3, 13 14, 22, 26, 27, 30, 31, 29, 35
<p>I'm working on a R Project. While trying to analyse the sentiments, I had to create a data frame (Here in my ex, it is "sentiment.df").</p>

<pre><code>sentiment.df &lt;- data.frame(text, emotion=emotion, polarity=polarity, stringsAsFactors=FALSE) 
</code></pre>

<p>Here, text - a list containing processed(cleaned) tweets split into keywords; emotion - contains a bag of emotions in characters; polarity - contains +ve,-ve critics. When running the above LOC my RStudio threw the following error: </p>

<pre><code>Error in data.frame(c("httpstcoux1aacnxbk", "endalz"), c("i", "have",  : 
  arguments imply differing number of rows: 2, 5, 19, 7, 1, 11, 4, 6, 9, 3, 13, 17, 8, 10, 24, 21, 15, 12, 25, 16, 20, 23, 18, 28, 14, 22, 26, 27, 30, 31, 29, 35
</code></pre>

<p>Length of those 3 variables - text, emotion &amp; polarity are all same : 2621</p>

<p>This is how my data looks like:</p>

<pre><code>    &gt; str(text)
List of 2621
 $ : chr [1:2] "httpstcoux1aacnxbk" "endalz"
 $ : chr [1:5] "i" "have" "the" "best" ...
 $ : chr [1:19] "kenny" "easley" "seahawks" "captain" ...
 $ : chr [1:2] "good" "defense"
 $ : chr [1:7] "superbowlxlix" "party" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__ "" ...
 $ : chr "ihatetombrady"
 $ : chr [1:11] "coachbourbonusa" "understood" "still" "dont" ...
 $ : chr [1:19] "tiwaworks" "whitney" "houston" "sings" ...
 $ : chr [1:4] "thats" "still" "bae" "&lt;U+2764&gt;&lt;U+FE0F&gt;""| __truncated__
 $ : chr [1:6] "were" "a" "thousand" "miles" ...
 $ : chr [1:7] "dredoo24" "what" "i" "like" ...
 $ : chr [1:2] "bww" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__
 $ : chr [1:9] "i" "seriously" "cant" "wait" ...
 $ : chr [1:3] "flyysociety" "photoshoot&lt;U+2716&gt;&lt;U+FE0F&gt;""| __truncated__ "httptcoxkywsj5i2x"
 $ : chr [1:5] "lienne11" "wait" "whos" "performing" ...
 $ : chr [1:13] "game" "on" "go" "wildcats&lt;U+FFFD&gt;&lt;U+FFFD&gt;\u2b07&lt;U+FE0F&gt;""| __truncated__ ...
 $ : chr [1:2] "good" "defense"
 $ : chr [1:11] "seattle" "seahawks" "fan" "" ...
 $ : chr [1:9] "realprestonj" "congratulations" "preston" "the" ...
 $ : chr [1:5] "tsu19" "so" "funny" "bruh" ...
 $ : chr [1:4] "drunk" "tweets" "coming" "soon"
 $ : chr "tb12"
 $ : chr [1:13] "hicksville" "schools" "will" "be" ...
 $ : chr [1:5] "but" "momma" "said" "superbowl" ...
 $ : chr [1:4] "raggedy" "ass" "bitch" ""
 $ : chr [1:5] "arbyscares" "arbys" "prairie" "village" ...
 $ : chr [1:17] "lovetruth79" "ltltltloves" "to" "send" ...
 $ : chr [1:8] "“boynamedhxlz""| __truncated__ "quote" "this" "tweet" ...
 $ : chr [1:13] "stretching" "for" "ballet" "now" ...
 $ : chr [1:7] "jerrodflusche" "janabewley" "narnia" "for" ...
 $ : chr [1:8] "here" "goes" "my" "whole" ...
 $ : chr [1:10] "who" "you" "going" "for" ...
 $ : chr [1:3] "good" "stop" "hawks"
 $ : chr [1:5] "brady" "be" "smokin" "blounts" ...
 $ : chr [1:8] "me" "decepcioné" "perdoné" "hice" ...
 $ : chr [1:7] "happy21stbirthdayharry" "" "its" "also" ...
 $ : chr [1:24] "teammic3rd" "sounds" "amazing" "" ...
 $ : chr [1:21] "millions" "of" "people" "packed" ...
 $ : chr [1:8] "missed" "idina" "singing" "by" ...
 $ : chr [1:2] "your" "stupid"
 $ : chr [1:5] "seahawks" "all" "the" "way" ...
 $ : chr [1:4] "takeathillpill" "you" "are" "vile"
 $ : chr [1:3] "lets" "goo" "superbowlixlix"
 $ : chr [1:4] "snow" "day" "nigga" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__
 $ : chr [1:6] "ill" "just" "watch" "total" ...
 $ : chr [1:9] "liveextra" "site" "down" "its" ...
 $ : chr [1:3] "time" "to" "punt"
 $ : chr [1:5] "zachdettloff516" "groans" "at" "terrible" ...
 $ : chr [1:3] "go" "seahawks" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__
 $ : chr [1:7] "pizza" "friends" "super" "bowl" ...
 $ : chr [1:9] "hold" "onto" "me" "cause" ...
 $ : chr [1:6] "tom" "gonna" "get" "his" ...
 $ : chr [1:6] "lets" "goooooo" "nice" "3rd" ...
 $ : chr [1:15] "2" "fatal" "crashes" "reported" ...
 $ : chr [1:12] "supra" "dope" "atx" "sundayfunday" ...
 $ : chr [1:19] "all" "these" "students" "from" ...
 $ : chr [1:3] "danstricko" "not" "happening"
 $ : chr [1:17] "tom" "brady" "may" "wear" ...
 $ : chr "httptconqabzdezwf"
 $ : chr [1:4] "i" "miss" "you" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__
 $ : chr [1:25] "john" "legend" "and" "idina" ...
 $ : chr [1:13] "snowed" "in" "with" "kadybuchler" ...
 $ : chr [1:6] "that" "bright" "green" "and" ...
 $ : chr [1:9] "ive" "got" "the" "seahawks" ...
 $ : chr [1:9] "sds" "by" "mac" "miller" ...
 $ : chr [1:5] "jakeski52" "rotowire" "or" "roger" ...
 $ : chr "damnit"
 $ : chr "hawks"
 $ : chr [1:7] "my" "nephews" "and" "niece" ...
 $ : chr [1:16] "liking" "your" "own" "posts" ...
 $ : chr [1:2] "bailaconbruce" "fb"
 $ : chr [1:4] "djones7" "hell" "no" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__
 $ : chr [1:7] "best" "part" "of" "the" ...
 $ : chr [1:13] "holls016" "f" "u" "i" ...
 $ : chr [1:6] "mikebarnicle" "nice" "to" "meet" ...
 $ : chr [1:5] "u" "played" "me" "dirty" ...
 $ : chr [1:13] "my" "bac" "is" "looking" ...
 $ : chr [1:2] "est" "2008"
 $ : chr [1:12] "vacation" "time" "" "thats" ...
 $ : chr [1:3] "&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__ "ok" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD&gt;&lt;U+FFFD"| __truncated__
 $ : chr [1:2] "common" "seattle"
 $ : chr [1:3] "no" "cacc" "talc"
 $ : chr "lob"
 $ : chr [1:3] "cut" "the" "crap"
 $ : chr [1:11] "im" "at" "las" "alitas" ...
 $ : chr [1:3] "backstreets" "back" "alrighttttt"
 $ : chr [1:6] "the" "seahawks" "are" "going" ...
 $ : chr [1:13] "baby" "its" "cold" "outside" ...
 $ : chr [1:15] "i" "have" "sooo" "much" ...
 $ : chr [1:10] "so" "whos" "gonna" "pull" ...
 $ : chr [1:5] "my" "driveway" "tonight" "nwiweather" ...
 $ : chr "fuck"
 $ : chr [1:21] "now" "that" "its" "actually" ...
 $ : chr [1:7] "green" "goats" "&lt;U+FFFD&gt;&lt;U+FFFD&gt;""| __truncated__ "" ...
 $ : chr [1:15] "i" "guess" "its" "time" ...
 $ : chr [1:3] "lets" "go" "seattle"
 $ : chr [1:20] "jozybrambila7" "do" "you" "ever" ...
 $ : chr [1:4] "reggiewo" "nice" "choice" "cheers"
 $ : chr [1:20] "i" "enjoy" "super" "bowl" ...
  [list output truncated]

&gt; str(emotion)
 chr [1:2621] "unknown" "unknown" "unknown" "unknown" "unknown" "unknown" "unknown" "joy" ...
&gt; str(polarity)
 chr [1:2621] "positive" "positive" "positive" "positive" "positive" "positive" "positive" ...
</code></pre>

<p>When I posted this error online, programmers say no.of rows &amp; cols are not same. i.e., its not a square matrix and Dataframe will not work for a rectangular matrix. </p>

<p>Would be grateful if someone helps me out from this error.</p>

<p>Thanks in advance!</p>