similar to: Writing text files out of a dataset

Displaying 20 results from an estimated 10000 matches similar to: "Writing text files out of a dataset"

2017 Dec 29
0
Writing text files out of a dataset
Hello, You have to create the vector 'd' outside the loop before using it. d <- numeric(nrow(data)) Only then comes the loop. Hope this helps, Rui Barradas On 12/29/2017 2:31 PM, Luca Meyer wrote: > Hello, > > I am trying to run the following syntax for all cases within the dataframe > "data" > > d1 <- data[1,c("material")] >
2011 Jul 04
1
writeLines + foreach/doMC
Hi I'm processing sequencing data trying to collapsing the locations of each unique sequence and write the results to a file (as storing that in a table will require 10GB mem at least) so I wrote a function that, given a sequence id, provide the needed line to be stored library(doMC) # load library registerDoMC(12) # assign the Number of CPU
2011 Apr 24
2
help with "\" in strings
I would like to create a "\%" that can be written to a file as I am writing a procedure to output to latex. I can't create a "\%" and it is driving me crazy. -------------------------------------- x = "This is a test % string" gsub ("%", "\\%", x) fileConn<-file("c:/biostats/test.txt") writeLines(x, fileConn) close(fileConn)
2012 Aug 06
5
regexpr with accents
Hello, I have build a syntax to find out if a given substring is included in a larger string that works like this: d1$V1[regexpr("some text = 9",d1$V2)>0] <- 9 and this works all right till "some text" contains standard ASCII set. However, it does not work when accents are included as the following: d1$V1[regexpr("some t?xt = 9",d1$V2)>0] <- 9 I have
2018 Apr 22
3
How to dynamically add variables to a dataframe
Hi, I am a bit rusty with R programming and do not seem to find a solution to add a number of variables to my existing dataframe. Basically I need to add n=dim(d1)[1] variables to my d0 dataframe and I would like them to be named V1, V2, V3, ... , V[dim(d1)[1]) When running the following code: for (t in 1:dim(d1)[1]){ d0$V[t] <- 0 } all I get is a V variable populated with zeros... I am
2018 Apr 30
3
How to visualise what code is processed within a for loop
Luca, If speed is important, you might improve performance by making d0 into a true matrix, rather than a data frame (assuming d0 is indeed a data frame at this point). Although data frames may look like matrices, they aren?t, and they have some overhead that matrices don?t. I don?t think you would be able to use the [[nm]] syntax with a matrix, but [ , nm] should work, provided the matrix has
2018 Apr 24
4
How to visualise what code is processed within a for loop
Hi, I am trying to debug the following code: for (i in 1:10){ t <- paste("d0$V",i,sep="") t <- ifelse(regexpr(d1[i,1],d0$X0)>0,1,0) } and I would like to see what code is actually processing R, how can I do that? More to the point, I am trying to update my variables d0$V1 to d0$V10 according to the presence or absence of some text (contained in the file d1)
2018 Apr 28
2
How to visualise what code is processed within a for loop
I forgot to explain why my suggestion. The logical condition returns FALSE/TRUE that in R are coded as 0/1. So all you have to do is coerce to integer. This works because the ifelse will return a 1 or a 0 depending on the condition. Meaning exactly the same values. And is more efficient since ifelse creates both vectors, the true part and the false part, and then indexes those vectors in
2018 Apr 28
2
How to visualise what code is processed within a for loop
Thanks Don, for (i in 1:10){ nm <- paste0("V", i) d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0) } is exaclty what I needed. Best regards, Luca 2018-04-25 23:03 GMT+02:00 MacQueen, Don <macqueen1 at llnl.gov>: > Your code doesn't make sense to me in a couple of ways. > > Inside the loop, the first line assigns a value to an
2018 Apr 30
0
How to visualise what code is processed within a for loop
Hi Rui Thank you for your suggestion, I have tested the code suggested by you against that supplied by Don in terms of timing and results are very much aligned: to populate a 5954x899 0/1 matrix on my machine your procedure took 79 secs, while the one with ifelse employed 80 secs, hence unfortunately not really any significant time saved there. Nevertheless thank you for your contribution.
2018 Apr 30
0
How to visualise what code is processed within a for loop
Thank you for both replies Don & Rui, The very issue here is that there is a search that needs to be done within a text field and I agree with Rui later comment that regexpr might indeed be the time consuming piece of code. I might try to optimise this piece of code later on, but for the time being I am working on the following part of building a neural network to try indeed classifying some
2018 Apr 22
0
How to dynamically add variables to a dataframe
Hi Luca, How about this? # create some dummy data since I don't have your d0 or d1 > n <- 3 > d0 <- data.frame(a=runif(5),b=runif(5)) # here's the suggested code > d1 <- cbind(d0, matrix(0,nrow(d0),n)) > colnames(d1)[1:n + ncol(d0)] <- paste("V",1:n,sep="") HTH, Eric On Sun, Apr 22, 2018 at 11:13 AM, Luca Meyer <lucam1968 at
2005 May 19
1
problems with truncate() with files > 2Gb under Windows (possibly (PR#7879)
This message relates to handling files > 2Gb under Windows. (I use 2Gb as shorthand for 2^31-1 -- the largest integer representable in a signed 32 bit integer.) First issue: truncate() is not able to successfully truncate files at a position > 2Gb. This appears to be due to the use of the Windows function chsize() in file_truncate() in main/connections.c (chsize() takes a long int
2008 Jul 17
2
problems with validation on STI
I have the following STI table: def self.up create_table :distributions do |t| t.string :type t.integer :simulation_id t.string :dist_name t.string :desc, :default=> ''fixed'' t.float :param1, :default => 5.0 t.float :param2, :param3 t.timestamps #fields for RscDist t.integer :resource_id #fields for LoadDist
2011 Feb 09
1
Adding labels into lattice's barchart
*** APOLOGIZES FOR THOSE READING THE LIST THROUGH NABBLE THIS WAS ALREADY POSTED THERE BUT NOT FORWARDED TO THE LIST FOR SOME UNKNOWN REASON *** I have a dataset that looks like: $ V1: factor with 4 levels $ V2: factor with 4 levels $ V3: factor with 2 levels $ V4: num (summing up to 100 within V3 levels) $ V5: num (nr of cases for each unique combination of V1*V2*V3 levels) Quite new to
2018 Apr 28
0
How to visualise what code is processed within a for loop
Hello, instead of ifelse, the following is exactly the same and much more efficient. d0[[nm]] <- as.integer(regexpr(d1[i,1], d0$X0) > 0) Hope this helps, Rui Barradas On 4/28/2018 8:45 PM, Luca Meyer wrote: > Thanks Don, > > for (i in 1:10){ > nm <- paste0("V", i) > d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0) > }
2018 Apr 24
0
How to visualise what code is processed within a for loop
The loop never assigns anything to d0, only t. The first line makes t a character string "d0$V1" (or "d0$V2" etc.). The second line assigns either 0 or 1 to t. Looking at this, I don't think you've got into the R psychology (bad news if you want to use R, good news in many other ways). I assume d0 is a list, so could you put the V's into a vector, and then just use
2018 Apr 25
0
How to visualise what code is processed within a for loop
Your code doesn't make sense to me in a couple of ways. Inside the loop, the first line assigns a value to an object named "t". Then, the second line does the same thing, assigns a value to an object named "t". The value of the object named "t" after the second line will be the output of the ifelse() expression, whatever that is. This has the effect of making
2011 Aug 28
4
How do I get a weighted frequency table?
? 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/20110828/d35f51a1/attachment.pl>
2011 May 04
2
speexenc/speexdec doubles file size
this is not really a development question, but i didn't find another mailing list to ask it. any idea why size of wav file doubles when it is encoded to speex and back to wav: $ ls -ls testi.wav 40 -rw-r--r-- 1 foo foo 40674 May 4 14:38 testi.wav $ speexenc --denoise --agc --quality 10 testi.wav testi.spx Encoding 8000 Hz audio using narrowband mode (mono) $ ls -ls testi.spx 20