similar to: write.csv feature/bug with pipe

Displaying 20 results from an estimated 10000 matches similar to: "write.csv feature/bug with pipe"

2009 Oct 27
2
Why I get this error? Error in close.connection(f) : invalid connection
I don't understand why I can not close 'f'. This may be very simple, but I don't see why. Could somebody let me know? $ cat gzfile.csv "","V1","V2","V3","V4","V5" "1",1,5,9,13,17 "2",2,6,10,14,18 "3",3,7,11,15,19 "4",4,8,12,16,20 $ Rscript gzfile.R > f =
2009 Feb 22
2
how to recover a list structure
I am experiencing some problems at working with lists at high level. In the following "coef" contains the original DWT coefficients organized in a list. Thorugh applying the following two commands: coef.abs <- lapply(unlist(coef,recursive=FALSE,use.names =TRUE),abs) coef.abs.sorted <- sort(unlist(coef.abs),decreasing=TRUE) I get vector "coef.abs.sorted" containing
2012 Mar 30
4
list assignment syntax?
Dear R wizards: is there a clean way to assign to elements in a list? what I would like to do, in pseudo R+perl notation is f <- function(a,b) list(a+b,a-b) (c,d) <- f(1,2) and have c be assigned 1+2 and d be assigned 1-2. right now, I use the clunky x <- f(1,2) c <- x[[1]] d <- x[[2]] rm(x) which seems awful. is there a nicer syntax? regards, /iaw ---- Ivo Welch
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
2008 Jun 03
3
How to solve a non-linear system of equations using R
Dear R-list members, I've had a hard time trying to solve a non-linear system (nls) of equations which structure for the equation i, i=1,...,4, is as follows: f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0 (1) In the expression above, both f_i and k_i are known functions and l, m and s are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4) which is solution
2009 Feb 12
2
beginner's question: group of regressors by name vector?
dear r-experts: there is probably a very easy way to do it, but it eludes me right now. I have a large data frame with, say, 26 columns named "a" through "z". I would like to define "sets of regressors" from this data frame. something like myregressors=c("b", "j", "x") lm( l ~ myregressors, data=... ) is the best way to create new
2010 Jan 08
4
fast lm se?
dear R experts---I am using the coef() function to pick off the coefficients from an lm() object. alas, I also need the standard errors and I need them fast. I know I can do a "summary()" on the object and pick them off this way, but this computes other stuff I do not need. Or, I can compute (X' X)^(-1) s^2 myself. Has someone written a fast se() function? incidentally, I think
2010 Jun 11
3
lm without error
this is not an important question, but I wonder why lm returns an error, and whether this can be shut off. it would seem to me that returning NA's would make more sense in some cases---after all, the problem is clearly that coefficients cannot be computed. I know that I can trap the lm.fit() error---although I have always found this to be quite inconvenient---and this is easy if I have only
2012 May 09
2
big quasi-fixed effects OLS model
dear R experts---now I have a case where I want to estimate very large regression models with many fixed effects---not just the mean type, but cross-fixed effects---years, months, locations, firms. Many millions of observations, a few thousand variables (most of these variables are interaction fixed effects). could someone please point me to packages, if any, that would help me estimate such
2011 Apr 21
1
Help with matching rows
Dear Sir, Please excuse my akwardness as I a new to R and computers, but would kindly appreciate help. { a <- sample (1:10,100,replace=T ) b <-sample(10:20,100,replace=T) c <- sample(20:30,100,replace=T) d <- sample(30:40,100,replace=T) e <- sample(40:50,100,replace=T) } d1 <- a d2 <- b d3 <-c d4 <- d d5 <- e data.frame(d1,d2,d3,d4,d5) dd <-
2012 Nov 22
1
Data Extraction - benchmark()
Hi Berend, I see you are one of the contributors to the rbecnhmark package. I am sorry that I am bothering you again. I have tried to run your code (slightly tweaked) involving the benchmark function, and I am getting the following error message. What am I doing wrong? Error in benchmark(d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df), : could not find function
2011 Jan 15
2
Rounding variables in a data frame
Hi All I am trying to use the round function on some columns of a dataframe while leaving others unchanged. I wish to specify those columns to leave unchanged. My attempt is below - here, I would like the column d3 to be left but columns d1, d2 and d4 to be rounded to 0 decimal places. I would welcome any suggestions for a nicer way of doing this. d1= rnorm(10,10) d2= rnorm(10,6) d3=
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, The obvious way would be to preallocate the resulting data.frame, to expand an empty one on each iteration being a time expensive operation. n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D4 <- data.frame(distance=integer(n),difference=integer(n)) k <- 0 for (i in 1:nrow(D1)){ for (j in 1:nrow(D2)) { k <- k + 1 D4[k, ] <-
2010 Jun 14
2
Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ?
Hi R help, Hi R help, Which is the easiest (most elegant) way to force "aov" to treat numerical variables as categorical ? Sincerely, Andrea Bernasconi DG PROBLEM EXAMPLE I consider the latin squares example described at page 157 of the book: Statistics for Experimenters: Design, Innovation, and Discovery by George E. P. Box, J. Stuart Hunter, William G. Hunter. This example use
2009 Feb 09
2
How to plot multiple graphs each with multiple y variables
I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow.  The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1))
2009 Mar 20
4
how to make aggregation in R ?
Hi, I am trying to aggregate the sum of my test data.frame as follow: testDF <- data.frame(v1 = c("a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "d", "d", "d", "d",
2017 Jun 23
1
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, Another way would be n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D5 <- data.frame(distance=integer(n),difference=integer(n)) D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) t(sapply(seq_len(nrow(D2)), function(j){ c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2) } )))) identical(D3, D5) In my first answer I forgot to say that
2017 Jun 23
4
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
For certain reason, the content was not visible in the last mail, so posting it again. Dear Members, I have two different dataframes with a different number of rows. I need to apply a set of functions to each possible combination of rows with one row coming from 1st dataframe and other from 2nd dataframe. Though I am able to perform this task using for loops, I feel that there must be a more
2011 May 17
2
Minimum value by ID
Hello, I have a longitudinal dataset where each individual has a different number of entries. Thus, it is of the following structure: x <- runif(12) id.var <- factor(c(rep("D1",4),rep("D2",2),rep("D3",3),rep("D4",3))) dat <- as.data.frame(x) dat$id.var <- id.var dat > dat x id.var 1 0.9611269 D1 2 0.6738606 D1 3
2013 Feb 06
5
First R Package --- Advice?
Dear R experts--- after many years, I am planning to give in and write my first R package. I want to combine my collection of collected useful utility routines. as my guide, I am planning to use Friedrich Leisch's "Creating R Packages: A Tutorial" from Sep 2009. Is there a newer or better tutorial? this one is 4 years old. I also plan on one change---given that the