Displaying 20 results from an estimated 600 matches similar to: "reshaping column items into rows per unique ID"
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame
(presumably the "table" data structure you describe) can *not* contain
"blanks" -- all columns must be the same length, which means NA's are
filled in as needed.
Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any
local version of R (maybe it would in some server version --
2018 Feb 25
0
reshaping column items into rows per unique ID
Hi Allaisone,
If you want a data frame as the output you will have to put up with a
few NA values unless each Customer has the same number of diet types:
a1df<-read.table(text="CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4
2018 Feb 25
1
reshaping column items into rows per unique ID
Hi Allaisone,
I took a slightly different approach but you might find this either as or
more useful than your approach, or at least a start on the path to a
solution you need.
df1 <-
data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"),
2018 Apr 15
4
Adding a new conditional column to a list of dataframes
Hi all ..,
I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
When I extract one dataframe and apply my code it works very well as follows :-
First suppose this is my first dataframe in the list
> OneDF <- Mylist[[1]]
> OneDF
ID Pdate
2010 Jun 05
1
Problem with GROUP()
Hello list,
using asterisk 1.4.30 and trying GROUP() and GROUP_COUNT() for the first
time... Having some troubles.
This the dialplan (using a sub) :
exten => s,n,Set(_custID=${custID})
exten => s,n,GROUP(${custID})
exten => s,n,NoOp(grouppcount = GROUP_COUNT(${custID}))
exten => s,n,GoToIf($[ ${GROUP_COUNT(${custID})} > 2 ]?maxreached)
The CLI shows :
[Jun 5 16:06:26] --
2018 Apr 15
0
Adding a new conditional column to a list of dataframes
> On Apr 15, 2018, at 4:08 AM, Allaisone 1 <Allaisone1 at hotmail.com> wrote:
>
>
> Hi all ..,
>
>
> I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
>
>
> When I extract one dataframe and apply my code it works very well as
2011 Mar 02
4
Contingency table in R
Hi,
I have a table in R with data I needed and need to create a contingency table out of it. The table I have so far looks like this:
Binger
r
DietType No Yes
Dangerous 15 12
Healthy 52 9
None 134 24
Unhealthy 72 23
These are the error messages that I keep getting whenever I try to get a contingency table. I'm not sure why it won't work
2006 Feb 14
6
[newb] Find vs Find :all question
I''m playing out with writing an online store.
So far it has accounts, addressbooks, and orders, and those 3 are tied
together with an customer ID. I also have orderDetails, which are
associated to the order via an order number. See models below...
When I do the following I can access the orderDetails information just
fine:
@order = Order.find(params[:id]) # i pass it a customer
2013 Sep 02
1
R dataframe and looping help
HI,
You may try this:
dat1<- read.table(text="
CustID TripDate Store Bread Butter Milk Eggs
1 2-Jan-12 a 2 0 2 1
1 6-Jan-12 c 0 3 3 0
1 9-Jan-12 a 3 3 0 0
1 31-Mar-13 a 3 0 0 0
2 31-Aug-12 a 0 3 3 0
2 24-Sep-12 a 3 3 0 0
2 25-Sep-12 b 3 0 0 0
",sep="",header=TRUE,stringsAsFactors=FALSE)
dat2<- dat1[,-c(1:3)]
res<- lapply(seq_len(ncol(dat2)),function(i)
2006 Apr 26
5
accessing created_on causes type error
I assume that this is some newbie stupidity, but I haven''t found my
way around this problem. I have an ActiveRecord object fetched
from the database, and I need to evaluate the contents of the
updated_on field. However, *any* attempt to access that data in the
program results in a TypeError with the message ''no implicit conversion
from nil to integer''.
cust =
2004 Sep 11
3
SAS to R migration questions
Hi,
I'd like to get away from SAS, but I don't really know R well enough at
this point to know if it would be good for this project. I tried to
describe the essence of the project below without getting bogged down in
details.
It starts when I receive a data flat file. There's lots of columns, but
the relevant ones are:
custid (customer ID number)
saledt (date of sale)
2008 Sep 08
1
ActiveRecord::StatementInvalid Error
Hi There,
I''m gettings the following errors while accessing my application.
Can someone please tell what is the possible cause and can it
be resolved.
"
ActiveRecord::StatementInvalid in Site#showalladdress
Showing site/showalladdress.rhtml where line #3 raised:
Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version
2010 May 17
1
suggestions/improvements for recoding strategy
I am recoding some data. Many values that should be 1.5 are recorded
as 1-2. Some example data and my solution is below. I am curious about
better approaches or any other suggestions. Thanks!
# example input data
myData <- read.table(textConnection("id, v1, v2, v3
a,1,2,3
b,1-2,,3-4
c,,3,4"),header=TRUE,sep=",")
closeAllConnections()
# the first column is IDs so remove
2017 Nov 18
3
Complicated analysis for huge databases
The loop :
AllMAFs <- list()
for (i in length(SeparatedGroupsofmealsCombs) {
AllMAFs[[i]] <- apply( SeparatedGroupsofmealsCombs[[i]], 2, function(x)maf( tabulate( x+1) ))
}
gives these errors (I tried this many times and I'm sure I copied it entirely) :-
Error in apply(SeparatedGroupsofmealsCombs[[i]], 2, function(x) maf(tabulate(x + :
object 'i' not found
> }
2005 Sep 22
6
Autocomplete - setting a second value?
I''m using the autocomplete function, and need a way to grab a second
value from the ajax request... an example would probably speak better:
This is my HTML:
<input name="CustomerName" id="CustomerName" type="text" />
<div id="CustomerList"></div>
<input name="CustomerID" id="CustomerID"
2006 Sep 13
7
inserting columns in the middle of a dataframe
Dear R users:
Is there a built-in and simple way to insert new columns after other columns
in a dataframe?
I.e. currently I have:
V1 V2 V3 V4
[1,]
[2,]
Etc.
But I want
V1 V5 V2 V3 V4
[1,]
[2,]
Etc.
Can this be done in one line?
Jon Minton
[[alternative HTML version deleted]]
2017 Nov 18
0
Complicated analysis for huge databases
> On Nov 18, 2017, at 1:52 AM, Allaisone 1 <allaisone1 at hotmail.com> wrote:
>
> Although the loop seems to be formulated correctly I wonder why
> it gives me these errors :
>
> -object 'i' not found
> - unexpected '}' in "}"
You probably did not copy the entire code offered. But we cannot know since you did not "show your code",
2009 Jun 07
2
How do I construct a one matrix from another? (newbie)
Apologies if this is an obvious question but I am teaching myself R and the
occasional push in the right direction is much appreciated?
I have a data.frame containing data that looks like this
CustID itemID
1 a
1 b
2 c
3 a
3 c
I want to assemble the vector of all the items bought by a particular
customer and can't quite see how to do it.
What is the best
2017 Nov 18
2
Complicated analysis for huge databases
Although the loop seems to be formulated correctly I wonder why
it gives me these errors :
-object 'i' not found
- unexpected '}' in "}"
the desired output is expected to be very large as for each dataframe in the list of dataframes I expect to see maf value for each of the 600 columns! and this is only for
for one dataframe in the list .. I have around 150-200
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
Full_Name: Steven McKinney
Version: 2.9.0
OS: Mac OS X 10.5.6
Submission from: (NULL) (142.103.207.10)
A corrupt data frame can be constructed as follows:
foo <- matrix(1:12, nrow = 3)
bar <- data.frame(foo)
bar$NewCol <- foo[foo[, 1] == 4, 4]
bar
lapply(bar, length)
> foo <- matrix(1:12, nrow = 3)
> bar <- data.frame(foo)
> bar$NewCol <- foo[foo[, 1] == 4, 4]