Declaring an array of strings and integers I have two csv file - one is a list of strings and other has both strings and floating values. If the strings in both the files match I need to copy the complete row from the second file to a temporary array. I have declared a matrix with n rows and m columns and saved is as dataframe temp &lt;- as.data.frame(matrix(nrow = n, ncol = m)). I am using for loop to iterate over all rows and strcmp to compare the strings. But when the data is written to temp the strings are stored as integers. How should I declare this array? Is it possible to write this loop without declaring an array in R?
When you read in your two CSV files, you can explicitly declare the variable types for each column:

&gt; a &lt;- read.csv(..., colClasses=c("character"), ...)
&gt; b &lt;- read.csv(..., colClasses=c("character", "numeric", "numeric", ...), ...)


You could also investigate as.is or stringsAsFactors, although this can cause problems where there are duplicate strings. Using colClasses is more explicit. 

Read the help documentation in ?read.csv for a more complete explanation of these operators.

You can filter with the %in% operator in match:

&gt; strings_of_interest &lt;- as.vector(a$V1)
&gt; b.filtered &lt;- b[b$V1 %in% strings_of_interest,]


If I am reading your question correctly, perhaps you can then take b.filtered and turn that into the matrix you want.

Avoid use of for loops where you can. They can slow R down considerably. A good read on this subject is in the third chapter of Patrick Burns' The R Inferno.