Hello,
Maybe something like the following is what you want.
I have added an extra argument 'fill' to allow to choose what to print
in the end. It's default value is "" making the entire matrix elements
characters but it can be NA or 0.
print0 <- function(x, len = 10, digits = 2, fill = ""){
Dear All:
Below is what I meant. Procedure print0 allows me to print a vector of
length 53 in four rows of 10 plus 1 row of 3 (Ido not like the NA). This
is silly. I am hoping that there is a candid way to print the matrix.
Thank you.
Steven Yen
===
n<-53; x<-runif(n); # x<-round(x,2)
print0
Is there a convenient way to print a vector into rows of a specified
column length? What I need is to print in the old FORTRAN format, viz.,
format(10F8.2)
which would print, for instance, a vector of 25 into two rows of 10 plus
an incomplete row of 5. I managed to write a procedure for that ta
Thank you much, this was very helpful. Jim’s and Daniel’s code was spot on.
Indeed, as Jeff Newmiller pointed out, one of the problems was that I assumed
that R could recognise decimals - I did as Richard O’Keefe suggested and the
problem was gone.
Thanks again!
Faradj
> On 21 Jul 2019, a
Here is one more option using the ave() function. Using Jim's data and
naming convention
fkdf$X1_change <- ave(fkdf[,'X1'], fkdf$Country, FUN=function(x)
c(0,diff(x)))
fkdf$X2_change <- ave(fkdf[,'X2'], fkdf$Country, FUN=function(x)
c(0,diff(x)))
hope this is helpful,
Dan
--
Daniel Nordlun
5 matches
Mail list logo