Displaying 20 results from an estimated 1000 matches similar to: "With an example - Re: rbind.data.frame drops attributes for factor variables"
2011 Nov 24
3
Is there way to add a new row to a data frame in a specific location
Is there easy way (without copying the existing rows to a temporary
location and copying back) to add a new row to a specific index location in
an existing data frame?
Example
df = data.frame( A= c('a','b','c'), B=c(1,2,3), C=(10,20,30))
newrow = c('X', 100, 200)
I want to add the newrow as the second row to the data frame df
Please suggest a solution that is
2011 Nov 11
1
rbind.data.frame drops attributes for factor variables
Hi all,
When I use rbind() or rbind.data.frame() to add a row to an existing
dataframe, it appears that attributes for the column of type "factor" are
dropped. I see the following post with same problem. However i did not see
any reply to the following posting offering a solution. Could someone
please help.
2010 Jun 01
2
Help on aggregate method
Dear R experts,
I would really appreciate if you had an idea on how to use more
efficiently the aggregate method:
More specifically, I would like to calculate the mean of certain
values on a data frame,? grouped by various attributes, and then
create a new column in the data frame that will have the corresponding
mean for every row. I attach part of my code:
matchMean <-
2005 Aug 10
1
Why only a "" string for heading for row.names with write.csv with a matrix?
Consider:
> x <- matrix(1:6, 2,3)
> rownames(x) <- c("ID1", "ID2")
> colnames(x) <- c("Attr1", "Attr2", "Attr3")
> x
Attr1 Attr2 Attr3
ID1 1 3 5
ID2 2 4 6
> write.csv(x,file="x.csv")
"","Attr1","Attr2","Attr3"
"ID1",1,3,5
2010 Jul 02
3
Knowledge discovery
Hi,
I have 100000 units with 10 attributes (attr1, attr2, attr3, etc...)
For instance:
unit attr1 attr2 attr3 ...
1 a ww 12
2 a re 11
3 b ww 09
4 c yt 02
5 a qw 02
...
I'd like to answer to the question:
a) what are the most frequent combinations of attributes?
b) How could I describe the relations
2006 Jan 05
2
Confused...
Ok,
So, I''ve got two data tables associated through a foreign key.
class Child < ActiveRecord::Base
belongs_to :parent, :class => Parent, :foreign_key => "parent_id"
# also has attr1, attr2
end
class Parent < ActiveRecord::Base
has_many :children, :class => Child, :foreign_key => "parent_id"
end
So, I''m trying to build the new/edit
2009 Sep 18
1
inconsistency in attaching attributes to NULL
In R-devel (svn 49628) and back to at least R 2.7.0 we get
inconsistent results when attempting to attach attributes to
a variable with the value NULL.
If we use attributes<- it finishes but changes the value to list().
> a<-NULL
> attributes(a)<-list(attr1="First attribute", attr2=2+2i)
> a
list()
attr(,"attr1")
[1] "First
2003 Oct 23
1
Can you create a MySQL database with RMySQL?
Is it possible to create a database in MySQL via RMySQL?
Also, is the format for the authorization field
'userName/password at databasename'? I saw an example like this somewhere
in the documenation, but I haven't found the actual specification.
Thanks,
Barnet Wagman
2012 Jan 04
1
AR update / create pattern: is there an easier way?
I find myself writing the following frequently:
r = MyActiveRecord.where(:attr1 => cond1, :attr2 => cond2, ...)
r.exists? ? r.first : r.create
... which has the effect of returning an instance of MyActiveRecord if
all the conditions are met, or creating one if it doesn''t. A variant of
this:
c = MyActiveRecord.new(:attr1 => val1, :attr2 => val2, ...)
r =
2006 May 17
6
ActiveRecord#to_param
Hello,
to implement some some kind of optimistic locking, I want to build a
view, where an object is displayed together with a link containing the
data of the displayed object. My first try looked something like
<%= object.object_discription %>
<%= link_to "action", :action => "take_action", :data => object %>
this won''t work because object is of
2006 Aug 15
6
Theoretical: Should models be subclasses of AR or mix it in?
All,
My apologies if this is a little long-winded and stream of
consciousness-y :).
SUMMARY: Why do we extend ActiveRecord instead of mixing it in to our
model classes?
Been thinking about my app''s models and starting to want to build
something of a hierarchy. I have some commonality across 3 of my model
classes and I''d liek to aggregate the behavior in a superclass.
2009 Dec 17
2
multiple usb apc smart ups with nut?
Hello everybody,
I got tree UPS devices connected to a Debian server, and i am
searching for a way to configure them.
The server power-cord is only connected to one of the ups devices, and
should monitor the other ups systems to sent email status.
I got a HP R3000XR UPS with has a RS232 communication port that I have
working perfectly.
Then I have two APC SmartUPS 750V devices that are
2009 Oct 11
1
Problem with symlinks
Hi,
currently I'm trying to extend my existing backup concept but I have
issues due to symlinks.
rsync has problems with symlinks. First some background information:
I regularly back up my / and /home from my desktop PC and my netbook to
my Synology DiskStation (500GB) using rsync 3.0.6 with this script:
http://pastebin.com/m43d4e353 . This works without any error messages.
On the DS
2011 May 11
2
Issue with Arel::SelectManager and insert Method
Hello,
Arel::SelectManager (arel 2.0.9) uses following statement to insert a
new record:
@engine.connection.insert im.to_sql, ''AREL'', primary_key_name,
primary_key_value
But in DatabaseStatements insert ist defined as:
insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
Actually, Arel::SelectManager does not use the sequence name. This
leads to issues
2009 Oct 11
2
people(:sam) should be saved to a @sam variable?
Hi all
When creating unit tests, I wondered whether I should rather use the
following...
people(:sam).name = "Sammy"
people(:sam).city = "Blah"
...or rather the following form:
@sam = people(:sam)
@sam.name = "Sammy"
@sam.city = "Blah"
Thanks
Josh
--
Posted via http://www.ruby-forum.com/.
2012 Feb 28
1
Alphanumeric DTMF !?
Hi list,
What possibilities are there in asterisk to send an *alphanumeric
DTMF*from/to asterisk !?
Regards,
Sammy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120228/e62e7890/attachment.htm>
2011 Oct 25
7
additional model attributes
Hi,
i have a "place" model with 2 columns (id, name).
I''m calling an external api which gives me data to create a new place
object.
I would like to add the address from the external place to the place
object and render it as a json result, without storing it in the
database.
i don''t get any errors, but the address never shows up within the json
output. i''ve
2008 Jun 13
1
Output of silhouette (cluster package)
Dear R users,
I am mailing you about the graphical output of silhouette (cluster
package)
From the example of silhouette in help(silhouette):
> ar <- agnes(ruspini)
> si3 <- silhouette(cutree(ar, k = 5), # k = 4 gave the same as pam()
above
+ daisy(ruspini))
> plot(si3, nmax = 80, cex.names = 0.5)
from which one may conclude that group 1 is composed by
2012 Feb 16
2
Asterisk && RTCP
Hello list,
I need to know about Asterisk's friendly nature with RTCP. I've phones
which support RTCP and they connect to the outer world via multiple
carriers. In one of my recent packet traces I've observed that the caller
initiated a call with rtcp string in SDP while for the same
call dialling our from Asterisk to the carrier has no RTCP string in SDP !
Can anyone please tell why
2012 Feb 11
1
Asterisk perl AGI confusing variables
Hello all,
I'm struck with a very strange problem today. I've an AGI with some code
subroutine snippet as follows:
sub enable_sbc($) {
my $carrier = shift;
my $tmp = substr($carrier,1);
my $jkh = $tmp;
$server_port = $ast_agi->get_variable("SIPPEER($jkh,port)");
$ser_ip = $ast_agi->get_variable("SIPPEER($tmp,ip)");