R производительность с изменением данных

Я использую Bitstream Vera Без Моно , но необходимо активировать ClearType для получения его читаемый.

мне нравится 'Illegal1 = O0' readablility тест, упомянутый ранее в этом потоке, спасибо за это.

10
задан Alexander L. Belikoff 7 December 2009 в 15:59
поделиться

3 ответа

Полезный трюк состоит в том, чтобы объединить переменные id в вектор символов, а затем выполнить изменение формы.

tbl$NEWID <- with(tbl, paste(ID, DATE1, DATE2, sep=";"))
tbl2 <- recast(tbl2, NEWID ~ VALTYPE, measure.var="VALUE")

Это примерно на 40% быстрее в задаче аналогичного размера в моем Intel Core2 Duo 2,2 ГГц macbook.

1
ответ дан 4 December 2019 в 04:21
поделиться

What about doing this in a non-R-like manner? I assume you have a TYPE1 and a TYPE2 row for each value of ID,DATE1,DATE2? Then sort the dataframe by those variables, and write a big for loop. You can repeatedly do rbind() operations to build the table, or you could try to pre-allocate the table (maybe) and just assign the VALUE.TYPE1 and VALUE.TYPE2 slots with [<-, which should do the assignment in-place.

(Note that if you're using rbind(), I believe that it's inefficient if you have any factor variables, so make sure everything is a character instead!)

1
ответ дан 4 December 2019 в 04:21
поделиться

Может быть, вы могли бы использовать функцию cat ()?

1
ответ дан 4 December 2019 в 04:21
поделиться
Другие вопросы по тегам:

Похожие вопросы: