我想要按行数据表的第一个,第二个,第三个最大名称。 例如:
( ! ) Fatal error: Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in /var/www/whitesmoke/public_html/whitesmoke/vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php on line 89
( ! ) Symfony\Component\Routing\Exception\ResourceNotFoundException: in /var/www/whitesmoke/public_html/whitesmoke/app/cache/prod/appProdUrlMatcher.php on line 39
Call Stack
# Time Memory Function Location
1 0.0005 238728 {main}( ) ../app.php:0
2 0.0200 1601096 Symfony\Component\HttpKernel\Kernel->handle( ) ../app.php:28
3 0.0437 3599400 Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle( ) ../bootstrap.php.cache:2444
4 0.0437 3600624 Symfony\Component\HttpKernel\HttpKernel->handle( ) ../bootstrap.php.cache:3222
5 0.0437 3601576 Symfony\Component\HttpKernel\HttpKernel->handleRaw( ) ../bootstrap.php.cache:3071
6 0.0445 3636880 Symfony\Component\EventDispatcher\EventDispatcher->dispatch( ) ../bootstrap.php.cache:3098
7 0.0476 3932472 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch( ) ../EventDispatcher.php:48
8 0.0501 4221216 call_user_func:{/var/www/whitesmoke/public_html/whitesmoke/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:160} ( ) ../EventDispatcher.php:160
9 0.0501 4221800 Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest( ) ../EventDispatcher.php:160
10 0.0501 4222560 Symfony\Component\Routing\Router->matchRequest( ) ../RouterListener.php:137
11 0.0512 4321448 Symfony\Component\Routing\Matcher\UrlMatcher->matchRequest( ) ../Router.php:256
12 0.0512 4321568 appProdUrlMatcher->match( ) ../UrlMatcher.php:112
( ! ) Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /Check%20app_dev.php" in /var/www/whitesmoke/public_html/whitesmoke/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php on line 159
Call Stack
# Time Memory Function Location
1 0.0005 238728 {main}( ) ../app.php:0
2 0.0200 1601096 Symfony\Component\HttpKernel\Kernel->handle( ) ../app.php:28
3 0.0437 3599400 Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle( ) ../bootstrap.php.cache:2444
4 0.0437 3600624 Symfony\Component\HttpKernel\HttpKernel->handle( ) ../bootstrap.php.cache:3222
5 0.0437 3601576 Symfony\Component\HttpKernel\HttpKernel->handleRaw( ) ../bootstrap.php.cache:3071
6 0.0445 3636880 Symfony\Component\EventDispatcher\EventDispatcher->dispatch( ) ../bootstrap.php.cache:3098
7 0.0476 3932472 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch( ) ../EventDispatcher.php:48
8 0.0501 4221216 call_user_func:{/var/www/whitesmoke/public_html/whitesmoke/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:160} ( ) ../EventDispatcher.php:160
9 0.0501 4221800 Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest( ) ../EventDispatcher.php:160
( ! ) Symfony\Component\Debug\Exception\ContextErrorException: Catchable Fatal Error: Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::getConfigurations() must be of the type array, integer given, called in /var/www/whitesmoke/public_html/whitesmoke/vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php on line 61 and defined in /var/www/whitesmoke/public_html/whitesmoke/vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php on line 89
Call Stack
# Time Memory Function Location
1 0.0005 238728 {main}( ) ../app.php:0
2 0.0200 1601096 Symfony\Component\HttpKernel\Kernel->handle( ) ../app.php:28
3 0.0437 3599400 Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle( ) ../bootstrap.php.cache:2444
( ! ) Symfony\Component\Debug\Exception\ContextErrorException: Catchable Fatal Error: Argument 1 passed to Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::getConfigurations() must be of the type array, integer given, called in /var/www/whitesmoke/public_html/whitesmoke/vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php on line 61 and defined in /var/www/whitesmoke/public_html/whitesmoke/vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php on line 89
Call Stack
# Time Memory Function Location
1 0.0809 7921816 Symfony\Component\Debug\ErrorHandler->handleException( ) ../ErrorHandler.php:0
2 0.0839 8171088 Symfony\Component\Debug\ErrorHandler->handleException( ) ../ErrorHandler.php:511
它将返回第一行,例如包含v1-v10之一的三列DF <- matrix(sample(1:9,9),ncol=10,nrow=10)
DF <- as.data.frame.matrix(DF)
,max1
,max2
。
有帮助吗?
感谢
答案 0 :(得分:1)
我们可以apply
使用MARGIN=1
来循环行,sort
元素,并获取前3个元素
t(apply(DF, 1, function(x) head(sort(x, decreasing=TRUE),3)))
如果我们对unique
值感兴趣
t(apply(DF, 1, function(x) head(unique(sort(x, decreasing=TRUE)),3))
或者@Roland提到,如果我们需要列名
t(apply(DF, 1, function(x) head(names(DF)[order(x, decreasing=TRUE)],3)))