Java Mailing List Archive

http://www.r-help.com/

Home » R Help for Statistical Computing »

[R] R code output issues

MARCEL CURLIN

2010-09-03

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi all,
I have a short R code file that I am using to perform calculations on a
dataset. I am having a few issues with output:

1. Although my input data file is 2149 lines long, when I type "results.df"
from the command line, I get the appropriate calculation results for only
the first 46 rows. Same result if I "sink" the output to a file, and type
"results.df" at the command line. This creates a file with the first 46
entries. I do get the entire input data file back if I type "data", and I
can't see anything in my input file around line 46 that would account for
this.

2. If I run the code from a file using the command
"source("TransmissionCalc2") with the "results.df" command embedded in the
file, there is no output to the terminal at all (or to the output file, if I
use sink). Sink just creates an empty file.

So, not sure why my results dataframe seems to only include a small fraction
of the data, or why the write commands are ignored when embedded in the code
and called by "source("etc...."

CODE

rm(list = ls(all = TRUE))
alldata
<-read.table("/Users/marcel/Desktop/V1V2TransmAnalysis/3_transmissiondata",
header=T)
#sink("/Users/marcel/Desktop/V1V2TransmAnalysis/4_output")
data <- data.frame(alldata)
V1V2means <- with(data, tapply(V1V2, list(Pair, DR), mean))
V1V4means <- with(data, tapply(V1V4, list(Pair, DR), mean))
results.df <- data.frame(V1V2means, V1V4means, V1V2dif = V1V2means[, "R"] -
V1V2means[, "D"], V1V4dif = V1V4means[, "R"] - V1V4means[, "D"] )
data

SAMPLE OF INPUT DATA FILE

Pair   DR   V1V2   V1V4
1   D   63   277
1   D   63   277
1   D   63   277
.


Thoughts greatly appreciated.

Marcel
--
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@(protected)
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.
©2008 r-help.com - Jax Systems, LLC, U.S.A.