[R] unexpected results

Petr Pikal petr.pikal at precheza.cz
Fri Jul 21 14:28:19 CEST 2006


On 21 Jul 2006 at 4:36, nathan wrote:

Date sent:      	Fri, 21 Jul 2006 04:36:53 -0700 (PDT)
From:           	nathan <sirrahn at hotmail.com>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] unexpected results

> Hi, 
> I'm just learning R and am encountering some unexpected results
> following a guide on the internet. If anyone can help that would be
> great - I think it is something about the way the data has been read
> in!
> I've read a coma delimited text data file that was saved from excel:
> > jacs.data <- read.table("/Users/natha/Desktop/JACSdata2.txt",
> > header=TRUE, sep=",")
> This seemed to work fine, but then I start to get unusual results that
I do not think so. Probably separation character of your file is not 
"," as you set in sep=",".

> don't seem right:
> The guide says that names(file.data) will give output like "ID"

e.g. ID.JURIS.RESCODE was read into one column.

Best way how to copy data from Excel (if you have Excel) 

Select your data in Excel including first row with headers
Go to R
Write mydata <- read.delim("clipboard")

or look at JACSdata2.txt what is the separator between fields and set 
it in your read.table command accordingly. From later I suppose your 
txt file is tab delimited so
shall capture it.


> The guide says that file.data[5,1] will give me the data for the 5th
> subject but i get: [1] 7\tACT\t\t\tSUMMONS\tACTCC321.001\tA.C.T. -
> MINOR THEFT (REPLACEMENT VALUE $2000 OR LESS)\ etc - which seems
> scrambled
> The guide says that file.data[var5>0] will give me the data for all
> subject who meet that condition (ie greater than 0 on var5), but I
> get:
> Error in "[.data.frame"(jacs.data, offend > 0) : 
>  object "offend" not found
> can anyone help? Thanks nathan
> -- 
> View this message in context:
> http://www.nabble.com/unexpected-results-tf1979786.html#a5432210 Sent
> from the R help forum at Nabble.com.
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

Petr Pikal
petr.pikal at precheza.cz

More information about the R-help mailing list