Displaying 20 results from an estimated 10000 matches similar to: "converting multiple lines of text to a data frame"
2010 Jul 28
2
read.delim()
I am reading in a very large file with names in it and R is truncating the number of rows it reads in. The separator in this file is a pipe '|' and so I use
dat <- read.delim('pathToMyFile', header= TRUE, sep='|')
It turns out that it is reading up to row 61145 and stopping and I think I see why, but am not sure of the best solution to this problem. I see the name of
2007 May 18
1
naive question about using an object as the name of another object
This is a dumb question, but I'm having trouble finding the answer to this.
I'd like to do the following:
x<-"asdf"
and then have
the object x.y become automatically converted/represented as asdf.y (sort of
akin to macro variables in SAS where you would do:
%let x=asdf and do &x..y)
What is the syntax for having x represented as "asdf" in x.y ?
Thanks,
2007 Aug 16
3
multiple colors within same line of text
Hi, I'm interested in using mtext(), but with the option of having multiple
colors in the same line of text.
For example, creating a line of text where:
Red is red and blue is blue
How do you create a text argument that lets you do this within mtext()?
Thanks,
Andrew
MGH Cancer Center
[[alternative HTML version deleted]]
2009 Nov 10
3
creating multiple plots using a splitting factor
Hello,
I am new to R. I often collect data at multiple sites and need to
create separate graphs (such as scatterplots or histograms) of specific
variables for each site. I have tried to do this by splitting the data
frame and then using lapply, but it seems that the graphing commands
cannot be called as functions. Here is a sample of my data, called
"seeddist2":
site
2004 Mar 19
2
using "unstack" inside my function: that old scope problem again
I've been reading the R mail archives and I've found a lot of messages
with this same kind of problem, but I can't understand the answers. Can
one of you try to explain this to me?
Here's my example. Given a regression model and a variable, I want to
use unstack() on the vector of residuals and make some magic with the
result. But unstack hates me.
PCSE <- function
2009 Nov 15
1
Help with unstack() function
Hi Everyone,
I am trying to understand the unstack() function but after struggling for
two days, I have given up. More specifically, I am trying the exercises at
the end of Chapter 1 of Data Analysis and Graphics Using R by Maindonald
and Braun, 2nd ed. Exercise 18 (p. 41) asks to unstack the Rabbit data frame
from the MASS package to get a certain data frame that is shown in the
exercise.
2007 Aug 23
2
read big text file into R
Dear Rs:
Hi, I am trying to read a big text file (nrows=243440, ncols=144). It
seems the computational time of all the read methods
(scan,readtable,read.delim) is not linear to the number of rows I
want to read in: things became really slow once I tried to read in
100000 lines compare to 10000 lines).
If I am reading the profiling result right, I guess scan wouldn't
help either.
My
2010 Oct 18
1
questions on unstack()
Folks,
I have the following dataframe:
> x <- structure(list(name = c("EU B", "EU B", "EU B", "EU B", "EU B",
"EU B", "AU A", "AU A", "AU A", "AU A", "AU A", "AU A"), date = c("2010-10-11",
"2010-10-12", "2010-10-13",
2009 Oct 03
2
converting matrix of lists to a regular matrix
Take the following code:
foo <- list()
foo[[1]] <- list(a=1, b=2)
foo[[2]] <- list(a=11, b=22)
foo[[3]] <- list(a=111, b=222)
result <- do.call(rbind, foo)
result[,'a']
In this case, result[,'a'] shows a list. Is there a more elegant way such
that result is a "regular" matrix of vectors? I imagine there are manual
ways of going about this, but I was
2011 Mar 12
1
Column order in stacking/unstacking
Dear R users,
I'm having some problems with the stack() and unstack() functions, and
wondered if you could help.
I have a large data frame (400 rows x 2000 columns), which I need to reduce
to a single column of values (and therefore 800000 rows), so that I can use
it in other operations (e.g., generating predictions from a GLM object).
However, the problem I'm having can be reproduced
2007 May 15
2
converting a row of a data.frame to a vector
I've searched for the answer to this in the help list archive, but wasn't
able to get the answer to work.
I'm interested in converting a row of a data.frame into a vector.
However, when I use as.vector(x,[1,]) I get another data.frame, instead of a
vector. (On the other hand, when I use as.vector(x,[,1]), I get a vector.)
Thanks,
Andrew
[[alternative HTML version deleted]]
2006 Nov 13
2
Embedded carriage returns in text document
Colleagues,
I am using R 2.4.0 on both a Mac (10.4.8) and Linux (RedHat 9). To
read data from an Excel spreadsheet, I do "save as" in Excel, then
select the "Text (tab-delimited)" format. The resulting file uses a
tab separator and I can usually read the file using read.delim.
Sometimes, the header row contains embedded carriage returns. When I
view the file,
2004 Oct 06
3
read.delim problem with trailing spaces
I'm trying to read a comma delimited dataset that uses '.' for NA. I
found that if the last field on a line was a missing '.'
it was not read as NA, but just a '.', and the life variable was made a
factor. The data looks like this,
income,imr,region,oilexprt,imr80,gnp80,life
Afghanistan,75,400.0,4,0,185.0,.,37.5
Algeria,400,86.3,2,1,20.5,1920,50.7
2011 Apr 04
2
how to handle no lines in input with pipe()
This has to do with using pipe() and grep and read.csv()
I have a .csv file that I grep using pipe() and read.csv() as follows:
read.csv(pipe('grep foo bar.csv'))
However, is there a way to have this command run when for example,
there is no "foo" text in the bar.csv file? I get an error message
(appropriately):
Error in read.table(file = file, header = header, sep = sep,
2009 Jan 19
3
download/retain text file structure with RCurl/getURL()
Dear list,
I'm trying to download a text file directly from the internet using the RCurl package and the command getURL. Duncan Lang graciously helped me solve the first step in this problem using the following command:
#################
txtfile <- getURL('ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt',
ftp.use.epsv = FALSE)
#################
2013 Apr 09
3
Question on Stopword Removal from a Cyrillic (Bulgarian)Text
Hi,
I bumped into a serious issue while trying to analyse some texts in
Bulgarian language (with the tm package). I import a tab-separated csv
file, which holds a total of 22 variables, most of which are text cells
(not factors), using the read.delim function:
data<-read.delim("bigcompanies_ascii.csv",
header=TRUE,
quote="'",
2013 Apr 09
3
Question on Stopword Removal from a Cyrillic (Bulgarian)Text
Hi,
I bumped into a serious issue while trying to analyse some texts in
Bulgarian language (with the tm package). I import a tab-separated csv
file, which holds a total of 22 variables, most of which are text cells
(not factors), using the read.delim function:
data<-read.delim("bigcompanies_ascii.csv",
header=TRUE,
quote="'",
2008 Apr 03
1
why is text being rasterized with text()
Here's a question: I noticed that when I tried to create this simple
graph of rectangles and text, R appears to generate text that is
rasterized (this is seen both on the monitor and when the output is
directed to a pdf file). Any thoughts?
value.seq <- c("<4",as.character(seq(from=4,to=10)),">11")
frame()
par(usr=c(0,10,0,10) )
for (r in 1:9) {
2016 Jun 27
1
stack problem
One would normally want the original order that so that one can stack
a list, operate on the result and then unstack it back with the
unstacked result having the same ordering as the original.
LL <- list(z = 1:3, a = list())
# since we can't do s <- stack(LL,. drop = FALSE) do this instead:
s <- transform(stack(LL), ind = factor(as.character(ind), levels = names(LL)))
unstack(s)
2006 Dec 30
1
Crosstab from sql dump
Hello all,,
Im looking for a simple function to produce a crosstab from a dumped
sql query result. Its very hard to produce crosstabs with most
databases (Access being the exception), so with the vast array of R
packages, Im sure this has to have already been implemented somewhere.
Examples are always good:
Take a csv dump like
name code
user1 100
user2 100
user1 200
user2 210
user1 300
user2