Displaying 20 results from an estimated 61 matches for "__end__".
2009 Sep 11
2
Anyone know why __END__ and DATA don't work in Rails?
When writing Ruby you have the option to end the file early with
__END__. Anything after the __END__ is assigned to a constant called
DATA which is available within the file.
I recently tried using this in Rails and it didn''t work. Instead I get
an uninitialized constant exception. Anyone know why?
Has it been disabled in Rails?
thanks
Gavin
2006 Feb 07
4
__END__ equivalent for erb?
Time and time again I find the need to terminate evaluation of an erb
file on a certain line for debugging purposes, but can''t figure out a
way to do it. Is this possible?
Thanks!
John
--
Posted with http://DevLists.com. Sign up and save your time!
2008 Dec 21
3
Globbing Files in R
Dear all,
For example I want to process set of files.
Typically Perl's idiom would be:
__BEGIN__
@files = glob("/mydir/*.txt");
foreach my $file (@files) {
# process the file
}
__END__
What's the R's way to do that?
- Gundala Viswanath
Jakarta - Indonesia
2008 Jun 12
1
Data.matrix fail to convert data.frame into matrix
...a.strings = "null");
# Select n-genes by random sample
# n = 1
nosamp <- 1
geneid <- sequence(nrow(dat))
geneid.samp <- sample(geneid,nosamp)
geneid.samp
gexp<- dat[geneid.samp,]
gexp.arr <- data.matrix(gexp, rownames.force = NA)
print(is.matrix(gexp.arr))
print(gexp.arr)
__END__
Yielding this output:
__BEGIN__
> print(is.matrix(gexp.arr))
[1] TRUE
> print(gexp.arr)
V1 V2 V3 V4 V5 V6 V7 V8
10354 803.1 1107.8 431.6 349.8 386.7 646.3 744.2 620.9
__END__
I expect "gexp.arr" to be a plain vector (numeric).
What's wrong...
2008 Aug 05
1
About Creating a List by Parsing Text
...t;
[6] "\tGene 12682 213301_x_at TRIM24 k= 3 LL= -947.379 "
[7] "\tGene 13764 214385_s_at AI521646 k= 1 LL= -827.86 "
[8] "\tGene 13764 214385_s_at AI521646 k= 2 LL= -777.756 "
[9] "\tGene 13764 214385_s_at AI521646 k= 3 LL= -812.083 "
__END__
I expect to get this kind of data structure:
> wanted_output
[['211952_at']]
$ll.list
[1] -970.692 -965.35 -963.669
[['213301_x_at']]
$ll.list
[1] -948.527 -947.275 -947.379
etc.
How can I achieve that?
I am stuck with the following construct
__BEGIN__
comp.ll <- model...
2008 Jun 16
4
Superimposing Line over Histogram in Density Plot
...I have a density plot generated with this
snippet.
Is there a way I can add a line curve on top of it?
I mean in one figure
__BEGIN__
myhist <- hist(x
col="blue",
main = "Density Plot",
xlab = "Exp Level",
)
__END__
- Gundala Viswanath
Jakarta - Indonesia
2008 Jun 11
3
Finding Coordinate of Max/Min Value in a Data Frame
...C4 PC5
FL 0.2889810 0.3232500 -0.5071698 0.7342907 0.1248816
RW 0.1972824 0.8647159 0.4141356 -0.1483092 -0.1408623
CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656
CW 0.6616550 -0.2879790 0.4913755 0.1256282 0.4712202
BD 0.2837317 0.1598447 -0.5468821 -0.6343657 0.4386868
__END__
Is there a way to identify the "coordinate" of a max/min value of all the
points above.
For example the coord of maximum value is (RW,PC2) = 0.865,
and coord of min value is (CW,PC2) = - 0.288.
--
Gundala Viswanath
2012 Aug 03
3
embedding data frame in R code?
I would like to insert a few modest size data frames directly into my
R code. a short illustration example of what I want is
d <- read.csv( _END_, row.names=1 )
, "col1", "col2"
"row1",1,2
"row2",3,4
__END__
right now, the data sits in external files. I could put each column
into its own vector and then combine into a data frame, but this seems
ugly. is there a better way to embed data frames? I searched for the
answer via google, but could not find it. it wasn't obvious in the
data import/exp...
2008 Aug 05
2
Iterating Named List
...90
What I want to do is to iterate this name list and process its members.
To do that I attempt the following code (but failed):
__BEGIN__
ny <- names(y)
for (i in ny) {
val <- paste("`",i,"`",sep="")
print(y$val)
# later we want to process y$val
}
__END__
However the after printing it gives "NULL".
What's wrong with my code above?
- Gundala Viswanath
Jakarta - Indonesia
2009 Jan 08
2
Faster Printing Alternatives to 'cat'
...his type of loop.
# because using write(), I need to create a matrix which
# consumes so much memory. Note that "foo, bar, qux" object
# is already very large (>2Gb)
for ( s in 1:length(x) ) {
cat(as.character(foo[s]),"\t",bar[s],"\t", qux[s],"\n")
}
__END__
for "x" of size ~1.5million, takes more than 10 hours to print.
On my Linux 1994.MHz AMD processor.
Is there any faster alternatives to "cat" ?
- Gundala Viswanath
Jakarta - Indonesia
2009 Jan 09
3
Pack and Unpack Strings in R
...ed;
my @data;
# Store the compressed bit into array
push @data, $compressed;
# process the array
foreach my $dat ( @data ) {
my $decompressed = unpack 'b*', $dat;
$decompressed =~ s/(..)/$digmap{$1}/ge;
print "$decompressed\n";
# or do further processing on $dat
}
__END__
- Gundala Viswanath
Jakarta - Indonesia
2008 Jun 23
2
Pairwise Partitioning of a Vector
...in 1:ncol(gexp)) {
sp_b <- pose+1
sp_e <- ncol(gexp)
# This two doesn't do what I want
part1 <- sort.gexp[posb:pose]
part2 <- sort.gexp[sp_b:sp_e]
# we later want to process part1 and part2 separately
}
}
}
__END__
- Gundala Viswanath
Jakarta - Indonesia
2008 Jun 16
2
Creating a Hash from Data.Frame
Hi,
I have the following data frame:
> print(mydatframe)
__DATAFRAME__
V1 V2 V3
1 1007_s_at DDR1 discoidin domain receptor tyrosine kinase 1
2 1053_at RFC2 replication factor C (activator 1) 2, 40kDa
3 117_at HSPA6 heat shock 70kDa protein 6 (HSP70B')
__END__
Is there a way to create a hash with
V2 as Key and V3 as its value?
- Gundala Viswanath
Jakarta - Indonesia
2008 May 23
2
About Passing Arguments to Function
...p in 1:k_func) {
curr_mll <- (- sum(dgamma(samp, shape = x_func,
scale=theta_func, log = TRUE)))
tot_mll <- tot_mll + curr_mll
}
tot_mll
}
# Calling the function above
mlogl_out <- nlm(mlogl_k, mean(vsamples), k_func =2, x_func = 1,
theta_func = 1, samp=vsamples)
__END__
I thought under NLM, I already assign
the parameter correctly.
However it gives me the following error.
Error in f(x, ...) : unused argument(s) (14.3166666666667)
Calls: nlm -> <Anonymous> -> f
Execution halted
What's wrong with my code above?
- Edward
2005 Jul 11
2
[ win32utils-Bugs-2093 ] unable to open existing shortcut
...s.path = ''c:\winnt\notepad.exe''
s.show_cmd = Shortcut::SHOWNORMAL
s.working_directory = "C:\"
s.save
fail "LNK creation failed: #{link}" unless File.exists?(link)
puts "Link #{link} created"
s = Shortcut.open(link)
puts "Path: #{s.path}"
__END__
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=411&aid=2093&group_id=85
2008 Jun 19
2
Create Matrix from Loop of Vectors, Sort It and Pick Top-K
...gex <- as.vector(data.matrix(data[gi,],rownames.force=FALSE))
#compute variance
gexvar <- var(gex)
# join variance with its original vector
nvec <- c(gexvar,gex)
# I'm stuck here.....This doesn't seem to work
all.arr <- data.frame(nvec)
}
print(all.arr)
__END__
--
Gundala Viswanath
Jakarta - Indonesia
2008 Jun 10
1
Concat Multiple Plots into one PNG figure
...par(mfrow = c(1,2))
# Two plots which I want to put into one PNG figure
xyplot(dat.pca$x[,1] ~ dat.pca$x[,2], xlab="First Component",
ylab="Second Component")
xyplot(dat.pca$x[,2] ~ dat.pca$x[,3], xlab="Second Component",
ylab="Third Component")
dev.off()
__END__
--
Gundala Viswanath
2008 Jun 16
1
Separator with " | " for read.table
...frame:
__DATA__
#GDS_ID GENE_NAME GENE_DESCRIPTION GENE_FUNCTION
1007_s_at | DDR1 | discoidin domain receptor tyrosine kinase 1 | protein-coding
1053_at | RFC2 | replication factor C (activator 1) 2, 40kDa | protein-coding
117_at | HSPA6 | heat shock 70kDa protein 6 (HSP70B') | protein-coding
__END__
In particular it is separated by " | " , namely - space, bar, space.
However I tried this without avail:
geneinfo <- read.table("mydata.txt", sep=" | ", comment.char="\#")
print(geneinfo)
I also tried with sep= "|", it gave a wrong parsing. Pl...
2008 May 22
1
Computing Maximum Loglikelihood With "nlm" Problem
...<- function(alpha, x) {
if (length(alpha) > 1) stop("alpha must be scalar")
if (alpha <= 0) stop("alpha must be positive")
return(- sum(dgamma(x, shape = alpha, log = TRUE)))
}
mlogl_out <- nlm(mlogl, mean(vsamples),vsamples=vsamples)
print(mlogl_out)
__END__
However, it gives the following error:
Error in f(x, ...) :
unused argument(s) (vsamples = c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4))
Calls: nlm -> <Anonymous> -> f
Execution halted
What's wrong in my way of calling 'nlm" function?
Please advice.
- Edward
2008 May 26
1
Joining Histograms Into a Figure
...hist(dat$V2, main="AIC Freq", xlab = "\# Component", breaks = 36, xlim =
c(0,max(dat$V2)), col = "dark red", freq = TRUE)
hist(dat$V3, main="BIC Freq", xlab = "\# Component", breaks = 36, xlim =
c(0,max(dat$V2)), col = "blue", freq = TRUE)
__END__
How can I joint this two histograms into one figure?
Regards,
Edward