similar to: reading in a Fortran binary array

Displaying 20 results from an estimated 11000 matches similar to: "reading in a Fortran binary array"

2012 Feb 15
1
Using readBin to read binary "unformatted" output files from Fortran?
Hello, I'm wondering if I can get some help with reading Fortran binary "unformatted" output files into R. The Fortran output files were generated in Ubuntu 10.04 LTS using gfortran4.4, on a 32bit Intel Core 2 Duo 3.16 GHz machine, with little-endian and record marker lengths equal to 4. The machine I'm currently trying to read this Fortran output file is a Macbook Pro
2008 Apr 09
1
preallocating matrices and rda read-back objects
I've read in Phil Spector's new book that it's a good idea to preallocate a big matrix, like u <- matrix(0,nrow,ncol) # (1) Now, I read contents of a huge matrix from a Fortran binary dump. u <- readBin(con,what="double",n=nrow*ncol) # (2) If I do (1) and then (2), u is a vector, obviously it's either reallocated or its matrix nature is lost -- overridden?
2007 Nov 23
2
printing levels as tuples
I'm running rle() on a long vector, and get a result which looks like > uc Run Length Encoding lengths: int [1:16753] 1 1 1 1 1 1 1 1 1 1 ... values : int [1:16753] 29462748 22596107 18322820 14323315 12684505 9909036 7296916 6857692 5884755 5883697 ... I can print uc$names or uc$levels separately. Is there any way to print them together as tuples, looking like (29462748, 1)
2008 Sep 17
1
creating horizontal dataframes with column names
Greetings -- in order to write back to SQL databases, one needs to create a dataframe with values. I can get column names of an existing table with sqlColumns. Say I have a vector of values (if they're all the same type), or a list (if different). How do I create a dataframe with column names given by my sqlColumns? To make it concrete, how do we make a dataframe A B C 1 2 3
2008 Oct 02
4
namespaces
I'd like to control my namespace thoroughly, separated by task. Is there a way, in R session, to introduce namespaces for tasks dynamically and switch them as needed? Or, is there a combination of load/save workspace steps which can facilitate this? Cheers, Alexy
2008 Sep 09
2
splitting time vector into days
Greetings -- I have a dataframe a with one element a vector, time, of POSIXct values. What's a good way to split the data frame into periods of a$time, e.g. days, and apply a function, e.g. mean, to some other column of the dataframe, e.g. a$value? Cheers, Alexy
2007 Nov 27
2
exporting a split list
Using wk <- with(d, split(word, kind)), I get the following class table: wk$`1` [1] "a" "bra" ... # (*) wk$`10` "ca" "dabra" ... Now I need to export it in the following format: class num_members examples 1 23 a bra ... 10 4 ca dabra For each class C such as `1`, I need to print the
2007 Nov 21
2
uniq -c
Is there an R analog of the Unix command uniq -c: http://en.wikipedia.org/wiki/Uniq Given an array x, uniq -c replaces each contiguous subsequence of identical numbers with a tuple (count, number). E.g. $ cat > usample 10 10 9 8 8 7 7 7 6 3 1 1 1 0 $ uniq -c usample 2 10 1 9 2 8 3 7 1 6 1 3 3 1 1 0 Cheers, Alexy
2009 Feb 24
2
growing dataframes with rbind
I'm growing a large dataframe by composing new rows and then doing row <- compute.new.row.somehow(...) d <- rbind(d,row) Is this a fast/preferred way? Cheers, Alexy
2009 Jan 26
2
name scoping within dataframe index
Every time I have to prefix a dataframe column inside the indexing brackets with the dataframe name, e.g. df[df$colname==value,] -- I am wondering, why isn't there an R scoping rule that search starts with the dataframe names, as if we'd said with(df, df[colname==value,]) -- wouldn't that be a reasonable default to prepend to the name search path? Cheers, Alexy
2008 Jan 07
2
output into an unformatted direct fortran file
Hello everybody Is there a way to output data into a file like the unformatted, direct fortran files? That's the kind that can be opened with: open(30, file='file', format='unformatted', access='direct', rec=1000, convert='big endian') Thank you in advance Kostas Douvis
2008 Oct 29
2
Functional pattern-matching in R
I found there's a very good functional set of operations in R, such as apply family, Hadley Wickham's lovely plyr, etc. There's even a Reduce (a.k.a. fold). Now I wonder how can we do pattern-matching? E.g., now I split dimensions like this: m <- dim(V)[1] # R n <- dim(V)[2] # still R While even Matlab allows for [m,n] = size(V) % MATLAB! Ideally I'd be able to
2009 Feb 23
2
1.095e+09 for integers
I've had a very long file written out by R with write.table, with fields of time values, converted from POSIXlt as.numeric. Among 2.5 million values, very few had 6 trailing zeroes, and those were output in scientific notation as in the subject. Is this the default behavior for long integers, and how can it be turned off (with all digits for any integer field in write.table)? This
2007 Nov 21
3
shrink a dataframe for plotting
I get tables with millions of rows. For plotting to a screen-size jpg, obviously just about 1000 points are enough. Instead of feeding plot() the original millions of rows, I'd rather shrink the original dataframe, using some kind of the following interpolation: -- split dataframe into chunks of N rows each, e.g. 1000 rows each -- compute average for each column -- issue one new row
2007 Nov 24
1
ragged array with append
I wonder what's the right way in R to do the following -- placing objects of the same kind together in subarrays of varying length. Here's what I mean: > word <- c("a","b","c","d","e","f","g","h","i","j") > kind <- c(1,1,1,2,3,4,5,5,7,7) > d <-
2008 Oct 09
1
R/OCaml?
Did anyone try to write R extensions in OCaml? What would it entail to enable it? Cheers, Alexy
2011 Mar 23
1
rbind a heterogeneous row
I have a dataframe with many rows like this: > df X1 X2 X3 X4 X5 X6 X7 week d sim1 FALSE TRUE TRUE TRUE TRUE TRUE TRUE 1 0.3064985 sim1 is the rowname, X1..X7,week,d are the column names. X1..X7 are factors, booleans in this case. I need to add another row, represented by the following list: list(rep(T,7),5,0.0) -- i.e, TRUE in all boolean columns,
2008 Sep 05
1
dealing with NAs in time series
Certain timeseries I have had outliers, which I removed by assigning NA to their positions. Now acf() refuses to go to work. What's the right way to remove outliers from ts objects, and what are teh standard ways to interpolate NAs in them? Cheers, Alexy
2008 Sep 28
1
partitioning vectors of intervals
I have two pairs of time intervals: coarse- and fine-grained. They're components of their respective dataframes, looking like, coarse: endtime starttime 1 t1_end t1_start 2 t2_end t2_start ... fine: is the same, except that its intervals presumably fall into the coarse's enclosing ones. The problem is to partition
2011 Mar 15
1
applying to dataframe rows
How do I apply a function to every row of a dataframe most naturally? Specifically, I'd like to filter out any row which contains an Inf in any column. Since all columns are numeric, I guess max should work on a row... -- Alexy