similar to: Loading List data into R with scan()

Displaying 20 results from an estimated 50000 matches similar to: "Loading List data into R with scan()"

2012 Apr 01
1
scan() vs readChar() speed
Dear list, I am trying to find a fast solution to read moderately large (1 -- 10 million entries) text files containing only tab-delimited numeric values. My test file is the following, nr <- 1000 nc <- 5000 m <- matrix(round(rnorm(nr*nc),3),nr=nr) write.table(m, file = "a.txt", append=FALSE, row.names = FALSE, col.names = FALSE) scan() is faster than
2008 Jun 17
2
Calling functions
Another newbie question. I've written a function and saved the file as Xtabs.R, in a central place on a network so others will be able ot use the function, My question is how do i call this function? I've tried to chance the working directory, and tried to load it via; > library(Xtabs, lib.loc="//filer/common/technical/surveys/R_test") but neither seem to work? the function
2006 Nov 20
2
problem with loop to put data into array with missing data for some files
Dear R-help community, My main goal of this message is to find a way of skipping a file of a month/year in a loop that does not exist (and making it's output into an data.out array would be NA) and moving onto the next year/month in the loop to carry on filling data.out with real precipitation data. The situation so far: I downloaded 50 years worth of GRIB data files from the NCEP data
2006 Nov 20
3
problem with loop to put data into array with missing data forsome files
Hi Jenny If you want a general solution I understand. However I just downloaded the file fine (as far as I can tell) so you are welcome to have a copy. I can email it to you if you want. I do not think your test for NA is valid. i.e if(test != "NA"){ } I think you should use if(is.na(test)){ } Or something similar. J --- John Seers Institute of Food Research Norwich
2009 Nov 02
4
Incremental ReadLines
I've been trying to figure out how to read in a large file for a few days now, and after extensive research I'm still not sure what to do. I have a large comma delimited text file that contains 59 fields in each record. There is also a header every 121 records This function works well for smallish records getcsv=function(fname){ ff=file(description = fname) x <- readLines(ff)
2005 Apr 04
3
scan html: sep = "<td>"
Hi I try to import html text and I need to split the fields at each <td> or </td> entry How can I succeed? sep = '<td>' doens't yield the right result thanks for hints
2010 May 05
4
any function in R similar to the "scan" function in SAS?
I am wondering if there is any function in R that is similar to the "scan" function in SAS. I have a data.frame which has two columns as the following: one two 1 2 3 4 5 6 I used the "paste" function to create the third column: three <- paste(one,'-',two,sep="") so the data.frame is like this now: one two three 1 2 1-2 3
2009 Dec 17
2
Problem with spliting a dataframe values
Hi all, Hi this is kiran I am facing a problem to split a dataframe that is.. i have a string like: "a,b,c|1,2,3|4,5,6|7,8,8" first I have to split with respect to "|" I did it with command unlist(strsplit("a,b,c|1,2,3|4,5,6|7,8,8", "\\,")) after getting that set i made it as a dataframe and it comes like a,b,c 1,2,3 4,5,6 7,8,8 now i have to
2005 Jan 27
7
getting package version inside .First.lib
Greetings - Is it possible, inside .First.lib, to find out the version number of the package that is being loaded? If only one version of the package has been installed, we could scan the DESCRIPTION file, something like .First.lib <- function(lib, pkg) { library.dynam("spatstat", pkg, lib) dfile <- system.file("DESCRIPTION", package="spatstat")
2007 Aug 02
4
Finding multiple characters in the same string
Hi I have this problem where I need to find if there is any numbers in a string, this is no problem if theres only one number per string. I would then simply use the regexpr() funtion togheter with the substring function to extract the number. But regexpr only picks one number per string either from the beginning or the end, but not multiple. Can this be done? And how for example My string <-
2007 Dec 20
1
auto named savings (pngs & data-frames)
Hello, i only got a small problem. i try to create automatic new dataframes, or png?s. the main problem i got is: how can i create automatic a new name for a file (read out by simply "for") - i tried to use "(paste...) but theres an errormessage, about a wrong declination. R told it is as.character, but need as.Real. Should i use another method than "paste"? i tried as
2002 Dec 19
2
More on scan()
Hi, If I have a CSV file which has several comments at the top, and the data start immediately after the line: @DATA Is it possible to use the scan() command to get the CSV data into R, by only reading the lines after @DATA? If so, how can I do it? Cheers, Kevin ------------------------------------------------------------------------------ /* Time is the greatest teacher, unfortunately it
2008 Sep 12
4
reading in results from system(). There must be an easier way...
Hello, I am currently using R to run an external program and then read the results the external program sends to the stdout which are tsv data. When R reads the results in it converts it to to a list of strings which I then have to maniuplate with a whole slew of commands (which, figuring out how to do was a reall challenge for a newbie like myself)--see below. Here's the code I'm
2004 Nov 11
6
scan or source a text file into a list
I've ported somebody else's rather cumbersome Matlab model to R for colleagues that want a free build of the model with the same type of I/O. The Matlab model reads a text file with the initial parameters specified as: C:\Data\Carluc\Rport>more Params.R # Number of years to simulate nYears = 50; # Initial year for graphing purposes year0 = 1970; # NPP/GPP ratio (cpp0 unitless) fnr =
2012 Mar 22
3
How to get the input of a function right?
Hi, I wrote a function with three inputs fun(x,y,z). x is a matrix of three vectors combined with cbind. e.g. x1<-(1,2,3,4) x2<-(2,3,4,5) x3<-(3,4,5,6) x<-cbind(x1,x2,x3) y is a vector e.g y<-c(7,8,9) z is a real number e.g. z<-2.5 If a give the function an input like this, I get 'NA' in return. If I give the function a vector e.g c(1,2,3) instead of 'x'
2013 Jan 27
1
scan not working
Hi all, I am trying to use the scan function in an R script that I am calling from the command line on a Mac; at the shell prompt I type: $ Rscript get_q_values.R LRT_codeml_output in the hope that LRT_codeml_output will get passed to the get_q_values R script. The first line of that script is: chidata <- scan(file="") which, as I understand how scan works, will read the
2006 Nov 01
4
splitting very long character string
Hello, I've a very long character array (>500k characters) that need to split by '\n' resulting in an array of about 60k numbers. The help on strsplit says to use perl=TRUE to get better formance, but still it takes several minutes to split this string. The massive string is the return value of a call to xmlElementsByTagName from the XML library and looks like this: ... 12345
2011 Nov 17
1
how to read a free text file into individual variables
hi ,I am writing a soft package based on R. But when I try to read a configure file showed as below. How can I read the parameter in this text file. How can I read the parameter into each variable in this file ? configinfo<-scan(file(configfile),ok=TRUE,n=-1) scan seems need every line have same column ? configinfo <- readLines(configfile,ok=TRUE,n=-1) methodnum <-
2005 Dec 06
3
reading in data with variable length
I have very large csv files (up to 1GB each of ASCII text). I'd like to be able to read them directly in to R. The problem I am having is with the variable length of the data in each record. Here's a (simplified) example: $ cat foo.csv Name,Start Month,Data Foo,10,-0.5615,2.3065,0.1589,-0.3649,1.5955
2012 Nov 29
4
splitting a string by space except when contained within quotes
I've been trying to split a space delimited string with double-quotes in R for some time but without success. An example of a string is as follows: /rainfall snowfall "Channel storage" "Rivulet storage"/ It's important for us because these are column headings that must match the subsequent data. Here is some code I've been trying: str <- 'rainfall