Displaying 20 results from an estimated 2000 matches similar to: "Column renaming"
2008 May 12
2
Collection of lm()s
Hello,
I would like to create a subscriptable collection (presumably a list)
of lm() models.
I have a data frame DX containing 6 groups of data. The general idea
is (NOT RUN) ...
for (i in 1:6)
{ DXS = subset( DX, <whatever>);
LMX[ i] = lm( <formula>, data = DXS);
}
Now access model results by subscript ... e.g. coefficients( LMX[
2]). Or would it be [[ 2]]?
I
2008 May 09
1
Data frame row manipulation
Greetings,
Q #1
------
How does one combine data frames by row ... no cleverness a la
merge(), just add rows.
For example, given A with 20 rows and B with 30 rows, I want C =
combine( A, B) having 50 rows.
Columns having matching names should be filled from both (all)
sources with suitable coercion, unmatched would get NA in rows whose
source does not have that column.
Q #2
------
Given
2008 Apr 30
1
Aggregate() questions
Dear all --
I have a data frame containing data related to heat gain through
windows. The general form is ...
Key ProfA IAC <many other numeric columns>
AAA 0 .7
AAA 10 .6
AAA 0 .66
AAA 20 .45
(more AAA rows)
(then AAB rows)
'Key' identifies the physical configuration ... rows with a given Key
contain data for same window under various
2008 May 28
1
Grouped weighted.mean
Dear all --
I want to compute weighted.mean() for grouped rows.
Data frame extract is just below. For each Key, I want the mean of
IAC weighted by Wt.
DP0[1:20,]
Key
IAC Wt
2 C3-PD030020050.PD030020050.3.12.3.0 0.765 0.8590000
3 C3-PD030020050.PD030020050.3.12.3.0 0.764 0.8449651
4 C3-PD030020050.PD030020050.3.12.3.0
2008 May 30
1
Aggregation and the meaning of class
Dear R-ers,
My aggregation saga continues.
Using the following sequence, I can calculate any statistic for row
groups and merge the result back to all associated rows ...
> WM = by( D60, D60[ "KeyProfA"], FUN=function(x) weighted.mean( x$IAC, x$Wt))
> D60$IAC.WM = as.numeric( WM[ D60$KeyProfA])
> class( WM)
[1] "by"
Questions ...
1) Is this a reasonable way
2008 Apr 07
2
predict.lm() question
Dear R-people ...
I'm a new user. I can't get predict.lm() to produce predictions for
new independent data. There are some messages in archived help about
this problem, but I still don't see my error after reviewing
those. I understand that the new independent data must have the same
name(s) as used when the model was made.
In the example below, predict.lm produces the
2004 Jun 08
1
data.frame size limit
Is there a limit to the number of columns that a data.frame can have? For
example, can I read.csv() a file that has 1000 columns and 10,000 rows,
will it break or is it limited by available memory.
...................................................................................
Philip Sobolik 781-862-8719 x111
Wrightsoft Corporation 781-861-2058 fax
394 Lowell
2017 Jun 26
2
Odd behaviour in within.list() when deleting 2+ variables
The behaviour of within() with list input changes if you delete 2 or more variables, compared to deleting one:
l <- list(x=1, y=2, z=3)
within(l,
{
rm(z)
})
#$x
#[1] 1
#
#$y
#[1] 2
within(l, {
rm(y)
rm(z)
})
#$x
#[1] 1
#
#$y
#NULL
#
#$z
#NULL
When 2 or more variables are deleted, the list entries are instead set to NULL. Is this intended?
2008 Dec 23
3
Using transform to add a date column to a dataframe
I would like to add a column to the airquality dataset that contains the date
1950-01-01 in each row. This method does not appear to work:
> attach(airquality)
> data1 <- transform(airquality,Date=as.Date("1950-01-01"))
Error in data.frame(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L, 23L, 19L, :
arguments imply differing number of rows: 153, 1
I can't decipher what
2005 Jul 01
2
Simple indexing conundrum
My apologies in advance for my thickness but I can't seem to solve the
following, seemingly simple, data manipulation problem:
I have a data frame that contains multiple factors and multiple
continuous response variables, but duplicates of some factor
combinations. The duplicates contain bad data, so I would like to
eliminate the duplicates. I would like to retain the entire rows
2017 Jun 26
2
Odd behaviour in within.list() when deleting 2+ variables
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 26 Jun 2017 13:43:28 +0200 writes:
> This seems to be due to changes made by Martin Maechler in
> 2008. Presumably this fixed something, but it escapes my
> memory.
Yes: The change set (svn -c46441) also contains the following NEWS entry
BUG FIXES
o
2010 Jan 24
2
How to define degree=1 in mgcv
Hi, all
I have a question on mgcv and ns. Now I want to compare the results from
glm, gam and ns. Take a simple model y~x for example.
glm1 = glm(y~x, data=data1)
gam1 = gam(y~s(x), data=data1)
ns1 = glm(y~ns(x),data=data1)
In order to confirm the result from glm1 is consistent to those from gam1
and ns1, I want to define degree=1 in mgcv and ns. I am wondering if there
is somebody can give me
2001 Mar 22
1
two easy questions...
Hi all.
1) If I have a dataframe with variable names as follow: PC1 PC2 ... PCn and I want to pass only some of them to a function, e.g.
glm(resp~from PC1 to PC10, PC15, etc.,...)
is there a faster way than simply writing each variable name in the formula?
2) Again, I have a dataframe, say ali.df, with tha following variables: ali1, ali2, ...ali78
I want to sum, for example, ali1+al2+ali7+f rom
2007 Sep 16
1
Identifying objects from a data set
Hello
Given the following data for a data set called airquality. To identify the nature of the objects from the data set airquality example "Ozone" would it be best to use the command is. like is.character(airquality$Ozone) ....... I tried attributes(airquality$Ozone) but it came up null. Would there be a better way to identify these objects.
Thanking you in advance for your
2010 Nov 11
4
Troubleshooting sweave
Hi All,
I've reproduced the example from Prof. Friedrich Leisch's webpage. When I
write sweave("Example-1.Snw") OR sweave("Example-1.Rnw"), (yes, I renamed
them). I get the following error:
Writing to file example-1.tex
Processing code chunks ...
1 : echo term verbatim
Error: chunk 1
Error in library(ctest) : there is no package called 'ctest'
Also while
2011 Aug 04
1
randomForest partial dependence plot variable names
Hello,
I am running randomForest models on a number of species. I would like to be
able to automate the printing of dependence plots for the most important
variables in each model, but I am unable to figure out how to enter the
variable names into my code. I had originally thought to extract them from
the $importance matrix after sorting by metric (e.g. %IncMSE), but the
importance matrix is n
2008 Mar 24
2
Newbie help with Sweave
I think I've gotten my Emacs/Sweave/R system set up correctly, thanks to
Vincent and Jim, but I haven't been successful getting my first document
produced. I'm trying to use one of Friedrich Leisch's examples,
http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw. I cut and
pasted the text into a document sweaveexample.Rnw in Emacs. It seemed to
be processed successfully with R:
2006 Jan 29
1
What does this command "~" mean?
Hi all,
I am reading books and tutorials about R.
I don't understand the following:
plot(salary~rank, data=salary)
plot(Ozone~date, data=airquality)
I don't understand what does "~" here, and how can plot() have a input
argument called "data"... I have looked it up in "plot"'s help but I could
not find about argument "data".
Could you please
1999 Aug 24
3
Error in get(x, envir, mode, inherits)
Dear R list,
members of my course have encountered the following error message:
> slm <- lm(price ~ engsize, autoframe)
Error in get(x, envir, mode, inherits) : variable "FUN" was not found
[more context is given in the fuller listing below].
Once the error is encountered it seems to persist; for example early in one
session:
> summary(blin.fit)
Call:
lm(formula = Response
2011 Dec 23
2
cast in reshape and reshape2
> library(reshape2)
> x = melt(airquality, id=c('month', 'day'))
With reshape I can cast with multiple functions:
> library(reshape)
> cast(x, month+variable~., c(mean,sd))
month variable mean sd
1 5 ozone 23.615385 22.224449
2 5 solar.r 181.296296 115.075499
3 5 wind 11.622581 3.531450
4 5 temp 65.548387