Dear R users,
I want to extract column's from different data frame with different row
length.
How can I do this in R?
Thank you very much!
best regards!
CR
--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229,
Wow!! Thank you so much for your suggestions! For now, A.K's suggestion #1
is perfect for me!
Thank you very much!
Best,
Charles
On Thu, Oct 17, 2013 at 2:34 AM, William Dunlap wdun...@tibco.com wrote:
You could bump up the day each time an hour was less than the previous
one. E.g.,
Le mercredi 16 octobre 2013 à 23:45 -0400, Earl Brown a écrit :
I'm using the XML package and specifically the saveXML() function but I
can't get the prefix argument of saveXML() to work:
library(XML)
concepts - c(one, two, three)
info - c(info one, info two, info three)
root -
Dear all,
I have been trying to find a simple solution to my problem without success,
though i have a feeling a simple syntaxe detail coul make the job.
I am doing a polynomial linear regression with 2 independent variables such as :
lm(A ~ B + I(B^2) + I(lB^3) + C, data=Dataset))
R return
-Original Message-
I am doing a polynomial linear regression with 2 independent variables
such as :
lm(A ~ B + I(B^2) + I(lB^3) + C, data=Dataset))
R return me a coefficient per independent variable, and I would need
the coefficient of the C parameter to equal 1.
Leaving
For the record. I have found a possible sollution:
nn - nodeapply(z)
n.names= names(unlist(nn[[1]]))
ext - unlist(sapply(n.names, function(x) grep(split.varid., x, value=T)))
ext - gsub(kids.split.varid., , ext)
ext - gsub(split.varid., , ext)
dep.var - as.character(terms(z)[1][[2]])
plus =
On 10/17/2013 06:17 PM, catalin roibu wrote:
Dear R users,
I want to extract column's from different data frame with different row
length.
How can I do this in R?
Hi catalin,
If I understand your question, which I think is:
I want to extract columns from different data frames with differing
mattbju2013 wrote
Hi guys this is my first post, i need help summing the number of NA's in a
few vectors
for example..
c1-c(1,2,NA,3,4)
c2-c(NA,1,2,3,4)
c3-c(NA,1,2,3,4)
how would i get a result that only sums the number of NA's in the vector?
the.result.i.want-c(2,0,1,0,0)
See
hello togehter,
i have a little problem, maybe you can help me.
I have a data.frame like this one:
IDName
1 Andy
2 John
3 Amy
and a data.frame like this:
ID DateValue
12013-10-0110
12013-10-0215
22013-10-017
22013-10-0310
2
Or faster (both computational speed and amount of code):
colSums(is.na(rbind(c1, c2, c3)))
On Thu, Oct 17, 2013 at 4:34 AM, Carl Witthoft c...@witthoft.com wrote:
mattbju2013 wrote
Hi guys this is my first post, i need help summing the number of NA's in
a
few vectors
for example..
Consider the function f(x) = x on the open interval (0,1). It does not have a
maximum.
That is what your likelihood function will look like. The MLE does not exist.
Chris
(Although if everything is continuous and you are okay with limits there is an
extension that gets you to Terry's original
Greetings,
Meanwhile I have figured out how do do it only to find out that I have more
serious problems.
Generally calling Base::f on the base class object is not what you want,
instead you want to call
Base::f on the full object for the following reasons:
If the base class is virtual, then
Sorry,
if the previous message seems without context.
Indeed, the first message was bounced by filtering rules (triggered by subject
heading than which nothing could be more benign or less liable to suspician).
It was:
Greetings,
I have an S4 class B (Base) which defines a function
I have functions that generate lists objects of class foo and lists of
lists of these, of class
foolist, similar to what is shown below.
How can I flatten something like this to remove the top-level list
structure, i.e.,
return a single-level list of foo objects, of class foolist?
foo -
On 17/10/2013 9:01 AM, Michael Meyer wrote:
Sorry,
if the previous message seems without context.
Indeed, the first message was bounced by filtering rules (triggered by subject
heading than which nothing could be more benign or less liable to suspician).
It was:
Greetings,
I have an S4
unlist(mfoo, recursive = FALSE) gets you pretty close.
Best,
Ista
On Thu, Oct 17, 2013 at 9:15 AM, Michael Friendly frien...@yorku.ca wrote:
I have functions that generate lists objects of class foo and lists of
lists of these, of class
foolist, similar to what is shown below.
How can I
On 17/10/2013 9:15 AM, Michael Friendly wrote:
I have functions that generate lists objects of class foo and lists of
lists of these, of class
foolist, similar to what is shown below.
You can use c() to join lists. So in the example below,
c(mfoo$A, mfoo$B)
will give you a list with the
Does this get you the rest of the way?
mfoo2 - unlist(mfoo, recursive = FALSE)
names(mfoo2) - unlist(lapply(mfoo, names))
class(mfoo2) - foolist
str(mfoo2)
List of 4
$ A1:List of 2
..$ x: int 3
..$ y: int 10
..- attr(*, class)= chr foo
$ A2:List of 2
..$ x: int [1:2] 6 4
..$ y:
Thanks to all who replied.
Here are two versions of a function (sans sanity checks) that do what I
want:
foo1 - multifoo(1:2, A)
foo2 - multifoo(1:2, B)
mfoo - list(A=foo1, B=foo2)
class(mfoo) - c(foolist, list)
#' flatten a list of lists
# from Duncan Murdoch
flatten - function(list,
When I specify pch = 19 for a scatter plot the points are filled circles.
Deapite reading ?points and trial-and-error experimentation I have not found
how to have the legend symbols (now open circles) filled.
An example command is:
xyplot(pct.quant ~ sampdate, data = ffg.st, groups =
put the pch into the par.settings
On Thu, Oct 17, 2013 at 11:17 AM, Rich Shepard rshep...@appl-ecosys.com wrote:
When I specify pch = 19 for a scatter plot the points are filled circles.
Deapite reading ?points and trial-and-error experimentation I have not found
how to have the legend
Milan is correct.
The prefix is used when saving the XML content that is represented in
a different format in R.
To get the prefix
?xml version=1.0?
on the XML content that you save, use a document object
doc = newXMLDoc()
root = newXMLNode(foo, doc = doc)
saveXML(doc)
?xml version=1.0?
This is the world-famous fizzbuzz problem. You should be able to find
lots of implementations by Googling that word. Here's a pointless
collection I wrote once:
# a really dumb fizzbuzz alg competition
#fbfun1 is 2.5x faster than fbfun2
# fbfun3 is 10x faster than fbfun1
# fbfun1 is 2x faster
Quote
By the way, your use of the syntax D::f and B::f suggests that youapos;re
thinking from a C++ point of view. Thatapos;s very likely to lead to
frustration: the S4 object system is very different from C++. Methods
donapos;t belong to classes, they belong to generics. There is no such
Dear Forum,
I have a data frame as
mydat = data.frame(basel_asset_class = c(2, 8, 8 ,8), defa_frequency = c(0.15,
0.07, 0.03, 0.001))
mydat
basel_asset_class defa_frequency
1 2 0.150
2 8 0.070
3 8 0.030
4
So why not start with some statistical textbook? There are plenty of them
available in CRAN.
I wasn't implying, that I haven't read any textbook, or didn't do any
research. I read some textbooks/Papers/etc. during the research about what
to do and came across the wilcox test. I meant to imply
On Thu, 17 Oct 2013, Richard M. Heiberger wrote:
put the pch into the par.settings
Richard,
Tried this again, but I'm not finding the proper location within
par.settings.
par.settings = list(superpose.points = list(col = rainbow(7)),
superpose.lines = list(col = rainbow(7)), pch = 19)
Katherine,
There are multiple ways to do this and I highly recommend you look into a
basic R manual or search the forums. One quick example would be:
mysub - subset(mydat, basel_asset_class 2)
Cheers,
Charles
On Thu, Oct 17, 2013 at 1:55 AM, Katherine Gobin
katherine_go...@yahoo.comwrote:
Hi David,
That worked brilliantly! Many thanks. I also had trouble getting subplot()
to work with either TeachingDemos or Hmisc.
Best,
Mark
--
View this message in context:
http://r.789695.n4.nabble.com/map-with-inset-tp4678341p4678426.html
Sent from the R help mailing list archive at
Hi all,
I'm trying to graph the results of a weighted regression analysis. Is anyone
aware of a way to make my markers appear a different sizes to be consistent
with their respective weights?
Thanks,
-Mike Sugarman
Wayne State University
--
View this message in context:
Greetings,
I have an S4 class B (Base) which defines a function f=f(this=B,...)
Dervided from B we have a derived class D which also defines a function
f=f(this=D,...)
In the definition of D::f we want to call the version B::f and could do this by
simply calling
f(baseClassObject(this),...)
Hi,
I have a set of matrix data named invest consists of 450 observations (75
countries, 6 years) with 7 variables (set as I, pop, inv, gov, c, life, d;
which each is numeric[450]). The procedure is modify from code provided
by B.E. Hansen at
Dear all,
I have a problem where I must represent points with XYZ coordinates
changing over time. I will do a number of operations on this data such as
calculating the YZ-projection distance of the points to the origin over
time, the frequency spectrum of the X-T data etc. I am trying to find a
Hi,
I have some code in R with a lot of matrix multiplication and inverting. R can
be very slow for larger matrices like 5000x5000.
I have seen the new programming language Julia (www.julialang.org) which is
quite fast in doing matrix algebra. So my idea is to set up the simulations in
R and
Hi,
I think based on your title, the output you provided is not clear. If it
depends on Date, there should be four columns.
library(reshape2)
res1 - dcast(merge(dat,dat2,by=ID),ID+Name~Date,value.var=Value)
colnames(res1)[3:6] - c(First, Second, Third, Fourth)
rownames(res1) - 1:nrow(res1)
par.settings = list(
superpose.points = list(col = rainbow(7), pch = 19),
superpose.lines = list(col = rainbow(7))
)
On Thu, Oct 17, 2013 at 11:48 AM, Rich Shepard rshep...@appl-ecosys.com wrote:
On Thu, 17 Oct 2013, Richard M. Heiberger wrote:
put the pch into the par.settings
On Thu, 17 Oct 2013, Richard M. Heiberger wrote:
par.settings = list(
superpose.points = list(col = rainbow(7), pch = 19),
superpose.lines = list(col = rainbow(7))
)
I had tried that, too. Legend symbols stubbornly remain unfilled.
Thanks, Richard,
Rich
Hi,
Try:
dat - read.table(text=
ID Name
1 Andy
2 John
3 Amy,sep=,header=TRUE,stringsAsFactors=FALSE)
dat2 - read.table(text=
ID Date Value
1 2013-10-01 10
1 2013-10-02 15
2 2013-10-01 7
2 2013-10-03 10
2 2013-10-04 15
3 2013-10-01
Hello,
my dots of 0 and 2 are quite close to the marging. So I would like to move
the 0 and the 2 both towards the 1. I wish to be my dots more centered.
And: I dont need so much space between 0,1 and 2.
How does it work?
I tried:
plot (data, axes=FALSE, main=i, ylab= expression (z^2))
Kindly guide ...
This is a very basic question, so the kindest guide I can give is to read
an Introduction to R (ships with R) or a R web tutorial of your choice so
that you can learn how R works instead of posting to this list.
Cheers,
Bert
On Wed, Oct 16, 2013 at 11:55 PM, Katherine Gobin
On 17 Oct 2013, at 13:44 , Hermann Norpois wrote:
Hello,
my dots of 0 and 2 are quite close to the marging. So I would like to move
the 0 and the 2 both towards the 1. I wish to be my dots more centered.
And: I dont need so much space between 0,1 and 2.
How does it work?
I tried:
That should have worked. I think something else is interfering.
Did you redefine either T or F?
Please send the output from dput(head(ffg.st))
so we can experiment in your setting.
Rich
On Thu, Oct 17, 2013 at 12:12 PM, Rich Shepard rshep...@appl-ecosys.com wrote:
On Thu, 17 Oct 2013, Richard
You want the offset function in the formula:
lm( A ~ B + I(B^2) + offset(C), data=Dataset)
This will force the coefficient on C to be 1, if you wanted a coefficient
of another value then just do the multiplication yourself, e.g. offset( 2 *
C ) for a slope of 2.
Also you can use poly(B,2) to
Hi there,
another beginners question, I'm afraid. Basically i want to selct the
maximum of values, that correspond to different variables. I have a table
of oil production that looks somewhat like this:
oil - data.frame( YEAR = c(2011, 2012),
TX = c(2, 3),
On Thu, 17 Oct 2013, Richard M. Heiberger wrote:
That should have worked.
That's what I thought when I first tried it.
I think something else is interfering. Did you redefine either T or F?
Not intentionally.
Please send the output from dput(head(ffg.st)) so we can experiment in
From your question it is not clear what your question/concerns really are,
and from what we can see it could very well be that you do not understand
the statistics that you are computing (not just the R implementation). We
ask for a reproducible example because that helps us to help you, just a
I work very mutch with the packages RWeka and multicore. If you try to run
J48 or any tree of RWeka with multicore we hava some errors.
Example I:
library(RWeka);
library(multicore);
mclapply(1:100, function(i) {
J48(Species ~., iris);
});
Output: Error in .jcall(o, \Ljava/lang/Class;\,
On 10/17/2013 08:54 AM, Michael Meyer wrote:
Suppose you have a base class Base which implements a function Base::F
which works in most contexts but not in the context of ComplicatedDerived
class
where some preparation has to happen before this very same function can be
called.
You would
I received the following error message with the multicore package:
install.packages(multicore)
Warning in install.packages :
package multicore is not available (for R version 3.0.2)
Warning in install.packages :
package multicore is not available (for R version 3.0.2)
Warning message:
Hi,
You may try:
unlist(lapply(seq_len(nrow(oil)),function(i) oil[i,-1][which.max(oil[i,-1])]))
# CA ND
#4 6
#or
library(reshape2)
datM - melt(oil,id.var=YEAR)
datM[as.logical(with(datM,ave(value,list(YEAR),FUN= function(x) x%in%
max(x,]
# YEAR variable value
#3 2011
The simplest approach is to specify the cex parameter in the call to plot.
plot(1:3, 1:3, cex=3:1) for example will plot the 1st point 3 times as
big, the 2nd 2 times as big, and the 3rd at the standard size.
You can get more control by using the symbols function instead of the plot
function and
On 17-10-2013, at 18:48, Tim Umbach tim.umb...@hufw.de wrote:
Hi there,
another beginners question, I'm afraid. Basically i want to selct the
maximum of values, that correspond to different variables. I have a table
of oil production that looks somewhat like this:
oil - data.frame( YEAR
If all your data is numeric then you can use an array instead of a data
frame and arrays can easily be 3, 4, or higher dimensional. Or you can use
a data frame with a column each for x, y, z, and time; with possible other
columns representing groups or other attributes, essentially a 3
I am sorry perhaps was not able to put the question properly. I am not
looking for the subset of the data.frame where the basel_asset_class is 2. I
do agree that would have been a basic requirement. Let me try to put the
question again.
I have a data frame as
mydat =
Correction. (2nd para first three lines)
Pl read following line
What I need is to select only those records for which there are more than two
default frequencies (defa_frequency), Thus, there is only one default frequency
= 0.150 w.r.t basel_asset_class = 4 whereas there are default
I always get lost in simpleKey. The approach of directly modifying
the trellis object usually works.
tmp - xyplot(pct.quant ~ sampdate, data = ffg.st, groups = func_feed_grp,
type =
+ 'p', pch = 19, key = simpleKey(text = levels(ffg.st$func_feed_grp), space =
+ 'right', points = T, lines =
@Martin Morgan, Duncan Murdoch:
OK Thanks.
I did not understand the callNextMethod.
I will investigate this in detail.
This is great!
Thanks again,
Michael Meyer
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
You may try:
mydat[with(mydat,ave(seq_along(basel_asset_class),basel_asset_class,FUN=length)2),]
# basel_asset_class defa_frequency
#2 8 0.070
#3 8 0.030
#4 8 0.001
#or
library(plyr)
On Thu, 17 Oct 2013, Richard M. Heiberger wrote:
I always get lost in simpleKey.
As this is my first use of it I take what's offered by those more
experienced than I.
The approach of directly modifying the trellis object usually works.
tmp - xyplot(pct.quant ~ sampdate, data = ffg.st,
# Suppose I have a vector:
myvec = c(1,0,3,0,77,9,0,1,2,0)
# I want to randomly pick an element from myvec
# where element == 0
# and print the value of the corresponding index.
# So, for example I might randomly pick the 3rd 0
# and I would print the corresponding index
# which is 7,
# My
Hi folks,
Wondering if anyone might be able to help me on this one. I have just done
some geochemistry with X-ray Diffraction and Rietveld Refinement in order to
quantify the data. I have a observed spectra from my sample and a calculated
spectra from the Rietveld Refinement (in the attached
Not only does it not require a loop, this is a one-liner:
myvec - c(1,0,3,0,77,9,0,1,2,0)
sample(which(myvec == 0), 1)
[1] 4
sample(which(myvec == 0), 1)
[1] 7
sample(which(myvec == 0), 1)
[1] 2
If there's a possibility of not having zeros then you'll need to check
that separately, otherwise
Typo fix below:
On Thu, Oct 17, 2013 at 3:05 PM, Sarah Goslee sarah.gos...@gmail.com wrote:
Not only does it not require a loop, this is a one-liner:
myvec - c(1,0,3,0,77,9,0,1,2,0)
sample(which(myvec == 0), 1)
[1] 4
sample(which(myvec == 0), 1)
[1] 7
sample(which(myvec == 0), 1)
[1] 2
On Oct 16, 2013, at 10:04 AM, Msugarman wrote:
Hi all,
I'm trying to graph the results of a weighted regression analysis. Is anyone
aware of a way to make my markers appear a different sizes to be consistent
with their respective weights?
You have not produced any data or code. If using
On 10/17/2013 11:54 AM, Stock Beaver wrote:
# Suppose I have a vector:
myvec = c(1,0,3,0,77,9,0,1,2,0)
# I want to randomly pick an element from myvec
# where element == 0
# and print the value of the corresponding index.
# So, for example I might randomly pick the 3rd 0
# and I would
Hi,
You could also check ?data.table() as it could be faster.
#Speed comparison
set.seed(498)
oilT -
data.frame(YEAR=rep(rep(1800:2012,50),100),state=rep(rep(state.abb,each=213),100),value=sample(2000:8,1065000,replace=TRUE),stringsAsFactors=FALSE)
system.time(res1 -
On 10/17/2013 04:04 AM, Msugarman wrote:
Hi all,
I'm trying to graph the results of a weighted regression analysis. Is anyone
aware of a way to make my markers appear a different sizes to be consistent
with their respective weights?
Hi Mike,
Have a look at the size_n_color function in the
May I ask why:
count_by_class - with(dat, ave(numeric(length(basel_
asset_class)), basel_asset_class, FUN=length))
should not be more simply done as:
count_by_class - with(dat, ave(basel_asset_class, basel_asset_class,
FUN=length))
?
-- Bert
On Thu, Oct 17, 2013 at 12:36 PM, William Dunlap
What I need is to select only those records for which there are more than two
default
frequencies (defa_frequency),
Here is one way. There are many others:
dat - data.frame( # slightly less trivial example
basel_asset_class=c(4,8,8,8,74,3,74),
defa_frequency=(1:7)/8)
May I ask why:
count_by_class - with(dat, ave(numeric(length(basel_asset_class)),
basel_asset_class, FUN=length))
should not be more simply done as:
count_by_class - with(dat, ave(basel_asset_class, basel_asset_class,
FUN=length))
The way I did it would work if basel_asset_class
Thanks, Bill.
But ?ave specifically says:
ave(x, ..., FUN = mean)
Arguments:
x
A numeric.
So that it should not be expected to work properly if the argument is
not (coercible to) numeric. Nevertheless, defensive programming is
always wise.
Cheers,
Bert
On Thu, Oct 17, 2013 at 1:34 PM,
Hi Bill,
#seq_along() worked in the cases you showed.
ave(seq_along(fac),fac,FUN=length)
#[1] 3 1 3 3
ave(seq_along(num), num, FUN=length)
#[1] 3 1 3 3
ave(seq_along(char), char, FUN=length)
#[1] 3 1 3 3
I thought, there might be some advantages in speed, but they were similar in
seq_along(x), integer(length(x)), is.na(x), or anything that produces an integer
(or numeric or logical) vector the length of x would work. I use integer() or
numeric()
to indicate I'm not using its value: it is just a vector in which to place the
return values of FUN().
Bill Dunlap
Spotfire,
Hey R professionals,
I have a large dataset and I want to run a loop on it basically creating a
new column which gathers information from another reference table.
When I run the code, R just freezes and even does not response after 30min
which is really unusual. I tried sapply as well but does
On 17 October 2013 15:38, Timo Schmid timo_sch...@hotmail.com wrote:
I have some code in R with a lot of matrix multiplication and inverting. R
can be very slow for larger matrices like 5000x5000.
I have seen the new programming language Julia (www.julialang.org) which is
quite fast in doing
See ?pmax for getting the max for each year.
do.call('pmax', oil[-1])
Or equivalently:
pmax(oil$TX, oil$CA, oil$AL, oil$ND)
apply and which.max will give you the index:
i - apply(oil[-1], 1, which.max)
which you can use to extract the state:
names(oil[-1])[i]
Jason
-Original
Hi all
I do not understand why I am getting the following error message. Can
anybody help me with this? Thanks in advance.
install.packages(cmprsk)
library(cmprsk)
result1 -crr(ftime, fstatus, cov1, failcode=1, cencode=0 )
one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2))
On Oct 17, 2013, at 2:56 PM, Ye Lin wrote:
Hey R professionals,
I have a large dataset and I want to run a loop on it basically creating a
new column which gathers information from another reference table.
When I run the code, R just freezes and even does not response after 30min
which
78 matches
Mail list logo