Displaying 20 results from an estimated 4000 matches similar to: "Applying a transformation to multiple data frame columns"
2010 Feb 14
4
Newbie woes with *apply
Dataframe cust has Date-type column open.date. I wish to set up another
column, with (first day of) the quarter of open.date.
To be comprehensive (of course, improvement suggestions are welcome),
month = function(date)
{
return(as.numeric(format(date,"%m")))
}
first.day.of.month = function(date)
{
return(date + 1 - as.numeric(format(date,"%d")))
}
first.day.of.quarter =
2010 Aug 26
5
Quick GREP challenge
> grep("f[0-9]+=", "f1=5,f22=3,", value = T)
[1] "f1=5,f22=3,"
How do I make the line output c("f1", "f22") instead? (Actually, c(1,22)
would be even better).
Thank you.
--
View this message in context: http://r.789695.n4.nabble.com/Quick-GREP-challenge-tp2339486p2339486.html
Sent from the R help mailing list archive at Nabble.com.
2010 Sep 06
3
Failure to aggregate
I have a (very big - 1.5 rows) dataframe with a (POSIXt" "POSIXlt") column h
(hour). Surprisingly, I cannot calculate a simple aggregate over the
dataframe.
> n.h1 = sqldf("select distinct h, count(*) from x group by h")
Error in sqliteExecStatement(con, statement, bind.data) :
RS-DBI driver: (error in statement: no such table: x)
In addition: Warning message:
In
2010 Jan 24
3
Is there a quicker way to drop a data frame column than setting it to NULL?
If I want to drop columns x, y, z from dataframe df, is there a better
alternative to
df$x = NULL
df$y = NULL
df$z = NULL
There are sufficiently many columns remaining to make
df = subset(df, select = c(a,b,c,d[etc]))
cumbersome.
Thank you.
--
View this message in context: http://n4.nabble.com/Is-there-a-quicker-way-to-drop-a-data-frame-column-than-setting-it-to-NULL-tp1288617p1288617.html
2010 Jan 23
3
How to implement a "select distinct x, count(distinct y) ... group by x" for a data frame
... Being an R newbie, I can only think of extracting distinct x values with
unique, looping over them, extracting matching rows from the original data
frame, applying table, and recording the size of table's output alongside
the x value being checked. Is there a more elegant way?
Thank you.
--
View this message in context:
2007 Oct 21
6
exporting text output to pdf
Hello,
I am new to R and I am trying to figure out how to print text output from an operation like table() to a pdf file. Is there a simple command to do this, or do you need to work with connections at a rudimentary level?
Thanks you,
Jesse
[[alternative HTML version deleted]]
2011 Oct 12
3
Applying function to only numeric variable (plyr package?)
My data frame consists of character variables, factors, and proportions,
something like
c1 <- c("A", "B", "C", "C")
c2 <- factor(c(1, 1, 2, 2), labels = c("Y","N"))
x <- c(0.5234, 0.6919, 0.2307, 0.1160)
y <- c(0.9251, 0.7616, 0.3624, 0.4462)
df <- data.frame(c1, c2, x, y)
pct <- function(x) round(100*x, 1)
I want to
2010 Apr 28
2
How to read contents of a text file into a single string?
... Both readLines() and scan() produce a number_of_lines x 1 vector; trying
paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector
elements (lines) into a single string?
Thank you.
--
View this message in context: http://r.789695.n4.nabble.com/How-to-read-contents-of-a-text-file-into-a-single-string-tp2069303p2069303.html
Sent from the R help mailing list archive at
2010 Feb 14
2
Problems with boxplot in ggplot2:qplot
Dataframe closed contains balances of closed accounts: each row has month of
closure (Date-type column month) and latest balance. I would like to plot
by-month distributions of balances. A qplot call below produces several
warnings and no output.
Can anyone help?
Thank you.
PS. A really basic task, very similar to the examples on p. 71 of the
ggplot2 book, apart from a Date grouping column; I
2015 Aug 17
2
Update from 6.6 to 6.7 > automount logs error message
On Mon, Aug 17, 2015 at 8:39 AM, Phelps, Matthew <mphelps at cfa.harvard.edu>
wrote:
>
>
> On Tue, Aug 11, 2015 at 10:55 AM, Ralf Aum?ller <
> Ralf.Aumueller at informatik.uni-stuttgart.de> wrote:
>
>> Hello,
>>
>> after an update from 6.6 to 6.7 the following error message is logged to
>> /var/log/messages when I login (per ssh):
>>
2010 Dec 27
1
Can't merge on datetime?
x = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L,
3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L,
23L, 24L,
2010 Apr 07
1
unexpected behaviour with ddply and colwise
Hi,
I am confused by results from:
> ddply(aa, names(aa), colwise(sum))
I thought ddply was just calling colwise(sum)() with each column.
However ddply() returns a 13 x 5 result !!
The general result I expected is similar to that of apply() , or
using colwise(sum)() alone. Shouldn't ddply() produce the same ?
Thanks in advance for your help,
- Stuart Andrews
>
2010 Feb 02
1
[R] Suppressing scientific notation on plot axis tick labels (PR#14202)
On 02/02/2010 6:20 AM, Dimitri Shvorob wrote:
> Ruben Roa has kindly suggested using 'scipen' option - cf.
>
>> fixed notation will be preferred unless it is more than ???scipen??? digits
>> wider.
>
> However,
>
> options(scipen = 50)
> x = c(1e7, 2e7)
> barplot(x)
>
> still does not produce the desired result.
This is strange. I see what
2008 Nov 03
4
How do you apply a function to each variable in a data frame?
I want to apply a more complicated function than what I use in my example,
but the idea is the same:
Suppose you have a data frame named x and you want to a function applied to
each variable, we'll just use the quantile function for this example. I'm
trying all sorts of apply functions, but not having luck. My best guess
would be:
sapply(x, FUN=quantile)
--
View this message in
2015 Aug 11
3
Update from 6.6 to 6.7 > automount logs error message
Hello,
after an update from 6.6 to 6.7 the following error message is logged to
/var/log/messages when I login (per ssh):
Aug 11 16:31:21 a1234 automount[1598]: set_tsd_user_vars: failed to get passwd
info from getpwuid_r
Checked all log-files of my systems running 6.6 with same configuration -- never
got such a message (We use NFS/autofs for home-directories, NIS and tcsh (login
shell)).
2011 May 23
1
Applying boxplot.stats to multiple value lists
Hello all R gurus,
I have a following problem which I hope someone will help me to solve.
I have a data.frame in form similar to below. > testframe<-data.frame("Name"=c("aa","aa","aa","aa","aa","bb","bb","bb","bb","bb"),"Value"=c(1,100,1,1,1,100,100,100,100,1))
2010 Feb 21
2
Newbie woes with par:mar
I have a simple barchart with horizontal bars and horizontal tick labels,
produced with
barplot(x, horiz = T, names.arg = c, las = 1)
The labels are longish strings, truncated on the plot. I wish to leave more
space for the left margin, and experiment with mar parameter,
barplot(x, horiz = T, names.arg = c, las = 1, mar = c(5, 15, 4, 2))
trying various values for the second vector element, but
2010 Dec 25
1
Extracting a dataframe column as a dataframe
> x = structure(list(time = structure(c(1020232904.818, 1020232904.818
), class = c("POSIXt", "POSIXct"), tzone = ""), price = c(321,
323.5)), .Names = c("time", "price"), row.names = 1:2, class = "data.frame")
> x1 = x[,c("price")]
> dput(x1)
c(321, 323.5)
Is there similar syntax that gets "price" as a
2013 Jun 18
1
transform 3 numeric vectors empty of 0/1
Dear all,
Without a loop, I would like transform 3 numeric vectors empty of 0/1 of
same length
Vec1 : transform 1 to A and 0 to ""
Vec2 : transform 1 to B and 0 to ""
Vec3 : transform 1 to C and 0 to ""
to obtain only 1 vector Vec who is the paste of the 3 vectors (Ex : ABC,
BC, AC, AB,...)
Any idea ?
Thank you for your help
--
Michel ARNAUD
2019 Sep 25
3
Update to Centos 7.7 / Arch ppc64le / Problem with nvidia driver
Hello,
today I updated a CentOS 7.6 ppc64le machine to CentOS 7.7. After reboot to the
new kernel (4.18.0-80.7.2.el7.ppc64le) dkms could not build the nvidia-module.
Error-message from dkms:
Compiler version check failed:
The major and minor number of the compiler used to
compile the kernel:
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
does not match the compiler used here:
cc (GCC)