similar to: solution of split data.frame

Displaying 20 results from an estimated 1000 matches similar to: "solution of split data.frame"

2006 May 16
2
split the data.frame
Dear R folks: I wonder anyone has a elegent way of doing what I need to do. I have a data frame called with four columns: V1, V2, A1 and A2: V1 V2 A1 A2 A B 1.2 2.0 A D 1.2 4.0 A C 2.4 2.2 What I need to do is to convert it into the following data frame with a new column x, where x is just the stacked up of A1 and A2 placed with respective V1 and V2 in the first two
2011 Jun 09
1
Error: missing values where TRUE/FALSE needed
I'm writing a function and keep getting the following error message. myfunc <- function(lst) { lst <- list(roots = c("car insurance", "auto insurance"), roots2 = c("insurance"), prefix = c("cheap", "budget"), prefix2 = c("low cost"), suffix = c("quote", "quotes"), suffix2 = c("rate",
2011 Jun 09
2
Problem with a if statement inside a function
I have a really long functions, and at the end of the function, I am using a if statement to tag certain keywords based on whether they have certain values contained in them. However, the if statement doesn't seem to work. When I had split up the commands into various functions, it worked fine, but I'm not sure what going on now that it's combined into a single function. myfunc
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
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 --
2006 Apr 27
2
add city and point in the map
Dear Helpers: I'm trying to use packages "maps" and "mapdata" (see blow) to display the research resutls on map (Mid-Atlantic region). In particular, I need to mark a number of points in the map by giving their latitude and longitude information. For instance, I would like to mark a point on (long, lat) =(75.56027, 39.09271). Also, I need to mark several cities that I
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All I have a datafram which looks like this : CustomerID DietType 1 a 1 c 1 b 2 f 2 a 3 j 4 c 4 c 4 f And I would like to reshape this so I can
2011 Jun 09
1
Using a function inside a function
I'm trying to run a function inside a function but get an error message. lst <- list(roots = c("car insurance", "auto insurance"), roots2 = c("insurance"), prefix = c("cheap", "budget"), prefix2 = c("low cost"), suffix = c("quote", "quotes"), suffix2 = c("rate", "rates"), suffix3 =
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"),
2006 May 18
1
How to write output in a specific formate with irregular space
Dear R users: My question is how to write output in a specific formate with irregular spacing? Say that I have the following DF with three columns (A-C): A B C a10 100.0 212 The objective is to write an output file such that column A occupies 1-10 spaces aligned to the left, column B occupies 11-15 spaces aligned to the right, and finally column C takes 16-25 spaces
2006 Jul 11
1
problem of fixed-formated output using sprintf
Dear R users: I'm trying to generate a output file with fixed format using function "sprintf" in R. However, the execution time in R is very long even the toy data (smaller size df) seems to work fine. The syntax that I used is as follows: df.fmt <- sprintf("%2s%2s%2.4f", df$v1, df$v2, df$v3) write.table(df.fmt, output.name,...) The actual dataset is a df with the
2012 Feb 25
1
Unexpected behavior in factor level ordering
Hello, Everybody: This may not be a "bug", but for me it is an unexpected outcome. A factor variable's levels do not retain their ordering after the levels function is used. I supply an example in which a factor with values "BC" "AD" (in that order) is unintentionally re-alphabetized by the levels function. To me, this is very bad behavior. Would you agree? #
2011 Nov 11
2
One step way to create data frame with variable "variable names"?
Suppose plotx <- "someName" modx <- "otherName" plotxRange <- c(10,20) modxVals <- c(1,2,3) It often happens I want to create a dataframe or object with plotx or modx as the variable names. But can't understand syntax to do that. I can get this done in 2 steps, creating the data frame and then assigning names, as in newdf <- data.frame( c(1, 2, 3, 4),
2006 May 19
1
Writing to a file with fixed precision
Dear R users; A follow-up question regarding writing to a file with fixed precision: Assuming for each column of x, I would like to have a different format, then I modify the code as: x.fmt <- apply(x, 1, function(x) sprintf("%.14f %.10f %2.5f", x)) where three different formats are %.14f %.10f %2.5f. The error message I got is "Error in sprintf(fmt, ...) : too few
2012 Apr 20
1
predictOMatic for regression. Please try and advise me
I'm pasting below a working R file featuring a function I'd like to polish up. I'm teaching regression this semester and every time I come to something that is very difficult to explain in class, I try to simplify it by writing an R function (eventually into my package "rockchalk"). Students have a difficult time with predict and newdata objects, so right now I'm
2012 May 14
2
Error in names(x) <- value: 'names' attribute must be the same length as the vector
Dear R-helpers, I am stuck on an error in R: When I run my code (below), I get this error back: Error in names(x) <- value : 'names' attribute must be the same length as the vector Then when I use traceback(), R gives me back this in return: `colnames<-`(`*tmp*`, value = c(""Item", "Color" ,"Number", "Size")) I'm not exactly
2004 Mar 10
3
How to use MLE-class?
Hi there, I had successfully use "MLE" function to solve my problem. Is there anyone knows how to get related information? i.e., value of likelihood function, information matrix, and etc. I know MLE-class can do it but I can not find any information tells me how to do it. Thanks a billions, Yihsu [[alternative HTML version deleted]]
2011 Jun 06
0
lme, stepAIC, predict: scope and visibility
Hello all, I've run into a problem where I can't run predict.lme on an object simplified via a stepAIC. A similar post has been recorded on this list: https://stat.ethz.ch/pipermail/r-help/2008-May/162047.html but in my case, I'm going to great lengths to not repeat that poster's error and still coming up short. Any advice would be much appreciated. It would seem that, after
2011 May 04
0
Fwd: simple question
Sorry I had typo in previous email, this typo corrected version: Dear R experts I have simple question, please execuse me: #example data, the real data consists of 20000 pairs of variables K1 <- c(1,2,1, 1, 1,1); K2 <- c(1, 1,2,2, 1,2); K3 <- c(3, 1, 3, 3, 1, 3) M1a <- rep( K1, 100); M1b <- rep(K2, 100) M2a <- rep(K1, 100); M2b <- rep(K1, 100) M3a <- rep(K1, 100); M3b
2007 Dec 09
3
editor under MAC system
Dear R-user; I recently switched from PC to MAC. Is there a compatible editor as Win-editor with package RWinEdit for MAC? Thanks Yihsu Chen [[alternative HTML version deleted]]