Hello,
I'm using <read.csv("filename",header=TRUE) but need to extract
just certain
columns or rows from the file.
Much thanks.
--
View this message in context:
http://n4.nabble.com/selecting-certain-columns-or-rows-from-a-csv-tp1835692p1835692.html
Sent from the R help mailing list archive at Nabble.com.
?read.csv colCLasses nrows On Sat, Apr 10, 2010 at 6:11 PM, doconnor <oconnor.david.b@gmail.com> wrote:> > Hello, > > I'm using <read.csv("filename",header=TRUE) but need to extract just > certain > columns or rows from the file. > > Much thanks. > > > -- > View this message in context: > http://n4.nabble.com/selecting-certain-columns-or-rows-from-a-csv-tp1835692p1835692.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
dataFile = read.csv("filename.csv",header= TRUE);
#suppose u want col 1, col 9 and col 15
col1 = 1;
col9 = 9;
col15 = 15;
modifiedDataFile1 = dataFile[,c(col1, col9, col15)];
#if u want rows from 1-100 and then 1000-5000
modifiedDataFile2 = dataFile[c(1:100, 1000:5000), ];
#If u want to select rows and col simultaneously as specified above then
modifiedDataFile = dataFile[c(1:100, 1000:5000), c(col1, col9, col15)];
Hope this will work.
Thanks
Fahim Mohammad
Grad student
CECS, Univ of Louisville
--
View this message in context:
http://n4.nabble.com/selecting-certain-columns-or-rows-from-a-csv-tp1835692p1835760.html
Sent from the R help mailing list archive at Nabble.com.