hi
thank you all for the great replies, very useful indeed even if some of them
a bit too aggressive (which is never, ever a good approach in my very humble
opinion... but that's a matter of taste and style I do not want to discuss
here); sorry again for bothering someone with such a trivial and
i
Turns out my column and row names were too long to fit in the console and
when I widened the window the table didn't automatically adjust and widen
as well. I had to widen the console first and then retype the same command
so it fit. Silly mistake. I usually keep the console pretty narrow on my
lap
Oops, Bill's reply and mine crossed in the email. His is essentially
the same as mine except probably more efficient.
-- Bert
Bert Gunter
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
-- Clifford Stoll
On Thu, Jul 23, 2015 at 2:44 PM, Willia
You could do something like the following
> rowsToShiftLeft <- c(2,4,5) # 4, not the 3 that was in the original post
> mat <- as.matrix(df_start)
> mat[rowsToShiftLeft, 1:3] <- mat[rowsToShiftLeft, 2:4]
> result <- data.frame(mat[, 1:3], stringsAsFactors=FALSE)
> str(result)
'data.frame
sorry but honestly I do not get your point
I need to shift to left by one position (i.e. one column) the entire rows
2,4,5 of "df_start" so that to obtain as final result the structure
indicated in "df_end"
I know in advance the rows that I need to shift
hope it clears a bit, now
--
View thi
On Thu, Jul 23, 2015 at 3:56 PM, maxbre wrote:
> Hi
>
> thank you for your reply: it's a neat solution but unfortunately not
> applicable to my specific case;
I'm going to assume you're replying to me, although there's no context
whatsoever in your response (this is the R-help email list, not
Nab
Ah, so apparently you require some sort of psychic abilities...
For how else would one choose which three values to keep in a row that was:
a 2 b 5
based on your specification that "xxx could be anything."
Cheers,
Bert
Bert Gunter
"Data is not information. Information is not knowledge. An
Hi
thank you for your reply: it's a neat solution but unfortunately not
applicable to my specific case;
in fact as I specified in my first post (I may have been not enough clear,
sorry for that!) I can not rely on any search method grep-like because the
value "xxx" in the rows of "df_start" can b
With one minor change to your reproducible example (thank you!):
df_start <- data.frame(v0,v1,v2,v3, stringsAsFactors=FALSE)
data.frame(t(apply(df_start, 1, function(i)i[!grepl("xxx", i)])),
stringsAsFactors=FALSE)
I'll leave it to you to deal with columns that you'd like to have
numeric. (You mi
9 matches
Mail list logo