[R] Strange column shifting with read.table
jim holtman
jholtman at gmail.com
Sun Aug 2 23:27:05 CEST 2009
You need to post the first 10 lines of your data so that we can see
what it is doing. Most likely you have a format problem, comment
characters, or mismatched quotes.
On Sun, Aug 2, 2009 at 5:24 PM, Noah Silverman<noah at smartmediacorp.com> wrote:
> Jim,
>
> The "write.table" was simply a diagnostic step.
>
> My problem is that R is automatically adding row_names and then shifting my
> column labels over. (The shifting creates a bunch of related problems.)
>
> Thanks for the help.
>
> -Noah
>
>
> On 8/2/09 2:22 PM, jim holtman wrote:
>
> try 'row.names=FALSE' in the write.table.
> On Sun, Aug 2, 2009 at 5:10 PM, Noah Silverman<noah at smartmediacorp.com>
> wrote:
>
>
> Hi,
> I am reading in a dataframe from a CSV file. It has 70 columns. I do
> not have any kind of unique "row id".
> rawdata <- read.table("r_work/train_data.csv", header=T, sep=",",
> na.strings=0)
> When training an svm, I keep getting an error
> So, as an experiment, I wrote the data back out to a new file so that I
> could see what the svm function sees.
> write.table(rawdata, file="r_work/output_data.csv", quote=FALSE, sep=",")
> It appears as if R has added a column for me with id numbers for each
> row. That would be fine, except that R SHIFTS ALL MY COLUMN LABELS OVER
> ONE. That causes several problems:
> 1) The header names are now wrong for each column
> 2) My last column has no label
> 3) The SVM complains about the unlabeled column
> Would someone please help me sort this out.
> Thanks!
> -N
> [[alternative HTML version deleted]]
> ______________________________________________
> R-help at 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
> 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?
More information about the R-help
mailing list