Displaying 20 results from an estimated 34 matches for "ncolumns".
Did you mean:
columns
2006 Jan 30
2
yet another vectorization question
...the desired result, still needs
some more vectorizing; in particular, I can't figure out how could one modify
the element of a matrix using apply on a different matrix...
To produce the above outcome, I use:
> all.expr(LETTERS[1:3])
"all.expr" <-
function(column.names) {
ncolumns <- length(column.names)
return.matrix <- matrix(NA, nrow=(3^ncolumns - 1), ncol=ncolumns)
colnames(return.matrix) <- column.names
rownames(return.matrix) <- 1:nrow(return.matrix)
start.row <- 1
all.combn <- sapply(1:ncolumns, function(idx) {...
2005 Dec 15
1
millions of comparisons, speed wanted
...)
but only for a reasonable number of rows. I am searching for:
- ways to improve my code (if possible)
- ideas: create a C code for the slow parts of the code? use MySQL? other
ways?
As a toy example, having an input matrix called "input", my algorithm looks
like this:
## code start
ncolumns <- 6
input <- bincombinations(ncolumns) # from package e1071
# subset, let's say 97% of rows
input <- input[sample(2^ncolumns, round(2^ncolumns*0.97, 0), ]
minimized <- 1
while (sum(minimized) > 0) {
minimized <- logical(nrow(input))
to.be.compared <- combn2(1:nrow...
2006 Jun 04
1
strange (to me) ncolumns default value in 'write'
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20060604/a8854663/attachment.pl
2008 Mar 14
3
write function (PR#10953)
Full_Name: Alexander Yephremov
Version: R 2.6.2 GUI 1.23 (4932) (4932)
OS: Mac OS X 10.4
Submission from: (NULL) (193.174.239.91)
Hi!
> array <- 0*1:50
> array
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
> write(array, "array.file", sep=",")
This is how array.file looks:
0,0,0,0,0
0,0,0,0,0
0,0,0,0,0
1997 Apr 03
0
R-alpha: Re: Pretest Version + Notes --- write.table
...Kurt's write.table.
The issue really was to be able to "write a data.frame or matrix" such that
read.table would reproduce it.
write <- function(x, file = "data", ...) UseMethod("write")
write.default <- function (x, file = "data",
ncolumns = if (is.character(x)) 1 else 5,
append = FALSE, ...)
{
if(is.matrix(x))
write.matrix(x, file=file, append= FALSE, ...)
else
write0.basic(x, file = file, ncolumns= ncolumns, append = append)
}
write0.basic <- function (x, file, ncolumns, append = FALSE)
cat(x, file = file, s...
2007 Jul 20
1
Column-mean-values for targeted rows
Hi all,
I'm handling massive data.frames and matrices in R (30000 x 400).
In the 1st column, say, I have 0s and 1s indicating rows that matter; other columns have probability values.
One simple task I would like to do would be to get the column mean values for signaled rows (the ones with 1)
As a very fresh "programmer" I have build a simple function in R which should not be very
2006 Jul 04
1
[Fwd: formatting using the write statement]
...is below and it works fine. my only question is
>there a way to tell the write statement that i want the data
>to be written in a fixed format ( same number of spaces
>betweewn character strings and numbers ) rather than written as it
>is above ? i tried sep = " ", instead of ncolumns butt hat
>just makde things worse. thanks.
>
>for (rownum in 1 (1:nrow(sortedForecastData)) {
>
>outfile=paste(forecsastfiledir,rownames(sortedForecastData[rownum],".mls",sep="")
>
>for colnum in (1:ncol(sortedForecastData) {
>
>if ( colnum == 1 ) {
&...
2006 Jul 24
5
change the name of file
...anging variable?
For instance. I generate random numbers in a loop and at each iteration I
want data to write to file (I do not want to write everything in one file
using 'append'):
for (i in 1:50){
x<-matrix(runif(100, min=0,max=1),nrow=5,ncol=20)
Write(t(x),file="Data_i.txt",ncolumns=5,sep="\t")
}
Of course file name Data_i.txt will be the same for changing i,
unfortunately.
Any suggestion would be appreciate
Robert
2009 Apr 25
2
Extracting an object name?
...tead of files
because of FEAR of reserved words!!!
for(i in 1:length(flies))
{
s <- flies[i]
print(i) # print everything for debugging
print(s)
model <- load(s)
print(model)
z <- predict( model ,rclnow) ############## what will model be?????
print(z)
write( z, fname , append = TRUE, ncolumns = L)
write( as.character(s) , filesused , append = TRUE, ncolumns = 1 )
}
}
THANKS for any help!
Greg Allen
2009 Nov 24
1
write to file append by column
Readers,
Scenario: data x consists of one column;
1
2
3
data y;
4
5
6
Is it possible to write to file such that the file is:
1,4
2,5
3,6
using the write.file function? I have tried the command:
write(x,file="file.csv",ncolumns=1,append=TRUE,sep=",")
write(y,file="file.csv",ncolumns=1,append=TRUE,sep=",")
but the result is:
1
2
3
4
5
6
yours,
rhelpatconference.jabber.org
r 251
mandriva 2008
2002 Apr 17
1
concat
...to return the list into variables
trial1,trial2,...trial10
is there a generic way to get this to happen
i have a similar process that does the same thing to an external file:
paste("connection", trial, ".net", sep="") -> outfile
write(header, file=outfile, ncolumns=2)
write("*Edges", file=outfile, append=TRUE)
write(connection, file=outfile, ncolumns=2, append=TRUE)
where trial progresses so that these outputs are written to
connection1.net, coneection2.net and so forth
i am having a tough time figuring out how to do the same for a variable...
2006 Dec 18
2
write() gotcha
Hi
I used write() the other day to save some results.
It seems that write() does not record the full precision of
the objects being written:
> write(pi,file="~/f",ncolumns=1)
> pi.saved <- scan("~/f")
Read 1 item
> dput(pi)
3.14159265358979
> dput(pi.saved)
3.141593
> pi-pi.saved
[1] -3.464102e-07
>
This difficulty was particularly difficult to find because pi.saved
*looks*
the same as pi.
What's going on here?
>...
2008 Mar 30
2
problem with white space
...ers. I am currently doing this by first inserting a space
after each character in the dataset and then using the following commands:
y <- as.matrix(read.table("data.txt"), stringsAsFactors=FALSE)
bstrap <- sample(length(y), 100000, TRUE)
write(y[bstrap], file="Rep1.txt", ncolumns=50, append=FALSE)
bstrap <- sample(length(y), 100000, TRUE)
write(y[bstrap], file="Rep2.txt", ncolumns=50, append=FALSE)
bstrap <- sample(length(y), 100000, TRUE)
.
.
.
and so on for 500 reps.
I think there should be a better way of doing this. My specific questions:
1. Is there...
2009 Jul 21
3
writte file doubt
Hi I wrotte this function but when I get the "tmp.xls" file it shows data
in a rare way. I mean not appears a matrix with 2000 rows and 100 columns.
Can anyone help me, guide me?
kim<-function(){
tmp<-randz<-matrix(rnorm(200000, mean=0,sd=0.01 ),2000,100);
dim(tmp)
write(tmp,file="tmp.xls")
Thanks in advance.
On the other hand, everytime I execute a function
2011 Dec 12
1
littler: Use for batch processing of data sets: How to pass filename?
...(argv) | length(argv)!=1) {
cat("Usage: auswertung.r datafile \n")
q()
}
filename <- as.character(argv[1])
d = data.frame(x=scan("/tmp/data"))
write(sum(d$x), "/tmp/data.result", ncolumns=1)
Could someone help me how I can substitude `/tmp/data` with the value
stored in `filename`? I do not get it to work using `do.Call` or
`paste()`.
Thanks,
Paul
[1] http://code.google.com/p/littler/
-------------- next part --------------
1
2
3
4
-------------- next part --------------
#!/us...
2012 May 15
2
Transfering data from R list to other document format
...uot;My first list", matrix(1:6, ncol=3), c(1,2,3,4,5,6) )
# Imagining I forgot something and want to add it to the list like:
list1[[4]] <- list(c(4,4,4), "This is it")
# Now I want to transfer the list to e.g. a text document:
lapply(L1, write, "test.txt", append=TRUE, ncolumns=100)
However, this does not work and I don't know why. Also I would be interested
in better options to get lists out of R (with tables I never had any
problems).
Thank you for your help and ideas!
--
View this message in context: http://r.789695.n4.nabble.com/Transfering-data-from-R-list-to...
2007 May 20
4
Running an R script without running R
Is there any way to run an R script without running R?
As an example, suppose I have a tcl/tk interface that asks
for a number (in a GUI) and displays its factorial. Is there a
way to invoke this script without invoking R?
I'm using R 2.4.1 in GNU/Linux Fedora Core 4.
Alberto Monteiro
2018 May 18
3
Exporting to text files
...811 0.009801 **
e:(Intercept) 94.493 59.579 1.5860 0.143820
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
Residual standard error:
22.03492 (10 degrees of freedom)
> write(summary(mymodel), "kinetics.txt")
Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"), :
argument 1 (type 'list') cannot be handled by 'cat'
If I try to unlist(mymodel):
> write(unlist(summary(mymodel)), "kinetics.txt")
I get the following contents of "kinetics.txt":
485.537711262143
4501.62443636671
3821.31920509004...
2012 Jan 11
3
summarizing a complex dataframe
I need some help summarizing complex data frames (small example below):
m1_1 m2_1 m3_1 m1_2 m2_2 m3_2
i1 1 1 1 2 2 2
i1 2 1 1 2 2 2
i2 2 2 1 2 2 2
For an arbitrary number of columns (say m1 ?. m199) where the column names have variable patterns,
and such that each set of columns is repeated (with potentially unique data) an
2005 Jun 01
1
A problem on sink() and format,suggestions appreciated
Dear R users
I get a weired problem when use sink:
since the data set pretty big, I sink intermediate result for further
use,following
lines are consistently used when write data
###########################
sink("dataname.txt")
data
sink()
##########################
at first couples of run, all 10 variables are wrote to a file in following
format:
V1 V2 ....... V10
1