[R] Output of tapply function as data frame

2024-03-26 Thread Ogbos Okike
Warm greetings to you all. Using the tapply function below: data<-read.table("FD1month",col.names = c("Dates","count")) x=data$count f<-factor(data$Dates) AB<- tapply(x,f,mean) I made a simple calculation. The result, stored in AB, is of the form below. But an effort to write AB to a file as a

Re: [R] Printout and saved results

2024-03-26 Thread Ben Bolker
Fragile and probably a bad idea, but: "%.%" <- function(x,y) { assign(deparse(substitute(x)), y, parent.frame()); print(y) } > a %.% "hello" [1] "hello" > a [1] "hello" Not sure how much value this has over other idioms such as wrapping the assignment in parentheses, which makes

Re: [R] Printout and saved results

2024-03-26 Thread avi.e.gross
Just FYI, the R interpreter typically saves the last value returned briefly in a variable called .Last.value that can be accessed before you do anything else. > sin(.5) [1] 0.4794255 > temp <- .Last.value > print(temp) [1] 0.4794255 > sin(.666) [1] 0.6178457 > .Last.value [1] 0.6178457 > temp [1]