[R] R code output issues

Marcel Curlin cemarcel at u.washington.edu
Sat Sep 4 02:32:59 CEST 2010


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
-- 
View this message in context: http://r.789695.n4.nabble.com/R-code-output-issues-tp2526415p2526415.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list