0
Sample1<-read.csv(paste0(filename,".csv"),header=T,stringAsFactors=F)

My question is I want to extract specific rows and columns out of 100000 records Also what is the use of paste0() function here

3
  • Specific? Characterized by some particular value or something? Provide some example please. Commented Jun 21, 2017 at 7:14
  • For example i want to read out of my csv file that contains records for hospital claims i want to read on the "names "column and "claims" column Commented Jun 21, 2017 at 7:23
  • It's better to read whole file than extract specific data, as it's shown in answer below, here it is how paste function works.paste("some_string", 1, "@%#%@") making one string, result: [1] "some_string 1 @%#%@" Commented Jun 21, 2017 at 7:32

1 Answer 1

2

paste0() is used to add strings together. In your example, the filename and .csv are made one.

As for selecting specific rows. You don't do that with read.csv. You do that after. For example, this selects the first, third and sixt row from the second and fourth column.

Sample1[c(1,3,6),c(2,4)]

This is 100% a duplicate question. I don't know how to flag it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you that i understood well the function and use of paste0() , i am not able to get why it is used in this manner or say why it is used with read.csv and what would happen in case i dont use it . Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.