Displaying 20 results from an estimated 60000 matches similar to: "List of lists to data frame?"
2009 Oct 28
5
PDF Corrupted?
I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe Reader 9.2 but when I try to open it the reader responds with
"There was an error opening this document. The file is damaged and cannot be repaired.:
I am using the R command(s):
pdf(file="cat.pdf", title="Historical Sales By Category")
for(j in 1:length(master))
{
d <-
2008 Jul 15
4
Iterations
I have a command that reads in some data:
x <- read.csv("Sales2007.dat", header=TRUE)
Then I try to organize the data:
sc <- split(x, list(x$Category, x$SubCategory), drop=TRUE)
Then I want to iterate through the data. I was able to get the following to run on the R console:
for(i in 1:length(sc))
{
sum(sc[[i]]$Quantity)
}
But notiing is primted on the console. I find
2008 Aug 09
1
Reshape set operations?
I have mange to use the library reshape to give me data structures that I want. Specifically:
m2008 <- melt(t2008, id.var=c("DayOfYear","Category","SubCategory","Sku"), measure.var=c("Quantity"))
m2007 <- melt(t2007, id.var=c("DayOfYear","Category","SubCategory","Sku"),
2009 Mar 11
1
Reshape question.
This hopefully is trivial. I am trying to reshape the data using the reshape package.
First I read in the data:
a2009 <- read.csv("Total2009.dat", header = TRUE)
Then I trim it so that it only contains the columns that I have interested in:
m2009 <- melt(a2009, id.var=c("DayOfYear","Category","SubCategory","Sku"),
2008 Aug 05
1
RESHAPE cast help.
I have a set of data that is basically sales figures for a given year. It has columns for Yeaqr, Day Of Year, Sku, SubCatetory, and Category. The first few lines of data look like:
Year DayOfYear Sku Quantity CatId Category SubCategory
1 2007 1 100091 1 10862 HOLIDAY Christmas
2 2007 1 100138 1 11160 PET COSTUMES Famous
2008 Jul 12
1
Assoociative array?
I have search the archive and I could not find what I need so I will try to ask the question here.
I read a table in (read.table)
a <- read.table(.....)
The table has column names like DayOfYear, Quantity, and Category.
The values in the row for Category are strings (characters).
I want to get all of the rows grouped by Category. The number of unique category names could be around 50. Say
2008 Oct 09
1
Basic aggregate help
>From what I read this should work. So please help my misunderstanding:
> x <- data.frame(Name=c("A","A","C"), Category=c("a","a","b"), Quantity=c(1,2,3))
> x
Name Category Quantity
1 A a 1
2 A a 2
3 C b 3
> aggregate(x,
2009 Apr 03
3
data.frame to array?
I have a list of data.frames
> str(bins)
List of 19217
$ 100026:'data.frame': 1 obs. of 6 variables:
..$ Sku : chr "100026"
..$ Bin : chr "T149C"
..$ Count: int 108
..$ X : int 20
..$ Y : int 149
..$ Z : chr "3"
$ 100030:'data.frame': 1 obs. of 6 variables:
.......
As you can see one 'column' is
2008 Jul 15
1
Filtering output
I have a command which returns a data fram if I am not mistaken:
sc <- split(x, list(x$Category, x$SubCategory), drop=TRUE)
Now I wish to get the Category and SubCategory that the data was split on. So my first attempt would be:
sc[[1]]$Category[1]
But that yields
[1] (Unknown)
46 Levels: (Unknown) 10" Plates 7" Plates (Dessert) ... WOMEN
Is all I want is '(Unknown)'.
2008 Jul 26
1
Simple vector question.
I have some data that I read in via read.csv:
sales2007 <- read.csv("Total2007.dat", header=TRUE)
The data looks like:
> sales2007[1:605,]
Year DayOfYear Sku Quantity CatId Category SubCategory
1 2007 1 100091 1 10862 HOLIDAY Christmas
2 2007 1 100138 1 11160 PET COSTUMES Famous (Licensed)
3 2007
2010 Mar 22
2
Factors attribute?
I noticed that when I fit a linear model using 'lm' there is an attribute called "factors" that is added to the "term". It doesn't seem to appear for 'model.matrix', just 'lm'. I have been unable to find where it gets constructed or what it means? It looks like a two dimensional array that I may be able to use so I would just like to get some
2011 Nov 08
3
window?
Can someone enlighten me on why the following doesn't work?
setwd('C:/Temp/R')
d <- rep(1:53,2)
(s <- ts(d, frequency=53, start=c(2000,10)))
n <- length(s)
k <- n%/%3
for(i in (n-k):n)
{
st <- c(start(s)[1] + (start(s)[2] + i)%/%frequency(s), (start(s)[2] +
i) %% frequency(s))
ed <- c(start(s)[1] +
2008 Aug 11
3
Exporting a list of lists
I have a list
List(Sku=" ", Shape=1, Scale=3, DayOfYear=daylist)
Note: picture daylist as c(2,3,4,3) it is a list with variable length.
Then I have a list of lists
al <- c(al, List(List(Sku=" ", Shape=1, Scale=3, DayOfYear=daylist))
Note: same comment on daylist as above.
So far this creates a list of lists just how I want it. If I do al[1] I get each member and the
2008 Oct 07
4
sort a list?
I am trying to sort a list and the data is obiously not in the right format. I am trying:
x <- list()
x[["A"]] <- 1
x[["B"]] <- 2
order(x)
But am getting:
Error in order(x) : unimplemented type 'list' in 'orderVector1'
How should I change the list so that it can be sorted? What kinds of objects (classes of objects) can be sorted?
Thank you.
Kevin
2006 Jun 19
10
Trying to delete from a unordered list using ajax
I have a controller method as such:
def delete
@category = Category.find_by_name(params[:name])
@element_id = @category.name
Category.delete_all(["name = ?", @category.name])
end
(For the purpose of this exercise, category names are unique)
I have the corresponding delete.rjs file:
if @element_id
page.remove :id => @element_id
page.visual_effect :highlight,
2011 Oct 22
7
"Plotting" text?
I noticed that the text() command adds text to a plot. Is there a way to
either make the plot blank or add text to a "blank sheet". I would like
to "plot" a page that contains just text, no plot lines, labels, etc.
Suggestions?
Kevin
[[alternative HTML version deleted]]
2008 Oct 10
2
Leap year?
Given a Date object or simply a year is there an R function to tell me if the it is a leap year or not? I was hoping for something like 'is.leapyear'. I probably can build my own function (year divisible by 4 etc.) but I would rather use an existing function if it is available.
Thank you.
Kevin
2008 Aug 28
6
Function not returning a vector?
Why does:
(shape/scale) * (1:365/scale)^(shape - 1)
return a vector of numbers but calling a function
hasard(1:365,shape,scale)
defined like:
hazard <- function(x,shape,scale)
{
return (shape/scale) * (x/scale)^(shape - 1)
}
Only return a single value? It is like x becomes a single value passed as an argument.
Thank you.
Kevin
2008 Aug 08
2
Length of data.frame column
I have a beginner question. After I finally get the data to a data.frame that I can work with I have the following a data frame that is fairly long:
> length(r2007)
[1] 17409
If I look at the first element:
> r2007[1]
$`100009`
DayOfYear Quantity
1 66 1
2 128 1
3 137 1
4 193 1
Now how do I get the length of this list (actually it is
2011 Nov 26
3
Time series merge?
I have two time series
a <- ts(1:10, start=c(1,6), end=c(2,5), frequency=10)
b <- ts(1:5, start=c(2,1), end=c(2,5), frequency=10)
Obviously 'b' is a subset of 'a'. I want a single index value indicating
where that start of 'b' lines up with the start of 'a'. So in this simple
example I would expect an index of 5. I was playing with 'merge'.